Improve reset mechanism when MQTT is not connected (#1338)
This enables to wait less for the reset to trigger
This commit is contained in:
1 parent
8ee1c4e524
commit
dee3ef4de5
3 files changed
+11
-6
No files matched your search
+2
-2
@@ -165,8 +165,8 @@ The pre-built binaries for **rfbridge** and **avatto-bakeey-ir** have the above
|
||||
The gateway can support up to 3 LED to display its operating state:
|
||||
* LED_INFO
|
||||
switched ON when network and MQTT connection are OK
|
||||
5s ON, 5s OFF when WIFI is disconnected
|
||||
1s ON, 4s OFF when MQTT is disconnected
|
||||
5s ON, 5s OFF when MQTT is disconnected
|
||||
2s ON, 2s OFF when NETWORK is disconnected
|
||||
|
||||
* LED_RECEIVE
|
||||
Blink for `TimeLedON` 1s when the gateway receive a signal from one of its module so as to send to MQTT
|
||||
|
||||
@@ -64,7 +64,7 @@ void MeasureGPIOInput() {
|
||||
if (reading == LOW) {
|
||||
if (resetTime == 0) {
|
||||
resetTime = millis();
|
||||
} else if ((millis() - resetTime) > 10000) {
|
||||
} else if ((millis() - resetTime) > 3000) {
|
||||
Log.trace(F("Button Held" CR));
|
||||
Log.notice(F("Erasing ESP Config, restarting" CR));
|
||||
setup_wifimanager(true);
|
||||
|
||||
+8
-3
@@ -328,7 +328,6 @@ void pub(const char* topicori, JsonObject& data) {
|
||||
String dataAsString = "";
|
||||
serializeJson(data, dataAsString);
|
||||
Log.notice(F("Send on %s msg %s" CR), topicori, dataAsString.c_str());
|
||||
SendReceiveIndicatorON();
|
||||
String topic = String(mqtt_topic) + String(gateway_name) + String(topicori);
|
||||
#if valueAsATopic
|
||||
# ifdef ZgatewayPilight
|
||||
@@ -417,6 +416,7 @@ void pubMQTT(const char* topic, const char* payload) {
|
||||
*/
|
||||
void pubMQTT(const char* topic, const char* payload, bool retainFlag) {
|
||||
if (client.connected()) {
|
||||
SendReceiveIndicatorON();
|
||||
Log.trace(F("[ OMG->MQTT ] topic: %s msg: %s " CR), topic, payload);
|
||||
#if AWS_IOT
|
||||
client.publish(topic, payload); // AWS IOT doesn't support retain flag for the moment
|
||||
@@ -424,7 +424,7 @@ void pubMQTT(const char* topic, const char* payload, bool retainFlag) {
|
||||
client.publish(topic, payload, retainFlag);
|
||||
#endif
|
||||
} else {
|
||||
Log.warning(F("Client not connected, aborting thes publication" CR));
|
||||
Log.warning(F("Client not connected, aborting the publication" CR));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -526,6 +526,11 @@ void delayWithOTA(long waitMillis) {
|
||||
#if defined(ESP8266) || defined(ESP32)
|
||||
long waitStep = 100;
|
||||
for (long waitedMillis = 0; waitedMillis < waitMillis; waitedMillis += waitStep) {
|
||||
# ifndef ESPWifiManualSetup
|
||||
# if defined(ESP8266) || defined(ESP32)
|
||||
checkButton(); // check if a reset of wifi/mqtt settings is asked
|
||||
# endif
|
||||
# endif
|
||||
ArduinoOTA.handle();
|
||||
delay(waitStep);
|
||||
}
|
||||
@@ -589,7 +594,7 @@ void connectMQTT() {
|
||||
Log.warning(F("failed, ssl error code=%d" CR), ((WiFiClientSecure*)eClient)->getLastSSLError());
|
||||
#endif
|
||||
ErrorIndicatorON();
|
||||
delayWithOTA(2000);
|
||||
delayWithOTA(5000);
|
||||
ErrorIndicatorOFF();
|
||||
delayWithOTA(5000);
|
||||
if (failure_number_mqtt > maxRetryWatchDog) {
|
||||
|
||||
Reference in new issue
Block a user