Skip to content

Commit

Permalink
Improvement: Replace use of deprecated functions and improve compilat…
Browse files Browse the repository at this point in the history
…ion 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
  • Loading branch information
dalathegreat authored Jan 24, 2025
1 parent 854e909 commit 275eaa9
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/compile-all-batteries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,4 @@ jobs:
# in the build matrix, and using build flags to define the
# battery and inverter set in the build matrix.
- 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
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,4 @@ jobs:
# in the build matrix, and using build flags to define the
# battery and inverter set in the build matrix.
- 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
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,4 @@ jobs:
# in the build matrix, and using build flags to define the
# battery and inverter set in the build matrix.
- 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 changes: 1 addition & 1 deletion .github/workflows/compile-all-hardware.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,4 @@ jobs:
# in the build matrix, and using build flags to define the
# battery and inverter set in the build matrix.
- 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 changes: 1 addition & 1 deletion .github/workflows/compile-all-inverters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,4 @@ jobs:
# in the build matrix, and using build flags to define the
# battery and inverter set in the build matrix.
- 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
18 changes: 9 additions & 9 deletions Software/src/devboard/webserver/webserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,26 +37,26 @@ void init_webserver() {
server.on("/GetFirmwareInfo", HTTP_GET, [](AsyncWebServerRequest* request) {
if (WEBSERVER_AUTH_REQUIRED && !request->authenticate(http_username, http_password))
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
server.on("/", HTTP_GET, [](AsyncWebServerRequest* request) {
if (WEBSERVER_AUTH_REQUIRED && !request->authenticate(http_username, http_password))
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
server.on("/settings", HTTP_GET, [](AsyncWebServerRequest* request) {
if (WEBSERVER_AUTH_REQUIRED && !request->authenticate(http_username, http_password))
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
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
Expand All @@ -76,7 +76,7 @@ void init_webserver() {
// Define the handler to stop can logging
server.on("/stop_can_logging", HTTP_GET, [](AsyncWebServerRequest* request) {
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
Expand Down Expand Up @@ -119,15 +119,15 @@ void init_webserver() {
// Define the handler to delete can log
server.on("/delete_can_log", HTTP_GET, [](AsyncWebServerRequest* request) {
delete_can_log();
request->send_P(200, "text/plain", "Log file deleted");
request->send(200, "text/plain", "Log file deleted");
});
#endif

#ifdef LOG_TO_SD
// Define the handler to delete log file
server.on("/delete_log", HTTP_GET, [](AsyncWebServerRequest* request) {
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
Expand Down Expand Up @@ -171,14 +171,14 @@ void init_webserver() {
server.on("/cellmonitor", HTTP_GET, [](AsyncWebServerRequest* request) {
if (WEBSERVER_AUTH_REQUIRED && !request->authenticate(http_username, http_password))
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
server.on("/events", HTTP_GET, [](AsyncWebServerRequest* request) {
if (WEBSERVER_AUTH_REQUIRED && !request->authenticate(http_username, http_password))
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
Expand Down
10 changes: 5 additions & 5 deletions Software/src/devboard/wifi/wifi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ void wifi_monitor() {
}

// 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
if (current_full_reconnect_interval + STEP_WIFI_FULL_RECONNECT_INTERVAL <= MAX_WIFI_FULL_RECONNECT_INTERVAL) {
Expand All @@ -120,7 +120,7 @@ static void FullReconnectToWiFi() {
}

// Function to handle Wi-Fi connection
static void connectToWiFi() {
void connectToWiFi() {
if (WiFi.status() != WL_CONNECTED) {
lastReconnectAttempt = millis(); // Reset the reconnect attempt timer
#ifdef DEBUG_LOG
Expand All @@ -135,7 +135,7 @@ static void connectToWiFi() {
}

// 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);
set_event(EVENT_WIFI_CONNECT, 0);
connected_once = true;
Expand All @@ -153,7 +153,7 @@ static void onWifiConnect(WiFiEvent_t event, WiFiEventInfo_t info) {
}

// 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_event(EVENT_WIFI_DISCONNECT);
#ifdef DEBUG_LOG
Expand All @@ -164,7 +164,7 @@ static void onWifiGotIP(WiFiEvent_t event, WiFiEventInfo_t info) {
}

// 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)
set_event(EVENT_WIFI_DISCONNECT, 0);
#ifdef DEBUG_LOG
Expand Down
10 changes: 5 additions & 5 deletions Software/src/devboard/wifi/wifi.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ extern const char* passwordAP;

void init_WiFi();
void wifi_monitor();
static void connectToWiFi();
static void FullReconnectToWiFi();
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);
void connectToWiFi();
void FullReconnectToWiFi();
void onWifiConnect(WiFiEvent_t event, WiFiEventInfo_t info);
void onWifiDisconnect(WiFiEvent_t event, WiFiEventInfo_t info);
void onWifiGotIP(WiFiEvent_t event, WiFiEventInfo_t info);

#ifdef WIFIAP
void init_WiFi_AP();
Expand Down

0 comments on commit 275eaa9

Please sign in to comment.