The code allows entering configuration mode when the button is pressed.
lib_deps = ITTIoT
/* * IoT Configuration mode example * * IoT Button module is needed. When button is prsessed then module goes to * the config mode * * Created 04 March 2021 by Heiko Pikner */ // Includes global variables and librarys that the RGB LED and buzzer uses #include <Arduino.h> #include <ittiot.h> // Switch state to trigger restart only once. int swState; // Message received void iot_received(String topic, String msg){} // Function started after the connection to the server is established. void iot_connected() { // Send message to serial port to show that connection is established. Serial.println("MQTT connected callback"); // Send message to MQTT server to show that connection is established. iot.log("IoT Boot mode sample!"); } void setup() { // Initialize serial port and send message // setting up serial connection parameter Serial.begin(115200); Serial.println("Booting"); // print IoT json config to serial iot.printConfig(); // Initialize IoT Button module switch pin D3 (0) as a boot pin.The pin was read, when module boots up. iot.setBootPin(0); // Initialize IoT library iot.setup(); } void loop() { // IoT behind the plan work, it should be periodically called. iot.handle(); delay(20); // Read the switch pin to force restart the module if it is in normal or config mode. if(!digitalRead(0) && !swState) { iot.restart(ITT::configMode); swState = 1; } }