通過telnet或串口登錄終端,執(zhí)行nvram。如圖
usage: nvram [get name] [set name=value] [unset name] [show]
設(shè)置參數(shù):nvram set wan_enable=1
獲取參數(shù)值: nvram get wan_enable
打開 nvram set wan_enable=1
關(guān)閉 nvram set wan_enable=0
打開nvram set wifi_enable=1
關(guān)閉nvram set wifi_enable=0
打開nvram set wire1_enable==1
關(guān)閉nvram set wire1_enable==0
nvram set network_wifi_update=1
通過執(zhí)行 network 生效,如圖:
不需要設(shè)置更新標(biāo)志
最后再執(zhí)行 nvram commit 保存參數(shù),如圖:
優(yōu)先級順序:
net_priority1 > net_priority2 > net_priority3
優(yōu)先級定義:
0:有線
1:wifi
2: 3G/4g
例如設(shè)置 有線>wifi>3G/4G 應(yīng)該執(zhí)行:
nvram set net_priority1=0
nvram set net_priority2=1
nvram set net_priority3=2
PS:優(yōu)先級的值需要互斥,各不相同。
nvram set wired_connect_type=0
nvram set wan_proto=static
nvram set wan_static_ip=192.168.1.128
nvram set wan_static_netmask=255.255.255.0
nvram set wan_static_gw=192.168.1.1
nvram set wire_pri_dns=114.114.114.114
nvram set wire_sec_dns=0.0.0.0
nvram set wired_connect_type=1
nvram set wan_proto=dhcp
nvram set hostname=
nvram set wifi_connect_type=0
nvram set wifi_ip_proto=static
nvram set wifi_ssid=FourFaith-test
nvram set wifi_passwd=
nvram set wifi_static_ip=192.168.0.3
nvram set wifi_static_netmask=255.255.255.0
nvram set wifi_static_gw=192.168.0.1
nvram set wifi_pri_dns=114.114.114.114
nvram set wifi_sec_dns=0.0.0.0
nvram set wired_connect_type=1
nvram set wifi_ip_proto=auto
nvram set wifi_ssid=FourFaith-test
nvram set wifi_passwd=
nvram set wired_connect_type=2
nvram set wifi_ssid=FourFaith-test
nvram set wifi_passwd=
nvram set wifi_static_netmask=255.255.255.0
nvram set wifi_static_gw=192.168.0.1
nvram set wifi_pri_dns=114.114.114.114
nvram set wifi_sec_dns=0.0.0.0
nvram set WIFI_AP_IP_START=192.168.0.10
nvram set WIFI_AP_IP_END=192.168.0.254
無線頻道定義為1-12個頻段如圖:
定義如圖,從上到下分別為0、1、2、3、4
nvram set wan_dial=0
nvram set ppp_username=
nvram set ppp_passwd=
nvram set wan_apn=
nvram set wan_pin=
從上到下分別定義為1、2、6
nvram set KpOnlineMode=2
nvram set KpOnlineIcmpDest=8.8.8.8
0代表不在線,1代表在線,3G和4G使用不同的字段標(biāo)示在線狀態(tài),具體使用哪個標(biāo)志需要根據(jù)當(dāng)前設(shè)置的撥號方式來選取,查詢撥號方式:
nvram get wan_dial
值定義請參考7.1 呼叫中心號碼。
3G狀態(tài)
nvram get pppd_linkup
4G狀態(tài)
nvram get lte_linkup
nvram get module_name
nvram get dbm
nvram get sig_percent
0代表沒插卡,1代表插卡
nvram get sim_exist
在終端執(zhí)行wpa_cli -p /tmp/run/wpa_supplicant status ra0 查詢wifi狀態(tài),如果wifi關(guān)閉則查詢失敗,如圖:
正在搜索wifi狀態(tài)如圖:
Wifi已連接:
通過讀取proc節(jié)點獲取wifi信號值信息,
cat /proc/net/wireless
其中l(wèi)ink值代表信號質(zhì)量(百分比),level代表dbm信號值。
例子(使用WIFI功能):
配置WIFI上網(wǎng),有線,4G關(guān)閉
nvram set wan_enable=0//關(guān)閉有線
nvram set wire1_enable=0//關(guān)閉4G
nvram set wifi_enable=1//開啟WIFI
nvram set wifi_ssid=mywifi//wifi名
nvram set wifi_passwd=12345678//wifi密碼
nvram set wifi_connect_type=0//設(shè)置wifi連接后自動獲取Ip
nvram set network_wifi_update=1//通知系統(tǒng)WIFI更新()
nvram commit//保存配置參數(shù)
例子(使用有線功能):
nvram set wan_enable=1//開啟有線
nvram set wire1_enable=0//關(guān)閉4G
nvram set wifi_enable=0//關(guān)閉WIFI
nvram set wan_proto=static//配置有線為靜態(tài)IP
nvram set wan_static_ip=192.168.1.128//配置有線IP
nvram set wan_static_netmask=255.255.255.0//配置有線mask地址
nvram set wan_static_gw=192.168.1.1//配置有線網(wǎng)關(guān)
nvram set wire_pri_dns=114.114.114.114//主DNS地址
nvram set wire_sec_dns=8.8.8.8//次DNS地址
nvram commit//保存配置參數(shù)
network//更新系統(tǒng)有線參數(shù)
例子(使用4G功能):
nvram set wan_enable=0//關(guān)閉有線
nvram set wire1_enable=1//開啟4G
nvram set wifi_enable=0//關(guān)閉WIFI
nvram set wan_dial=2//4G模式撥號
nvram set ppp_username=//一般默認(rèn)不配置,除非特殊卡
nvram set ppp_passwd=//一般默認(rèn)不配置,除非特殊卡
nvram set wan_apn=cmiot//根據(jù)卡的實際情況配置
nvram set KpOnlineMode=2//開啟PING模式在線保持
nvram set KpOnlineIcmpDest=114.114.114//配置在線保持時檢測的ip地址
nvram commit//保存配置參數(shù)