3030#include " Helpers.h"
3131#include " WifiManager.h"
3232#include " QueueManager.h"
33-
33+ #if defined(ARDUINO_ARCH_ESP32)
34+ #include < esp_task_wdt.h>
35+ #endif
3436
3537class BootstrapManager {
3638
3739private:
3840 WifiManager wifiManager; // WifiManager classes for Wifi management
3941 QueueManager queueManager; // QueueManager classes for MQTT queue management
4042 Helpers helper;
43+ #if defined(ARDUINO_ARCH_ESP32)
44+ unsigned long lastMillisForWdt = millis();
45+ #endif
4146
4247public:
4348 StaticJsonDocument<BUFFER_SIZE> jsonDoc;
4449 StaticJsonDocument<BUFFER_SIZE_MAX_SIZE> jsonDocBigSize;
45-
4650 // using JsonDocument = StaticJsonDocument<BUFFER_SIZE>;
47- StaticJsonDocument<BUFFER_SIZE>
48- parseQueueMsg (char *topic, byte *payload, unsigned int length); // print the message arriving from the queue
49- StaticJsonDocument<BUFFER_SIZE>
50- parseHttpMsg (String payload, unsigned int length); // print the message arriving from HTTP
51+ StaticJsonDocument<BUFFER_SIZE> parseQueueMsg (char * topic, byte* payload, unsigned int length); // print the message arriving from the queue
52+ StaticJsonDocument<BUFFER_SIZE> parseHttpMsg (String payload, unsigned int length); // print the message arriving from HTTP
5153 void littleFsInit ();
52-
53- void bootstrapSetup (void (*manageDisconnectionFunction)(), void (*manageHardwareButton)(), void (*callback)(char *, byte *, unsigned int )); // bootstrap setup()
54- void bootstrapSetup (void (*manageDisconnectionFunction)(), void (*manageHardwareButton)(), void (*callback)(char *, byte *, unsigned int ), bool waitImprov,
55- void (*listener)()); // bootstrap setup()
54+ void bootstrapSetup (void (*manageDisconnectionFunction)(), void (*manageHardwareButton)(), void (*callback)(char *, byte*, unsigned int )); // bootstrap setup()
55+ void bootstrapSetup (void (*manageDisconnectionFunction)(), void (*manageHardwareButton)(), void (*callback)(char *, byte*, unsigned int ), bool waitImprov, void (*listener)()); // bootstrap setup()
5656 void bootstrapLoop (void (*manageDisconnectionFunction)(), void (*manageQueueSubscription)(), void (*manageHardwareButton)()); // bootstrap loop()
5757 static void setMQTTWill (const char *topic, const char *payload, int qos, boolean retain, boolean cleanSession); // set the last will parameters for mqtt
5858 static void publish (const char *topic, const char *payload, boolean retained); // send a message on the queue
@@ -63,12 +63,12 @@ class BootstrapManager {
6363 JsonObject getJsonObject (); // return a new json object instance
6464 [[maybe_unused]] static void nonBlokingBlink (); // blink default LED when sending data to the queue
6565 [[maybe_unused]] static void getMicrocontrollerInfo (); // print or display microcontroller's info
66- [[maybe_unused]] void drawInfoPage (const String & softwareVersion, const String & author); // draw a page with all the microcontroller's info
67- [[maybe_unused]] void drawScreenSaver (const String & txt); // useful for OLED displays
68- [[maybe_unused]] static void sendState (const char *topic, JsonObject objectToSend, const String & version); // send microcontroller's info on the queue
69- [[maybe_unused]] static void writeToLittleFS (const DynamicJsonDocument & jDoc, const String & filenameToUse); // write json file to storage
70- [[maybe_unused]] static StaticJsonDocument<BUFFER_SIZE> readLittleFS (const String & filenameToUse); // read json file from storage
71- [[maybe_unused]] String readValueFromFile (const String & filenameToUse, const String & paramName); // read a param from a json file
66+ [[maybe_unused]] void drawInfoPage (const String& softwareVersion, const String& author); // draw a page with all the microcontroller's info
67+ [[maybe_unused]] void drawScreenSaver (const String& txt); // useful for OLED displays
68+ [[maybe_unused]] static void sendState (const char *topic, JsonObject objectToSend, const String& version); // send microcontroller's info on the queue
69+ [[maybe_unused]] static void writeToLittleFS (const DynamicJsonDocument& jDoc, const String& filenameToUse); // write json file to storage
70+ [[maybe_unused]] static StaticJsonDocument<BUFFER_SIZE> readLittleFS (const String& filenameToUse); // read json file from storage
71+ [[maybe_unused]] String readValueFromFile (const String& filenameToUse, const String& paramName); // read a param from a json file
7272 static bool isWifiConfigured (); // check if wifi is correctly configured
7373 void launchWebServerForOTAConfig (); // if no ssid available, launch web server to get config params via browser
7474 void launchWebServerCustom (bool waitImprov, void (*listener)()); // if no ssid available, launch web server to get config params via browser
0 commit comments