【樹莓派】樹莓派使用4G模組上網

來源:互聯網
上載者:User

標籤:撥號   擷取   sha   file   網路   div   reg   null   實現   

想瞭解一下樹莓派通過4G網路模組通訊如何?,看到這篇文章(http://www.lxway.com/95811506.htm),準備接下來有機會實踐一下,先留存學習;

一、4G Luci配置

1、 建立一個wwan介面;

2、 上網方式為dhcp自動擷取;

3、 物理設定選擇wwan0;

4、 防火牆選擇wan

二、重連指令碼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

  

三、crontab

*/2 * * * * /etc/myLte/redial4g

重連時間不要設太短,太短可能還沒撥號結束就又進行重播,會重複了。

四、撥號指令碼dial4g

PORT=/dev/ttyUSB0MODE="AT+CFUN=1" gcom -d $PORT -s /etc/gcom/setmode.gcomsleep 3MODE="AT+COPS=0" gcom -d $PORT -s /etc/gcom/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=1,1" gcom -d $PORT -s /etc/gcom/setmode.gcomsleep 3ifup wwan &exit 0

  

五、開機啟動

# Put your custom commands here that should be executed once# the system init finished. By default this file does nothing./etc/myLte/dial4gexit 0

  




 

【樹莓派】樹莓派使用4G模組上網

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.