diff --git a/scripts/setup.sh b/scripts/setup.sh index a5ec692..cfa7b9b 100644 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -141,24 +141,27 @@ echo "Configuring Networking..." rfkill unblock wlan || true if command -v nmcli > /dev/null; then - echo "NetworkManager detected. Configuring hotspot (WiFi-Safe)..." - # Clean up any existing MPVJ connection + echo "NetworkManager detected. Configuring stable hotspot..." + # Clean up existing profiles nmcli con delete MPVJ-AP 2>/dev/null || true - # Create the Access Point profile (but don't activate it yet) + # Ensure wlan0 is not connected to anything else (prevents supplicant-timeout) + nmcli device set wlan0 autoconnect no + nmcli device disconnect wlan0 2>/dev/null || true + + # Create the Access Point with specific 2.4GHz settings for Pi 3B stability nmcli con add type wifi ifname wlan0 mode ap con-name MPVJ-AP autoconnect yes ssid "$WIFI_SSID" - nmcli con modify MPVJ-AP 802-11-wireless.mode ap 802-11-wireless.band bg ipv4.method shared + nmcli con modify MPVJ-AP 802-11-wireless.mode ap 802-11-wireless.band bg + nmcli con modify MPVJ-AP ipv4.method shared ipv4.addresses 192.168.4.1/24 nmcli con modify MPVJ-AP wifi-sec.key-mgmt wpa-psk nmcli con modify MPVJ-AP wifi-sec.psk "$WIFI_PASS" - nmcli con modify MPVJ-AP ipv4.addresses 192.168.4.1/24 nmcli con modify MPVJ-AP connection.autoconnect-priority 100 - # Ensure hostapd/dnsmasq are disabled + # Ensure legacy services are out of the way systemctl stop hostapd dnsmasq 2>/dev/null || true - systemctl disable hostapd dnsmasq 2>/dev/null || true systemctl mask hostapd dnsmasq 2>/dev/null || true - echo "NetworkManager Hotspot 'MPVJ-AP' configured." + echo "Stable NetworkManager Hotspot configured." else echo "Using legacy hostapd/dnsmasq logic..." # hostapd