diff --git a/luci-app-modem/luasrc/controller/modem.lua b/luci-app-modem/luasrc/controller/modem.lua
index 04f1efd..5067038 100644
--- a/luci-app-modem/luasrc/controller/modem.lua
+++ b/luci-app-modem/luasrc/controller/modem.lua
@@ -54,25 +54,46 @@ end
at_command AT命令
]]
function at(at_port,at_command)
- local odpall = io.popen("cd "..script_path.." && source "..script_path.."modem_debug.sh && at "..at_port.." "..at_command)
+ local odpall = io.popen("source "..script_path.."modem_debug.sh && at "..at_port.." "..at_command)
local odp = odpall:read("*a")
odpall:close()
odp=string.gsub(odp, "\r", "")
return odp
end
+--[[
+@Description 获取模组拨号模式
+@Params
+ at_port AT串口
+ manufacturer 制造商
+ platform 平台
+]]
+function getMode(at_port,manufacturer,platform)
+ local mode="unknown"
+
+ if at_port and manufacturer~="unknown" then
+ local odpall = io.popen("source "..script_path..manufacturer..".sh && "..manufacturer.."_get_mode "..at_port.." "..platform)
+ opd = odpall:read("*a")
+ odpall:close()
+ mode = string.gsub(opd, "\n", "")
+ end
+
+ return mode
+end
+
--[[
@Description 获取模组连接状态
@Params
at_port AT串口
manufacturer 制造商
+ define_connect 连接定义
]]
-function getModemConnectStatus(at_port,manufacturer)
+function getModemConnectStatus(at_port,manufacturer,define_connect)
local connect_status="unknown"
if at_port and manufacturer~="unknown" then
- local odpall = io.popen("cd "..script_path.." && source "..script_path..manufacturer..".sh && "..manufacturer.."_get_connect_status "..at_port)
+ local odpall = io.popen("source "..script_path..manufacturer..".sh && "..manufacturer.."_get_connect_status "..at_port.." "..define_connect)
opd = odpall:read("*a")
odpall:close()
connect_status = string.gsub(opd, "\n", "")
@@ -94,7 +115,7 @@ function getModemDeviceInfo(at_port)
--获取数据接口
local data_interface=modem_device["data_interface"]:upper()
--获取连接状态
- local connect_status=getModemConnectStatus(modem_device["at_port"],modem_device["manufacturer"])
+ local connect_status=getModemConnectStatus(modem_device["at_port"],modem_device["manufacturer"],modem_device["define_connect"])
--设置值
modem_device_info=modem_device
@@ -113,10 +134,10 @@ end
at_port AT串口
manufacturer 制造商
]]
-function getModemMoreInfo(at_port,manufacturer)
+function getModemMoreInfo(at_port,manufacturer,define_connect)
--获取模组信息
- local odpall = io.popen("sh "..script_path.."modem_info.sh".." "..at_port.." "..manufacturer)
+ local odpall = io.popen("sh "..script_path.."modem_info.sh".." "..at_port.." "..manufacturer.." "..define_connect)
local opd = odpall:read("*a")
odpall:close()
@@ -138,7 +159,7 @@ function getModemInfo()
local modem_more_info
if at_port then
modem_device_info=getModemDeviceInfo(at_port)
- modem_more_info=getModemMoreInfo(at_port,modem_device_info["manufacturer"])
+ modem_more_info=getModemMoreInfo(at_port,modem_device_info["manufacturer"],modem_device_info["define_connect"])
end
--设置信息
@@ -254,16 +275,21 @@ function getModems()
local translation={}
uci:foreach("modem", "modem-device", function (modem_device)
-- 获取连接状态
- local connect_status=getModemConnectStatus(modem_device["at_port"],modem_device["manufacturer"])
+ local connect_status=getModemConnectStatus(modem_device["at_port"],modem_device["manufacturer"],modem_device["define_connect"])
+ -- 获取拨号模式
+ local mode=getMode(modem_device["at_port"],modem_device["manufacturer"],modem_device["platform"])
-- 获取翻译
translation[connect_status]=luci.i18n.translate(connect_status)
- translation[modem_device["name"]]=luci.i18n.translate(modem_device["name"])
- translation[modem_device["mode"]]=luci.i18n.translate(modem_device["mode"])
+ if modem_device["name"] then
+ translation[modem_device["name"]]=luci.i18n.translate(modem_device["name"])
+ end
+ translation[mode]=luci.i18n.translate(mode)
-- 设置值
local modem=modem_device
modem["connect_status"]=connect_status
+ modem["mode"]=mode
local modem_tmp={}
modem_tmp[modem_device[".name"]]=modem
@@ -381,7 +407,7 @@ function getQuickCommands()
local commands={}
if quick_option=="auto" then
--获取模组AT命令
- -- local odpall = io.popen("cd "..script_path.." && source "..script_path.."modem_debug.sh && get_quick_commands "..quick_option.." "..manufacturer)
+ -- local odpall = io.popen(source "..script_path.."modem_debug.sh && get_quick_commands "..quick_option.." "..manufacturer)
local odpall = io.popen("cat "..script_path..manufacturer.."_at_commands.json")
local opd = odpall:read("*a")
odpall:close()
@@ -437,13 +463,13 @@ function setNetworkPrefer()
end)
--设置模组网络偏好
- local odpall = io.popen("cd "..script_path.." && source "..script_path..manufacturer..".sh && "..manufacturer.."_set_network_prefer "..at_port.." "..network_prefer_config)
+ local odpall = io.popen("source "..script_path..manufacturer..".sh && "..manufacturer.."_set_network_prefer "..at_port.." "..network_prefer_config)
odpall:close()
--获取设置好后的模组网络偏好
local network_prefer={}
if at_port and manufacturer and manufacturer~="unknown" then
- local odpall = io.popen("cd "..script_path.." && source "..script_path..manufacturer..".sh && "..manufacturer.."_get_network_prefer "..at_port)
+ local odpall = io.popen("source "..script_path..manufacturer..".sh && "..manufacturer.."_get_network_prefer "..at_port)
local opd = odpall:read("*a")
network_prefer=json.parse(opd)
odpall:close()
@@ -473,13 +499,13 @@ function setMode()
end)
--设置模组拨号模式
- local odpall = io.popen("cd "..script_path.." && source "..script_path..manufacturer..".sh && "..manufacturer.."_set_mode "..at_port.." "..mode_config)
+ local odpall = io.popen("source "..script_path..manufacturer..".sh && "..manufacturer.."_set_mode "..at_port.." "..mode_config)
odpall:close()
--获取设置好后的模组拨号模式
local mode
if at_port and manufacturer and manufacturer~="unknown" then
- local odpall = io.popen("cd "..script_path.." && source "..script_path..manufacturer..".sh && "..manufacturer.."_get_mode "..at_port)
+ local odpall = io.popen("source "..script_path..manufacturer..".sh && "..manufacturer.."_get_mode "..at_port)
mode = odpall:read("*a")
mode=string.gsub(mode, "\n", "")
odpall:close()
@@ -509,7 +535,7 @@ function getModeInfo(at_port,manufacturer)
end)
--获取模组拨号模式
- local odpall = io.popen("cd "..script_path.." && source "..script_path..manufacturer..".sh && "..manufacturer.."_get_mode "..at_port)
+ local odpall = io.popen("source "..script_path..manufacturer..".sh && "..manufacturer.."_get_mode "..at_port)
local opd = odpall:read("*a")
odpall:close()
local mode=string.gsub(opd, "\n", "")
@@ -531,7 +557,7 @@ end
function getNetworkPreferInfo(at_port,manufacturer)
--获取模组网络偏好
- local odpall = io.popen("cd "..script_path.." && source "..script_path..manufacturer..".sh && "..manufacturer.."_get_network_prefer "..at_port)
+ local odpall = io.popen("source "..script_path..manufacturer..".sh && "..manufacturer.."_get_network_prefer "..at_port)
local opd = odpall:read("*a")
odpall:close()
local network_prefer_info=json.parse(opd)
@@ -539,6 +565,23 @@ function getNetworkPreferInfo(at_port,manufacturer)
return network_prefer_info
end
+--[[
+@Description 获取自检信息
+@Params
+ at_port AT串口
+ manufacturer 制造商
+]]
+function getSelfTestInfo(at_port,manufacturer)
+
+ --获取模组自检信息
+ local odpall = io.popen("source "..script_path..manufacturer..".sh && "..manufacturer.."_get_self_test_info "..at_port)
+ local opd = odpall:read("*a")
+ odpall:close()
+ local self_test_info=json.parse(opd)
+
+ return self_test_info
+end
+
--[[
@Description 获取模组调试信息
]]
@@ -559,15 +602,18 @@ function getModemDebugInfo()
--获取值
local mode_info={}
local network_prefer_info={}
+ local self_test_info={}
if manufacturer~="unknown" then
mode_info=getModeInfo(at_port,manufacturer)
network_prefer_info=getNetworkPreferInfo(at_port,manufacturer)
+ self_test_info=getSelfTestInfo(at_port,manufacturer)
end
--设置值
local modem_debug_info={}
modem_debug_info["mode_info"]=mode_info
modem_debug_info["network_prefer_info"]=network_prefer_info
+ modem_debug_info["self_test_info"]=self_test_info
-- 写入Web界面
luci.http.prepare_content("application/json")
diff --git a/luci-app-modem/luasrc/model/cbi/modem/config.lua b/luci-app-modem/luasrc/model/cbi/modem/config.lua
index 94f5b9a..b8e99b6 100644
--- a/luci-app-modem/luasrc/model/cbi/modem/config.lua
+++ b/luci-app-modem/luasrc/model/cbi/modem/config.lua
@@ -84,6 +84,12 @@ pdp_type:value("ipv4", translate("IPv4"))
pdp_type:value("ipv6", translate("IPv6"))
pdp_type:value("ipv4v6", translate("IPv4/IPv6"))
+-- 网络桥接
+network_bridge = s:taboption("advanced", Flag, "network_bridge", translate("Network Bridge"))
+network_bridge.description = translate("After checking, enable network interface bridge.")
+network_bridge.default = "0"
+network_bridge.rmempty = false
+
-- 接入点
apn = s:taboption("advanced", Value, "apn", translate("APN"))
apn.default = ""
diff --git a/luci-app-modem/luasrc/model/cbi/modem/index.lua b/luci-app-modem/luasrc/model/cbi/modem/index.lua
index fc856c3..9afb953 100644
--- a/luci-app-modem/luasrc/model/cbi/modem/index.lua
+++ b/luci-app-modem/luasrc/model/cbi/modem/index.lua
@@ -68,6 +68,7 @@ o.cfgvalue = function(t, n)
return translate(dial_tool)
end
+
o = s:option(DummyValue, "pdp_type", translate("PDP Type"))
o.cfgvalue = function(t, n)
local pdp_type = (Value.cfgvalue(t, n) or "")
@@ -79,6 +80,10 @@ o.cfgvalue = function(t, n)
return pdp_type
end
+o = s:option(Flag, "network_bridge", translate("Network Bridge"))
+o.width = "5%"
+o.rmempty = false
+
o = s:option(DummyValue, "apn", translate("APN"))
o.cfgvalue = function(t, n)
local apn = (Value.cfgvalue(t, n) or "")
diff --git a/luci-app-modem/luasrc/view/modem/modem_debug.htm b/luci-app-modem/luasrc/view/modem/modem_debug.htm
index d660ffe..5643416 100644
--- a/luci-app-modem/luasrc/view/modem/modem_debug.htm
+++ b/luci-app-modem/luasrc/view/modem/modem_debug.htm
@@ -182,6 +182,8 @@
document.getElementById("cbi-mode").style.display="none";
//隐藏网络偏好界面
document.getElementById("cbi-network-prefer").style.display="none";
+ //隐藏模组自检界面
+ document.getElementById("cbi-modem-self-test").style.display="none";
//隐藏AT界面
document.getElementById("cbi-at").style.display="none";
}
@@ -208,6 +210,8 @@
document.getElementById("cbi-mode").style.display="none";
//隐藏网络偏好界面
document.getElementById("cbi-network-prefer").style.display="none";
+ //隐藏模组自检界面
+ document.getElementById("cbi-modem-self-test").style.display="none";
}
// 全功能界面
@@ -217,6 +221,8 @@
document.getElementById("cbi-mode").style.display="block";
//显示网络偏好界面
document.getElementById("cbi-network-prefer").style.display="block";
+ //显示模组自检界面
+ document.getElementById("cbi-modem-self-test").style.display="block";
//隐藏提示信息
document.getElementById("cbi-info").style.display="none";
}
@@ -320,12 +326,14 @@
//拨号模式
if (function_name=="mode")
{
- //模式选项
- document.getElementById('mode_option_qmi').disabled=status;
- document.getElementById('mode_option_ecm').disabled=status;
- document.getElementById('mode_option_mbim').disabled=status;
- document.getElementById('mode_option_rndis').disabled=status;
- document.getElementById('mode_option_ncm').disabled=status;
+ modes=["qmi","ecm","mbim","rndis","ncm"]
+ for(mode of modes)
+ {
+ mode_element=document.getElementById('mode_option_'+mode)
+ if (mode_element!=null) {
+ mode_element.disabled=status;
+ }
+ }
//模式按钮
document.getElementById('mode_button').disabled=status;
@@ -484,6 +492,49 @@
}
}
+ // 设置模组自检信息
+ function set_modem_self_test_info(self_test_info)
+ {
+ // console.log(self_test_info);
+
+ //获取模组自检
+ // var self_test=self_test_info["self_test"];
+
+ // //获取自检视图
+ // var self_test_view=set_current_self_test_view(self_test);
+ // //获取
+ // var self_test_view=set_current_self_test_view(self_test);
+
+ // //设置当前电压信息
+ // document.getElementById('current_voltage').innerHTML=current_self_test_view;
+ document.getElementById('current_voltage').innerHTML=self_test_info/1000;
+
+ // 设置电压状态
+ var state = '';
+ var css = '';
+ if (self_test_info<3135)
+ {
+ state = "<%:Abnormal%>";
+ color = "red";
+ }
+ else if (self_test_info>3135 && self_test_info<3300)
+ {
+ state = "<%:Low%>";
+ color = "goldenrod";
+ }
+ else //大于3300(3.3V)
+ {
+ state = "<%:Normal%>";
+ color = "green";
+ }
+ var voltage_status=document.getElementById('voltage_status');
+ voltage_status.innerHTML=state;
+ voltage_status.style.color=color
+
+ // //设置当前温度信息
+ // document.getElementById('current_temperature').innerHTML=current_self_test_view;
+ }
+
// 设置网络偏好
function set_network_prefer()
{
@@ -543,6 +594,7 @@
{
var mode_info=data["mode_info"];
var network_prefer_info=data["network_prefer_info"];
+ var self_test_info=data["self_test_info"];
if (Object.keys(mode_info).length==0||Object.keys(network_prefer_info).length==0) {
//显示未适配模组界面
not_adapted_modems_view();
@@ -555,6 +607,9 @@
//设置网络偏好信息
set_network_prefer_info(network_prefer_info,debug_params.first_cache);
+ //设置模组自检信息
+ set_modem_self_test_info(self_test_info);
+
//设置第一次获取数据标志
debug_params.first_cache=false;
@@ -599,6 +654,9 @@
get_quick_commands();
}
modem_select_cache=select_modem_name;
+
+ //设置第一次获取数据标志
+ debug_params.first_cache=true;
}
//获取模组调试信息
@@ -693,6 +751,54 @@
+
+
+
+
+
+