RT-IPC_camera/bin/vslocal/cgi-bin/netqrcodescan.sh

140 lines
3.2 KiB
Bash
Raw Normal View History

2023-03-31 22:47:53 -06:00
#!/bin/sh
wifi_audio_connectsuccess()
{
return
CustomNum=`cat /mnt/config/ipcamera/config_devm.ini | grep customernum= -m1 | cut -d = -f 2 `
if [ ! -z $CustomNum ] && [ $CustomNum == "47" ] || [ $CustomNum == "123" ];
then
return ;
fi
if [ ! -e /bin/vs/media/connectsuccess.g711a ]
then
show_error "Have no connectsuccess audio"
return
else
wget -O /tmpfs/wifiaudio.log "http://127.0.0.1/web/cgi-bin/hi3510/playaudio.cgi?&-playstate=1&-playfile=connectsuccess"
fi
}
wifi_audio_connectfailure()
{
return
CustomNum=`cat /mnt/config/ipcamera/config_devm.ini | grep customernum= -m1 | cut -d = -f 2 `
if [ ! -z $CustomNum ] && [ $CustomNum == "56" ] || [ $CustomNum == "47" ] || [ $CustomNum == "123" ];
then
return ;
fi
if [ ! -e /bin/vs/media/connectfailure.g711a ]
then
show_error "Have no connectfailure audio"
return
else
wget -O /tmpfs/wifiaudio.log "http://127.0.0.1/web/cgi-bin/hi3510/playaudio.cgi?&-playstate=1&-playfile=connectfailure"
fi
}
wifi_audio_connecting()
{
return
CustomNum=`cat /mnt/config/ipcamera/config_devm.ini | grep customernum= -m1 | cut -d = -f 2 `
if [ ! -z $CustomNum ] && [ $CustomNum == "56" ] || [ $CustomNum == "47" ] || [ $CustomNum == "123" ];
then
return ;
fi
if [ ! -e /bin/vs/media/connecting.g711a ]
then
show_error "Have no connecting audio"
return
else
wget -O /tmpfs/wifiaudio.log "http://127.0.0.1/web/cgi-bin/hi3510/playaudio.cgi?&-playstate=1&-playfile=connecting"
fi
}
ZBAR_LOG="/tmpfs/zbar.log"
count=1
tcount=120
#sleep 5
while([ $count -lt $tcount ])
do
while true
do
JPEG_PATH=`wget -q -O - "http://127.0.0.1/web/cgi-bin/hi3510/snap.cgi?&-chn=2"| cut -d\" -f2`
if [ "A""${JPEG_PATH}" == "A" ]
then
echo"snap failure!"
continue
else
break
fi
done
/usr/bin/zbar ${JPEG_PATH} > ${ZBAR_LOG}
rm ${JPEG_PATH} -rf
DATA_TYPE=`cat ${ZBAR_LOG} | grep QRcode -w| cut -d= -f2`
if [ ! -s $ZBAR_LOG ]
then
echo "Unscanned information!"
count=`expr $count + 1`
continue
elif [ "${DATA_TYPE}" == "wifi" ]
then
WIFI_SSID=`cat ${ZBAR_LOG} | grep wifie_ssid -w| cut -d= -f2`
if [ "A""${WIFI_SSID}" == "A" ]
then
echo "Scan failure,WIFI_SSID=NULL"
wifi_audio_connectfailure
break
else
echo "WIFI_SSID=${WIFI_SSID}"
fi
WIFI_KEY=`cat /tmpfs/zbar.log | grep wifi_key -w| cut -d= -f2`
echo "WIFI_KEY=${WIFI_KEY}"
wifi_audio_connecting
/bin/vslocal/cgi-bin/scanwifi.cgi
WIFI_TYPE=`cat /tmpfs/wifiaplist | grep $WIFI_SSID -w|awk -F" " '{print $4}'`
if [ "A""${WIFI_TYPE}" == "A" ]
then
echo "WIFI_SSID NO FIND!"
break
else
WIFI_WKTYPE=`echo $WIFI_TYPE | grep WPA`
if [ ! -z $WIFI_WKTYPE ]
then
SMTCN_WKTYPE="3"
else
WIFI_WKTYPE=`echo $WIFI_TYPE | grep [ESS]`
if [ ! -z $WIFI_WKTYPE ] && [ $WIFI_WKTYPE == "[ESS]" ]
then
SMTCN_WKTYPE="1"
else
SMTCN_WKTYPE="2"
fi
fi
fi
if [ ! -z "$WIFI_SSID" ]&&[ ! -z "$WIFI_TYPE" ]
then
/bin/vs/cgi-bin/setwifiattr.cgi "cmd=setwifiattr&-enable=1&-ssid=${WIFI_SSID}&-wktype=${SMTCN_WKTYPE}&-wepid=0&-key=${WIFI_KEY}"
fi
wifi_audio_connectsuccess
/bin/vslocal/cgi-bin/wifi_networking.sh "STA"
else
wifi_audio_connectfailure
fi
break
done