今天我們來探討一下基于OpenWRT的嵌入式系統(tǒng)用4G網(wǎng)卡(EC20)自動(dòng)撥號(hào)配置方法。
查看驅(qū)動(dòng)
首先,查看一下4G網(wǎng)卡(EC20)驅(qū)動(dòng)是否成功
ls /dev
依下圖可以cdc-wdm0 ttyUSB0 ttyUSB1 ttyUSB2? 都是4G網(wǎng)卡的設(shè)備號(hào),則我們的4G網(wǎng)卡(EC20)驅(qū)動(dòng)是成功的。
添加端口
然后,添加端口wwan0,用vim打開網(wǎng)卡配置文件/etc/config/network
vim /etc/config/network
最后面追加內(nèi)容(按"i"鍵, 進(jìn)入編輯模式):
.........
config?interface?'wwan'
option?proto?'dhcp'
option?ifname?'wwan0'
按"Esc"鍵退出,編輯模式
輸入命令":wq"保存退出
重啟網(wǎng)關(guān)
最后,重啟網(wǎng)關(guān),驗(yàn)證是否配置成功,不成功的話,再檢查配置文件
reboot
4G網(wǎng)卡撥號(hào)入網(wǎng)
輸入撥號(hào)命令
uqmi?-d?/dev/cdc-wdm0?--start-network?internet?--autoconnect
撥號(hào)狀態(tài)查詢命令:
uqmi -d /dev/cdc-wdm0 --get-data-status
如果成功,可以看到以下信息
uqmi?-d?/dev/cdc-wdm0?--get-data-status
"connected"
顯示?"connected",則拔號(hào)成功, 否則失敗
查看網(wǎng)絡(luò)連接情況
ifconfig
.....
wwan0 Link encap:Ethernet HWaddr C2:28:EB:4D:61:C8
inet addr:10.7.104.115 Bcast:10.7.104.119 Mask:255.255.255.248
inet6 addr: fe80::c028:ebff:fe4d:61c8/64 Scope:Link
UP BROADCAST RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:68 errors:0 dropped:0 overruns:0 frame:0
TX packets:482 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:10735 (10.4 KiB) TX bytes:125275 (122.3 KiB)
設(shè)置開機(jī)自動(dòng) 4G 撥號(hào)上網(wǎng)
vim /etc/rc.local
exit0 前添加
sleep?5
uqmi -d /dev/cdc-wdm0 --start-network internet --autoconnect &
再次重啟網(wǎng)關(guān)
reboot
再次查看網(wǎng)絡(luò)連接情況
ifconfig
.....
wwan0 Link encap:Ethernet HWaddr C2:28:EB:4D:61:C8
inet addr:10.7.104.115 Bcast:10.7.104.119 Mask:255.255.255.248
inet6 addr: fe80::c028:ebff:fe4d:61c8/64 Scope:Link
UP BROADCAST RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:68 errors:0 dropped:0 overruns:0 frame:0
TX packets:482 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:10735 (10.4 KiB) TX bytes:125275 (122.3 KiB)
設(shè)置一切OK