mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-03 17:59:27 +02:00
Improvement: Replace use of deprecated functions and improve compilation warnings (#817)
* Change deprecated Send_P to send function * Fix compilation warnings in Wifi files * Change warnings into compilation errors * Add -Wall -Wextra -Wpedantic -Werror to github actions
This commit is contained in:
parent
854e9093fd
commit
275eaa9be8
8 changed files with 24 additions and 24 deletions
2
.github/workflows/compile-all-batteries.yml
vendored
2
.github/workflows/compile-all-batteries.yml
vendored
|
@ -112,4 +112,4 @@ jobs:
|
||||||
# in the build matrix, and using build flags to define the
|
# in the build matrix, and using build flags to define the
|
||||||
# battery and inverter set in the build matrix.
|
# battery and inverter set in the build matrix.
|
||||||
- name: Compile Sketch
|
- name: Compile Sketch
|
||||||
run: arduino-cli compile --fqbn ${{ matrix.fqbn }} --build-property "build.extra_flags=-Wall -DESP32 -D${{ matrix.battery}} -D${{ matrix.inverter}} -D${{ matrix.hardware}}" ./Software
|
run: arduino-cli compile --fqbn ${{ matrix.fqbn }} --build-property "build.extra_flags=-Wall -Wextra -Wpedantic -Werror -DESP32 -D${{ matrix.battery}} -D${{ matrix.inverter}} -D${{ matrix.hardware}}" ./Software
|
||||||
|
|
|
@ -118,4 +118,4 @@ jobs:
|
||||||
# in the build matrix, and using build flags to define the
|
# in the build matrix, and using build flags to define the
|
||||||
# battery and inverter set in the build matrix.
|
# battery and inverter set in the build matrix.
|
||||||
- name: Compile Sketch
|
- name: Compile Sketch
|
||||||
run: arduino-cli compile --fqbn ${{ matrix.fqbn }} --build-property "build.extra_flags=-Wall -DESP32 -D${{ matrix.battery}} -D${{ matrix.inverter}} -D${{ matrix.hardware}}" ./Software
|
run: arduino-cli compile --fqbn ${{ matrix.fqbn }} --build-property "build.extra_flags=-Wall -Wextra -Wpedantic -Werror -DESP32 -D${{ matrix.battery}} -D${{ matrix.inverter}} -D${{ matrix.hardware}}" ./Software
|
||||||
|
|
|
@ -118,4 +118,4 @@ jobs:
|
||||||
# in the build matrix, and using build flags to define the
|
# in the build matrix, and using build flags to define the
|
||||||
# battery and inverter set in the build matrix.
|
# battery and inverter set in the build matrix.
|
||||||
- name: Compile Sketch
|
- name: Compile Sketch
|
||||||
run: arduino-cli compile --fqbn ${{ matrix.fqbn }} --build-property "build.extra_flags=-Wall -DESP32 -D${{ matrix.battery}} -D${{ matrix.inverter}} -D${{ matrix.hardware}}" ./Software
|
run: arduino-cli compile --fqbn ${{ matrix.fqbn }} --build-property "build.extra_flags=-Wall -Wextra -Wpedantic -Werror -DESP32 -D${{ matrix.battery}} -D${{ matrix.inverter}} -D${{ matrix.hardware}}" ./Software
|
||||||
|
|
2
.github/workflows/compile-all-hardware.yml
vendored
2
.github/workflows/compile-all-hardware.yml
vendored
|
@ -90,4 +90,4 @@ jobs:
|
||||||
# in the build matrix, and using build flags to define the
|
# in the build matrix, and using build flags to define the
|
||||||
# battery and inverter set in the build matrix.
|
# battery and inverter set in the build matrix.
|
||||||
- name: Compile Sketch
|
- name: Compile Sketch
|
||||||
run: arduino-cli compile --fqbn ${{ matrix.fqbn }} --build-property "build.extra_flags=-Wall -DESP32 -D${{ matrix.battery}} -D${{ matrix.inverter}} -D${{ matrix.hardware}}" ./Software
|
run: arduino-cli compile --fqbn ${{ matrix.fqbn }} --build-property "build.extra_flags=-Wall -Wextra -Wpedantic -Werror -DESP32 -D${{ matrix.battery}} -D${{ matrix.inverter}} -D${{ matrix.hardware}}" ./Software
|
||||||
|
|
2
.github/workflows/compile-all-inverters.yml
vendored
2
.github/workflows/compile-all-inverters.yml
vendored
|
@ -105,4 +105,4 @@ jobs:
|
||||||
# in the build matrix, and using build flags to define the
|
# in the build matrix, and using build flags to define the
|
||||||
# battery and inverter set in the build matrix.
|
# battery and inverter set in the build matrix.
|
||||||
- name: Compile Sketch
|
- name: Compile Sketch
|
||||||
run: arduino-cli compile --fqbn ${{ matrix.fqbn }} --build-property "build.extra_flags=-Wall -DESP32 -D${{ matrix.battery}} -D${{ matrix.inverter}} -D${{ matrix.hardware}}" ./Software
|
run: arduino-cli compile --fqbn ${{ matrix.fqbn }} --build-property "build.extra_flags=-Wall -Wextra -Wpedantic -Werror -DESP32 -D${{ matrix.battery}} -D${{ matrix.inverter}} -D${{ matrix.hardware}}" ./Software
|
||||||
|
|
|
@ -37,26 +37,26 @@ void init_webserver() {
|
||||||
server.on("/GetFirmwareInfo", HTTP_GET, [](AsyncWebServerRequest* request) {
|
server.on("/GetFirmwareInfo", HTTP_GET, [](AsyncWebServerRequest* request) {
|
||||||
if (WEBSERVER_AUTH_REQUIRED && !request->authenticate(http_username, http_password))
|
if (WEBSERVER_AUTH_REQUIRED && !request->authenticate(http_username, http_password))
|
||||||
return request->requestAuthentication();
|
return request->requestAuthentication();
|
||||||
request->send_P(200, "application/json", get_firmware_info_html, get_firmware_info_processor);
|
request->send(200, "application/json", get_firmware_info_html, get_firmware_info_processor);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Route for root / web page
|
// Route for root / web page
|
||||||
server.on("/", HTTP_GET, [](AsyncWebServerRequest* request) {
|
server.on("/", HTTP_GET, [](AsyncWebServerRequest* request) {
|
||||||
if (WEBSERVER_AUTH_REQUIRED && !request->authenticate(http_username, http_password))
|
if (WEBSERVER_AUTH_REQUIRED && !request->authenticate(http_username, http_password))
|
||||||
return request->requestAuthentication();
|
return request->requestAuthentication();
|
||||||
request->send_P(200, "text/html", index_html, processor);
|
request->send(200, "text/html", index_html, processor);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Route for going to settings web page
|
// Route for going to settings web page
|
||||||
server.on("/settings", HTTP_GET, [](AsyncWebServerRequest* request) {
|
server.on("/settings", HTTP_GET, [](AsyncWebServerRequest* request) {
|
||||||
if (WEBSERVER_AUTH_REQUIRED && !request->authenticate(http_username, http_password))
|
if (WEBSERVER_AUTH_REQUIRED && !request->authenticate(http_username, http_password))
|
||||||
return request->requestAuthentication();
|
return request->requestAuthentication();
|
||||||
request->send_P(200, "text/html", index_html, settings_processor);
|
request->send(200, "text/html", index_html, settings_processor);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Route for going to advanced battery info web page
|
// Route for going to advanced battery info web page
|
||||||
server.on("/advanced", HTTP_GET, [](AsyncWebServerRequest* request) {
|
server.on("/advanced", HTTP_GET, [](AsyncWebServerRequest* request) {
|
||||||
request->send_P(200, "text/html", index_html, advanced_battery_processor);
|
request->send(200, "text/html", index_html, advanced_battery_processor);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Route for going to CAN logging web page
|
// Route for going to CAN logging web page
|
||||||
|
@ -76,7 +76,7 @@ void init_webserver() {
|
||||||
// Define the handler to stop can logging
|
// Define the handler to stop can logging
|
||||||
server.on("/stop_can_logging", HTTP_GET, [](AsyncWebServerRequest* request) {
|
server.on("/stop_can_logging", HTTP_GET, [](AsyncWebServerRequest* request) {
|
||||||
datalayer.system.info.can_logging_active = false;
|
datalayer.system.info.can_logging_active = false;
|
||||||
request->send_P(200, "text/plain", "Logging stopped");
|
request->send(200, "text/plain", "Logging stopped");
|
||||||
});
|
});
|
||||||
|
|
||||||
#ifndef LOG_CAN_TO_SD
|
#ifndef LOG_CAN_TO_SD
|
||||||
|
@ -119,7 +119,7 @@ void init_webserver() {
|
||||||
// Define the handler to delete can log
|
// Define the handler to delete can log
|
||||||
server.on("/delete_can_log", HTTP_GET, [](AsyncWebServerRequest* request) {
|
server.on("/delete_can_log", HTTP_GET, [](AsyncWebServerRequest* request) {
|
||||||
delete_can_log();
|
delete_can_log();
|
||||||
request->send_P(200, "text/plain", "Log file deleted");
|
request->send(200, "text/plain", "Log file deleted");
|
||||||
});
|
});
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ void init_webserver() {
|
||||||
// Define the handler to delete log file
|
// Define the handler to delete log file
|
||||||
server.on("/delete_log", HTTP_GET, [](AsyncWebServerRequest* request) {
|
server.on("/delete_log", HTTP_GET, [](AsyncWebServerRequest* request) {
|
||||||
delete_log();
|
delete_log();
|
||||||
request->send_P(200, "text/plain", "Log file deleted");
|
request->send(200, "text/plain", "Log file deleted");
|
||||||
});
|
});
|
||||||
|
|
||||||
// Define the handler to export debug log
|
// Define the handler to export debug log
|
||||||
|
@ -171,14 +171,14 @@ void init_webserver() {
|
||||||
server.on("/cellmonitor", HTTP_GET, [](AsyncWebServerRequest* request) {
|
server.on("/cellmonitor", HTTP_GET, [](AsyncWebServerRequest* request) {
|
||||||
if (WEBSERVER_AUTH_REQUIRED && !request->authenticate(http_username, http_password))
|
if (WEBSERVER_AUTH_REQUIRED && !request->authenticate(http_username, http_password))
|
||||||
return request->requestAuthentication();
|
return request->requestAuthentication();
|
||||||
request->send_P(200, "text/html", index_html, cellmonitor_processor);
|
request->send(200, "text/html", index_html, cellmonitor_processor);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Route for going to event log web page
|
// Route for going to event log web page
|
||||||
server.on("/events", HTTP_GET, [](AsyncWebServerRequest* request) {
|
server.on("/events", HTTP_GET, [](AsyncWebServerRequest* request) {
|
||||||
if (WEBSERVER_AUTH_REQUIRED && !request->authenticate(http_username, http_password))
|
if (WEBSERVER_AUTH_REQUIRED && !request->authenticate(http_username, http_password))
|
||||||
return request->requestAuthentication();
|
return request->requestAuthentication();
|
||||||
request->send_P(200, "text/html", index_html, events_processor);
|
request->send(200, "text/html", index_html, events_processor);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Route for clearing all events
|
// Route for clearing all events
|
||||||
|
|
|
@ -108,7 +108,7 @@ void wifi_monitor() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to force a full reconnect to Wi-Fi
|
// Function to force a full reconnect to Wi-Fi
|
||||||
static void FullReconnectToWiFi() {
|
void FullReconnectToWiFi() {
|
||||||
|
|
||||||
// Increase the current reconnect interval if it's not at the maximum
|
// Increase the current reconnect interval if it's not at the maximum
|
||||||
if (current_full_reconnect_interval + STEP_WIFI_FULL_RECONNECT_INTERVAL <= MAX_WIFI_FULL_RECONNECT_INTERVAL) {
|
if (current_full_reconnect_interval + STEP_WIFI_FULL_RECONNECT_INTERVAL <= MAX_WIFI_FULL_RECONNECT_INTERVAL) {
|
||||||
|
@ -120,7 +120,7 @@ static void FullReconnectToWiFi() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to handle Wi-Fi connection
|
// Function to handle Wi-Fi connection
|
||||||
static void connectToWiFi() {
|
void connectToWiFi() {
|
||||||
if (WiFi.status() != WL_CONNECTED) {
|
if (WiFi.status() != WL_CONNECTED) {
|
||||||
lastReconnectAttempt = millis(); // Reset the reconnect attempt timer
|
lastReconnectAttempt = millis(); // Reset the reconnect attempt timer
|
||||||
#ifdef DEBUG_LOG
|
#ifdef DEBUG_LOG
|
||||||
|
@ -135,7 +135,7 @@ static void connectToWiFi() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Event handler for successful Wi-Fi connection
|
// Event handler for successful Wi-Fi connection
|
||||||
static void onWifiConnect(WiFiEvent_t event, WiFiEventInfo_t info) {
|
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;
|
connected_once = true;
|
||||||
|
@ -153,7 +153,7 @@ static void onWifiConnect(WiFiEvent_t event, WiFiEventInfo_t info) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Event handler for Wi-Fi Got IP
|
// Event handler for Wi-Fi Got IP
|
||||||
static void onWifiGotIP(WiFiEvent_t event, WiFiEventInfo_t info) {
|
void onWifiGotIP(WiFiEvent_t event, WiFiEventInfo_t info) {
|
||||||
//clear disconnects events if we got a IP
|
//clear disconnects events if we got a IP
|
||||||
clear_event(EVENT_WIFI_DISCONNECT);
|
clear_event(EVENT_WIFI_DISCONNECT);
|
||||||
#ifdef DEBUG_LOG
|
#ifdef DEBUG_LOG
|
||||||
|
@ -164,7 +164,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) {
|
void onWifiDisconnect(WiFiEvent_t event, WiFiEventInfo_t info) {
|
||||||
if (connected_once)
|
if (connected_once)
|
||||||
set_event(EVENT_WIFI_DISCONNECT, 0);
|
set_event(EVENT_WIFI_DISCONNECT, 0);
|
||||||
#ifdef DEBUG_LOG
|
#ifdef DEBUG_LOG
|
||||||
|
|
|
@ -17,11 +17,11 @@ extern const char* passwordAP;
|
||||||
|
|
||||||
void init_WiFi();
|
void init_WiFi();
|
||||||
void wifi_monitor();
|
void wifi_monitor();
|
||||||
static void connectToWiFi();
|
void connectToWiFi();
|
||||||
static void FullReconnectToWiFi();
|
void FullReconnectToWiFi();
|
||||||
static void onWifiConnect(WiFiEvent_t event, WiFiEventInfo_t info);
|
void onWifiConnect(WiFiEvent_t event, WiFiEventInfo_t info);
|
||||||
static void onWifiDisconnect(WiFiEvent_t event, WiFiEventInfo_t info);
|
void onWifiDisconnect(WiFiEvent_t event, WiFiEventInfo_t info);
|
||||||
static void onWifiGotIP(WiFiEvent_t event, WiFiEventInfo_t info);
|
void onWifiGotIP(WiFiEvent_t event, WiFiEventInfo_t info);
|
||||||
|
|
||||||
#ifdef WIFIAP
|
#ifdef WIFIAP
|
||||||
void init_WiFi_AP();
|
void init_WiFi_AP();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue