[SYS] Publish the reboot reason with retain flag (#1802)
So as to have the information stored on the MQTT broker Also remove stopProcessing, not necessary as we follow by a restart
This commit is contained in:
1 parent
cf285fba15
commit
83137f6ac9
3 files changed
+14
-3
No files matched your search
@@ -697,6 +697,7 @@ Adafruit_NeoPixel leds2(ANEOPIX_IND_NUM_LEDS, ANEOPIX_IND_DATA_GPIO2, ANEOPIX_IN
|
|||||||
#define TimeLedON 1 // time LED are ON
|
#define TimeLedON 1 // time LED are ON
|
||||||
#define InitialMQTTConnectionTimeout 10 // time estimated (s) before the board is connected to MQTT
|
#define InitialMQTTConnectionTimeout 10 // time estimated (s) before the board is connected to MQTT
|
||||||
#define subjectSYStoMQTT "/SYStoMQTT" // system parameters
|
#define subjectSYStoMQTT "/SYStoMQTT" // system parameters
|
||||||
|
#define subjectLOGtoMQTT "/LOGtoMQTT" // log informations
|
||||||
#define subjectRLStoMQTT "/RLStoMQTT" // latest release information
|
#define subjectRLStoMQTT "/RLStoMQTT" // latest release information
|
||||||
#define subjectMQTTtoSYSset "/commands/MQTTtoSYS/config"
|
#define subjectMQTTtoSYSset "/commands/MQTTtoSYS/config"
|
||||||
#define subjectMQTTtoSYSupdate "/commands/MQTTtoSYS/firmware_update"
|
#define subjectMQTTtoSYSupdate "/commands/MQTTtoSYS/firmware_update"
|
||||||
|
|||||||
@@ -115,7 +115,6 @@ void btScanWDG() {
|
|||||||
scanCount != 0 &&
|
scanCount != 0 &&
|
||||||
(now - lastBtScan > ((BTConfig.BLEinterval + BTConfig.scanDuration) < GeneralTimeOut ? GeneralTimeOut + 1000 : (BTConfig.BLEinterval + BTConfig.scanDuration)))) {
|
(now - lastBtScan > ((BTConfig.BLEinterval + BTConfig.scanDuration) < GeneralTimeOut ? GeneralTimeOut + 1000 : (BTConfig.BLEinterval + BTConfig.scanDuration)))) {
|
||||||
Log.error(F("BLE Scan watchdog triggered at : %ds" CR), lastBtScan / 1000);
|
Log.error(F("BLE Scan watchdog triggered at : %ds" CR), lastBtScan / 1000);
|
||||||
stopProcessing();
|
|
||||||
ESPRestart(4);
|
ESPRestart(4);
|
||||||
} else {
|
} else {
|
||||||
previousBtScanCount = scanCount;
|
previousBtScanCount = scanCount;
|
||||||
|
|||||||
+13
-2
@@ -63,8 +63,8 @@ unsigned long timer_sys_checks = 0;
|
|||||||
|
|
||||||
# include <queue>
|
# include <queue>
|
||||||
int queueLength = 0;
|
int queueLength = 0;
|
||||||
int queueLengthSum = 0;
|
unsigned long queueLengthSum = 0;
|
||||||
int blockedMessages = 0;
|
unsigned long blockedMessages = 0;
|
||||||
int maxQueueLength = 0;
|
int maxQueueLength = 0;
|
||||||
# ifndef QueueSize
|
# ifndef QueueSize
|
||||||
# define QueueSize 18
|
# define QueueSize 18
|
||||||
@@ -1478,7 +1478,15 @@ bool wifi_reconnect_bypass() {
|
|||||||
6 - OTA Update
|
6 - OTA Update
|
||||||
7 - Parameters changed
|
7 - Parameters changed
|
||||||
*/
|
*/
|
||||||
|
#if defined(ESP8266) || defined(ESP32)
|
||||||
void ESPRestart(byte reason) {
|
void ESPRestart(byte reason) {
|
||||||
|
delay(1000);
|
||||||
|
StaticJsonDocument<128> jsonBuffer;
|
||||||
|
JsonObject jsondata = jsonBuffer.to<JsonObject>();
|
||||||
|
jsondata["reason"] = reason;
|
||||||
|
jsondata["retain"] = true;
|
||||||
|
jsondata["uptime"] = uptime();
|
||||||
|
pub(subjectLOGtoMQTT, jsondata);
|
||||||
Log.warning(F("Rebooting for reason code %d" CR), reason);
|
Log.warning(F("Rebooting for reason code %d" CR), reason);
|
||||||
# if defined(ESP32)
|
# if defined(ESP32)
|
||||||
ESP.restart();
|
ESP.restart();
|
||||||
@@ -1486,6 +1494,9 @@ void ESPRestart(byte reason) {
|
|||||||
ESP.reset();
|
ESP.reset();
|
||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
void ESPRestart(byte reason) {}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(ESPWifiManualSetup)
|
#if defined(ESPWifiManualSetup)
|
||||||
void setup_wifi() {
|
void setup_wifi() {
|
||||||
|
|||||||
Reference in new issue
Block a user