diff --git a/boot_hotspot.sh b/boot_hotspot.sh index b30ae68..6852891 100755 --- a/boot_hotspot.sh +++ b/boot_hotspot.sh @@ -62,6 +62,12 @@ SSH_TUNNEL_PORT=$(sqlite3 /var/www/nebuleair_pro_4g/sqlite/sensors.db "SELECT va #need to wait for the network manager to be ready sleep 20 + +# IMPORTANT: Always enable WiFi radio at boot (in case it was disabled by power save) +echo "Ensuring WiFi radio is enabled..." +nmcli radio wifi on +sleep 2 + # Get the connection state of wlan0 STATE=$(nmcli -g GENERAL.STATE device show wlan0) diff --git a/wifi/power_save.py b/wifi/power_save.py index f90551f..a2c8b80 100755 --- a/wifi/power_save.py +++ b/wifi/power_save.py @@ -12,8 +12,9 @@ r''' |____/ \__,_| \_/ \___| WiFi Power Saving Script -Disables WiFi after 10 minutes of boot if wifi_power_saving is enabled in config. +Disables WiFi completely after 10 minutes of boot if wifi_power_saving is enabled in config. Saves ~100-200mA of power consumption. +WiFi is automatically re-enabled at next boot (see boot_hotspot.sh). Usage: /usr/bin/python3 /var/www/nebuleair_pro_4g/wifi/power_save.py @@ -67,8 +68,10 @@ def is_wifi_enabled(): return None def disable_wifi(): - """Disable WiFi radio using nmcli""" + """Disable WiFi radio completely using nmcli""" try: + # Disable WiFi radio completely to save maximum power + # WiFi will be re-enabled automatically at next boot by boot_hotspot.sh result = subprocess.run( ["sudo", "nmcli", "radio", "wifi", "off"], capture_output=True, @@ -76,7 +79,7 @@ def disable_wifi(): timeout=10 ) if result.returncode == 0: - log_message("WiFi disabled successfully - saving ~100-200mA power") + log_message("WiFi disabled completely - saving ~100-200mA power (will re-enable at next boot)") return True else: log_message(f"Failed to disable WiFi: {result.stderr}") @@ -115,13 +118,13 @@ def main(): log_message("WiFi is already disabled - nothing to do") return 0 - # Disable WiFi - log_message("Disabling WiFi after 10-minute configuration window...") + # Disable WiFi completely after 10-minute configuration window + log_message("Disabling WiFi completely after 10-minute configuration window...") if disable_wifi(): - log_message("WiFi power save completed successfully") + log_message("WiFi disabled successfully - will re-enable at next boot") return 0 else: - log_message("WiFi power save failed") + log_message("WiFi disable failed") return 1 if __name__ == "__main__":