Example #1
0
void switchDelay()
{
	if (digitalRead(SWITCH_PIN))
	{
		setConfigMode();
	}
}
Example #2
0
/**
 *  Callback for messages, arrived from MQTT broker
 */
void onMessageReceived(String topic, String message) {

	Serial.println("Message received: " + message);

	// Messages from mobile-app
	if (message.equals("AUTH_REQUEST")) {

		authStartRequest();
	}

	if (message.equals("AUTH_REJECT")) {


		}

	if (message.equals("AUTH_END")) {

		setConfigMode(false);
	}

	// Messages from server
	if (message.equals("START_AUTH")) {

		startAuth();
	}
}
Example #3
0
void init()
{
	spiffs_mount(); // Mount file system

	Serial.begin(SERIAL_BAUD_RATE); // 115200 by default
	Serial.systemDebugOutput(true); // Enable debug output to serial

	AppSettings.load();

	pinMode(GREEN_LED_PIN, OUTPUT);
	pinMode(RED_LED_PIN, OUTPUT);
	pinMode(SWITCH_PIN, INPUT);

	WifiStation.enable(true);
	WifiStation.enableDHCP(true);

	sendDataTimer.initializeMs(1000, sendData);
	sleepTimer.initializeMs(1000, sleeping);

	configMode = false;
	successSent = false;

	String currentNetwork = WifiStation.getSSID();
	String currentPassword = WifiStation.getPassword();


	if (digitalRead(SWITCH_PIN) || currentNetwork.length() == 0 || currentPassword.length() == 0)
	{
		debounceTimer.initializeMs(1200, debounceReset);
		configTimer.initializeMs(1000, switchDelay);

		//attachInterrupt(SWITCH_PIN, switchPressed, RISING);

		startWebServer();
		WifiStation.startScan(networkScanCompleted);
		WifiAccessPoint.config("iot-meets-business", "", AUTH_OPEN); // AUTH_WPA_WPA2_PSK
		setConfigMode();
	}
	else
	{
		WifiStation.waitConnection(connectOk, 5, connectFail);
	}

}
Example #4
0
void init() {

	Serial.begin(SERIAL_BAUD_RATE); // 115200 by default
	Serial.systemDebugOutput(true); // Debug output to serial
	//commandHandler.registerSystemCommands();

	// Enable rboot in makefile!
	int slot = rboot_get_current_rom();
	Serial.printf("\r\nCurrently running rom %d.\r\n", slot);


	if (!digitalRead(SWITCH_PIN)) {

			// Reboot in operation-mode
			rboot_set_current_rom(0);
			Serial.println("Restarting...");
			System.restart();
		}

	pinMode(GREEN_LED_PIN, OUTPUT);
	pinMode(RED_LED_PIN, OUTPUT);
	pinMode(SWITCH_PIN, INPUT);

	WifiStation.enable(true);
	WifiStation.enableDHCP(true);

	WifiAccessPoint.enable(false);

	configMode = false;
	smartConfigActive = false;

	debounceTimer.initializeMs(1200, debounceReset);
	configTimer.initializeMs(1000, switchDelay);
	attachInterrupt(SWITCH_PIN, switchPressed, RISING);

	setConfigMode(true);

}
Example #5
0
void ShellUI::toggleConfigMode()
{
    setConfigMode(!m_configMode);
}