Skip to content

Commit

Permalink
solved problem in reconnect wifi client after a failure with esp32dui…
Browse files Browse the repository at this point in the history
…no version 3; new release
  • Loading branch information
pat1 committed Oct 17, 2024
1 parent eb848c8 commit 030d255
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions platformio/stima_v3/stimawifi/include/stimawifi_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#define STIMAWIFI_CONFIG_H_

// increment on change
#define SOFTWARE_VERSION "2024-10-16T00:00" // date and time
#define MAJOR_VERSION "20241016" // date YYYYMMDD
#define SOFTWARE_VERSION "2024-10-17T00:00" // date and time
#define MAJOR_VERSION "20241017" // date YYYYMMDD
#define MINOR_VERSION "0" // time HHMM without leading 0

#define WIFI_SSED "STIMA-config"
Expand Down
8 changes: 8 additions & 0 deletions platformio/stima_v3/stimawifi/src/publish_thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ publishThread::publishThread(publish_data_t* publish_data)
//data->logger->notice("Create Thread %s %d", GetName().c_str(), data->id);
data->status->connect=unknown;
data->status->publish=unknown;
errorcount=0;
//Start();
};

Expand Down Expand Up @@ -369,11 +370,18 @@ void publishThread::Run() {
mqttDisconnect();
if (mqttConnect(true)) { // manage mqtt reconnect as RMAP standard
data->logger->notice(F("publish MQTT connected"));
errorcount = 0;
data->status->connect=ok;
} else {
data->status->connect=error;
data->logger->error(F("publish MQTT connect failed"));
data->status->publish=error;
errorcount++;
if (errorcount > 15) {
data->logger->error(F("publish too much error: drop WiFi"));
WiFi.disconnect();
errorcount = 0;
}
delay(3000);
}
}
Expand Down
1 change: 1 addition & 0 deletions platformio/stima_v3/stimawifi/src/publish_thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class publishThread : public Thread {
publish_data_t* data;
IPStack ipstack;
MQTT::Client<IPStack, Countdown, MQTT_PACKET_SIZE, 1 > mqttclient;
uint8_t errorcount;
};

#endif

0 comments on commit 030d255

Please sign in to comment.