From 2e12bff420d3688522aafb9e62fc7e3da8ebe067 Mon Sep 17 00:00:00 2001 From: Ruledo Date: Sun, 12 Jan 2025 00:26:40 -0800 Subject: [PATCH] Fixed wifi setup menu. Restarting wpa_supplicant, calling dhclient and setting wifi enable on meshtastic was not needed. --- .../usr/local/bin/femto-wifi-config.sh | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-wifi-config.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-wifi-config.sh index fdb3322..6d9afec 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-wifi-config.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-wifi-config.sh @@ -29,7 +29,7 @@ if [ $# -eq 0 ]; then fi # Parse options -while getopts ":s:p:c:hr" opt; do +while getopts ":s:p:c:h:r" opt; do case ${opt} in s) # Option -s (ssid) sed -i "/ssid=/s/\".*\"/\"$OPTARG\"/" "$wpa_supplicant_conf" @@ -48,6 +48,7 @@ while getopts ":s:p:c:hr" opt; do ;; h) # Option -h (help) echo -e "$help" + exit 0 ;; r) # Option -r (restart wifi) updated_wifi="true" @@ -65,17 +66,12 @@ while getopts ":s:p:c:hr" opt; do esac done +# Reconfigure wpa_supplicant if changes were made if [ "$updated_wifi" = true ]; then - systemctl restart wpa_supplicant - wpa_cli -i wlan0 reconfigure # <-------- add watch for FAIL response, error out - timeout 30s dhclient -v - echo " Wifi restarted. Enabling Meshtastic wifi setting." - updatemeshtastic.sh "--set network.wifi_enabled true" 10 "USB config" #| tee -a /tmp/femtofox-config.log - if [ $? -eq 1 ]; then - echo "Update of Meshtastic FAILED." - exit 1 - else - echo "Updated Meshtastic successfully." - exit 0 + if ! wpa_cli -i wlan0 reconfigure | grep -q "OK"; then + echo "Failed to reconfigure wpa_supplicant on wlan0." + exit 1 fi + echo "Wi-Fi configuration updated successfully for wlan0." fi +