mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-05 02:39:57 +02:00
pre-commit fixes
This commit is contained in:
parent
ae475c3b24
commit
3a5e39171f
3 changed files with 43 additions and 50 deletions
|
@ -2,13 +2,13 @@
|
|||
#include "../../include.h"
|
||||
#include "../utils/events.h"
|
||||
|
||||
|
||||
// Configuration Parameters
|
||||
static const uint16_t WIFI_CHECK_INTERVAL = 5000; // 5 seconds
|
||||
static const uint16_t INIT_WIFI_FULL_RECONNECT_INTERVAL = 10000; // 10 seconds
|
||||
static const uint16_t MAX_WIFI_FULL_RECONNECT_INTERVAL = 60000; // 60 seconds
|
||||
static const uint16_t STEP_WIFI_FULL_RECONNECT_INTERVAL = 5000; // 5 seconds
|
||||
static const uint16_t MAX_RECONNECT_ATTEMPTS = 3; // Maximum number of reconnect attempts before forcing a full connection
|
||||
static const uint16_t MAX_RECONNECT_ATTEMPTS =
|
||||
3; // Maximum number of reconnect attempts before forcing a full connection
|
||||
|
||||
// State variables
|
||||
static unsigned long lastReconnectAttempt = 0;
|
||||
|
@ -46,7 +46,6 @@ void init_WiFi() {
|
|||
|
||||
// Start Wi-Fi connection
|
||||
connectToWiFi();
|
||||
|
||||
}
|
||||
|
||||
// Task to monitor Wi-Fi status and handle reconnections
|
||||
|
@ -58,7 +57,7 @@ void wifi_monitor() {
|
|||
lastWiFiCheck = currentMillis;
|
||||
|
||||
wl_status_t status = WiFi.status();
|
||||
if (status != WL_CONNECTED ) {
|
||||
if (status != WL_CONNECTED) {
|
||||
Serial.println("Wi-Fi not connected, attempting to reconnect...");
|
||||
|
||||
// Try WiFi.reconnect() if it was successfully connected at least once
|
||||
|
@ -82,7 +81,6 @@ void wifi_monitor() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Function to force a full reconnect to Wi-Fi
|
||||
|
@ -102,7 +100,7 @@ static void FullReconnectToWiFi() {
|
|||
static void connectToWiFi() {
|
||||
if (WiFi.status() != WL_CONNECTED) {
|
||||
Serial.println("Connecting to Wi-Fi...");
|
||||
WiFi.begin( ssid.c_str(), password.c_str(),wifi_channel);
|
||||
WiFi.begin(ssid.c_str(), password.c_str(), wifi_channel);
|
||||
} else {
|
||||
Serial.println("Wi-Fi already connected.");
|
||||
}
|
||||
|
@ -118,7 +116,6 @@ static void onWifiConnect(WiFiEvent_t event, WiFiEventInfo_t info) {
|
|||
reconnectAttempts = 0; // Reset the attempt counter
|
||||
current_full_reconnect_interval = INIT_WIFI_FULL_RECONNECT_INTERVAL; // Reset the full reconnect interval
|
||||
clear_event(EVENT_WIFI_CONNECT);
|
||||
|
||||
}
|
||||
|
||||
// Event handler for Wi-Fi Got IP
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
#define WIFI_H
|
||||
|
||||
#include <WiFi.h>
|
||||
#include "../../include.h"
|
||||
#include <string>
|
||||
#include "../../include.h"
|
||||
|
||||
extern std::string ssid;
|
||||
extern std::string password;
|
||||
|
@ -11,7 +11,6 @@ extern const uint8_t wifi_channel;
|
|||
extern const char* ssidAP;
|
||||
extern const char* passwordAP;
|
||||
|
||||
|
||||
void init_WiFi();
|
||||
void wifi_monitor();
|
||||
static void connectToWiFi();
|
||||
|
@ -20,8 +19,6 @@ static void onWifiConnect(WiFiEvent_t event, WiFiEventInfo_t info);
|
|||
static void onWifiDisconnect(WiFiEvent_t event, WiFiEventInfo_t info);
|
||||
static void onWifiGotIP(WiFiEvent_t event, WiFiEventInfo_t info);
|
||||
|
||||
|
||||
|
||||
#ifdef WIFIAP
|
||||
void init_WiFi_AP();
|
||||
#endif // WIFIAP
|
||||
|
@ -31,5 +28,4 @@ void init_WiFi_AP();
|
|||
void init_mDNS();
|
||||
#endif // MDNSRESPONDER
|
||||
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue