mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-03 17:59:27 +02:00
apply the same connected_once logic to wifi
This commit is contained in:
parent
9983d81cac
commit
cbd1fd996e
1 changed files with 4 additions and 1 deletions
|
@ -24,6 +24,7 @@ static bool hasConnectedBefore = false;
|
||||||
static uint16_t reconnectAttempts = 0; // Counter for reconnect attempts
|
static uint16_t reconnectAttempts = 0; // Counter for reconnect attempts
|
||||||
static uint16_t current_full_reconnect_interval = INIT_WIFI_FULL_RECONNECT_INTERVAL;
|
static uint16_t current_full_reconnect_interval = INIT_WIFI_FULL_RECONNECT_INTERVAL;
|
||||||
static uint16_t current_check_interval = WIFI_CHECK_INTERVAL;
|
static uint16_t current_check_interval = WIFI_CHECK_INTERVAL;
|
||||||
|
static bool connected_once = false;
|
||||||
|
|
||||||
void init_WiFi() {
|
void init_WiFi() {
|
||||||
|
|
||||||
|
@ -141,6 +142,7 @@ static void connectToWiFi() {
|
||||||
static void onWifiConnect(WiFiEvent_t event, WiFiEventInfo_t info) {
|
static void onWifiConnect(WiFiEvent_t event, WiFiEventInfo_t info) {
|
||||||
clear_event(EVENT_WIFI_DISCONNECT);
|
clear_event(EVENT_WIFI_DISCONNECT);
|
||||||
set_event(EVENT_WIFI_CONNECT, 0);
|
set_event(EVENT_WIFI_CONNECT, 0);
|
||||||
|
connected_once = true;
|
||||||
#ifdef DEBUG_VIA_USB
|
#ifdef DEBUG_VIA_USB
|
||||||
Serial.println("Wi-Fi connected.");
|
Serial.println("Wi-Fi connected.");
|
||||||
Serial.print("IP address: ");
|
Serial.print("IP address: ");
|
||||||
|
@ -166,6 +168,7 @@ static void onWifiGotIP(WiFiEvent_t event, WiFiEventInfo_t info) {
|
||||||
|
|
||||||
// Event handler for Wi-Fi disconnection
|
// Event handler for Wi-Fi disconnection
|
||||||
static void onWifiDisconnect(WiFiEvent_t event, WiFiEventInfo_t info) {
|
static void onWifiDisconnect(WiFiEvent_t event, WiFiEventInfo_t info) {
|
||||||
|
if (connected_once)
|
||||||
set_event(EVENT_WIFI_DISCONNECT, 0);
|
set_event(EVENT_WIFI_DISCONNECT, 0);
|
||||||
#ifdef DEBUG_VIA_USB
|
#ifdef DEBUG_VIA_USB
|
||||||
Serial.println("Wi-Fi disconnected.");
|
Serial.println("Wi-Fi disconnected.");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue