WiFi fail safe solution
About
This article describes how to have ability to select AP or STA with jumper.
Hardware
Put jumper between GND and GPIO7 to activate AP mode. Remove to leave in STA mode.
Configuring
- Create script
/usr/bin/wifi_mode.sh
and fill with content
#!/bin/sh EXPORT='echo 7 > /sys/class/gpio/export' DIRECTION='echo in > /sys/devices/virtual/gpio/gpio7/direction' BODY=`cat /sys/devices/virtual/gpio/gpio7/value`; if [ "$BODY" == 1 ]; then echo "AP mode" cp /etc/config/wireless_ap /etc/config/wireless else echo "STA mode" cp /etc/config/wireless_sta /etc/config/wireless fi
- Create two versions of wireless configuration file.
/etc/config/wireless_ap
and/etc/config/wireless_sta
. Add "option auto 0" to interface configuration.
Run on boot
- Edit
/etc/rc.local
file to be like this:
/usr/bin/wifi_mode.sh wifi exit 0