Tag: Dial get Sha file network div reg NULL implementation
Want to know how the Raspberry Pi through the 4G Network module communication How to achieve, see this article (http://www.lxway.com/95811506.htm), ready to next have the opportunity to practice, first retained learning;
One, 4G Luci configuration
1. Create a new Wwan interface;
2, the Internet mode for automatic access to DHCP;
3, the physical setting choice wwan0;
4. Firewall Select WAN
Second, the re-connected script redial4g
Logfile=/root/4g_log.logmdate= ' Date +%r-%d-%m-%y ' if [-e/var/run/udhcpc-wwan0.pid]; Then echo 4G pid is ok! #echo $mdate 4G pid is ok! >> $LogFile #exit 0else echo 4G pid is failed! echo $mdate 4G pid is failed! >> $LogFile #/etc/mylte/dial4g #reboot #exit 0fiif ping-c3 www.baidu.com >/dev/null 2>&1then Echo Ping Baidu is ok! #echo $mdate Ping Baidu is ok! >> $LogFile echo 0 >/tmp/4g_tmp.txt exit 0else echo Ping Baidu is failed! echo $mdate Ping Baidu is failed! >> $LogFile/etc/mylte/dial4g #must Place here #read Pvar </tmp/4g_temp.txt #if [-Z "$pvar"]; Then # pvar=0 #fi if [!-F "/tmp/4g_tmp.txt"]; Then pvar=0 echo File not exist else read Pvar </tmp/4g_tmp.txt echo file exist fi Pvar= ' expr $pvar + 1 ' echo $pvar >/tmp/4g_tmp.txt If [$pvar-ge 5]; Then echo failed 5 times! echo $mdate failed 5 times! >> $LogFile reboot fi fiexit 0
Third, crontab
*/2 * * * */ETC/MYLTE/REDIAL4G
The re-connect time should not be set too short, too short may not dial the end of the replay again, will repeat.
Four, dial script dial4g
Port=/dev/ttyusb0mode= "At+cfun=1" gcom-d $PORT-S/etc/gcom/setmode.gcomsleep 3mode= "at+cops=0" gcom-d $PORT-S/ETC/GC Om/setmode.gcomsleep 3mode= "At+cereg=1" gcom-d $PORT-S/etc/gcom/setmode.gcomsleep 3mode= "AT+CGDCONT=1, ' IP '" gcom-d $ Port-s/etc/gcom/setmode.gcomsleep 3mode= "at+cgact=1,1" gcom-d $PORT-S/etc/gcom/setmode.gcomsleep 3MODE= "AT+ZGACT= "Gcom-d $PORT-S/etc/gcom/setmode.gcomsleep 3ifup wwan &exit 0
Five, boot start
# Put your custom commands here, should be executed once# the system Init finished. By default this file does Nothing./etc/mylte/dial4gexit 0
Raspberry Pi Raspberry Pi uses 4G module to surf the internet