├── po
├── zh_Hans
└── zh-cn
│ └── modem.po
├── root
├── usr
│ ├── share
│ │ └── cpe
│ │ │ ├── delatcmd.sh
│ │ │ ├── atcmd.sh
│ │ │ ├── Quectel
│ │ │ ├── cpedebug
│ │ │ ├── Fibocom
│ │ │ ├── SIMCOM
│ │ │ └── rssi
│ └── bin
│ │ ├── jkillall
│ │ ├── set_gpio
│ │ ├── rsrp2rssi
│ │ ├── bmask128
│ │ ├── encodemask
│ │ └── chan2band.sh
└── etc
│ ├── init.d
│ ├── modem
│ └── cpeinit
│ ├── uci-defaults
│ └── luci-modem
│ └── config
│ └── modem
├── README-CN.md
├── README.md
├── Makefile
└── luasrc
├── view
└── cpe
│ ├── at.htm
│ └── net_status.htm
├── controller
└── admin
│ └── cpe.lua
└── model
└── cbi
└── cpe
└── modem.lua
/po/zh_Hans:
--------------------------------------------------------------------------------
1 | zh-cn
--------------------------------------------------------------------------------
/root/usr/share/cpe/delatcmd.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | rm -f /tmp/result.at
--------------------------------------------------------------------------------
/root/usr/share/cpe/atcmd.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | rec=$(sendat $1 $2)
3 | echo $rec >> /tmp/result.at
--------------------------------------------------------------------------------
/root/etc/init.d/modem:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ouyangzq/luci-app-cpe/HEAD/root/etc/init.d/modem
--------------------------------------------------------------------------------
/root/usr/share/cpe/Quectel:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ouyangzq/luci-app-cpe/HEAD/root/usr/share/cpe/Quectel
--------------------------------------------------------------------------------
/root/etc/init.d/cpeinit:
--------------------------------------------------------------------------------
1 | #!/bin/sh /etc/rc.common
2 |
3 | START=99
4 |
5 | start() {
6 | /bin/sh /usr/share/cpe/rssi &
7 | }
--------------------------------------------------------------------------------
/README-CN.md:
--------------------------------------------------------------------------------
1 | # luci-app-cpe
2 | luci-app-cpe
3 | H69K
4 |
5 |
6 | luci-app-cpe_new 新版使用ATTool_WebSocketServer 处理打包整体lui—app-cpe工具包全依赖 支持相同拨号 信号查看 短信读取 等, 项目等待开源...
7 |
--------------------------------------------------------------------------------
/root/etc/uci-defaults/luci-modem:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | uci -q batch <<-EOF >/dev/null
4 | delete ucitrack.@modem[-1]
5 | add ucitrack modem
6 | set ucitrack.@modem[-1].init=modem
7 | commit ucitrack
8 | EOF
9 |
10 | rm -f /tmp/luci-indexcache
11 | exit 0
12 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # luci-app-cpe
2 | luci-app-cpe
3 |
4 | luci-app-cpe needs sendat to work
5 |
6 | git clone https://github.com/ouyangzq/sendat package/sendat
7 |
8 |
9 | luci-app-cpe_new 新版使用ATTool_WebSocketServer 处理打包整体lui—app-cpe工具包全依赖 支持相同拨号 信号查看 短信读取 等, 项目等待开源...
10 |
--------------------------------------------------------------------------------
/root/usr/bin/jkillall:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | LOOKFOR=$1
3 | KILLLIST=$(ps | grep $LOOKFOR)
4 | echo "$KILLLIST" | while read line; do
5 | if `echo "$line" | grep "/$LOOKFOR" > /dev/null` ; then
6 | PIDV=$(echo $line | grep -o "^[0-9]\{1,5\}" | grep -o "[0-9]\{1,5\}")
7 | kill $PIDV
8 | fi
9 | done
--------------------------------------------------------------------------------
/root/usr/bin/set_gpio:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | PIN=$1
4 | VALUE=$2
5 |
6 | PIN_FILE=/sys/class/gpio/gpio$PIN
7 |
8 | if [ -z "$PIN" -o -z "$VALUE" ]; then
9 | exit 1
10 | fi
11 |
12 | echo $PIN >/sys/class/gpio/export
13 |
14 | if [ $(cat $PIN_FILE/direction) = "out" ]; then
15 | echo $VALUE >$PIN_FILE/value
16 | fi
17 |
18 | echo $PIN >/sys/class/gpio/unexport
--------------------------------------------------------------------------------
/root/etc/config/modem:
--------------------------------------------------------------------------------
1 |
2 | config ndis
3 | option enabled '1'
4 | option bandlist '0'
5 | option servertype '0'
6 | option ipaddress '114.114.114.114'
7 | option en '1'
8 | option an '5'
9 | option model 'nr5g'
10 | option tyyusb '2'
11 | option tool 'quectel-CM'
12 | option device '/dev/cdc-wdm0'
13 | option pdptype 'IPV4V6'
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/root/usr/bin/rsrp2rssi:
--------------------------------------------------------------------------------
1 | #!/usr/bin/lua
2 |
3 | rsrp = tonumber(arg[1])
4 | bw = tonumber(arg[2])
5 | if bw == 1.4 then
6 | n = 6
7 | else
8 | n = bw * 5
9 | end
10 |
11 | if tonumber(string.match(_VERSION, "%d+%.%d")) > 5.1 then
12 | rssi = rsrp + (10 * math.log(n * 12, 10))
13 | else
14 | rssi = rsrp + (10 * math.log10(n * 12))
15 | end
16 | if rssi < -113 then
17 | rssi = -113
18 | elseif rssi > -51 then
19 | rssi = -51
20 | end
21 | print(math.floor(rssi))
22 |
--------------------------------------------------------------------------------
/root/usr/bin/bmask128:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | printf "Band 128-bit bandmask\n"
4 | LBAND=1
5 | BBAND=1
6 | while [ $LBAND -le 48 ]
7 | do
8 | printf "%-6s%016X%016X\n" "$LBAND" "0" "$BBAND"
9 | LBAND=$(( $LBAND + 1 ))
10 | BBAND=$(( $BBAND * 2 ))
11 | done
12 | LBAND=65
13 | BBAND=1
14 | while [ $LBAND -le 85 ]
15 | do
16 | printf "%-6s%016X%016X\n" "$LBAND" "$BBAND" "0"
17 | LBAND=$(( $LBAND + 1 ))
18 | BBAND=$(( $BBAND * 2 ))
19 | done
20 |
--------------------------------------------------------------------------------
/root/usr/bin/encodemask:
--------------------------------------------------------------------------------
1 | #!/usr/bin/lua
2 |
3 | mtab = {}
4 | vtab = {1, 2, 4, 8}
5 |
6 | for i = 1, 32 do
7 | mtab[i] = 0
8 | end
9 |
10 | numarg = #arg
11 | for argval = 1, numarg do
12 | band = arg[argval]
13 | if tonumber(band) <= 128 then
14 | idx = math.floor((band - 1) / 4) + 1
15 | idxr = 33 - idx
16 | val = vtab[(band - ((idx - 1) * 4 ))]
17 | mtab[idxr] = mtab[idxr] + val
18 | end
19 | end
20 | for i = 1, 32 do
21 | mtab[i] = string.format("%X", mtab[i])
22 | end
23 |
24 | print(table.concat(mtab))
25 |
--------------------------------------------------------------------------------
/root/usr/share/cpe/cpedebug:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | en=1 #调试开关:0关闭,1打开 ,2输出到文件
4 | outfile="/tmp/cpe.log" #输出文件
5 | #日志信息
6 | Debug()
7 | {
8 | tim=$(date "+%Y-%m-%d %H:%M:%S") #获取系统时间
9 | if [ $en == 1 ]; then
10 | echo $tim $1 #打印输出
11 | elif [ $en == 2 ]; then
12 | echo $tim $1 >> $outfile #输出到文件
13 | fi
14 | }
15 | ATPORT()
16 | {
17 | MODEMNAME="ALL"
18 | # ATPORT=$(uci -q get modem.@ndis[0].tyyusb)
19 | lsusb=$( lsusb )
20 | RDFM650=$(echo "$lsusb" | grep "ID 2cb7:0a05 " | wc -l)
21 | if [ "$RDFM650" == 1 ]; then
22 | ATPORT=0
23 | MODEMNAME="FM650CN"
24 | else
25 | ATPORT=2
26 | fi
27 | }
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | #将openwrt顶层目录下的rules.mk文件中的内容导入进来
2 | include $(TOPDIR)/rules.mk
3 | #软件包名
4 | PKG_NAME:=luci-app-cpe
5 | #软件包版本
6 | PKG_VERSION:=5.0.1
7 | #真正编译当前软件包的目录
8 | PKG_BUILD_DIR:= $(BUILD_DIR)/$(PKG_NAME)
9 |
10 |
11 | #将$(TOPDIR)/include目录下的package.mk文件中的内容导入进来
12 | include $(INCLUDE_DIR)/package.mk
13 |
14 | define Package/luci-app-cpe
15 | PKGARCH:=all
16 | SECTION:=wrtnode
17 | CATEGORY:=Daocaoren
18 | SUBMENU :=CPE
19 | TITLE:=luci-app-cpe
20 | DEPENDS:=+sendat + luci-compat +kmod-usb-net +kmod-usb-net-cdc-ether +kmod-usb-acm \
21 | +kmod-usb-net-qmi-wwan +kmod-usb-net-rndis +kmod-usb-serial-qualcomm \
22 | +kmod-usb-net-sierrawireless +kmod-usb-ohci +kmod-usb-serial \
23 | +kmod-usb-serial-option +kmod-usb-wdm \
24 | +kmod-usb2 +kmod-usb3 \
25 | +quectel-CM-5G +kmod-usb-net-cdc-mbim
26 | endef
27 |
28 | PKG_LICENSE:=GPLv3
29 | PKG_LINCESE_FILES:=LICENSE
30 | PKF_MAINTAINER:=daocaoren <168620188@qq.com>
31 |
32 | include $(TOPDIR)/feeds/luci/luci.mk
33 | # call BuildPackage - OpenWrt buildroot signature
34 |
35 |
--------------------------------------------------------------------------------
/po/zh-cn/modem.po:
--------------------------------------------------------------------------------
1 | msgid ""
2 | msgstr ""
3 |
4 | msgid "Mobile Network"
5 | msgstr "模块设置"
6 |
7 |
8 | msgid "Automatic operation upon startup ooo"
9 | msgstr "开机自动启动:勾选"
10 |
11 | msgid "Tools"
12 | msgstr "拨号工具"
13 |
14 | msgid "PAP/CHAP Username"
15 | msgstr "PAP/CHAP 用户"
16 |
17 | msgid "PAP/CHAP Password"
18 | msgstr "PAP/CHAP 密码"
19 |
20 |
21 | msgid "Modem Server For OpenWrt"
22 | msgstr "4G/5G模块管理"
23 |
24 |
25 | msgid "SIM Settings"
26 | msgstr "SIM 配置 (联通ANP:3gnet) (电信APN:ctnet) (移动APN:cmnet) (广电APN:cbnet) "
27 |
28 | msgid "PdpType"
29 | msgstr "IP获取方式"
30 |
31 | msgid "AT Port Settings"
32 | msgstr "AT 模块配置"
33 |
34 | msgid "Set tyyUSB port"
35 | msgstr "AT 模块端口配置 (全模块指定端口)"
36 |
37 | msgid "tyyUSB port"
38 | msgstr "ttyUSB 配置ID"
39 |
40 | msgid "Network Diagnostics"
41 | msgstr "网络诊断"
42 |
43 |
44 | msgid "Network Diagnostics"
45 | msgstr "网络诊断"
46 |
47 |
48 | msgid "Network exception handling: check the network connection in a loop for 5 seconds. If the Ping IP address is not successful, After the network exceeds the abnormal number, restart and search the registered network again."
49 | msgstr "网络异常处理:循环检查网络连接5秒。如果Ping IP地址不成功,则在网络超过异常数量后,重新启动并搜索已注册的网络。"
50 |
51 | msgid "Ping IP address"
52 | msgstr "Ping IP地址"
53 |
54 | msgid "Abnormal number"
55 | msgstr "异常次数"
56 |
57 | msgid "Lock Band List"
58 | msgstr "锁定频段列表"
59 |
60 | msgid "Server Type"
61 | msgstr "服务类型"
62 |
63 | msgid "FMFM650-CN Settings"
64 | msgstr "FMFM650-CN 设置"
65 |
66 | msgid "[1]Automatic start upon startup: Check[2] FMFMFM650-CN module default ECM (36) mode. If not, please modify it, otherwise dialing cannot proceed normally"
67 | msgstr "【1】 开机自动启动:勾选 【2】 FMFM650-CN 模块默认 ECM (36)模式如果不是请修改 否则不能正常进行拨号 "
68 |
69 |
70 |
71 |
72 |
73 |
74 |
--------------------------------------------------------------------------------
/luasrc/view/cpe/at.htm:
--------------------------------------------------------------------------------
1 | <%+header%>
2 | <%
3 | local sys = require "luci.sys"
4 | local utl = require "luci.util"
5 | local fs = require "nixio.fs"
6 | local uci = require "luci.model.uci".cursor()
7 | local s = uci:get("custom", "bandlock", "enabled")
8 | local a = uci:get("custom", "atcmd", "enabled")
9 |
10 | local multilock = uci:get("custom", "multiuser", "multi") or "0"
11 | local rootlock = uci:get("custom", "multiuser", "root") or "0"
12 | nomulti=1
13 | if (multilock == "0") or (multilock == "1" and rootlock == "1") then
14 | nosms = 1
15 | if a == "1" then
16 | nosms = 0
17 | end
18 | else
19 | nosms = 1
20 | nomulti = 0
21 | end
22 | block = 1
23 | if s == "1" then
24 | block = 0
25 | end
26 |
27 | function showicon(lck)
28 | end
29 |
30 | -%>
31 |
32 |
65 |
66 |
67 |
68 |
69 |
<%:AT命令工具%>
70 |
71 |
97 |
98 |
99 |
148 |
149 |
150 |
151 |
152 | <%+footer%>
153 |
--------------------------------------------------------------------------------
/luasrc/controller/admin/cpe.lua:
--------------------------------------------------------------------------------
1 | module("luci.controller.admin.cpe", package.seeall)
2 |
3 | I18N = require "luci.i18n"
4 | translate = I18N.translate
5 |
6 | function index()
7 | entry({"admin", "modem"}, firstchild(), translate("移动数据"), 25).dependent=false
8 | entry({"admin", "modem", "nets"}, template("cpe/net_status"), translate("信号状态"), 0)
9 | entry({"admin", "modem", "get_csq"}, call("action_get_csq"))
10 | entry({"admin", "modem", "send_atcmd"}, call("action_send_atcmd"))
11 |
12 | -- entry({"admin", "modem", "sms"}, template("cpe/sms"), translate("短信信息"), 1)
13 | -- entry({"admin", "modem", "band"}, template("cpe/band"), translate("锁频段/锁PCI"), 1)
14 | entry({"admin", "modem", "at"}, template("cpe/at"), translate("AT工具"), 98)
15 |
16 | if not nixio.fs.access("/etc/config/modem") then
17 | return
18 | end
19 | entry({"admin", "modem", "modem"}, cbi("cpe/modem"), _("模块设置"), 99)
20 |
21 | end
22 |
23 | function action_send_atcmd()
24 | local rv ={}
25 | local file
26 | local p = luci.http.formvalue("p")
27 | local set = luci.http.formvalue("set")
28 | fixed = string.gsub(set, "\"", "~")
29 | port= string.gsub(p, "\"", "~")
30 | rv["at"] = fixed
31 | rv["port"] = port
32 |
33 | os.execute("/usr/share/cpe/atcmd.sh \'" .. port .. "\' \'" .. fixed .. "\'")
34 | result = "/tmp/result.at"
35 | file = io.open(result, "r")
36 | if file ~= nil then
37 | rv["result"] = file:read("*all")
38 | file:close()
39 | else
40 | rv["result"] = " "
41 | end
42 | os.execute("/usr/share/cpe/delatcmd.sh")
43 | luci.http.prepare_content("application/json")
44 | luci.http.write_json(rv)
45 |
46 | end
47 |
48 | function action_get_csq()
49 | local file
50 | stat = "/tmp/cpe_cell.file"
51 | file = io.open(stat, "r")
52 | local rv ={}
53 |
54 | -- echo 'RM520N-GL'
55 | -- echo 'conntype'
56 | -- echo '1e0e:9001'
57 | -- echo $COPS #运营商
58 | -- echo '' #端口
59 | -- echo '' #温度
60 | -- echo '' #协议
61 | rv["modem"] = file:read("*line")
62 | rv["conntype"] = file:read("*line")
63 | rv["modid"] = file:read("*line")
64 | rv["cops"] = file:read("*line")
65 | rv["port"] = file:read("*line")
66 | rv["tempur"] = file:read("*line")
67 | rv["proto"] = file:read("*line")
68 | file:read("*line")
69 |
70 |
71 | -- echo $IMEI #imei
72 | -- echo $IMSI #imsi
73 | -- echo $ICCID #iccid
74 | -- echo $phone #phone
75 | rv["imei"] = file:read("*line")
76 | rv["imsi"] = file:read("*line")
77 | rv["iccid"] =file:read("*line")
78 | rv["phone"] = file:read("*line")
79 | file:read("*line")
80 |
81 |
82 | -- echo $MODE
83 | -- echo $CSQ
84 | -- echo $CSQ_PER
85 | -- echo $CSQ_RSSI
86 | -- echo '' #参考信号接收质量 RSRQ ecio
87 | -- echo '' #参考信号接收质量 RSRQ ecio1
88 | -- echo '' #参考信号接收功率 RSRP rscp
89 | -- echo '' #参考信号接收功率 RSRP rscp1
90 | -- echo '' #信噪比 SINR rv["sinr"]
91 | -- echo '' #连接状态监控 rv["netmode"]
92 | rv["mode"] = file:read("*line")
93 | rv["csq"] = file:read("*line")
94 | rv["per"] = file:read("*line")
95 | rv["rssi"] = file:read("*line")
96 | rv["ecio"] = file:read("*line")
97 | rv["ecio1"] = file:read("*line")
98 | rv["rscp"] = file:read("*line")
99 | rv["rscp1"] = file:read("*line")
100 | rv["sinr"] = file:read("*line")
101 | rv["netmode"] = file:read("*line")
102 | file:read("*line")
103 |
104 | rssi = rv["rssi"]
105 | ecio = rv["ecio"]
106 | rscp = rv["rscp"]
107 | ecio1 = rv["ecio1"]
108 | rscp1 = rv["rscp1"]
109 | if ecio == nil then
110 | ecio = "-"
111 | end
112 | if ecio1 == nil then
113 | ecio1 = "-"
114 | end
115 | if rscp == nil then
116 | rscp = "-"
117 | end
118 | if rscp1 == nil then
119 | rscp1 = "-"
120 | end
121 |
122 | if ecio ~= "-" then
123 | rv["ecio"] = ecio .. " dB"
124 | end
125 | if rscp ~= "-" then
126 | rv["rscp"] = rscp .. " dBm"
127 | end
128 | if ecio1 ~= " " then
129 | rv["ecio1"] = " (" .. ecio1 .. " dB)"
130 | end
131 | if rscp1 ~= " " then
132 | rv["rscp1"] = " (" .. rscp1 .. " dBm)"
133 | end
134 |
135 | rv["mcc"] = file:read("*line")
136 | rv["mnc"] = file:read("*line")
137 | rv["rnc"] = file:read("*line")
138 | rv["rncn"] = file:read("*line")
139 | rv["lac"] = file:read("*line")
140 | rv["lacn"] = file:read("*line")
141 | rv["cid"] = file:read("*line")
142 | rv["cidn"] = file:read("*line")
143 | rv["lband"] = file:read("*line")
144 | rv["channel"] = file:read("*line")
145 | rv["pci"] = file:read("*line")
146 |
147 | rv["date"] = file:read("*line")
148 |
149 | -- rv["phonen"] = file:read("*line")
150 | --rv["host"] = "0"
151 |
152 | -- rv["simerr"] = "0"
153 | --
154 | --
155 | --
156 | --
157 | --
158 | --
159 | --
160 | --
161 | --
162 | --
163 |
164 |
165 | -- rv["down"] = file:read("*line")
166 | -- rv["up"] = file:read("*line")
167 | --
168 | --
169 |
170 | --
171 | -- rv["cell"] = file:read("*line")
172 | -- rv["modtype"] = file:read("*line")
173 | --
174 | --
175 | --
176 | --
177 | --
178 | --
179 |
180 |
181 | -- rv["lat"] = "-"
182 | -- rv["long"] = "-"
183 |
184 |
185 |
186 | rv["crate"] = translate("快速(每10秒更新一次)")
187 | luci.http.prepare_content("application/json")
188 | luci.http.write_json(rv)
189 | end
--------------------------------------------------------------------------------
/luasrc/model/cbi/cpe/modem.lua:
--------------------------------------------------------------------------------
1 | local m, section, m2, s2
2 |
3 | m = Map("modem", translate("Mobile Network"))
4 | m.description = translate("Modem Server For OpenWrt")
5 |
6 |
7 | -------------------------------Fibocom Wireless Inc. FM650 Module----------------------------------
8 | if (string.gsub(luci.sys.exec('lsusb |grep "ID 2cb7:0a05 " | wc -l'),"%s+","")=="1") then
9 | section = m:section(TypedSection, "ndis", translate("FMFM650-CN Settings"), translate("[1]Automatic start upon startup: Check[2] FMFMFM650-CN module default ECM (36) mode. If not, please modify it, otherwise dialing cannot proceed normally"))
10 | section.anonymous = true
11 | section.addremove = false
12 | enable = section:option(Flag, "enabled", translate("Enable"))
13 | enable.rmempty = false
14 | else
15 | section = m:section(TypedSection, "ndis", translate("SIM Settings"), translate("Automatic operation upon startup \r\n ooo"))
16 | section.anonymous = true
17 | section.addremove = false
18 | section:tab("general", translate("General Setup"))
19 | section:tab("advanced", translate("Advanced Settings"))
20 |
21 |
22 | enable = section:taboption("general", Flag, "enabled", translate("Enable"))
23 | enable.rmempty = false
24 |
25 | device = section:taboption("general",Value, "device", translate("Modem device"))
26 | device.rmempty = false
27 | local device_suggestions = nixio.fs.glob("/dev/cdc-wdm*")
28 | if device_suggestions then
29 | local node
30 | for node in device_suggestions do
31 | device:value(node)
32 | end
33 | end
34 | apn = section:taboption("general", Value, "apn", translate("APN"))
35 | username = section:taboption("general", Value, "username", translate("PAP/CHAP Username"))
36 | password = section:taboption("general", Value, "password", translate("PAP/CHAP Password"))
37 | password.password = true
38 | pincode = section:taboption("general", Value, "pincode", translate("PIN Code"))
39 | auth = section:taboption("general", Value, "auth", translate("Authentication Type"))
40 | auth.rmempty = true
41 | auth:value("", translate("-- Please choose --"))
42 | auth:value("both", "PAP/CHAP (both)")
43 | auth:value("pap", "PAP")
44 | auth:value("chap", "CHAP")
45 | auth:value("none", "NONE")
46 | tool = section:taboption("general", Value, "tool", translate("Tools"))
47 | tool:value("quectel-CM", "quectel-CM")
48 | tool.rmempty = true
49 | PdpType= section:taboption("general", Value, "pdptype", translate("PdpType"))
50 | PdpType:value("IPV4", "IPV4")
51 | PdpType:value("IPV6", "IPV6")
52 | PdpType:value("IPV4V6", "IPV4V6")
53 | PdpType.rmempty = true
54 |
55 |
56 | ---------------------------advanced------------------------------
57 | bandlist = section:taboption("advanced", ListValue, "bandlist", translate("Lock Band List"))
58 | -- if (string.gsub(luci.sys.exec('uci get system.@system[0].modem |grep lte |wc -l'),"%s+","")=="1") then
59 | -- bandlist.default = "0"
60 | -- bandlist:value("1", "LTE BAND1")
61 | -- bandlist:value("2", "LTE BAND2")
62 | -- bandlist:value("3", "LTE BAND3")
63 | -- bandlist:value("4", "LTE BAND4")
64 | -- bandlist:value("5", "LTE BAND5")
65 | -- bandlist:value("7", "LTE BAND7")
66 | -- bandlist:value("8", "LTE BAND8")
67 | -- bandlist:value("20", "LTE BAND20")
68 | -- bandlist:value("38", "LTE BAND38")
69 | -- bandlist:value("40", "LTE BAND40")
70 | -- bandlist:value("41", "LTE BAND41")
71 | -- bandlist:value("28", "LTE BAND28")
72 | -- bandlist:value("A", "AUTO")
73 | -- end
74 | bandlist:value("0", translate("Disable"))
75 |
76 | servertype = section:taboption("advanced", ListValue, "servertype", translate("Server Type"))
77 | servertype.default = "0"
78 |
79 | --if (string.gsub(luci.sys.exec('uci get system.@system[0].modem |grep nr5g |wc -l'),"%s+","")=="1") then
80 | servertype:value("1", "5G Only")
81 | servertype:value("5", "4G/5G Only")
82 | --end
83 | servertype:value("2", "4G Only")
84 | servertype:value("3", "3G Only")
85 | servertype:value("4", "2G Only")
86 | servertype:value("0", "AUTO")
87 |
88 |
89 | -- s1 = m:section(TypedSection, "ndis", translate("AT Port Settings"),translate("Set tyyUSB port"))
90 | -- s1.anonymous = true
91 | -- s1.addremove = false
92 | -- tyyusb= s1:option(Value, "tyyusb", translate("tyyUSB port"))
93 | -- tyyusb.default = "2"
94 | -- tyyusb:value("0", "0")
95 | -- tyyusb:value("1", "1")
96 | -- tyyusb:value("2", "2")
97 | -- tyyusb:value("3", "3")
98 | -- tyyusb:value("4", "4")
99 | -- tyyusb.rmempty=false
100 | end
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 | s2 = m:section(TypedSection, "ndis", translate("Network Diagnostics"),translate("Network exception handling: \
111 | check the network connection in a loop for 5 seconds. If the Ping IP address is not successful, After the network \
112 | exceeds the abnormal number, restart and search the registered network again."))
113 | s2.anonymous = true
114 | s2.addremove = false
115 |
116 | en = s2:option(Flag, "en", translate("Enable"))
117 | en.rmempty = false
118 |
119 |
120 |
121 | ipaddress= s2:option(Value, "ipaddress", translate("Ping IP address"))
122 | ipaddress.default = "114.114.114.114"
123 | ipaddress.rmempty=false
124 |
125 | an = s2:option(Value, "an", translate("Abnormal number"))
126 | an.default = "15"
127 | an:value("3", "3")
128 | an:value("5", "5")
129 | an:value("10", "10")
130 | an:value("15", "15")
131 | an:value("20", "20")
132 | an:value("25", "25")
133 | an:value("30", "30")
134 | an.rmempty=false
135 |
136 |
137 |
138 | local apply = luci.http.formvalue("cbi.apply")
139 | if apply then
140 | -- io.popen("/etc/init.d/modeminit restart")
141 | io.popen("/etc/init.d/modem restart")
142 | end
143 |
144 | return m,m2
145 |
--------------------------------------------------------------------------------
/root/usr/bin/chan2band.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | CHAN=$1
3 | CHAN=$(echo "$CHAN" | grep -o "[0-9]*")
4 |
5 | decode_lte() {
6 | if [ $CHAN -lt 600 ]; then
7 | BAND="B1"
8 | elif [ $CHAN -lt 1200 ]; then
9 | BAND="B2"
10 | elif [ $CHAN -lt 1950 ]; then
11 | BAND="B3"
12 | elif [ $CHAN -lt 2400 ]; then
13 | BAND="B4"
14 | elif [ $CHAN -lt 2650 ]; then
15 | BAND="B5"
16 | elif [ $CHAN -lt 2750 ]; then
17 | BAND="B6"
18 | elif [ $CHAN -lt 3450 ]; then
19 | BAND="B7"
20 | elif [ $CHAN -lt 3800 ]; then
21 | BAND="B8"
22 | elif [ $CHAN -lt 4150 ]; then
23 | BAND="B9"
24 | elif [ $CHAN -lt 4750 ]; then
25 | BAND="B10"
26 | elif [ $CHAN -lt 4950 ]; then
27 | BAND="B11"
28 | elif [ $CHAN -lt 5010 ]; then
29 | BAND="-"
30 | elif [ $CHAN -lt 5180 ]; then
31 | BAND="B12"
32 | elif [ $CHAN -lt 5280 ]; then
33 | BAND="B13"
34 | elif [ $CHAN -lt 5380 ]; then
35 | BAND="B14"
36 | elif [ $CHAN -lt 5730 ]; then
37 | BAND="-"
38 | elif [ $CHAN -lt 5850 ]; then
39 | BAND="B17"
40 | elif [ $CHAN -lt 6000 ]; then
41 | BAND="B18"
42 | elif [ $CHAN -lt 6150 ]; then
43 | BAND="B19"
44 | elif [ $CHAN -lt 6450 ]; then
45 | BAND="B20"
46 | elif [ $CHAN -lt 6600 ]; then
47 | BAND="B21"
48 | elif [ $CHAN -lt 7400 ]; then
49 | BAND="B22"
50 | elif [ $CHAN -lt 7500 ]; then
51 | BAND="-"
52 | elif [ $CHAN -lt 7700 ]; then
53 | BAND="B23"
54 | elif [ $CHAN -lt 8040 ]; then
55 | BAND="B24"
56 | elif [ $CHAN -lt 8690 ]; then
57 | BAND="B25"
58 | elif [ $CHAN -lt 9040 ]; then
59 | BAND="B26"
60 | elif [ $CHAN -lt 9210 ]; then
61 | BAND="B27"
62 | elif [ $CHAN -lt 9660 ]; then
63 | BAND="B28"
64 | elif [ $CHAN -lt 9770 ]; then
65 | BAND="B29"
66 | elif [ $CHAN -lt 9870 ]; then
67 | BAND="B30"
68 | elif [ $CHAN -lt 9920 ]; then
69 | BAND="B31"
70 | elif [ $CHAN -lt 10400 ]; then
71 | BAND="B32"
72 | elif [ $CHAN -lt 36000 ]; then
73 | BAND="-"
74 | elif [ $CHAN -lt 36200 ]; then
75 | BAND="B33"
76 | elif [ $CHAN -lt 36350 ]; then
77 | BAND="B34"
78 | elif [ $CHAN -lt 36950 ]; then
79 | BAND="B35"
80 | elif [ $CHAN -lt 37550 ]; then
81 | BAND="B36"
82 | elif [ $CHAN -lt 37750 ]; then
83 | BAND="B37"
84 | elif [ $CHAN -lt 38250 ]; then
85 | BAND="B38"
86 | elif [ $CHAN -lt 38650 ]; then
87 | BAND="B39"
88 | elif [ $CHAN -lt 39650 ]; then
89 | BAND="B40"
90 | elif [ $CHAN -lt 41590 ]; then
91 | BAND="B41"
92 | elif [ $CHAN -lt 43590 ]; then
93 | BAND="B42"
94 | elif [ $CHAN -lt 45590 ]; then
95 | BAND="B43"
96 | elif [ $CHAN -lt 46590 ]; then
97 | BAND="B44"
98 | elif [ $CHAN -lt 46790 ]; then
99 | BAND="B45"
100 | elif [ $CHAN -lt 54540 ]; then
101 | BAND="B46"
102 | elif [ $CHAN -lt 55240 ]; then
103 | BAND="B47"
104 | elif [ $CHAN -lt 56740 ]; then
105 | BAND="B48"
106 | elif [ $CHAN -lt 58240 ]; then
107 | BAND="B49"
108 | elif [ $CHAN -lt 59090 ]; then
109 | BAND="B50"
110 | elif [ $CHAN -lt 59140 ]; then
111 | BAND="B51"
112 | elif [ $CHAN -lt 60140 ]; then
113 | BAND="B52"
114 | elif [ $CHAN -lt 60255 ]; then
115 | BAND="B53"
116 | elif [ $CHAN -lt 65536 ]; then
117 | BAND="-"
118 | elif [ $CHAN -lt 66436 ]; then
119 | BAND="B65"
120 | elif [ $CHAN -lt 67336 ]; then
121 | BAND="B66"
122 | elif [ $CHAN -lt 67536 ]; then
123 | BAND="B67"
124 | elif [ $CHAN -lt 67836 ]; then
125 | BAND="B68"
126 | elif [ $CHAN -lt 68336 ]; then
127 | BAND="B69"
128 | elif [ $CHAN -lt 68586 ]; then
129 | BAND="B70"
130 | elif [ $CHAN -lt 68936 ]; then
131 | BAND="B71"
132 | elif [ $CHAN -lt 68986 ]; then
133 | BAND="B72"
134 | elif [ $CHAN -lt 69036 ]; then
135 | BAND="B73"
136 | elif [ $CHAN -lt 69466 ]; then
137 | BAND="B74"
138 | elif [ $CHAN -lt 70316 ]; then
139 | BAND="B75"
140 | elif [ $CHAN -lt 70366 ]; then
141 | BAND="B76"
142 | elif [ $CHAN -lt 70546 ]; then
143 | BAND="B85"
144 | elif [ $CHAN -lt 70596 ]; then
145 | BAND="B87"
146 | elif [ $CHAN -lt 70646 ]; then
147 | BAND="B88"
148 | else
149 | BAND="-"
150 | fi
151 | }
152 |
153 | decode_nr5g() {
154 | if [ $CHAN -lt 123400 ]; then
155 | BAND="-"
156 | elif [ $CHAN -le 130400 ]; then
157 | BAND="n71"
158 | elif [ $CHAN -lt 143400 ]; then
159 | BAND="-"
160 | elif [ $CHAN -lt 145600 ]; then
161 | BAND="n29"
162 | elif [ $CHAN -eq 145600 ]; then
163 | BAND="n29|n85"
164 | elif [ $CHAN -lt 145800 ]; then
165 | BAND="n85"
166 | elif [ $CHAN -eq 145800 ]; then
167 | BAND="n12|n85"
168 | elif [ $CHAN -lt 147600 ]; then
169 | BAND="n12|n85"
170 | elif [ $CHAN -lt 149200 ]; then
171 | BAND="n12|n67|n85"
172 | elif [ $CHAN -eq 149200 ]; then
173 | BAND="n12|n13|n67|n85"
174 | elif [ $CHAN -le 151200 ]; then
175 | BAND="n13|n67"
176 | elif [ $CHAN -lt 151600 ]; then
177 | BAND="n67"
178 | elif [ $CHAN -eq 151600 ]; then
179 | BAND="n14|n28|n67"
180 | elif [ $CHAN -le 153600 ]; then
181 | BAND="n14|n28"
182 | elif [ $CHAN -lt 158200 ]; then
183 | BAND="n28"
184 | elif [ $CHAN -eq 158200 ]; then
185 | BAND="n14|n20|n28"
186 | elif [ $CHAN -le 160600 ]; then
187 | BAND="n20|n28"
188 | elif [ $CHAN -le 164200 ]; then
189 | BAND="n20"
190 | elif [ $CHAN -lt 171800 ]; then
191 | BAND="-"
192 | elif [ $CHAN -lt 172000 ]; then
193 | BAND="n26"
194 | elif [ $CHAN -lt 173800 ]; then
195 | BAND="n18|n26"
196 | elif [ $CHAN -le 175000 ]; then
197 | BAND="n5|n18|n26"
198 | elif [ $CHAN -le 178800 ]; then
199 | BAND="n5|n26"
200 | elif [ $CHAN -lt 185000 ]; then
201 | BAND="-"
202 | elif [ $CHAN -le 192000 ]; then
203 | BAND="n8"
204 | elif [ $CHAN -lt 285400 ]; then
205 | BAND="-"
206 | elif [ $CHAN -lt 286400 ]; then
207 | BAND="n51|n76|n91|n93"
208 | elif [ $CHAN -eq 286400 ]; then
209 | BAND="n50|n51|n75|n76|n91|92|n93|94"
210 | elif [ $CHAN -lt 295000 ]; then
211 | BAND="n50|n75|n92|n94"
212 | elif [ $CHAN -eq 295000 ]; then
213 | BAND="n50|n74|n75|n92|n94"
214 | elif [ $CHAN -le 303400 ]; then
215 | BAND="n50|n74|n75|n92|n94"
216 | elif [ $CHAN -le 303600 ]; then
217 | BAND="n74"
218 | elif [ $CHAN -lt 305000 ]; then
219 | BAND="-"
220 | elif [ $CHAN -le 311800 ]; then
221 | BAND="n24"
222 | elif [ $CHAN -lt 361000 ]; then
223 | BAND="-"
224 | elif [ $CHAN -lt 376000 ]; then
225 | BAND="n3"
226 | elif [ $CHAN -eq 376000 ]; then
227 | BAND="n3|n39"
228 | elif [ $CHAN -le 384000 ]; then
229 | BAND="n39"
230 | elif [ $CHAN -lt 386000 ]; then
231 | BAND="-"
232 | elif [ $CHAN -le 398000 ]; then
233 | BAND="n2|n25"
234 | elif [ $CHAN -lt 399000 ]; then
235 | BAND="n25"
236 | elif [ $CHAN -eq 399000 ]; then
237 | BAND="n25|n70"
238 | elif [ $CHAN -lt 402000 ]; then
239 | BAND="n70"
240 | elif [ $CHAN -eq 402000 ]; then
241 | BAND="n34|n70"
242 | elif [ $CHAN -le 404000 ]; then
243 | BAND="n34|n70"
244 | elif [ $CHAN -le 405000 ]; then
245 | BAND="n34"
246 | elif [ $CHAN -lt 422000 ]; then
247 | BAND="-"
248 | elif [ $CHAN -le 434000 ]; then
249 | BAND="n1|n65|n66"
250 | elif [ $CHAN -le 440000 ]; then
251 | BAND="n65|n66"
252 | elif [ $CHAN -lt 460000 ]; then
253 | BAND="-"
254 | elif [ $CHAN -lt 470000 ]; then
255 | BAND="n40"
256 | elif [ $CHAN -eq 470000 ]; then
257 | BAND="n30|n40"
258 | elif [ $CHAN -le 472000 ]; then
259 | BAND="n30|n40"
260 | elif [ $CHAN -le 480000 ]; then
261 | BAND="n40"
262 | elif [ $CHAN -lt 496700 ]; then
263 | BAND="-"
264 | elif [ $CHAN -le 499000 ]; then
265 | BAND="n53"
266 | elif [ $CHAN -lt 499200 ]; then
267 | BAND="-"
268 | elif [ $CHAN -lt 514000 ]; then
269 | BAND="n41|n90"
270 | elif [ $CHAN -eq 514000 ]; then
271 | BAND="n38|n41|n90"
272 | elif [ $CHAN -lt 524000 ]; then
273 | BAND="n38|n41|n90"
274 | elif [ $CHAN -eq 524000 ]; then
275 | BAND="n7|n38|n41|n90"
276 | elif [ $CHAN -lt 538000 ]; then
277 | BAND="n7|n41|n90"
278 | elif [ $CHAN -eq 538000 ]; then
279 | BAND="n7|n90"
280 | elif [ $CHAN -lt 620000 ]; then
281 | BAND="-"
282 | elif [ $CHAN -lt 636667 ]; then
283 | BAND="n77|n78"
284 | elif [ $CHAN -le 646666 ]; then
285 | BAND="n48|n77|n78"
286 | elif [ $CHAN -le 653333 ]; then
287 | BAND="n77|n78"
288 | elif [ $CHAN -le 680000 ]; then
289 | BAND="n77"
290 | elif [ $CHAN -lt 693334 ]; then
291 | BAND="-"
292 | elif [ $CHAN -le 733333 ]; then
293 | BAND="n79"
294 | elif [ $CHAN -lt 743333 ]; then
295 | BAND="-"
296 | elif [ $CHAN -lt 795000 ]; then
297 | BAND="n46"
298 | elif [ $CHAN -eq 795000 ]; then
299 | BAND="n46|n96"
300 | elif [ $CHAN -le 875000 ]; then
301 | BAND="n96"
302 | else
303 | BAND="-"
304 | fi
305 | }
306 |
307 | if [ -z "$CHAN" ]; then
308 | BAND="-"
309 | elif [ "$CHAN" -lt 123400 ]; then
310 | decode_lte
311 | elif [ "$CHAN" -le 875000 ]; then
312 | decode_nr5g
313 | else
314 | BAND="-"
315 | fi
316 | echo $BAND
317 | exit
318 |
--------------------------------------------------------------------------------
/root/usr/share/cpe/Fibocom:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | ATPORT=1
3 |
4 |
5 |
6 | # SIMCOM获取基站信息
7 | Fibocom_Cellinfo()
8 | {
9 | #baseinfo.gcom
10 | OX=$( sendat $ATPORT "ATI")
11 | OX=$( sendat $ATPORT "AT+CGEQNEG=1")
12 |
13 | #cellinfo0.gcom
14 | OX1=$( sendat $ATPORT "AT+COPS=3,0;+COPS?")
15 | OX2=$( sendat $ATPORT "AT+COPS=3,2;+COPS?")
16 | OX=$OX1" "$OX2
17 |
18 | #cellinfo.gcom
19 | OY1=$( sendat $ATPORT "AT+CREG=2;+CREG?;+CREG=0")
20 | OY2=$( sendat $ATPORT "AT+CEREG=2;+CEREG?;+CEREG=0")
21 | OY3=$( sendat $ATPORT "AT+C5GREG=2;+C5GREG?;+C5GREG=0")
22 | OY=$OY1" "$OY2" "$OY3
23 |
24 |
25 | OXx=$OX
26 | OX=$(echo $OX | tr 'a-z' 'A-Z')
27 | OY=$(echo $OY | tr 'a-z' 'A-Z')
28 | OX=$OX" "$OY
29 |
30 | #Debug "$OX"
31 | #Debug "$OY"
32 |
33 | COPS="-"
34 | COPS_MCC="-"
35 | COPS_MNC="-"
36 | COPSX=$(echo $OXx | grep -o "+COPS: [01],0,.\+," | cut -d, -f3 | grep -o "[^\"]\+")
37 |
38 | if [ "x$COPSX" != "x" ]; then
39 | COPS=$COPSX
40 | fi
41 |
42 | COPSX=$(echo $OX | grep -o "+COPS: [01],2,.\+," | cut -d, -f3 | grep -o "[^\"]\+")
43 |
44 | if [ "x$COPSX" != "x" ]; then
45 | COPS_MCC=${COPSX:0:3}
46 | COPS_MNC=${COPSX:3:3}
47 | if [ "$COPS" = "-" ]; then
48 | COPS=$(awk -F[\;] '/'$COPS'/ {print $2}' $ROOTER/signal/mccmnc.data)
49 | [ "x$COPS" = "x" ] && COPS="-"
50 | fi
51 | fi
52 |
53 | if [ "$COPS" = "-" ]; then
54 | COPS=$(echo "$O" | awk -F[\"] '/^\+COPS: 0,0/ {print $2}')
55 | if [ "x$COPS" = "x" ]; then
56 | COPS="-"
57 | COPS_MCC="-"
58 | COPS_MNC="-"
59 | fi
60 | fi
61 | COPS_MNC=" "$COPS_MNC
62 |
63 | OX=$(echo "${OX//[ \"]/}")
64 | CID=""
65 | CID5=""
66 | RAT=""
67 | REGV=$(echo "$OX" | grep -o "+C5GREG:2,[0-9],[A-F0-9]\{2,6\},[A-F0-9]\{5,10\},[0-9]\{1,2\}")
68 | if [ -n "$REGV" ]; then
69 | LAC5=$(echo "$REGV" | cut -d, -f3)
70 | LAC5=$LAC5" ($(printf "%d" 0x$LAC5))"
71 | CID5=$(echo "$REGV" | cut -d, -f4)
72 | CID5L=$(printf "%010X" 0x$CID5)
73 | RNC5=${CID5L:1:6}
74 | RNC5=$RNC5" ($(printf "%d" 0x$RNC5))"
75 | CID5=${CID5L:7:3}
76 | CID5="Short $(printf "%X" 0x$CID5) ($(printf "%d" 0x$CID5)), Long $(printf "%X" 0x$CID5L) ($(printf "%d" 0x$CID5L))"
77 | RAT=$(echo "$REGV" | cut -d, -f5)
78 | fi
79 | REGV=$(echo "$OX" | grep -o "+CEREG:2,[0-9],[A-F0-9]\{2,4\},[A-F0-9]\{5,8\}")
80 | REGFMT="3GPP"
81 | if [ -z "$REGV" ]; then
82 | REGV=$(echo "$OX" | grep -o "+CEREG:2,[0-9],[A-F0-9]\{2,4\},[A-F0-9]\{1,3\},[A-F0-9]\{5,8\}")
83 | REGFMT="SW"
84 | fi
85 | if [ -n "$REGV" ]; then
86 | LAC=$(echo "$REGV" | cut -d, -f3)
87 | LAC=$(printf "%04X" 0x$LAC)" ($(printf "%d" 0x$LAC))"
88 | if [ $REGFMT = "3GPP" ]; then
89 | CID=$(echo "$REGV" | cut -d, -f4)
90 | else
91 | CID=$(echo "$REGV" | cut -d, -f5)
92 | fi
93 | CIDL=$(printf "%08X" 0x$CID)
94 | RNC=${CIDL:1:5}
95 | RNC=$RNC" ($(printf "%d" 0x$RNC))"
96 | CID=${CIDL:6:2}
97 | CID="Short $(printf "%X" 0x$CID) ($(printf "%d" 0x$CID)), Long $(printf "%X" 0x$CIDL) ($(printf "%d" 0x$CIDL))"
98 |
99 | else
100 | REGV=$(echo "$OX" | grep -o "+CREG:2,[0-9],[A-F0-9]\{2,4\},[A-F0-9]\{2,8\}")
101 | if [ -n "$REGV" ]; then
102 | LAC=$(echo "$REGV" | cut -d, -f3)
103 | CID=$(echo "$REGV" | cut -d, -f4)
104 | if [ ${#CID} -gt 4 ]; then
105 | LAC=$(printf "%04X" 0x$LAC)" ($(printf "%d" 0x$LAC))"
106 | CIDL=$(printf "%08X" 0x$CID)
107 | RNC=${CIDL:1:3}
108 | CID=${CIDL:4:4}
109 | CID="Short $(printf "%X" 0x$CID) ($(printf "%d" 0x$CID)), Long $(printf "%X" 0x$CIDL) ($(printf "%d" 0x$CIDL))"
110 | else
111 | LAC=""
112 | fi
113 | else
114 | LAC=""
115 | fi
116 | fi
117 | REGSTAT=$(echo "$REGV" | cut -d, -f2)
118 | if [ "$REGSTAT" == "5" -a "$COPS" != "-" ]; then
119 | COPS_MNC=$COPS_MNC" (Roaming)"
120 | fi
121 | if [ -n "$CID" -a -n "$CID5" ] && [ "$RAT" == "13" -o "$RAT" == "10" ]; then
122 | LAC="4G $LAC, 5G $LAC5"
123 | CID="4G $CID
5G $CID5"
124 | RNC="4G $RNC, 5G $RNC5"
125 | elif [ -n "$CID5" ]; then
126 | LAC=$LAC5
127 | CID=$CID5
128 | RNC=$RNC5
129 | fi
130 | if [ -z "$LAC" ]; then
131 | LAC="-"
132 | CID="-"
133 | RNC="-"
134 | fi
135 | }
136 | Fibocom_SIMINFO()
137 | {
138 | Debug "Fibocom_SIMINFO"
139 | # 获取IMEI
140 | IMEI=$( sendat $ATPORT "AT+CGSN" | sed -n '2p' )
141 | # 获取IMSI
142 | IMSI=$( sendat $ATPORT "AT+CIMI" | sed -n '2p' )
143 | # 获取ICCID
144 | ICCID=$( sendat $ATPORT "AT+ICCID" | grep -o "+ICCID:[ ]*[-0-9]\+" | grep -o "[-0-9]\{1,4\}" )
145 | # 获取电话号码
146 | phone=$( sendat $ATPORT "AT+CNUM" | grep "+CNUM:" )
147 | }
148 |
149 | #SIMCOM查找基站AT
150 | Fibocom_AT()
151 | {
152 | Debug "Fibocom_AT"
153 | ATPORT
154 | All_CSQ
155 | Fibocom_SIMINFO
156 | Fibocom_Cellinfo
157 |
158 | #温度
159 | OX=$( sendat $ATPORT "AT+CPMUTEMP")
160 | TEMP=$(echo "$OX" | grep -o "+CPMUTEMP:[ ]*[-0-9]\+" | grep -o "[-0-9]\{1,4\}")
161 | if [ -n "$TEMP" ]; then
162 | TEMP=$(echo $TEMP)$(printf "\xc2\xb0")"C"
163 | fi
164 |
165 |
166 | #基站信息
167 | OX=$( sendat $ATPORT "AT+CPSI?")
168 | rec=$(echo "$OX" | grep "+CPSI:")
169 | w=$(echo $rec |grep "NO SERVICE"| wc -l)
170 | if [ $w -ge 1 ];then
171 | Debug "NO SERVICE"
172 | return
173 | fi
174 | w=$(echo $rec |grep "NR5G_"| wc -l)
175 | if [ $w -ge 1 ];then
176 |
177 | w=$(echo $rec |grep "32768"| wc -l)
178 | if [ $w -ge 1 ];then
179 | Debug "-32768"
180 | return
181 | fi
182 |
183 | Debug "$rec"
184 | rec1=${rec##*+CPSI:}
185 | #echo "$rec1"
186 | MODE="${rec1%%,*}" # MODE="NR5G"
187 | rect1=${rec1#*,}
188 | rect1s="${rect1%%,*}" #Online
189 | rect2=${rect1#*,}
190 | rect2s="${rect2%%,*}" #460-11
191 | rect3=${rect2#*,}
192 | rect3s="${rect3%%,*}" #0xCFA102
193 | rect4=${rect3#*,}
194 | rect4s="${rect4%%,*}" #55744245764
195 | rect5=${rect4#*,}
196 | rect5s="${rect5%%,*}" #196
197 | rect6=${rect5#*,}
198 | rect6s="${rect6%%,*}" #NR5G_BAND78
199 | rect7=${rect6#*,}
200 | rect7s="${rect7%%,*}" #627264
201 | rect8=${rect7#*,}
202 | rect8s="${rect8%%,*}" #-940
203 | rect9=${rect8#*,}
204 | rect9s="${rect9%%,*}" #-110
205 | # "${rec1##*,}" #最后一位
206 | rect10=${rect9#*,}
207 | rect10s="${rect10%%,*}" #最后一位
208 | PCI=$rect5s
209 | LBAND="n"$(echo $rect6s | cut -d, -f0 | grep -o "BAND[0-9]\{1,3\}" | grep -o "[0-9]\+")
210 | CHANNEL=$rect7s
211 | RSCP=$(($(echo $rect8s | cut -d, -f0) / 10))
212 | ECIO=$(($(echo $rect9s | cut -d, -f0) / 10))
213 | if [ "$CSQ_PER" = "-" ]; then
214 | CSQ_PER=$((100 - (($RSCP + 31) * 100/-125)))"%"
215 | fi
216 | SINR=$(($(echo $rect10s | cut -d, -f0) / 10))" dB"
217 | fi
218 | w=$(echo $rec |grep "LTE"|grep "EUTRAN"| wc -l)
219 | if [ $w -ge 1 ];then
220 | rec1=${rec#*EUTRAN-}
221 | lte_band=${rec1%%,*} #EUTRAN-BAND
222 | rec1=${rec1#*,}
223 | rec1=${rec1#*,}
224 | rec1=${rec1#*,}
225 | rec1=${rec1#*,}
226 | #rec1=${rec1#*,}
227 | rec1=${rec1#*,}
228 | lte_rssi=${rec1%%,*} #LTE_RSSI
229 | lte_rssi=`expr $lte_rssi / 10` #LTE_RSSI
230 | Debug "LTE_BAND=$lte_band LTE_RSSI=$lte_rssi"
231 | if [ $rssi == 0 ];then
232 | rssi=$lte_rssi
233 | fi
234 | fi
235 | w=$(echo $rec |grep "WCDMA"| wc -l)
236 | if [ $w -ge 1 ];then
237 | w=$(echo $rec |grep "UNKNOWN"|wc -l)
238 | if [ $w -ge 1 ];then
239 | Debug "UNKNOWN BAND"
240 | return
241 | fi
242 | fi
243 |
244 |
245 |
246 |
247 |
248 |
249 | #CNMP
250 | OX=$( sendat $ATPORT "AT+CNMP?")
251 | CNMP=$(echo "$OX" | grep -o "+CNMP:[ ]*[0-9]\{1,3\}" | grep -o "[0-9]\{1,3\}")
252 | if [ -n "$CNMP" ]; then
253 | case $CNMP in
254 | "2"|"55" )
255 | NETMODE="1" ;;
256 | "13" )
257 | NETMODE="3" ;;
258 | "14" )
259 | NETMODE="5" ;;
260 | "38" )
261 | NETMODE="7" ;;
262 | "71" )
263 | NETMODE="9" ;;
264 | "109" )
265 | NETMODE="8" ;;
266 | * )
267 | NETMODE="0" ;;
268 | esac
269 | fi
270 |
271 | # CMGRMI 信息
272 | OX=$( sendat $ATPORT "AT+CMGRMI=4")
273 | CAINFO=$(echo "$OX" | grep -o "$REGXz" | tr ' ' ':')
274 | if [ -n "$CAINFO" ]; then
275 | for CASV in $(echo "$CAINFO"); do
276 | LBAND=$LBAND"
B"$(echo "$CASV" | cut -d, -f4)
277 | BW=$(echo "$CASV" | cut -d, -f5)
278 | decode_bw
279 | LBAND=$LBAND" (CA, Bandwidth $BW MHz)"
280 | CHANNEL="$CHANNEL, "$(echo "$CASV" | cut -d, -f2)
281 | PCI="$PCI, "$(echo "$CASV" | cut -d, -f7)
282 | done
283 | fi
284 |
285 | }
--------------------------------------------------------------------------------
/root/usr/share/cpe/SIMCOM:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | ATPORT=1
3 |
4 | #查询信息强度
5 | All_CSQ()
6 | {
7 | Debug "All_CSQ"
8 | #信号
9 | OX=$( sendat $ATPORT "AT+CSQ" |grep "+CSQ:")
10 | OX=$(echo $OX | tr 'a-z' 'A-Z')
11 | CSQ=$(echo "$OX" | grep -o "+CSQ: [0-9]\{1,2\}" | grep -o "[0-9]\{1,2\}")
12 | if [ $CSQ = "99" ]; then
13 | CSQ=""
14 | fi
15 | if [ -n "$CSQ" ]; then
16 | CSQ_PER=$(($CSQ * 100/31))"%"
17 | CSQ_RSSI=$((2 * CSQ - 113))" dBm"
18 | else
19 | CSQ="-"
20 | CSQ_PER="-"
21 | CSQ_RSSI="-"
22 | fi
23 | }
24 |
25 | # SIMCOM获取基站信息
26 | SIMCOM_Cellinfo()
27 | {
28 | #baseinfo.gcom
29 | OX=$( sendat 2 "ATI")
30 | OX=$( sendat 2 "AT+CGEQNEG=1")
31 |
32 | #cellinfo0.gcom
33 | OX1=$( sendat 2 "AT+COPS=3,0;+COPS?")
34 | OX2=$( sendat 2 "AT+COPS=3,2;+COPS?")
35 | OX=$OX1" "$OX2
36 |
37 | #cellinfo.gcom
38 | OY1=$( sendat 2 "AT+CREG=2;+CREG?;+CREG=0")
39 | OY2=$( sendat 2 "AT+CEREG=2;+CEREG?;+CEREG=0")
40 | OY3=$( sendat 2 "AT+C5GREG=2;+C5GREG?;+C5GREG=0")
41 | OY=$OY1" "$OY2" "$OY3
42 |
43 |
44 | OXx=$OX
45 | OX=$(echo $OX | tr 'a-z' 'A-Z')
46 | OY=$(echo $OY | tr 'a-z' 'A-Z')
47 | OX=$OX" "$OY
48 |
49 | #Debug "$OX"
50 | #Debug "$OY"
51 |
52 | COPS="-"
53 | COPS_MCC="-"
54 | COPS_MNC="-"
55 | COPSX=$(echo $OXx | grep -o "+COPS: [01],0,.\+," | cut -d, -f3 | grep -o "[^\"]\+")
56 |
57 | if [ "x$COPSX" != "x" ]; then
58 | COPS=$COPSX
59 | fi
60 |
61 | COPSX=$(echo $OX | grep -o "+COPS: [01],2,.\+," | cut -d, -f3 | grep -o "[^\"]\+")
62 |
63 | if [ "x$COPSX" != "x" ]; then
64 | COPS_MCC=${COPSX:0:3}
65 | COPS_MNC=${COPSX:3:3}
66 | if [ "$COPS" = "-" ]; then
67 | COPS=$(awk -F[\;] '/'$COPS'/ {print $2}' $ROOTER/signal/mccmnc.data)
68 | [ "x$COPS" = "x" ] && COPS="-"
69 | fi
70 | fi
71 |
72 | if [ "$COPS" = "-" ]; then
73 | COPS=$(echo "$O" | awk -F[\"] '/^\+COPS: 0,0/ {print $2}')
74 | if [ "x$COPS" = "x" ]; then
75 | COPS="-"
76 | COPS_MCC="-"
77 | COPS_MNC="-"
78 | fi
79 | fi
80 | COPS_MNC=" "$COPS_MNC
81 |
82 | OX=$(echo "${OX//[ \"]/}")
83 | CID=""
84 | CID5=""
85 | RAT=""
86 | REGV=$(echo "$OX" | grep -o "+C5GREG:2,[0-9],[A-F0-9]\{2,6\},[A-F0-9]\{5,10\},[0-9]\{1,2\}")
87 | if [ -n "$REGV" ]; then
88 | LAC5=$(echo "$REGV" | cut -d, -f3)
89 | LAC5=$LAC5" ($(printf "%d" 0x$LAC5))"
90 | CID5=$(echo "$REGV" | cut -d, -f4)
91 | CID5L=$(printf "%010X" 0x$CID5)
92 | RNC5=${CID5L:1:6}
93 | RNC5=$RNC5" ($(printf "%d" 0x$RNC5))"
94 | CID5=${CID5L:7:3}
95 | CID5="Short $(printf "%X" 0x$CID5) ($(printf "%d" 0x$CID5)), Long $(printf "%X" 0x$CID5L) ($(printf "%d" 0x$CID5L))"
96 | RAT=$(echo "$REGV" | cut -d, -f5)
97 | fi
98 | REGV=$(echo "$OX" | grep -o "+CEREG:2,[0-9],[A-F0-9]\{2,4\},[A-F0-9]\{5,8\}")
99 | REGFMT="3GPP"
100 | if [ -z "$REGV" ]; then
101 | REGV=$(echo "$OX" | grep -o "+CEREG:2,[0-9],[A-F0-9]\{2,4\},[A-F0-9]\{1,3\},[A-F0-9]\{5,8\}")
102 | REGFMT="SW"
103 | fi
104 | if [ -n "$REGV" ]; then
105 | LAC=$(echo "$REGV" | cut -d, -f3)
106 | LAC=$(printf "%04X" 0x$LAC)" ($(printf "%d" 0x$LAC))"
107 | if [ $REGFMT = "3GPP" ]; then
108 | CID=$(echo "$REGV" | cut -d, -f4)
109 | else
110 | CID=$(echo "$REGV" | cut -d, -f5)
111 | fi
112 | CIDL=$(printf "%08X" 0x$CID)
113 | RNC=${CIDL:1:5}
114 | RNC=$RNC" ($(printf "%d" 0x$RNC))"
115 | CID=${CIDL:6:2}
116 | CID="Short $(printf "%X" 0x$CID) ($(printf "%d" 0x$CID)), Long $(printf "%X" 0x$CIDL) ($(printf "%d" 0x$CIDL))"
117 |
118 | else
119 | REGV=$(echo "$OX" | grep -o "+CREG:2,[0-9],[A-F0-9]\{2,4\},[A-F0-9]\{2,8\}")
120 | if [ -n "$REGV" ]; then
121 | LAC=$(echo "$REGV" | cut -d, -f3)
122 | CID=$(echo "$REGV" | cut -d, -f4)
123 | if [ ${#CID} -gt 4 ]; then
124 | LAC=$(printf "%04X" 0x$LAC)" ($(printf "%d" 0x$LAC))"
125 | CIDL=$(printf "%08X" 0x$CID)
126 | RNC=${CIDL:1:3}
127 | CID=${CIDL:4:4}
128 | CID="Short $(printf "%X" 0x$CID) ($(printf "%d" 0x$CID)), Long $(printf "%X" 0x$CIDL) ($(printf "%d" 0x$CIDL))"
129 | else
130 | LAC=""
131 | fi
132 | else
133 | LAC=""
134 | fi
135 | fi
136 | REGSTAT=$(echo "$REGV" | cut -d, -f2)
137 | if [ "$REGSTAT" == "5" -a "$COPS" != "-" ]; then
138 | COPS_MNC=$COPS_MNC" (Roaming)"
139 | fi
140 | if [ -n "$CID" -a -n "$CID5" ] && [ "$RAT" == "13" -o "$RAT" == "10" ]; then
141 | LAC="4G $LAC, 5G $LAC5"
142 | CID="4G $CID
5G $CID5"
143 | RNC="4G $RNC, 5G $RNC5"
144 | elif [ -n "$CID5" ]; then
145 | LAC=$LAC5
146 | CID=$CID5
147 | RNC=$RNC5
148 | fi
149 | if [ -z "$LAC" ]; then
150 | LAC="-"
151 | CID="-"
152 | RNC="-"
153 | fi
154 | }
155 | SIMCOM_SIMINFO()
156 | {
157 | Debug "Quectel_SIMINFO"
158 | # 获取IMEI
159 | IMEI=$( sendat $ATPORT "AT+CGSN" | sed -n '2p' )
160 | # 获取IMSI
161 | IMSI=$( sendat $ATPORT "AT+CIMI" | sed -n '2p' )
162 | # 获取ICCID
163 | ICCID=$( sendat $ATPORT "AT+ICCID" | grep -o "+ICCID:[ ]*[-0-9]\+" | grep -o "[-0-9]\{1,4\}" )
164 | # 获取电话号码
165 | phone=$( sendat $ATPORT "AT+CNUM" | grep "+CNUM:" )
166 | }
167 | #SIMCOM查找基站AT
168 | SIMCOM_AT()
169 | {
170 | Debug "SIMCOM_AT"
171 | ATPORT
172 | All_CSQ
173 | SIMCOM_SIMINFO
174 | SIMCOM_Cellinfo
175 |
176 | #温度
177 | OX=$( sendat $ATPORT "AT+CPMUTEMP")
178 | TEMP=$(echo "$OX" | grep -o "+CPMUTEMP:[ ]*[-0-9]\+" | grep -o "[-0-9]\{1,4\}")
179 | if [ -n "$TEMP" ]; then
180 | TEMP=$(echo $TEMP)$(printf "\xc2\xb0")"C"
181 | fi
182 |
183 |
184 | #基站信息
185 | OX=$( sendat $ATPORT "AT+CPSI?")
186 | rec=$(echo "$OX" | grep "+CPSI:")
187 | w=$(echo $rec |grep "NO SERVICE"| wc -l)
188 | if [ $w -ge 1 ];then
189 | Debug "NO SERVICE"
190 | return
191 | fi
192 | w=$(echo $rec |grep "NR5G_"| wc -l)
193 | if [ $w -ge 1 ];then
194 |
195 | w=$(echo $rec |grep "32768"| wc -l)
196 | if [ $w -ge 1 ];then
197 | Debug "-32768"
198 | return
199 | fi
200 |
201 | Debug "$rec"
202 | rec1=${rec##*+CPSI:}
203 | #echo "$rec1"
204 | MODE="${rec1%%,*}" # MODE="NR5G"
205 | rect1=${rec1#*,}
206 | rect1s="${rect1%%,*}" #Online
207 | rect2=${rect1#*,}
208 | rect2s="${rect2%%,*}" #460-11
209 | rect3=${rect2#*,}
210 | rect3s="${rect3%%,*}" #0xCFA102
211 | rect4=${rect3#*,}
212 | rect4s="${rect4%%,*}" #55744245764
213 | rect5=${rect4#*,}
214 | rect5s="${rect5%%,*}" #196
215 | rect6=${rect5#*,}
216 | rect6s="${rect6%%,*}" #NR5G_BAND78
217 | rect7=${rect6#*,}
218 | rect7s="${rect7%%,*}" #627264
219 | rect8=${rect7#*,}
220 | rect8s="${rect8%%,*}" #-940
221 | rect9=${rect8#*,}
222 | rect9s="${rect9%%,*}" #-110
223 | # "${rec1##*,}" #最后一位
224 | rect10=${rect9#*,}
225 | rect10s="${rect10%%,*}" #最后一位
226 | PCI=$rect5s
227 | LBAND="n"$(echo $rect6s | cut -d, -f0 | grep -o "BAND[0-9]\{1,3\}" | grep -o "[0-9]\+")
228 | CHANNEL=$rect7s
229 | RSCP=$(($(echo $rect8s | cut -d, -f0) / 10))
230 | ECIO=$(($(echo $rect9s | cut -d, -f0) / 10))
231 | if [ "$CSQ_PER" = "-" ]; then
232 | CSQ_PER=$((100 - (($RSCP + 31) * 100/-125)))"%"
233 | fi
234 | SINR=$(($(echo $rect10s | cut -d, -f0) / 10))" dB"
235 | fi
236 | w=$(echo $rec |grep "LTE"|grep "EUTRAN"| wc -l)
237 | if [ $w -ge 1 ];then
238 | rec1=${rec#*EUTRAN-}
239 | lte_band=${rec1%%,*} #EUTRAN-BAND
240 | rec1=${rec1#*,}
241 | rec1=${rec1#*,}
242 | rec1=${rec1#*,}
243 | rec1=${rec1#*,}
244 | #rec1=${rec1#*,}
245 | rec1=${rec1#*,}
246 | lte_rssi=${rec1%%,*} #LTE_RSSI
247 | lte_rssi=`expr $lte_rssi / 10` #LTE_RSSI
248 | Debug "LTE_BAND=$lte_band LTE_RSSI=$lte_rssi"
249 | if [ $rssi == 0 ];then
250 | rssi=$lte_rssi
251 | fi
252 | fi
253 | w=$(echo $rec |grep "WCDMA"| wc -l)
254 | if [ $w -ge 1 ];then
255 | w=$(echo $rec |grep "UNKNOWN"|wc -l)
256 | if [ $w -ge 1 ];then
257 | Debug "UNKNOWN BAND"
258 | return
259 | fi
260 | fi
261 |
262 |
263 |
264 |
265 |
266 |
267 | #CNMP
268 | OX=$( sendat $ATPORT "AT+CNMP?")
269 | CNMP=$(echo "$OX" | grep -o "+CNMP:[ ]*[0-9]\{1,3\}" | grep -o "[0-9]\{1,3\}")
270 | if [ -n "$CNMP" ]; then
271 | case $CNMP in
272 | "2"|"55" )
273 | NETMODE="1" ;;
274 | "13" )
275 | NETMODE="3" ;;
276 | "14" )
277 | NETMODE="5" ;;
278 | "38" )
279 | NETMODE="7" ;;
280 | "71" )
281 | NETMODE="9" ;;
282 | "109" )
283 | NETMODE="8" ;;
284 | * )
285 | NETMODE="0" ;;
286 | esac
287 | fi
288 |
289 | # CMGRMI 信息
290 | OX=$( sendat $ATPORT "AT+CMGRMI=4")
291 | CAINFO=$(echo "$OX" | grep -o "$REGXz" | tr ' ' ':')
292 | if [ -n "$CAINFO" ]; then
293 | for CASV in $(echo "$CAINFO"); do
294 | LBAND=$LBAND"
B"$(echo "$CASV" | cut -d, -f4)
295 | BW=$(echo "$CASV" | cut -d, -f5)
296 | decode_bw
297 | LBAND=$LBAND" (CA, Bandwidth $BW MHz)"
298 | CHANNEL="$CHANNEL, "$(echo "$CASV" | cut -d, -f2)
299 | PCI="$PCI, "$(echo "$CASV" | cut -d, -f7)
300 | done
301 | fi
302 |
303 | }
304 |
--------------------------------------------------------------------------------
/luasrc/view/cpe/net_status.htm:
--------------------------------------------------------------------------------
1 | <%+header%>
2 | <%
3 | local fs = require "nixio.fs"
4 | nosms = 1
5 | if not fs.stat("/etc/nosim") then
6 | nosms = 0
7 | end
8 | havegps = 0
9 | if fs.stat("/etc/havegps") then
10 | havegps = 1
11 | end
12 | -%>
13 |
14 |
15 |
197 |
198 |
199 |
200 |
201 |
请注意该插件所有功能并无适配所有5G模块,不用妄想冷门模块插上就能用(有能力者自行适配)
202 |
203 |
204 |
214 |
215 |
216 |
228 |
229 | <% if nosms == 0 then %>
230 | <% end %>
231 |
232 |
242 |
243 |
244 |
258 |
259 |
273 |
274 |
275 | <% if havegps == 1 then %>
276 |
291 | <% end %>
292 |
293 |
294 |
295 | <%+footer%>
296 |
297 |
--------------------------------------------------------------------------------
/root/usr/share/cpe/rssi:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | source /usr/share/cpe/cpedebug
3 | source /usr/share/cpe/SIMCOM
4 | source /usr/share/cpe/Quectel
5 | source /usr/share/cpe/Fibocom
6 |
7 | #初值化数据结构
8 | InitData()
9 | {
10 | Date=''
11 | CHANNEL="-"
12 | ECIO="-"
13 | RSCP="-"
14 | ECIO1=" "
15 | RSCP1=" "
16 | NETMODE="-"
17 | LBAND="-"
18 | PCI="-"
19 | CTEMP="-"
20 | MODE="-"
21 | SINR="-"
22 | IMEI='-'
23 | IMSI='-'
24 | ICCID='-'
25 | phone='-'
26 | conntype=''
27 | Model=''
28 |
29 |
30 | }
31 | #写数据
32 | SETData()
33 | {
34 | {
35 | echo $Model #'RM520N-GL'
36 | echo $conntype #'conntype'
37 | echo '1e0e:9001'
38 | echo $COPS #运营商
39 | echo 'ttyUSB2' #端口
40 | echo $TEMP #温度
41 | echo 'QMI' #协议
42 | echo '---------------------------------'
43 | echo $IMEI #imei
44 | echo $IMSI #imsi
45 | echo $ICCID #iccid
46 | echo $phone #phone
47 | echo '---------------------------------'
48 |
49 | echo $MODE
50 | echo $CSQ
51 | echo $CSQ_PER
52 | echo $CSQ_RSSI
53 | echo $ECIO #参考信号接收质量 RSRQ ecio
54 | echo $ECIO1 #参考信号接收质量 RSRQ ecio1
55 | echo $RSCP #参考信号接收功率 RSRP rscp0
56 | echo $RSCP1 #参考信号接收功率 RSRP rscp1
57 | echo $SINR #信噪比 SINR rv["sinr"]
58 | echo $NETMODE #连接状态监控 rv["netmode"]
59 | echo '---------------------------------'
60 |
61 |
62 | echo $COPS_MCC #MCC
63 | echo $$COPS_MNC #MNC
64 | echo $LAC #eNB ID
65 | echo '' #LAC_NUM
66 | echo $RNC #TAC
67 | echo '' #RNC_NUM
68 | echo $CID
69 | echo '' #CID_NUM
70 | echo $LBAND
71 | echo $CHANNEL
72 | echo $PCI
73 |
74 | echo $Date
75 |
76 |
77 |
78 | echo $MODTYPE
79 | echo $QTEMP
80 |
81 | } > /tmp/cpe_cell.file
82 | }
83 | ATPORT=1
84 |
85 | # 自动处理模块信号
86 | AUTO_CPE()
87 | {
88 | Debug "------------------------------端口$ATPORT---------------------------"
89 | Debug "AUTO_CPE"
90 | Date=$(date "+%Y-%m-%d %H:%M:%S")
91 |
92 |
93 | #检测设备是否准备好
94 | rec=$(sendat $ATPORT "AT" 500 |grep OK |wc -l)
95 | if [ $rec == "1" ];then
96 | sleep 1s
97 | else
98 | sleep 5s
99 | return
100 | fi
101 | #读取模块信息
102 | # if [ "$conntype" == "" ]; then
103 | # {
104 | # Debug "计算模块"
105 | # ATATI=$( sendat $ATPORT "ATI")
106 | # Getconntype=$(echo "$ATATI" | sed -n '2p')
107 | # if [ "$Getconntype" == "" ]; then
108 | # {
109 | # sleep 5s
110 | # return
111 | # }
112 | # fi
113 | # Model=$(echo "$ATATI" | sed -n '3p')
114 | # conntype=$Getconntype
115 | # }
116 | # fi
117 |
118 | Debug "读取模块信息 计算模块"
119 | ATATI=$( sendat $ATPORT "ATI")
120 | Getconntype=$(echo "$ATATI" | sed -n '2p')
121 | if [ "$Getconntype" == "" ]; then
122 | {
123 | sleep 5s
124 | return
125 | }
126 | fi
127 | Model=$(echo "$ATATI" | sed -n '3p')
128 | conntype=$Getconntype
129 |
130 | cpin=$( sendat $ATPORT "at+cpin?")
131 | ERR=$(echo "$cpin" | grep "ERROR")
132 | if [ ! -z "$ERR" ]; then # No SIM
133 | Debug "No SIM"
134 | sleep 5s
135 | return
136 | fi
137 | RDY=$(echo "$cpin" | grep "READY")
138 | if [ -z "$RDY" ]; then # SIM Locked
139 | Debug "Correct Pin"
140 | sleep 5s
141 | return
142 | else
143 | Debug "Not Locked"
144 | fi
145 | #执行对应模块
146 | if [ $(echo $conntype |grep "Quectel"| wc -l) -ge 1 ];then
147 | {
148 | Quectel_AT
149 | }
150 | elif [ $(echo $conntype |grep "SIMCOM"| wc -l) -ge 1 ];then
151 | {
152 | SIMCOM_AT
153 | }
154 | elif [ $(echo $conntype |grep "Fibocom"| wc -l) -ge 1 ];then
155 | {
156 | Fibocom_AT
157 | }
158 | else
159 | {
160 | Debug "null "
161 | }
162 | fi
163 | }
164 | #重新联网
165 | modem_reset()
166 | {
167 |
168 | echo "Abnormal network restart"
169 | lsusb=$( lsusb )
170 | RDFM650=$(echo "$lsusb" | grep "ID 2cb7:0a05 " | wc -l)
171 | echo "RDFM650 $RDFM650"
172 | if [ "$RDFM650" == 1 ]; then
173 | {
174 | GTRNDIS=$(sendat $ATPORT "AT+GTRNDIS=1,1" 500 |grep OK |wc -l)
175 | sleep 2s
176 | }
177 | else
178 | {
179 | start="$( /etc/init.d/modem stop )"
180 | sleep 2s
181 | start="$( /etc/init.d/modem start )"
182 | sleep 5s
183 | }
184 | fi
185 | }
186 | #检测SIM卡是否插入,10次检测不到则重启模块
187 | check_sim()
188 | {
189 | while [ 1 ]
190 | do
191 | enabled=$(uci -q get modem.@ndis[0].enabled)
192 | if [ $enabled == '1' ] ;then
193 | echo "Check the sim"
194 | rec=$( sendat 2 "AT+CPIN?")
195 | rec1=$(echo $rec | grep "READY" | wc -l )
196 | if [ $rec1 == 1 ]; then
197 | x=0
198 | echo "SIM is READY"
199 | else
200 | let x++
201 | if [ $x == 10 ]; then
202 | echo "SIM abnormal restart"
203 | modem_reset #重启模块
204 | x=0
205 | fi
206 | fi
207 | fi
208 | sleep 6s
209 | done
210 | }
211 | #检测网络状态第一次开机
212 | chenk_firstdns()
213 | {
214 | while [ 1 ]
215 | do
216 | enabled=$(uci -q get modem.@ndis[0].enabled)
217 | en1=$(uci -q get modem.@ndis[0].en)
218 | if [ $enabled == '1' ] ;then
219 | if [ $en1 == '1' ] ;then
220 | echo "------------------------------开启任务---------------------------"
221 | ipadd=$(uci -q get modem.@ndis[0].ipaddress)
222 | ping -c 1 -w 1 $ipadd > /dev/null 2>&1
223 | if [ $? -eq 0 ];then
224 | echo "网络连接正常"
225 | xx=0
226 | return
227 | else
228 | echo "网络连接异常 $ipadd"
229 | let xx++
230 | let pxx++
231 | fi
232 | fi
233 | if [ $xx == 5 ];then
234 | xx=0
235 | modem_reset
236 | fi
237 | if [ $pxx == 10 ];then
238 | xx=0
239 | pxx=0
240 | return
241 | fi
242 | echo "------------------------------结束任务---------------------------"
243 | fi
244 | sleep 1s
245 | done
246 | }
247 | #检测网络状态
248 | chenk_dns()
249 | {
250 | en1=$(uci -q get modem.@ndis[0].en)
251 | if [ $en1 == '1' ] ;then
252 | echo "------------------------------开启任务---------------------------"
253 | ipadd=$(uci -q get modem.@ndis[0].ipaddress)
254 | ping -c 1 -w 1 $ipadd > /dev/null 2>&1
255 | if [ $? -eq 0 ];then
256 | echo "网络连接正常"
257 | xx=0
258 | else
259 | echo "网络连接异常 $ipadd 次数$xx"
260 | let xx++
261 | fi
262 | fi
263 | an=$(uci -q get modem.@ndis[0].an)
264 | if [ $xx == $an ];then
265 | xx=0
266 | modem_reset
267 | fi
268 | echo "------------------------------结束任务---------------------------"
269 |
270 | }
271 | # 信号任务
272 | chenk_Task()
273 | {
274 | while [ 1 ]
275 | do
276 | enabled=$(uci -q get modem.@ndis[0].enabled)
277 | if [ $enabled == '1' ] ;then
278 | ATPORT
279 | Debug "------------------------------开启任务---------------------------"
280 | AUTO_CPE
281 | SETData
282 | chenk_dns
283 | Debug "------------------------------结束任务---------------------------"
284 | fi
285 | sleep 10s
286 | done
287 | }
288 |
289 |
290 | #注册网卡
291 | RegisterNetwork()
292 | {
293 | # ATPORT
294 | Debug "RegisterNetwork 注册网卡 $ $MODEMNAME"
295 | # if [ "$MODEMNAME" == "FM650CN" ]; then
296 | # getFM650=$(uci -q get network.wwan5g |grep "interface"| wc -l)
297 | # if [ $getFM650 == "0" ] ;then
298 | # uci set network.wwan5g=interface
299 | # uci set network.wwan5g.ifname='usb0'
300 | # uci set network.wwan5g.proto=dhcp
301 | # uci commit network
302 |
303 | # uci set firewall.@zone[1].network="wan wan6 wwan5g wwan5g6 wlan"
304 | # uci commit firewall
305 |
306 | # $(/etc/init.d/network reload)
307 | # fi
308 | # getFM650=$(uci -q get network.wwan5g6|grep "interface"| wc -l)
309 | # if [ $getFM650 == "0" ] ;then
310 | # uci set network.wwan5g6=interface
311 | # uci set network.wwan5g6.ifname='usb0'
312 | # uci set network.wwan5g6.proto='dhcpv6'
313 | # uci set network.wwan5g6.reqaddress='try'
314 | # uci set network.wwan5g6.reqprefix='auto'
315 | # uci set network.wwan5g6._orig_ifname='usb0'
316 | # uci set network.wwan5g6._orig_bridge='false'
317 | # uci set network.wwan5g6.extendprefix='1'
318 | # uci commit network
319 | # uci set firewall.@zone[1].network="wan wan6 wwan wwan5g wwan5g6 wlan"
320 | # uci commit firewall
321 | # $(/etc/init.d/network reload)
322 | # fi
323 | # fi
324 |
325 |
326 |
327 | if [ $(uci -q get network.wwan5g |grep "interface"| wc -l) == "0" ] ;then
328 | uci set network.wwan5g=interface
329 | if [ "$MODEMNAME" == "FM650CN" ]; then
330 | uci set network.wwan5g.ifname='usb0'
331 | else
332 | uci set network.wwan5g.ifname='wwan0'
333 | fi
334 | uci set network.wwan5g.proto=dhcp
335 | uci commit network
336 | uci set firewall.@zone[1].network="wan wan6 wwan5g wwan5g6 wlan"
337 | uci commit firewall
338 | $(/etc/init.d/network reload)
339 | fi
340 | if [ $(uci -q get network.wwan5g6 |grep "interface"| wc -l) == "0" ] ;then
341 | uci set network.wwan5g6=interface
342 | if [ "$MODEMNAME" == "FM650CN" ]; then
343 | uci set network.wwan5g6.ifname='usb0'
344 | uci set network.wwan5g6._orig_ifname='usb0'
345 | else
346 | uci set network.wwan5g6.ifname='wwan0'
347 | uci set network.wwan5g6._orig_ifname='wwan0'
348 | fi
349 | uci set network.wwan5g6.proto='dhcpv6'
350 | uci set network.wwan5g6.reqaddress='try'
351 | uci set network.wwan5g6.reqprefix='auto'
352 | uci set network.wwan5g6._orig_bridge='false'
353 | uci set network.wwan5g6.extendprefix='1'
354 | uci commit network
355 | uci set firewall.@zone[1].network="wan wan6 wwan wwan5g wwan5g6 wlan"
356 | uci commit firewall
357 | $(/etc/init.d/network reload)
358 | fi
359 | if [ "$MODEMNAME" == "FM650CN" ]; then
360 | if [ $(uci -q get network.wwan5g.ifname |grep "usb0"| wc -l) == "0" ] ;then
361 | uci set network.wwan5g.ifname='usb0'
362 | uci commit network
363 | $(/etc/init.d/network reload)
364 | fi
365 | if [ $(uci -q get network.wwan5g6.ifname |grep "usb0"| wc -l) == "0" ] ;then
366 | uci set network.wwan5g6.ifname='usb0'
367 | uci commit network
368 | $(/etc/init.d/network reload)
369 | fi
370 | else
371 | if [ $(uci -q get network.wwan5g.ifname |grep "wwan0"| wc -l) == "0" ] ;then
372 | uci set network.wwan5g.ifname='wwan0'
373 | uci commit network
374 | $(/etc/init.d/network reload)
375 | fi
376 | if [ $(uci -q get network.wwan5g6.ifname |grep "wwan0"| wc -l) == "0" ] ;then
377 | uci set network.wwan5g6._orig_ifname='wwan0'
378 | uci set network.wwan5g6.ifname='wwan0'
379 | uci commit network
380 | $(/etc/init.d/network reload)
381 | fi
382 | fi
383 |
384 |
385 |
386 | }
387 |
388 |
389 |
390 | # 运行入口
391 | first()
392 | {
393 | Debug "开启RSSI服务"
394 | # 初值化数据结构
395 | InitData
396 | Debug "初值化数据完成"
397 | sleep 1s
398 | # 计算模块AT端口号
399 | ATPORT
400 | # 注册网卡
401 | RegisterNetwork
402 | # 第一次获取模块信息数据
403 | AUTO_CPE
404 | # 保存结构数据
405 | SETData
406 | #开机直接运行网络注册
407 | modem_reset
408 | # 第一次开机检测是否联网
409 | chenk_firstdns
410 | chenk_Task
411 | }
412 |
413 | #############################################
414 | # #
415 | # 进入主函数 #
416 | # #
417 | #############################################
418 | first
419 |
--------------------------------------------------------------------------------