Skip to content

Commit

Permalink
Merge pull request #16 from peteh/feature/wifi-forced-reconnect
Browse files Browse the repository at this point in the history
Feature/wifi forced reconnect
  • Loading branch information
peteh authored Feb 4, 2024
2 parents ad353fd + 40f478e commit 0458666
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions doorman/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "mqttview.h"

const uint WATCHDOG_TIMEOUT_S = 30;
const uint WIFI_DISCONNECT_FORCED_RESTART_S = 60;

WiFiClient net;
PubSubClient client(net);
Expand Down Expand Up @@ -84,6 +85,7 @@ unsigned long g_tsLastHandsetLiftup = 0;

bool g_wifiConnected = false;
bool g_mqttConnected = false;
unsigned long g_lastWifiConnect = 0;

// TODO: wifi auto config
// TODO: publish persistant
Expand Down Expand Up @@ -458,6 +460,9 @@ void setup()
log_debug(".");
delay(500);
}
g_wifiConnected = true;
g_lastWifiConnect = millis();

log_info("Wifi connected!");

log_info("Connected to SSID: %s", wifi_ssid);
Expand Down Expand Up @@ -546,12 +551,18 @@ void loop()
g_config.wifiDisconnectCounter++;
saveSettings(g_config);
}
if (millis() - g_lastWifiConnect > WIFI_DISCONNECT_FORCED_RESTART_S * 1000)
{
log_warn("Wifi could not connect in time, will force a restart");
esp_restart();
}
g_wifiConnected = false;
g_mqttConnected = false;
delay(1000);
return;
}
g_wifiConnected = true;
g_lastWifiConnect = millis();

server.handleClient(); // Handling of incoming web requests
ArduinoOTA.handle();
Expand Down
2 changes: 1 addition & 1 deletion doorman/src/platform.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once
#include <Arduino.h>

#define VERSION "2024.1.1"
#define VERSION "2024.1.2"

#ifdef ESP8266
#define PIN_BUS_READ D5
Expand Down

0 comments on commit 0458666

Please sign in to comment.