Remove the deep sleep logic
This commit is contained in:
@@ -12,6 +12,5 @@ void connect_mqtt(PubSubClient &client, Config *config);
|
||||
void disconnect_mqtt(PubSubClient &client, const char *topic);
|
||||
size_t construct_json(float *data, char *buffer, int buffer_size);
|
||||
void mqtt_transfer(PubSubClient &client, Config *config, float *data);
|
||||
void enter_deep_sleep(bool wifi_timeout, int sleep_time);
|
||||
|
||||
#endif /* WLAN_H */
|
||||
|
||||
11
src/wlan.cpp
11
src/wlan.cpp
@@ -13,11 +13,7 @@ void initial_connection(const char *ssid, const char *psk,
|
||||
void connect_wlan(Config *config) {
|
||||
if (WiFi.SSID() != config->ssid)
|
||||
initial_connection(config->ssid, config->psk, config->device_id);
|
||||
int retries = 0;
|
||||
while (WiFi.status() != WL_CONNECTED) {
|
||||
if (retries == config->connection_attempts)
|
||||
enter_deep_sleep(true, config->sleep_time);
|
||||
retries++;
|
||||
delay(1000);
|
||||
Serial.print(".");
|
||||
}
|
||||
@@ -55,10 +51,3 @@ void mqtt_transfer(PubSubClient &client, Config *config, float *data) {
|
||||
client.publish(config->topic, buffer, payload_size);
|
||||
Serial.println("Data transferred successfully");
|
||||
}
|
||||
|
||||
void enter_deep_sleep(bool wifi_timeout, int sleep_time) {
|
||||
Serial.println("Entering deep sleep");
|
||||
if (wifi_timeout)
|
||||
WiFi.disconnect();
|
||||
ESP.deepSleep(sleep_time, WAKE_RF_DEFAULT);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user