632 lines
16 KiB
Bash
632 lines
16 KiB
Bash
|
#!/bin/sh
|
|||
|
|
|||
|
###nolined means unplug line
|
|||
|
|
|||
|
##ACTION = NONE, PlugLine, UnplugLine, TO_STA, TO_WPS, TO_AP
|
|||
|
##WIFISTATE = NONE, (STA_CONNECTING, STA_FAILED), STA_OK, (WPS_CONNECTTING, WPS_FAILED, WPS_OK)
|
|||
|
##LINESTATE = LINED, NOLINED
|
|||
|
. /bin/vs/cgi-bin/netenv.conf
|
|||
|
. /bin/vs/cgi-bin/net_func.sh
|
|||
|
. /bin/vs/cgi-bin/wifiled.sh
|
|||
|
. /bin/vs/cgi-bin/ap_ssid.sh
|
|||
|
|
|||
|
var_wifi_connecting_times=0
|
|||
|
var_wificonnect_cnt=0
|
|||
|
var_wifi_fastlink_connecting_times=0
|
|||
|
var_wifi_playconnectfailure=0;
|
|||
|
var_wifi_disconnet=0
|
|||
|
|
|||
|
####如果WIFI器件不存在,退出脚本,如果后期WIFI器件存在,需要在程序中重新拉起脚本
|
|||
|
if [ $wifi_module_type == "0" ]
|
|||
|
then
|
|||
|
echo "wifi_off" > /proc/rt/led
|
|||
|
exit
|
|||
|
fi
|
|||
|
|
|||
|
wifi_connecting_cnt_reset()
|
|||
|
{
|
|||
|
var_wifi_connecting_times=0
|
|||
|
var_wificonnect_cnt=0
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
net_doaction()
|
|||
|
{
|
|||
|
#netaction=$net_action_curr
|
|||
|
netaction=$(net_getaction)
|
|||
|
|
|||
|
|
|||
|
#show_dbg2 "net_doaction $netaction "
|
|||
|
case $netaction in
|
|||
|
NONE)
|
|||
|
zzz=1
|
|||
|
;;
|
|||
|
PLUGLINE)
|
|||
|
wifi_ledflash 5 #add by liutao for 288192a
|
|||
|
show_info "process netaction plug line"
|
|||
|
wifi_modeswitch "LINED"
|
|||
|
net_setdev eth0
|
|||
|
#ifconfig $wifidev 0.0.0.0
|
|||
|
net_off $wifidev
|
|||
|
net_setaction NONE
|
|||
|
net_setip LINED
|
|||
|
wifi_ledflash 0
|
|||
|
;;
|
|||
|
UNPLUGLINE)
|
|||
|
### 判断是否wifi使能, 如果使能, 开始切换动作到 TO_STA
|
|||
|
### 否则, 什么都不做
|
|||
|
show_info "process netaction unplug line"
|
|||
|
wifienable=$(wifi_getenable)
|
|||
|
show_info "wifienable:$wifienable"
|
|||
|
##1 / 2
|
|||
|
if [ $wifienable == 1 -o $wifienable == 2 ]
|
|||
|
then
|
|||
|
show_info "unplug line, wifienable is $wifienable. will start wifi"
|
|||
|
#ifconfig eth0 0.0.0.0
|
|||
|
net_off eth0
|
|||
|
net_setdev $wifidev
|
|||
|
|
|||
|
#customernum=`paraconf r 2 customernum`
|
|||
|
show_info "customernum------>"$customernum
|
|||
|
. $wifi_config
|
|||
|
|
|||
|
############SBTC SSID="TEST-WIFI" GO TO SMTCN
|
|||
|
if [ ! -z $customernum ] && [ $customernum == "55" ] && [ $wifiessid == "TEST-WIFI" ] && [ $cfg_wifiautosmtcn == "1" ];then
|
|||
|
while [ 1 ]
|
|||
|
do
|
|||
|
if [ -f /tmpfs/vs_server.pid ];then
|
|||
|
break;
|
|||
|
fi
|
|||
|
show_info "--------------------->sbtc wait vs_server"
|
|||
|
sleep 1
|
|||
|
done
|
|||
|
net_setaction TO_SMTCN
|
|||
|
elif [ ! -z $customernum ] && [ $wifiessid == "TEST-WIFI" ] && [ $cfg_wifiautoap == "2" ];then
|
|||
|
show_info "--------------------->rentu_to_ap"
|
|||
|
net_setaction TO_AP
|
|||
|
elif [ $wifiessid == "544553542D57494649" ] && [ $cfg_wifiautoap == "0" ];then
|
|||
|
show_info "--------------------->quick_to_ap"
|
|||
|
net_setaction TO_AP
|
|||
|
else
|
|||
|
boardtype=`cat /etc/board.conf | grep boardtype= | cut -d = -f 2`
|
|||
|
if [ $customernum == "49" ] && [ $boardtype == "3500" ];then
|
|||
|
net_setaction TO_AP
|
|||
|
else
|
|||
|
net_setaction TO_STA
|
|||
|
fi
|
|||
|
|
|||
|
fi
|
|||
|
else
|
|||
|
if [ -e /tmpfs/pppd/pppd_connect.status ];then ###3G板子识别到sim,会产生此文件,并且设备3G设备使用的是3G网络,否则不会走此分支
|
|||
|
p2p_tran=`paraconf r 1 P2P_TRAN`
|
|||
|
echo "ppp0" > /tmpfs/netdev ###将当前的网络状态写ppp0
|
|||
|
killall $p2p_tran ###因为glink程序需要写入当前正使用的设备的网络状态信息方能ok,安全起见把其他tran程序也kill
|
|||
|
show_info "curr dev ppp0"
|
|||
|
fi
|
|||
|
show_info "unplug line, but wifienable is $wifienable. donothing"
|
|||
|
net_setaction NONE
|
|||
|
fi
|
|||
|
wifi_ledflash 4
|
|||
|
;;
|
|||
|
TO_STA)
|
|||
|
wifi_ledflash 4
|
|||
|
show_dbg2 "process netaction TO_STA"
|
|||
|
var_wifi_connecting_times=0
|
|||
|
var_wificonnect_cnt=0
|
|||
|
wifi_modeswitch "STA"
|
|||
|
net_setaction NONE
|
|||
|
|
|||
|
if [ ! -z $customernum ] && [ $customernum == "96" ];then
|
|||
|
wifi_audio_connecting
|
|||
|
fi
|
|||
|
;;
|
|||
|
TO_WPS)
|
|||
|
show_dbg2 "process netaction TO_WPS"
|
|||
|
wifi_modeswitch "WPS"
|
|||
|
net_setaction NONE
|
|||
|
wifi_ledflash 3
|
|||
|
;;
|
|||
|
TO_AP)
|
|||
|
show_dbg2 "process netaction TO_AP"
|
|||
|
## APFile="/etc/Wireless/RT2870AP/RT2870AP.orig.dat"
|
|||
|
|
|||
|
#wifi_module_type=`/bin/vslocal/cgi-bin/getwifimoduletype.sh`
|
|||
|
if [ $wifi_module_type == "7601" ]
|
|||
|
then
|
|||
|
if [ ! -e /etc/Wireless/RT2870AP/RT2870AP.orig.dat ]
|
|||
|
then
|
|||
|
show_error "$wifi_module_type Can't Enter AP mode. Not exist ap config "
|
|||
|
net_setaction "NONE"
|
|||
|
wifi_setstate NONE
|
|||
|
else
|
|||
|
###wifi_audio_to_ap ###提示声距进入ap的时差太久,故不放在这里提示放在start_to_ap处提示
|
|||
|
wifi_setstate "AP"
|
|||
|
wifi_modeswitch "AP"
|
|||
|
net_setaction NONE
|
|||
|
|
|||
|
fi
|
|||
|
elif [ $wifi_module_type == "8189" ]
|
|||
|
then
|
|||
|
wifi_setstate "AP"
|
|||
|
wifi_modeswitch "AP"
|
|||
|
net_setaction NONE
|
|||
|
else
|
|||
|
show_error "Can't Enter AP mode. unknown wifi_module: $wifi_module_type "
|
|||
|
net_setaction "NONE"
|
|||
|
wifi_setstate NONE
|
|||
|
fi
|
|||
|
;;
|
|||
|
TO_SMTCN)
|
|||
|
show_dbg2 "process netaction TO_SMTCN"
|
|||
|
wifi_modeswitch "SMTCN"
|
|||
|
net_setaction NONE
|
|||
|
wifi_ledflash 4
|
|||
|
;;
|
|||
|
TO_FATCN)
|
|||
|
show_dbg2 "process netaction TO_FATCN"
|
|||
|
wifi_modeswitch "FATCN"
|
|||
|
net_setaction NONE
|
|||
|
wifi_ledflash 4
|
|||
|
;;
|
|||
|
TO_FIXNET)
|
|||
|
show_dbg2 "process netaction TO_FIXNET"
|
|||
|
wifi_modeswitch "FIXNET"
|
|||
|
net_setaction NONE
|
|||
|
wifi_ledflash 4
|
|||
|
;;
|
|||
|
TO_TEST)
|
|||
|
;;
|
|||
|
*)
|
|||
|
echo "unknown action $netaction"
|
|||
|
net_setaction NONE
|
|||
|
;;
|
|||
|
esac
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
wifi_flags=0
|
|||
|
wifi_dostate()
|
|||
|
{
|
|||
|
prewifistate=$1
|
|||
|
curwifistate=$2
|
|||
|
|
|||
|
#show_dbg2 "wifi_dostate $prewifistate , $curwifistate"
|
|||
|
|
|||
|
case $curwifistate in
|
|||
|
NONE)
|
|||
|
;;
|
|||
|
STA_CONNECTING)
|
|||
|
show_dbg2 "STA_CONNECTING var_wifi_connecting_times $var_wifi_connecting_times var_wificonnect_cnt $var_wificonnect_cnt"
|
|||
|
|
|||
|
if [ $var_wifi_connecting_times -eq 0 ] && [ $var_wificonnect_cnt -eq 0 ]
|
|||
|
then
|
|||
|
sleep 2 #RT_LLQ,当从正在连接的STA切到错误的STA时,需要延时等状态改变
|
|||
|
fi
|
|||
|
|
|||
|
if [ $var_wifi_connecting_times -eq 0 ]
|
|||
|
then
|
|||
|
|
|||
|
###camsense使用
|
|||
|
if [ ! -z $customernum ] && [ $customernum == "123" ];then
|
|||
|
is_found=`cat /etc/network/wifista.conf`
|
|||
|
show_dbg2 "=== is_found_wifi=$is_found"
|
|||
|
if [ ${is_found}"A" = "NOTFOUNDA" ]
|
|||
|
then
|
|||
|
wifi_setstate STA_FAILED
|
|||
|
return
|
|||
|
fi
|
|||
|
fi
|
|||
|
|
|||
|
if [ $var_wificonnect_cnt -lt $cfg_wifi_retry ]
|
|||
|
then
|
|||
|
linkstatus=$(wifi_getstatus)
|
|||
|
if [ ${linkstatus}"A" = COMPLETED"A" ]
|
|||
|
then
|
|||
|
wifi_setstate STA_OK
|
|||
|
return
|
|||
|
fi
|
|||
|
var_wificonnect_cnt=`expr $var_wificonnect_cnt + 1`
|
|||
|
show_info "Linkstatus is $linkstatus"
|
|||
|
else
|
|||
|
linkstatus=$(wifi_getstatus)
|
|||
|
if [ ${linkstatus}"A" = COMPLETED"A" ]
|
|||
|
then
|
|||
|
wifi_setstate STA_OK
|
|||
|
else
|
|||
|
wifi_setstate STA_FAILED
|
|||
|
fi
|
|||
|
return
|
|||
|
fi
|
|||
|
var_wifi_connecting_times=`expr $var_wifi_connecting_times + 1`
|
|||
|
else
|
|||
|
var_wifi_connecting_times=`expr $var_wifi_connecting_times + 1`
|
|||
|
if [ $var_wifi_connecting_times -ge $cfg_wifi_retry_internal ]
|
|||
|
then
|
|||
|
var_wifi_connecting_times=0
|
|||
|
fi
|
|||
|
fi
|
|||
|
;;
|
|||
|
STA_FAILED)
|
|||
|
wifi_connecting_cnt_reset
|
|||
|
if [ $cfg_wifiautoap = 1 ]
|
|||
|
then
|
|||
|
show_info1 "STA connect failed. AUTO to AP"
|
|||
|
net_setaction TO_AP
|
|||
|
elif [ $cfg_wifiautoap = 2 ] #人图 ap_auto=2
|
|||
|
then
|
|||
|
show_info1 "STA connect failed. AUTO to AP"
|
|||
|
net_setaction TO_AP
|
|||
|
elif [ $cfg_wifiautofixnet = 1 ]
|
|||
|
then
|
|||
|
show_info1 "STA connect failed. AUTO to FIXNET"
|
|||
|
net_setaction TO_FIXNET
|
|||
|
else
|
|||
|
if [ $cfg_stafailedafter = "AP" ]
|
|||
|
then
|
|||
|
net_setaction TO_AP
|
|||
|
else
|
|||
|
net_setaction TO_STA
|
|||
|
fi
|
|||
|
fi
|
|||
|
|
|||
|
wifi_setstate NONE
|
|||
|
wifi_ledflash 4
|
|||
|
;;
|
|||
|
|
|||
|
STA_OK)
|
|||
|
|
|||
|
wifi_connecting_cnt_reset
|
|||
|
show_dbg2 "STA OK"
|
|||
|
#wifi_setstate NONE
|
|||
|
net_setip STA
|
|||
|
wifi_ledflash 1
|
|||
|
wifi_audio_connectsuccess
|
|||
|
var_wifi_disconnet=0
|
|||
|
wifi_setstate STA_CHECK
|
|||
|
;;
|
|||
|
STA_CHECK)
|
|||
|
sleep 2
|
|||
|
linkstatus=$(wifi_getstatus)
|
|||
|
if [ ${linkstatus}"A" = COMPLETED"A" ]
|
|||
|
then
|
|||
|
if [ $var_wifi_disconnet -eq 1 ]
|
|||
|
then
|
|||
|
var_wifi_disconnet=0
|
|||
|
wifi_ledflash 1
|
|||
|
fi
|
|||
|
else
|
|||
|
if [ $var_wifi_disconnet -eq 0 ]
|
|||
|
then
|
|||
|
show_dbg2 "STA CONNECTING BREAK!"
|
|||
|
var_wifi_disconnet=1
|
|||
|
if [ -e /bin/vs/cgi-bin/wifi_off_on.sh ];then
|
|||
|
/bin/vs/cgi-bin/wifi_off_on.sh &
|
|||
|
fi
|
|||
|
#wifi_setstate NONE
|
|||
|
wifi_ledflash 4
|
|||
|
fi
|
|||
|
fi
|
|||
|
;;
|
|||
|
WPS_CONNECTING)
|
|||
|
show_dbg2 "STA_CONNECTING var_wifi_connecting_times $var_wifi_connecting_times var_wificonnect_cnt $var_wificonnect_cnt"
|
|||
|
if [ $var_wifi_connecting_times -eq 0 ]
|
|||
|
then
|
|||
|
if [ $var_wificonnect_cnt -lt $cfg_wifiwps_retry ]
|
|||
|
then
|
|||
|
linkstatus=$(wifi_getstatus)
|
|||
|
if [ ${linkstatus}"A" = COMPLETED"A" ]
|
|||
|
then
|
|||
|
wifi_setstate WPS_OK
|
|||
|
return
|
|||
|
fi
|
|||
|
var_wificonnect_cnt=`expr $var_wificonnect_cnt + 1`
|
|||
|
show_info "Linkstatus is $linkstatus"
|
|||
|
else
|
|||
|
linkstatus=$(wifi_getstatus)
|
|||
|
if [ ${linkstatus}"A" = COMPLETED"A" ]
|
|||
|
then
|
|||
|
wifi_setstate WPS_OK
|
|||
|
else
|
|||
|
wifi_setstate WPS_FAILED
|
|||
|
fi
|
|||
|
return
|
|||
|
fi
|
|||
|
var_wifi_connecting_times=`expr $var_wifi_connecting_times + 1`
|
|||
|
else
|
|||
|
var_wifi_connecting_times=`expr $var_wifi_connecting_times + 1`
|
|||
|
if [ $var_wifi_connecting_times -ge $cfg_wifiwps_retry_internal ]
|
|||
|
then
|
|||
|
var_wifi_connecting_times=0
|
|||
|
fi
|
|||
|
fi
|
|||
|
;;
|
|||
|
WPS_FAILED)
|
|||
|
show_info "WPS_FAILED"
|
|||
|
wifi_connecting_cnt_reset
|
|||
|
###spotcam 2592版本WPS失败进入AP
|
|||
|
if [ $customernum == "92" ] && [ $boardtype == "2500" ];then
|
|||
|
wifi_setstate "AP"
|
|||
|
wifi_modeswitch "AP"
|
|||
|
net_setaction NONE
|
|||
|
else
|
|||
|
wifi_setmode STA
|
|||
|
##reread wpa_conf.conf file
|
|||
|
wpa_cli -i $wifidev reconfig
|
|||
|
wifi_setstate NONE
|
|||
|
net_setaction TO_STA
|
|||
|
fi
|
|||
|
|
|||
|
wifi_ledflash 3
|
|||
|
;;
|
|||
|
WPS_OK)
|
|||
|
show_info "WPS_OK"
|
|||
|
wifi_connecting_cnt_reset
|
|||
|
wifi_wpsOK
|
|||
|
wifi_setmode STA
|
|||
|
wifi_setstate NONE
|
|||
|
wifi_ledflash 1
|
|||
|
;;
|
|||
|
AP)
|
|||
|
wifi_connecting_cnt_reset
|
|||
|
wifi_ledflash 2
|
|||
|
wifi_setstate NONE
|
|||
|
;;
|
|||
|
SMTCN_CONNECTING)
|
|||
|
show_info "SMTCN_CONNECTING"
|
|||
|
smtcn_node=`get_smtcn_node`
|
|||
|
if [ -e $smtcn_node ];then
|
|||
|
SMTCN_SSID=`cat $smtcn_node | awk -F ", " '{printf $2}' | awk -F "=" '{printf $2}'`
|
|||
|
if [ "${SMTCN_SSID}""A" != "A" ];then
|
|||
|
wifi_setstate SMTCN_OK
|
|||
|
else
|
|||
|
echo "start" > $smtcn_node
|
|||
|
fi
|
|||
|
fi
|
|||
|
if [ -e /tmpfs/voice_wifi ];then
|
|||
|
SMTCN_SSID=`cat /tmpfs/voice_wifi | grep SSID | awk -F ": " '{printf $2}'`
|
|||
|
if [ "${SMTCN_SSID}""A" != "A" ];then
|
|||
|
wifi_setstate VOICE_OK
|
|||
|
fi
|
|||
|
fi
|
|||
|
;;
|
|||
|
SMTCN_OK)
|
|||
|
var_wifi_playconnectfailure="1"
|
|||
|
show_info "SMTCN_OK"
|
|||
|
wifi_smtcnOK
|
|||
|
if [ $? != "0" ];then
|
|||
|
wifi_setstate STA_FAILED
|
|||
|
wifi_setmode STA
|
|||
|
else
|
|||
|
close_voice_cfg_wifi_mode.sh ####当声波配置和smartlink共存时,此时去用smartlink去配置wifi会没有声音,故这里先关闭声波配置,不影响smartlink
|
|||
|
sleep 1
|
|||
|
net_setaction TO_STA
|
|||
|
wifi_setmode STA
|
|||
|
wifi_setstate NONE
|
|||
|
wifi_ledflash 1
|
|||
|
wifi_audio_connecting
|
|||
|
fi
|
|||
|
;;
|
|||
|
|
|||
|
VOICE_OK)
|
|||
|
var_wifi_playconnectfailure="1"
|
|||
|
show_info "VOICE_OK"
|
|||
|
wifi_smtcn_stop
|
|||
|
wifi_voiceOK
|
|||
|
if [ $? != "0" ];then
|
|||
|
wifi_setstate STA_FAILED
|
|||
|
wifi_setmode STA
|
|||
|
else
|
|||
|
net_setaction TO_STA
|
|||
|
wifi_setmode STA
|
|||
|
wifi_setstate NONE
|
|||
|
wifi_ledflash 1
|
|||
|
wifi_audio_connecting
|
|||
|
fi
|
|||
|
;;
|
|||
|
FATCN_CONNECTING)
|
|||
|
show_info "FATCN_CONNECTING"
|
|||
|
var_wifi_fastlink_connecting_times=`expr $var_wifi_fastlink_connecting_times + 1`
|
|||
|
|
|||
|
if [ $var_wifi_fastlink_connecting_times -gt $cfg_wififastlink_retry_internal ];then
|
|||
|
var_wifi_fastlink_connecting_times=0
|
|||
|
killall fastlink
|
|||
|
/bin/vslocal/cgi-bin/fastlink &
|
|||
|
fi
|
|||
|
|
|||
|
if [ -e /tmpfs/fastlink.conf ];then
|
|||
|
FATCN_SSID=`cat /tmpfs/fastlink.conf | grep SSID | awk -F ": " '{printf $2}'`
|
|||
|
if [ ! -z $FATCN_SSID ];then
|
|||
|
wifi_setstate FATCN_OK
|
|||
|
killall fastlink
|
|||
|
fi
|
|||
|
fi
|
|||
|
;;
|
|||
|
FATCN_OK)
|
|||
|
var_wifi_playconnectfailure="1"
|
|||
|
show_info "FATCN_OK"
|
|||
|
wifi_fatcnOK
|
|||
|
net_setaction TO_STA
|
|||
|
wifi_setmode STA
|
|||
|
wifi_setstate NONE
|
|||
|
wifi_ledflash 1
|
|||
|
wifi_audio_connecting
|
|||
|
;;
|
|||
|
FIXNET_CONNECTING)
|
|||
|
show_dbg2 "FIXNET_CONNECTING var_wifi_connecting_times $var_wifi_connecting_times var_wificonnect_cnt $var_wificonnect_cnt"
|
|||
|
if [ $var_wifi_connecting_times -eq 0 ]
|
|||
|
then
|
|||
|
if [ $var_wificonnect_cnt -lt $cfg_wifi_retry ]
|
|||
|
then
|
|||
|
linkstatus=$(wifi_getstatus)
|
|||
|
if [ ${linkstatus}"A" = COMPLETED"A" ]
|
|||
|
then
|
|||
|
wifi_setstate FIXNET_OK
|
|||
|
return
|
|||
|
fi
|
|||
|
var_wificonnect_cnt=`expr $var_wificonnect_cnt + 1`
|
|||
|
show_info "Linkstatus is $linkstatus"
|
|||
|
else
|
|||
|
linkstatus=$(wifi_getstatus)
|
|||
|
if [ ${linkstatus}"A" = COMPLETED"A" ]
|
|||
|
then
|
|||
|
wifi_setstate FIXNET_OK
|
|||
|
else
|
|||
|
show_info1 "FIXNET_FAILED"
|
|||
|
wifi_connecting_cnt_reset
|
|||
|
net_setaction TO_FIXNET
|
|||
|
#wifi_setstate FIXNET_FAILED
|
|||
|
fi
|
|||
|
#return
|
|||
|
fi
|
|||
|
var_wifi_connecting_times=`expr $var_wifi_connecting_times + 1`
|
|||
|
else
|
|||
|
var_wifi_connecting_times=`expr $var_wifi_connecting_times + 1`
|
|||
|
if [ $var_wifi_connecting_times -ge $cfg_wifi_retry_internal ]
|
|||
|
then
|
|||
|
var_wifi_connecting_times=0
|
|||
|
fi
|
|||
|
fi
|
|||
|
;;
|
|||
|
FIXNET_OK)
|
|||
|
wifi_connecting_cnt_reset
|
|||
|
show_dbg2 "FIXNET OK"
|
|||
|
wifi_fixnetOK
|
|||
|
wifi_setstate NONE
|
|||
|
wifi_setmode STA
|
|||
|
net_setip STA
|
|||
|
wifi_ledflash 1
|
|||
|
wifi_audio_connectsuccess
|
|||
|
;;
|
|||
|
*)
|
|||
|
;;
|
|||
|
esac
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
#if [ -e /tmpfs/net_serv.pid ]
|
|||
|
#then
|
|||
|
# kill -9 `cat /tmpfs/net_serv.pid`
|
|||
|
# rm /tmpfs/net_serv.pid -f
|
|||
|
#fi
|
|||
|
|
|||
|
echo $$ > /tmpfs/net_serv.pid
|
|||
|
show_info "start net_serv daemon $$"
|
|||
|
|
|||
|
|
|||
|
|
|||
|
if [ -e $ip_config ]
|
|||
|
then
|
|||
|
. $ip_config
|
|||
|
##不存在ip地址
|
|||
|
if [ -z $address ]
|
|||
|
then
|
|||
|
net_gen_ifattr
|
|||
|
fi
|
|||
|
else
|
|||
|
net_gen_ifattr
|
|||
|
fi
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
wifistate_prev=NONE
|
|||
|
linestate_prev=NONE
|
|||
|
|
|||
|
mkdir -p /tmpfs/net/
|
|||
|
mkdir /var/run/wpa_supplicant -p
|
|||
|
mkdir -p /var/run/hostapd
|
|||
|
net_setaction "NONE"
|
|||
|
|
|||
|
|
|||
|
|
|||
|
#net_setmac
|
|||
|
|
|||
|
wifi_realenable=$(wifi_getenable)
|
|||
|
show_info "wifi_realenable is $wifi_realenable"
|
|||
|
|
|||
|
preload_wifiko=0
|
|||
|
var_wifiko_check_cnt=0
|
|||
|
cur_network_mode="NONE"
|
|||
|
|
|||
|
##gen_last_wpa_config
|
|||
|
|
|||
|
while [ 1 ]
|
|||
|
do
|
|||
|
#获取有线状态
|
|||
|
linestate_curr=$(net_getlinedstatus)
|
|||
|
##show_dbg "linestate_curr is $linestate_curr and $linestate_prev"
|
|||
|
## 网线插拔状态有变化
|
|||
|
if [ $linestate_curr != $linestate_prev ]
|
|||
|
then
|
|||
|
show_dbg "linestate_change $linestate_prev TO $linestate_curr."
|
|||
|
linestatechanged=1
|
|||
|
if [ $linestate_curr = 0 -o $linestate_curr = 2 ]
|
|||
|
then
|
|||
|
net_setaction "UNPLUGLINE"
|
|||
|
elif [ $linestate_curr = 1 ]
|
|||
|
then
|
|||
|
net_setaction "PLUGLINE"
|
|||
|
fi
|
|||
|
fi
|
|||
|
|
|||
|
net_doaction
|
|||
|
linestate_prev=$linestate_curr
|
|||
|
###curnetaction=$(getnetaction)
|
|||
|
|
|||
|
#echo $wifistate_prev , $wifistate_curr
|
|||
|
wifi_dostate $wifistate_prev $wifistate_curr
|
|||
|
wifistate_prev=$wifistate_curr
|
|||
|
|
|||
|
if [ $preload_wifiko = 1 ]
|
|||
|
then
|
|||
|
if [ $wifi_realenable -ge 1 ]
|
|||
|
then
|
|||
|
preload_wifiko=0
|
|||
|
wifi_sta_start
|
|||
|
echo "wifimac=`cat /sys/class/net/${wifidev}/address`" > $mac_wifi_file
|
|||
|
else
|
|||
|
echo "wifimac=" > $mac_wifi_file
|
|||
|
fi
|
|||
|
preload_wifiko=0
|
|||
|
fi
|
|||
|
|
|||
|
#wifi_module_type=`/bin/vslocal/cgi-bin/getwifimoduletype.sh`
|
|||
|
|
|||
|
#####如果是有线模式,且WIFI驱动被加载了,则等待2分钟后卸载驱动
|
|||
|
cur_network_mode=`wifi_getmode`
|
|||
|
if [ ${cur_network_mode} == "NONE" ]
|
|||
|
then
|
|||
|
if [ $wifi_module_type == "7601" ]
|
|||
|
then
|
|||
|
ret=`lsmod | grep 7601 > /dev/null ;echo $?`
|
|||
|
elif [ $wifi_module_type == "8189" ]
|
|||
|
then
|
|||
|
ret=`lsmod | grep 8189 > /dev/null ;echo $?`
|
|||
|
else
|
|||
|
ret=1
|
|||
|
fi
|
|||
|
|
|||
|
if [ ${ret} == 0 ];then
|
|||
|
var_wifiko_check_cnt=`expr $var_wifiko_check_cnt + 1`
|
|||
|
echo "var_wifiko_check_cnt:"${var_wifiko_check_cnt}
|
|||
|
fi
|
|||
|
|
|||
|
if [ ${var_wifiko_check_cnt} -gt 60 ]
|
|||
|
then
|
|||
|
wifi_sta_stop
|
|||
|
var_wifiko_check_cnt=0
|
|||
|
fi
|
|||
|
else
|
|||
|
var_wifiko_check_cnt=0
|
|||
|
fi
|
|||
|
|
|||
|
|
|||
|
sleep 1
|
|||
|
###ledflash
|
|||
|
done
|
|||
|
|