VoCore2: AP + STA

It is not same as VoCore v1.

 

Just run this script every time you start VoCore2, you will able to make it into AP + STA mode.

If you do not run this script, it will go to AP mode.


uci set wireless.sta.ssid=[HOME AP SSID]
uci set wireless.sta.key=[AP PASSWORD]
uci set wireless.sta.network=wwan
uci set wireless.sta.disabled=0
uci commit
/etc/init.d/network restart
sleep 10
uci set wireless.sta.disabled=1
uci commit

This is not the best solution.
So I just remember one day Vernon Van Steenkist send me one script for VoCore.


#!/bin/sh
#
# Fix loss of AP when STA (Client) mode fails by reverting to default
# AP only configuration. Default AP configuration is assumed to be in
# /etc/config/wireless.ap-only
#

TIMEOUT=30
SLEEP=3

sta_err=0

while [ $(iwinfo | grep -c “ESSID: unknown”) -ge 1 ]; do
let sta_err=$sta_err+1
if [ $((sta_err * SLEEP)) -ge $TIMEOUT ]; then
cp /etc/config/wireless.ap-only /etc/config/wireless
wifi up
# uncomment the following lines to try AP+STA after reboot
# sleep 3
# cp /etc/config/wireless.ap+sta /etc/config/wireless
break
fi

sleep $SLEEP

done

This code is clever, using iwinfo to check if the STA is in normal state.
If after 30 seconds we still can not get into STA mode, we back to AP mode.
This works for VoCore.

For VoCore2, it is slightly different. If we failed to connect to STA, it will not block AP mode.

We can do this to setup your home AP one time:


uci set wireless.sta.ssid=[HOME AP SSID]
uci set wireless.sta.key=[AP PASSWORD]
uci set wireless.sta.network=wwan
uci set wireless.sta.disabled=1
uci commit

then put the following code into /etc/rc.local(run at every startup)


uci set wireless.sta.disabled=0
uci commit
/etc/init.d/network restart
sleep 10
uci set wireless.sta.disabled=1
uci commit

After this, your VoCore2 is able to connect/disconnect STA automatically. Even carry VoCore2 to another position without your home ap, it will still working.