Skip to content

Commit

Permalink
Disable Wifi after setup only in release builds (#64)
Browse files Browse the repository at this point in the history
Also update the flags to be generic DEBUG for a few features
  • Loading branch information
layog authored Feb 4, 2025
1 parent 361fb5b commit e68f50e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
3 changes: 1 addition & 2 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ build_flags =
extends = env
build_flags =
${env.build_flags}
-D WIFI_ON_BOOT # Enables WiFi on boot
-D DEBUG_WEBSERVER # Enables a web server for debugging
-D DEBUG_WIFI # Enables WiFi on boot, enables webserver, does not disable Wifi after setup
-D DISABLE_MASS_STORAGE # Disables mass storage on SD card mount
-D ARDUINO_USB_MODE=1
-D ARDUINO_USB_CDC_ON_BOOT=1 # Required for USB Serial on boot (for debugging)
Expand Down
4 changes: 3 additions & 1 deletion src/vario/PageMenuSystemWifi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,12 @@ void PageMenuSystemWifi::draw_menu_input(int8_t cursor_position) {
}

void PageMenuSystemWifi::closed(bool removed_from_stack) {
// Turn off WiFi once the page is closed
#ifndef DEBUG_WIFI
if (!removed_from_stack) return;
WiFi.disconnect();
wifi_state = WifiState::DISCONNECTED;
Serial.println("WiFi disconnected");
#endif
}

/**************************
Expand Down
10 changes: 4 additions & 6 deletions src/vario/vario.ino
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@
#include "tempRH.h"
#include "wind_estimate/wind_estimate.h"

#ifdef WIFI_ON_BOOT
#ifdef DEBUG_WIFI
#include <WiFi.h>
#endif
#ifdef DEBUG_WEBSERVER
#include "DebugWebserver.h"
#endif

Expand Down Expand Up @@ -90,14 +88,14 @@ void setup() {
delay(200);
Serial.println("Starting Setup");

#ifdef WIFI_ON_BOOT
#ifdef DEBUG_WIFI
// Start WiFi
WiFi.begin();
WiFi.onEvent([](WiFiEvent_t event, WiFiEventInfo_t info) {
Serial.println("WiFi Event " + WiFi.localIP().toString() + ": " + event);
});
#endif
#ifdef DEBUG_WEBSERVER
#ifdef DEBUG_WIFI
// Start WebServer
webserver_setup();
#endif
Expand Down Expand Up @@ -173,7 +171,7 @@ the pushbuttons, the GPS 1PPS signal, and perhaps others.

void loop() {

#ifdef DEBUG_WEBSERVER
#ifdef DEBUG_WIFI
webserver_loop();
#endif

Expand Down

0 comments on commit e68f50e

Please sign in to comment.