diff --git a/applications/luci-app-modem/luasrc/controller/modem.lua b/applications/luci-app-modem/luasrc/controller/modem.lua
index 89a23b2..eb418f0 100644
--- a/applications/luci-app-modem/luasrc/controller/modem.lua
+++ b/applications/luci-app-modem/luasrc/controller/modem.lua
@@ -5,6 +5,7 @@ local fs = require "nixio.fs"
local json = require("luci.jsonc")
uci = luci.model.uci.cursor()
local script_path="/usr/share/modem/"
+local run_path="/tmp/run/modem/"
function index()
if not nixio.fs.access("/etc/config/modem") then
@@ -22,6 +23,8 @@ function index()
entry({"admin", "network", "modem", "index"},cbi("modem/index"),translate("Dial Config"),20).leaf = true
entry({"admin", "network", "modem", "config"}, cbi("modem/config")).leaf = true
entry({"admin", "network", "modem", "get_modems"}, call("getModems"), nil).leaf = true
+ entry({"admin", "network", "modem", "get_dial_log_info"}, call("getDialLogInfo"), nil).leaf = true
+ entry({"admin", "network", "modem", "clean_dial_log"}, call("cleanDialLog"), nil).leaf = true
entry({"admin", "network", "modem", "status"}, call("act_status")).leaf = true
--模块调试
@@ -36,6 +39,10 @@ function index()
entry({"admin", "network", "modem", "send_at_command"}, call("sendATCommand"), nil).leaf = true
-- entry({"admin", "network", "modem", "get_modem_debug_info"}, call("getModemDebugInfo"), nil).leaf = true
+ --插件信息
+ entry({"admin", "network", "modem", "plugin_info"},template("modem/plugin_info"),translate("Plugin Info"),40).leaf = true
+ entry({"admin", "network", "modem", "get_plugin_info"}, call("getPluginInfo"), nil).leaf = true
+
--AT命令旧界面
entry({"admin", "network", "modem", "at_command_old"},template("modem/at_command_old")).leaf = true
end
@@ -355,6 +362,78 @@ function getModems()
luci.http.write_json(data)
end
+--[[
+@Description 获取拨号日志信息
+]]
+function getDialLogInfo()
+
+ local command="find "..run_path.." -name \"modem*_dial.cache\""
+ local result=shell(command)
+
+ local log_paths=string.split(result, "\n")
+ table.sort(log_paths)
+
+ local logs={}
+ local names={}
+ local translation={}
+ for key in pairs(log_paths) do
+
+ local log_path=log_paths[key]
+
+ if log_path ~= "" then
+ -- 获取模组
+ local tmp=string.gsub(log_path, run_path, "")
+ local modem=string.gsub(tmp, "_dial.cache", "")
+ local modem_name=uci:get("modem", modem, "name")
+
+ -- 获取日志内容
+ local command="cat "..log_path
+ log=shell(command)
+
+ -- 排序插入
+ modem_log={}
+ modem_log[modem]=log
+ table.insert(logs, modem_log)
+
+ --设置模组名
+ names[modem]=modem_name
+ -- 设置翻译
+ translation[modem_name]=luci.i18n.translate(modem_name)
+ end
+ end
+
+ -- 设置值
+ local data={}
+ data["dial_log_info"]=logs
+ data["modem_name_info"]=names
+ data["translation"]=translation
+
+ -- 写入Web界面
+ luci.http.prepare_content("application/json")
+ luci.http.write_json(data)
+end
+
+--[[
+@Description 清空拨号日志
+]]
+function cleanDialLog()
+
+ -- 获取拨号日志路径
+ local dial_log_path = http.formvalue("path")
+
+ -- 清空拨号日志
+ local command=": > "..dial_log_path
+ shell(command)
+
+ -- 设置值
+ local data={}
+ data["clean_result"]="clean dial log"
+
+ -- 写入Web界面
+ luci.http.prepare_content("application/json")
+ luci.http.write_json(data)
+end
+
--[[
@Description 模块列表状态函数
]]
@@ -658,7 +737,7 @@ end
-- 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
@@ -668,3 +747,125 @@ end
-- luci.http.prepare_content("application/json")
-- luci.http.write_json(modem_debug_info)
-- end
+
+--[[
+@Description 设置插件版本信息
+@Params
+ info 信息
+]]
+function setPluginVersionInfo(info)
+
+ -- 正则表达式
+ local version_regular_expression="[0-9]+.[0-9]+.[0-9]+"
+
+ for key in pairs(info) do
+
+ -- 获取插件版本
+ local command="opkg list-installed | grep -oE '"..key.." - "..version_regular_expression.."' | awk -F' ' '{print $3}' | tr -d '\n'"
+ local plugin_version=shell(command)
+
+ if plugin_version~="" then
+ info[key]=plugin_version
+ end
+ end
+
+end
+
+--[[
+@Description 获取内核模块状态
+@Params
+ result 命令返回值
+]]
+function getModelStatus(result)
+ local model_status="Not loaded"
+
+ if result~="" then
+ model_status="Loaded"
+ end
+
+ return model_status
+end
+
+--[[
+@Description 设置内核模块状态
+@Params
+ info 信息
+]]
+function setModelStatus(info)
+
+ for key in pairs(info) do
+
+ -- 获取内核模块名
+ local model_name=key:gsub(".ko","")
+
+ local command="lsmod | grep -oE '"..model_name.." '"
+ local result=shell(command)
+ local model_status=getModelStatus(result)
+
+ -- 修改信息表
+ info[key]=model_status
+ end
+
+end
+
+--[[
+@Description 获取插件信息
+]]
+function getPluginInfo()
+
+ -- 设置翻译
+ translation={}
+ translation["Unknown"]=luci.i18n.translate("Unknown")
+ translation["Loaded"]=luci.i18n.translate("Loaded")
+ translation["Not loaded"]=luci.i18n.translate("Not loaded")
+
+ -- 获取插件信息
+ local plugin_info={}
+ plugin_info["luci-app-modem"]="Unknown"
+ setPluginVersionInfo(plugin_info)
+
+ -- 获取拨号工具信息
+ local dial_tool_info={}
+ dial_tool_info["quectel-CM-5G"]="Unknown"
+ dial_tool_info["modemmanager"]="Unknown"
+ setPluginVersionInfo(dial_tool_info)
+
+ -- 获取通用驱动信息
+ local general_driver_info={}
+ general_driver_info["usbnet.ko"]="Not loaded"
+ general_driver_info["qcserial.ko"]="Not loaded"
+ setModelStatus(general_driver_info)
+
+ -- 获取模组USB驱动信息
+ local usb_driver_info={}
+ usb_driver_info["qmi_wwan.ko"]="Not loaded"
+ usb_driver_info["cdc_ether.ko"]="Not loaded"
+ usb_driver_info["cdc_mbim.ko"]="Not loaded"
+ usb_driver_info["rndis_host.ko"]="Not loaded"
+ usb_driver_info["cdc_ncm.ko"]="Not loaded"
+ setModelStatus(usb_driver_info)
+
+ -- 获取模组PCIE驱动信息
+ local pcie_driver_info={}
+ pcie_driver_info["mhi_net.ko"]="Not loaded"
+ pcie_driver_info["qrtr_mhi.ko"]="Not loaded"
+ pcie_driver_info["mhi_pci_generic.ko"]="Not loaded"
+ pcie_driver_info["mhi_wwan_mbim.ko"]="Not loaded"
+ pcie_driver_info["mhi_wwan_ctrl.ko"]="Not loaded"
+ pcie_driver_info["pcie_mhi.ko"]="Not loaded"
+ pcie_driver_info["mtk_pcie_wwan_m80.ko"]="Not loaded"
+ setModelStatus(pcie_driver_info)
+
+ -- 设置值
+ local data={}
+ data["translation"]=translation
+ data["plugin_info"]=plugin_info
+ data["dial_tool_info"]=dial_tool_info
+ data["general_driver_info"]=general_driver_info
+ data["usb_driver_info"]=usb_driver_info
+ data["pcie_driver_info"]=pcie_driver_info
+
+ -- 写入Web界面
+ luci.http.prepare_content("application/json")
+ luci.http.write_json(data)
+end
diff --git a/applications/luci-app-modem/luasrc/model/cbi/modem/index.lua b/applications/luci-app-modem/luasrc/model/cbi/modem/index.lua
index 9afb953..b6746ec 100644
--- a/applications/luci-app-modem/luasrc/model/cbi/modem/index.lua
+++ b/applications/luci-app-modem/luasrc/model/cbi/modem/index.lua
@@ -93,6 +93,9 @@ o.cfgvalue = function(t, n)
return apn
end
+-- 添加模块拨号日志
+m:append(Template("modem/modem_dial_log"))
+
-- m:append(Template("modem/list_status"))
return m
diff --git a/applications/luci-app-modem/luasrc/view/modem/modem_debug.htm b/applications/luci-app-modem/luasrc/view/modem/modem_debug.htm
index 926b989..75cd96c 100644
--- a/applications/luci-app-modem/luasrc/view/modem/modem_debug.htm
+++ b/applications/luci-app-modem/luasrc/view/modem/modem_debug.htm
@@ -15,8 +15,8 @@
get_modem_debug_info(debug_params);
});
- //获取tab菜单
- var tab_menu = document.getElementsByClassName('cbi-tabmenu')[0];
+ //获取标签菜单
+ var tab_menu = document.getElementById("tab_menu");
set_tab_event(tab_menu);
//获取快捷选项父元素
@@ -69,7 +69,7 @@
});
}
- //设置tab菜单事件
+ //设置标签菜单事件
function set_tab_event(parent_element)
{
//获取子元素
@@ -77,35 +77,36 @@
//获取需要禁用的元素
for (var i = 0; i < childElements.length; i++)
{
- // childElements[i].addEventListener('click', function(event) {
- // var debug_params={first_cache:true};
- // get_modem_debug_info(debug_params);
- // });
-
- // 创建一个 MutationObserver 实例
- var observer = new MutationObserver(function(mutationsList) {
- for (var mutation of mutationsList) {
- if (mutation.type === 'attributes' && mutation.attributeName === 'class') {
- //只处理当前变为禁用的tab
- if (mutation.target.className=='cbi-tab') {
- //获取模组调试信息
- var debug_params={first_cache:true};
- get_modem_debug_info(debug_params);
- //只处理一次
- break;
- }
- }
- }
+ childElements[i].addEventListener('click', function(event) {
+ tab_event(this);
+ var debug_params={first_cache:true};
+ get_modem_debug_info(debug_params);
});
- // 配置观察器选项
- var observerOptions = {
- attributes: true, // 监听属性值变化
- attributeFilter: ['class'], // 要监听的属性名称
- };
+ // // 创建一个 MutationObserver 实例
+ // var observer = new MutationObserver(function(mutationsList) {
+ // for (var mutation of mutationsList) {
+ // if (mutation.type === 'attributes' && mutation.attributeName === 'class') {
+ // //只处理当前变为禁用的tab
+ // if (mutation.target.className=='cbi-tab') {
+ // //获取模组调试信息
+ // var debug_params={first_cache:true};
+ // get_modem_debug_info(debug_params);
+ // //只处理一次
+ // break;
+ // }
+ // }
+ // }
+ // });
- // 开始观察目标元素
- observer.observe(childElements[i], observerOptions);
+ // // 配置观察器选项
+ // var observerOptions = {
+ // attributes: true, // 监听属性值变化
+ // attributeFilter: ['class'], // 要监听的属性名称
+ // };
+
+ // // 开始观察目标元素
+ // observer.observe(childElements[i], observerOptions);
}
}
@@ -123,7 +124,8 @@
function(x, data)
{
responseElement=document.getElementById("response");
- if ("response" in data) {
+ if ("response" in data)
+ {
//显示当前时间
responseElement.value+=data["time"]+" ";
//显示返回值
@@ -233,7 +235,26 @@
return disenable_element;
}
- // 设置tab显示
+ //获取需要禁用的元素
+ function get_enable_element(parent_element)
+ {
+ var enable_element;
+ //获取子元素
+ var childElements = parent_element.children;
+ //获取已启用的元素
+ for (var i = 0; i < childElements.length; i++)
+ {
+ // 检查当前子元素的class属性是否为cbi-tab
+ if (childElements[i].classList.contains('cbi-tab'))
+ {
+ enable_element=childElements[i];
+ break;
+ }
+ }
+ return enable_element;
+ }
+
+ // 设置标签显示
function set_tab_view(disenable_element,enable_element)
{
//获取tab内容父元素
@@ -246,6 +267,7 @@
var data_tab_disenable = disenable_element.getAttribute('data-tab');
var tab_context_disenable_element = tab_context.querySelector('div[data-tab="'+data_tab_disenable+'"]');
tab_context_disenable_element.setAttribute('data-tab-active','false');
+ tab_context_disenable_element.style.display="none";
//启用tab
enable_element.classList.remove('cbi-tab-disabled');
@@ -254,13 +276,15 @@
var data_tab_enable = enable_element.getAttribute('data-tab');
var tab_context_enable_element = tab_context.querySelector('div[data-tab="'+data_tab_enable+'"]');
tab_context_enable_element.setAttribute('data-tab-active','true');
+ tab_context_enable_element.style.display="block";
}
- // tab事件处理(更新选中的tab及tab内容)
+ // 标签事件(更新选中的标签及标签内容)
function tab_event(tab_element)
{
//获取需要禁用的tab元素
- var tab_menu = document.getElementsByClassName('cbi-tabmenu')[0];
+ // var tab_menu = document.getElementsByClassName("cbi-tabmenu")[0];
+ var tab_menu = document.getElementById("tab_menu");
var disenable_element=get_tab_enable_element(tab_menu);
if (tab_element != disenable_element) {
set_tab_view(disenable_element,tab_element);
@@ -277,22 +301,11 @@
//隐藏模组选择界面
document.getElementById("cbi-modem").style.display="none";
//隐藏tab菜单界面
- document.getElementsByClassName("cbi-tabmenu")[0].style.display="none";
+ document.getElementById("tab_menu").style.display="none";
//隐藏tab内容界面
document.getElementById("tab_context").style.display="none";
}
- // 有模组界面
- function modems_view()
- {
- //显示模组选择界面
- document.getElementById("cbi-modem").style.display="block";
- //显示AT命令标题
- document.getElementById("at_command_title").style.display="block";
- //隐藏提示信息
- // document.getElementById("cbi-info").style.display="none";
- }
-
// 未适配模组界面
function not_adapted_modems_view()
{
@@ -300,26 +313,30 @@
document.getElementById("info_message").innerHTML="<%:Not adapted to this modem%>";
//显示提示信息
document.getElementById("cbi-info").style.display="block";
- //显示tab内容界面
+ //显示模组选择界面
+ document.getElementById("cbi-modem").style.display="block";
+ //显示标签内容界面
document.getElementById("tab_context").style.display="block";
//显示AT命令标题
document.getElementById("at_command_title").style.display="block";
- //隐藏tab菜单界面
- document.getElementsByClassName("cbi-tabmenu")[0].style.display="none";
- //在tab菜单选中AT命令
+ //隐藏标签菜单界面
+ document.getElementById("tab_menu").style.display="none";
+ //在标签菜单选中AT命令
var data_tab="at_command_tab"
var at_command_tab_element = document.querySelector('li[data-tab="'+data_tab+'"]');
tab_event(at_command_tab_element);
- //隐藏tab内容界面
- // document.getElementById("tab_context").style.display="none";
}
// 全功能界面
function all_function_view()
{
- //显示tab菜单界面
- document.getElementsByClassName("cbi-tabmenu")[0].style.display="block";
- //显示tab内容界面
+ //更新提示信息
+ document.getElementById("info_message").innerHTML='
<%:Loading modem%>...';
+ //显示模组选择界面
+ document.getElementById("cbi-modem").style.display="block";
+ //显示标签菜单界面
+ document.getElementById("tab_menu").style.display="block";
+ //显示标签内容界面
document.getElementById("tab_context").style.display="block";
//隐藏AT命令标题
document.getElementById("at_command_title").style.display="none";
@@ -390,9 +407,6 @@
var command_select = document.getElementById('command_select');
//更新选项
update_option(command_select,data["quick_commands"],true);
-
- //显示有模组界面
- modems_view();
}
);
}
@@ -462,6 +476,11 @@
{
//获取当前拨号模式
var current_mode=mode_info["mode"];
+ if (current_mode=="unknown")
+ {
+ return
+ }
+
//获取支持的拨号模式
var modes=mode_info["modes"];
@@ -489,7 +508,10 @@
document.getElementById('mode_option').innerHTML=mode_option_view;
//设置拨号模式选项
- document.getElementById('mode_option_'+current_mode).checked=true;
+ element=document.getElementById('mode_option_'+current_mode).checked=true;
+
+ //设置第一次获取数据标志
+ first_cache=false;
}
}
@@ -588,6 +610,9 @@
//启用偏好复选框
disabled_prefer_custom_config(false);
}
+
+ //设置第一次获取数据标志
+ first_cache=false;
}
}
@@ -602,7 +627,7 @@
//设置当前电压
document.getElementById('current_voltage').innerHTML=voltage/1000+" V";
//设置当前温度
- document.getElementById('current_temperature').innerHTML=temperature+" °C";
+ document.getElementById('current_temperature').innerHTML=temperature*1+" °C";
//设置电压状态
var state = '';
@@ -719,7 +744,7 @@
var at_port = document.getElementById("modem_select").value;
//获取当前启用的tab元素
- var tab_menu = document.getElementsByClassName('cbi-tabmenu')[0];
+ var tab_menu = document.getElementById("tab_menu");
var tab_enable_element=get_tab_enable_element(tab_menu);
//获取当前选中的tab元素
@@ -733,19 +758,11 @@
var mode_info=data["mode_info"];
if (Object.keys(mode_info).length==0)
{
- //显示未适配模组界面
- not_adapted_modems_view();
return false
}
//设置模式信息
set_mode_info(mode_info,debug_params.first_cache);
-
- //设置第一次获取数据标志
- debug_params.first_cache=false;
-
- //显示全功能界面
- all_function_view();
}
);
}
@@ -757,19 +774,11 @@
var network_prefer_info=data["network_prefer_info"];
if (Object.keys(network_prefer_info).length==0)
{
- //显示未适配模组界面
- not_adapted_modems_view();
return false
}
//设置网络偏好信息
set_network_prefer_info(network_prefer_info,debug_params.first_cache);
-
- //设置第一次获取数据标志
- debug_params.first_cache=false;
-
- //显示全功能界面
- all_function_view();
}
);
}
@@ -781,53 +790,14 @@
var self_test_info=data["self_test_info"];
if (Object.keys(self_test_info).length==0)
{
- //显示未适配模组界面
- not_adapted_modems_view();
return false
}
//设置模组自检信息
set_modem_self_test_info(self_test_info);
-
- //设置第一次获取数据标志
- // debug_params.first_cache=false;
-
- //显示全功能界面
- all_function_view();
}
);
}
-
- //获取调试信息
- // XHR.get('<%=luci.dispatcher.build_url("admin", "network", "modem", "get_modem_debug_info")%>', {"port":at_port},
- // function(x, data)
- // {
- // 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();
- // return false
- // }
-
- // //设置模式信息
- // set_mode_info(mode_info,debug_params.first_cache);
-
- // //设置网络偏好信息
- // set_network_prefer_info(network_prefer_info,debug_params.first_cache);
-
- // //设置模组自检信息
- // set_modem_self_test_info(self_test_info);
-
- // //设置第一次获取数据标志
- // debug_params.first_cache=false;
-
- // //显示全功能界面
- // all_function_view();
- // }
- // );
-
}
// 定时触发更新AT串口
@@ -836,7 +806,7 @@
{
//缓存当前选择的模组
var modem_select_cache="";
- var debug_params={first_cache:true};
+ var debug_params={first_cache:true,view:0};
return function(x, data)
{
var at_ports=data["at_ports"];
@@ -848,8 +818,7 @@
//获取快捷命令
if (Object.keys(at_ports).length==0)
{
- //显示无模组界面
- no_modems_view();
+ debug_params.view=0;
}
else
{
@@ -857,6 +826,15 @@
var modem_select_element = document.getElementById('modem_select');
var select_modem_name = modem_select_element.options[modem_select_element.selectedIndex].text;
+ if (select_modem_name.includes("ttyUSB")||select_modem_name.includes("at")||select_modem_name.includes("DUN"))
+ {
+ debug_params.view=2;
+ }
+ else
+ {
+ debug_params.view=1;
+ }
+
if (select_modem_name != modem_select_cache)
{
//获取快捷选项
@@ -864,6 +842,7 @@
if (quick_option=="auto") {
get_quick_commands();
}
+ //缓存当前选中的模组
modem_select_cache=select_modem_name;
//设置第一次获取数据标志
@@ -873,6 +852,20 @@
//获取模组调试信息
get_modem_debug_info(debug_params);
}
+
+ //设置界面
+ if (debug_params.view==0) {
+ //显示无模组界面
+ no_modems_view();
+ }
+ else if (debug_params.view==1) {
+ //显示全功能界面
+ all_function_view();
+ }
+ else if (debug_params.view==2) {
+ //显示未适配模组界面
+ not_adapted_modems_view();
+ }
};
})()
);
@@ -913,7 +906,7 @@
display: none;
}
- /* 终端 */
+ /* AT命令响应 */
textarea {
background:#373737;
border:none;
@@ -975,16 +968,16 @@
-
+
-
+
-
+
-
+
-
+
-
+
<%:AT Command%>
@@ -1150,8 +1143,8 @@
<%:Response%>
-
-
+
+
diff --git a/applications/luci-app-modem/luasrc/view/modem/modem_dial_log.htm b/applications/luci-app-modem/luasrc/view/modem/modem_dial_log.htm
new file mode 100644
index 0000000..c9606d1
--- /dev/null
+++ b/applications/luci-app-modem/luasrc/view/modem/modem_dial_log.htm
@@ -0,0 +1,283 @@
+
+
+
+
+
diff --git a/applications/luci-app-modem/luasrc/view/modem/plugin_info.htm b/applications/luci-app-modem/luasrc/view/modem/plugin_info.htm
new file mode 100644
index 0000000..0c54704
--- /dev/null
+++ b/applications/luci-app-modem/luasrc/view/modem/plugin_info.htm
@@ -0,0 +1,262 @@
+<%+header%>
+
+
+
+
+
<%:Plugin Info%>
+
<%:View the version information of the plugin%>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+<%+footer%>
diff --git a/applications/luci-app-modem/po/zh-cn/modem.po b/applications/luci-app-modem/po/zh-cn/modem.po
index 3339794..3b6162b 100644
--- a/applications/luci-app-modem/po/zh-cn/modem.po
+++ b/applications/luci-app-modem/po/zh-cn/modem.po
@@ -1,11 +1,5 @@
msgid ""
msgstr ""
-"Project-Id-Version: \n"
-"POT-Creation-Date: \n"
-"PO-Revision-Date: 2024-04-10 09:38+0000\n"
-"Last-Translator: MkQtS \n"
-"Language-Team: Chinese (Simplified) \n"
"Language: zh_Hans\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@@ -58,6 +52,12 @@ msgstr "在此页面给所有模组添加拨号配置"
msgid "Global Config"
msgstr "全局配置"
+msgid "Dial Log"
+msgstr "拨号日志"
+
+msgid "Download Log"
+msgstr "下载日志"
+
msgid "connect"
msgstr "已连接"
@@ -510,3 +510,54 @@ msgstr "中国电信"
msgid "46011"
msgstr "中国电信"
+
+msgid "Plugin Info"
+msgstr "插件信息"
+
+msgid "View the version information of the plugin"
+msgstr "查看插件的版本信息"
+
+msgid "Plugin Version"
+msgstr "插件版本"
+
+msgid "Dial Tool Info"
+msgstr "拨号工具信息"
+
+msgid "quectel-CM Version"
+msgstr "quectel-CM 版本"
+
+msgid "modemmanager Version"
+msgstr "modemmanager 版本"
+
+msgid "Modem General Driver Info"
+msgstr "模组通用信息"
+
+msgid "Driver Type"
+msgstr "驱动类型"
+
+msgid "Kernel Model"
+msgstr "内核模块"
+
+msgid "USB Network"
+msgstr "USB网络"
+
+msgid "Serial Port"
+msgstr "串口"
+
+msgid "Loaded"
+msgstr "已加载"
+
+msgid "Not loaded"
+msgstr "未加载"
+
+msgid "Modem USB Driver Info"
+msgstr "模组USB驱动信息"
+
+msgid "Modem PCIE Driver Info"
+msgstr "模组PCIE驱动信息"
+
+msgid "General"
+msgstr "通用"
+
+msgid "Private"
+msgstr "私有"
\ No newline at end of file
diff --git a/applications/luci-app-modem/po/zh_Hans b/applications/luci-app-modem/po/zh_Hans
new file mode 100644
index 0000000..41451e4
--- /dev/null
+++ b/applications/luci-app-modem/po/zh_Hans
@@ -0,0 +1 @@
+zh-cn
\ No newline at end of file
diff --git a/applications/luci-app-modem/po/zh_Hans/modem.po b/applications/luci-app-modem/po/zh_Hans/modem.po
deleted file mode 100644
index 3339794..0000000
--- a/applications/luci-app-modem/po/zh_Hans/modem.po
+++ /dev/null
@@ -1,512 +0,0 @@
-msgid ""
-msgstr ""
-"Project-Id-Version: \n"
-"POT-Creation-Date: \n"
-"PO-Revision-Date: 2024-04-10 09:38+0000\n"
-"Last-Translator: MkQtS \n"
-"Language-Team: Chinese (Simplified) \n"
-"Language: zh_Hans\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-"Plural-Forms: nplurals=1; plural=0;\n"
-"X-Generator: Weblate 5.5-dev\n"
-
-msgid "Base Setting"
-msgstr "基本设置"
-
-msgid "Modem"
-msgstr "移动通信模组"
-
-msgid "Modem Config"
-msgstr "模组配置"
-
-msgid "Modem Status"
-msgstr "模组状态"
-
-msgid "Modem Name"
-msgstr "模组名称"
-
-msgid "Modem Debug"
-msgstr "模组调试"
-
-msgid "Modem Select"
-msgstr "模组选择"
-
-msgid "Check information about adapted modem on this page"
-msgstr "在此页面查看已适配模组的信息"
-
-msgid "Not adapted to this modem"
-msgstr "未适配该模组"
-
-msgid "Loading modem information"
-msgstr "正在加载模组信息"
-
-msgid "Loading modem status"
-msgstr "正在加载模组状态"
-
-msgid "Loading modem"
-msgstr "正在加载模组"
-
-msgid "Dial Config"
-msgstr "拨号配置"
-
-msgid "Add dialing configuration to all modules on this page"
-msgstr "在此页面给所有模组添加拨号配置"
-
-msgid "Global Config"
-msgstr "全局配置"
-
-msgid "connect"
-msgstr "已连接"
-
-msgid "disconnect"
-msgstr "未连接"
-
-msgid "disabled"
-msgstr "未启用"
-
-msgid "Data Interface"
-msgstr "数据接口"
-
-msgid "Mode"
-msgstr "模式"
-
-msgid "Connect Status"
-msgstr "连接状态"
-
-msgid "Config List"
-msgstr "配置列表"
-
-msgid "Debug Your Module"
-msgstr "调试你的模组"
-
-msgid "Select a modem for debugging"
-msgstr "选择一个模组进行调试"
-
-msgid "Network Preferences"
-msgstr "网络偏好"
-
-msgid "Self Test"
-msgstr "自检"
-
-msgid "Current"
-msgstr "当前"
-
-msgid "Option"
-msgstr "选项"
-
-msgid "Config"
-msgstr "配置"
-
-msgid "Item"
-msgstr "项目"
-
-msgid "Voltage"
-msgstr "电压"
-
-msgid "Status"
-msgstr "状态"
-
-msgid "Abnormal"
-msgstr "异常"
-
-msgid "Normal"
-msgstr "正常"
-
-msgid "Low"
-msgstr "偏低"
-
-msgid "Somewhat High"
-msgstr "偏高"
-
-msgid "Excessively High"
-msgstr "过高"
-
-msgid "AT Command"
-msgstr "AT命令"
-
-msgid "Quick Option"
-msgstr "快捷选项"
-
-msgid "Auto"
-msgstr "自动"
-
-msgid "Custom"
-msgstr "自定义"
-
-msgid "Quick Commands"
-msgstr "快捷命令"
-
-msgid "Enter Command"
-msgstr "输入命令"
-
-msgid "Apply"
-msgstr "应用"
-
-msgid "Send"
-msgstr "发送"
-
-msgid "Clean"
-msgstr "清空"
-
-msgid "Response"
-msgstr "响应"
-
-msgid "Return to old page"
-msgstr "返回旧界面"
-
-msgid "Return to modem debug"
-msgstr "返回模组调试界面"
-
-msgid "Custom quick commands"
-msgstr "自定义快捷命令"
-
-msgid "Customize your quick commands"
-msgstr "自定义你的快捷命令"
-
-msgid "Custom Commands"
-msgstr "自定义命令"
-
-msgid "Serial Number"
-msgstr "序号"
-
-msgid "Description"
-msgstr "描述"
-
-msgid "Command"
-msgstr "命令"
-
-msgid "Modem Information"
-msgstr "模组信息"
-
-msgid "No modems found"
-msgstr "没有找到模组"
-
-msgid "Check to enable all configurations"
-msgstr "勾选启用全部配置"
-
-msgid "General Settings"
-msgstr "通用配置"
-
-msgid "Advanced Settings"
-msgstr "高级配置"
-
-msgid "Remarks"
-msgstr "备注"
-
-msgid "Mobile Network"
-msgstr "移动网络"
-
-msgid "UNKNOWN"
-msgstr "未知"
-
-msgid "Unknown"
-msgstr "未知"
-
-msgid "unknown"
-msgstr "未知"
-
-msgid "Mobile network not found"
-msgstr "未发现移动网络"
-
-msgid "The network device was not found"
-msgstr "找不到网络设备"
-
-msgid "Only display the modes available for the adaptation modem"
-msgstr "仅显示适配模组可用的拨号模式"
-
-msgid "Config ID"
-msgstr "配置 ID"
-
-msgid "Dial Tool"
-msgstr "拨号工具"
-
-msgid "After switching the dialing tool, it may be necessary to restart the module or restart the router to recognize the module."
-msgstr "切换拨号工具后,可能需要重启模组或重启路由器才能识别模组。"
-
-msgid "Auto Choose"
-msgstr "自动选择"
-
-msgid "quectel-CM"
-msgstr "移远模组拨号工具"
-
-msgid "mmcli"
-msgstr "调制解调器管理工具"
-
-msgid "PDP Type"
-msgstr "网络类型"
-
-msgid "Network Bridge"
-msgstr "网络桥接"
-
-msgid "After checking, enable network interface bridge."
-msgstr "勾选后,启用网络接口桥接。"
-
-msgid "APN"
-msgstr "接入点"
-
-msgid "China Mobile"
-msgstr "中国移动"
-
-msgid "China Unicom"
-msgstr "中国联通"
-
-msgid "China Telecom"
-msgstr "中国电信"
-
-msgid "China Broadcast"
-msgstr "中国广电"
-
-msgid "Skytone"
-msgstr "天际通"
-
-msgid "Authentication Type"
-msgstr "认证类型"
-
-msgid "PAP/CHAP (both)"
-msgstr "PAP/CHAP (均使用)"
-
-msgid "NONE"
-msgstr "无"
-
-msgid "PAP/CHAP Username"
-msgstr "PAP/CHAP 用户名"
-
-msgid "PAP/CHAP Password"
-msgstr "PAP/CHAP 密码"
-
-msgid "Message"
-msgstr "信息"
-
-msgid "Base Information"
-msgstr "基本信息"
-
-msgid "Manufacturer"
-msgstr "制造商"
-
-msgid "Revision"
-msgstr "固件版本"
-
-msgid "AT Port"
-msgstr "AT串口"
-
-msgid "Temperature"
-msgstr "温度"
-
-msgid "Update Time"
-msgstr "更新时间"
-
-msgid "SIM Information"
-msgstr "SIM卡信息"
-
-msgid "Unknown SIM card status"
-msgstr "未知SIM卡状态"
-
-msgid "SIM card not inserted"
-msgstr "SIM卡未插入"
-
-msgid "ISP"
-msgstr "运营商"
-
-msgid "SIM Status"
-msgstr "SIM卡状态"
-
-msgid "miss"
-msgstr "未插入"
-
-msgid "locked"
-msgstr "锁定"
-
-msgid "SIM Slot"
-msgstr "SIM卡卡槽"
-
-msgid "SIM Number"
-msgstr "SIM卡号码"
-
-msgid "IMEI"
-msgstr "国际移动设备识别码"
-
-msgid "IMSI"
-msgstr "国际移动用户识别码"
-
-msgid "ICCID"
-msgstr "集成电路卡识别码"
-
-msgid "Network Information"
-msgstr "网络信息"
-
-msgid "Network Type"
-msgstr "网络类型"
-
-msgid "Tx Rate"
-msgstr "上传速率"
-
-msgid "Rx Rate"
-msgstr "下载速率"
-
-msgid "RSSI"
-msgstr "接收信号强度指示"
-
-msgid "BER"
-msgstr "信道误码率"
-
-msgid "Cell Information"
-msgstr "小区信息"
-
-msgid "Network Mode"
-msgstr "网络模式"
-
-msgid "NR5G-SA Mode"
-msgstr "NR5G-SA 模式"
-
-msgid "EN-DC Mode"
-msgstr "EN-DC 模式"
-
-msgid "LTE Mode"
-msgstr "LTE 模式"
-
-msgid "WCDMA Mode"
-msgstr "WCDMA 模式"
-
-msgid "MCC"
-msgstr "移动国家代码"
-
-msgid "MNC"
-msgstr "移动网络代码"
-
-msgid "Duplex Mode"
-msgstr "双工模式"
-
-msgid "LAC"
-msgstr "位置区码"
-
-msgid "Cell ID"
-msgstr "小区ID"
-
-msgid "Physical Cell ID"
-msgstr "物理小区ID"
-
-msgid "TAC"
-msgstr "跟踪区编码"
-
-msgid "ARFCN"
-msgstr "绝对射频信道号"
-
-msgid "EARFCN"
-msgstr "E-UTRA绝对射频信道号"
-
-msgid "UARFCN"
-msgstr "UTRA绝对射频信道号"
-
-msgid "Band"
-msgstr "频段"
-
-msgid "Freq band indicator"
-msgstr "频带指示"
-
-msgid "UL Bandwidth"
-msgstr "上行带宽"
-
-msgid "DL Bandwidth"
-msgstr "下行带宽"
-
-msgid "RSRP"
-msgstr "参考信号接收功率"
-
-msgid "RSRQ"
-msgstr "参考信号接收质量"
-
-msgid "RSSI"
-msgstr "接收信号强度指示"
-
-msgid "SINR"
-msgstr "信号与干扰加噪声比"
-
-msgid "RSSNR"
-msgstr "信号干扰比"
-
-msgid "SCS"
-msgstr "NR子载波间隔"
-
-msgid "CQI"
-msgstr "信道质量指示"
-
-msgid "TX Power"
-msgstr "TX 功率"
-
-msgid "PSC"
-msgstr "主扰码"
-
-msgid "RAC"
-msgstr "路由区域码"
-
-msgid "RSCP"
-msgstr "接收信号码功率"
-
-msgid "每比特能量与干扰功率密度(干扰比)之比"
-msgstr "Eb/Io"
-
-msgid "每比特能量与噪声功率密度(噪声比)之比"
-msgstr "Eb/No"
-
-msgid "每码片能量与干扰功率密度(干扰比)之比"
-msgstr "Ec/Io"
-
-msgid "每码片能量与噪声功率密度(噪声比)之比"
-msgstr "Ec/No"
-
-msgid "Physical Channel"
-msgstr "物理信道"
-
-msgid "Spreading Factor"
-msgstr "扩频因子"
-
-msgid "Slot"
-msgstr "插槽格式"
-
-msgid "Speech Code"
-msgstr "语音编码"
-
-msgid "Compression Mode"
-msgstr "压缩模式"
-
-msgid "RxLev"
-msgstr "接收信号功率"
-
-msgid "CHN-CMCC"
-msgstr "中国移动"
-
-msgid "CMCC"
-msgstr "中国移动"
-
-msgid "46000"
-msgstr "中国移动"
-
-msgid "CHN-UNICOM"
-msgstr "中国联通"
-
-msgid "UNICOM"
-msgstr "中国联通"
-
-msgid "CUCC"
-msgstr "中国联通"
-
-msgid "46001"
-msgstr "中国联通"
-
-msgid "CHN-CT"
-msgstr "中国电信"
-
-msgid "CHN-TELECOM"
-msgstr "中国电信"
-
-msgid "CTCC"
-msgstr "中国电信"
-
-msgid "CT"
-msgstr "中国电信"
-
-msgid "46011"
-msgstr "中国电信"
diff --git a/applications/luci-app-modem/root/usr/share/modem/fibocom.sh b/applications/luci-app-modem/root/usr/share/modem/fibocom.sh
index 2c2d139..6dbe8a9 100755
--- a/applications/luci-app-modem/root/usr/share/modem/fibocom.sh
+++ b/applications/luci-app-modem/root/usr/share/modem/fibocom.sh
@@ -20,6 +20,59 @@ fibocom_presets()
sh "${SCRIPT_DIR}/modem_at.sh" "$at_port" "$at_command"
}
+#获取DNS
+# $1:AT串口
+# $2:连接定义
+fibocom_get_dns()
+{
+ local at_port="$1"
+ local define_connect="$2"
+
+ [ -z "$define_connect" ] && {
+ define_connect="1"
+ }
+
+ local public_dns1_ipv4="223.5.5.5"
+ local public_dns2_ipv4="119.29.29.29"
+ local public_dns1_ipv6="2400:3200::1" #下一代互联网北京研究中心:240C::6666,阿里:2400:3200::1,腾讯:2402:4e00::
+ local public_dns2_ipv6="2402:4e00::"
+
+ #获取DNS地址
+ at_command="AT+GTDNS=${define_connect}"
+ local response=$(at ${at_port} ${at_command} | grep "+GTDNS: " | grep -E '[0-9]+.[0-9]+.[0-9]+.[0-9]+' | sed -n '1p')
+
+ local ipv4_dns1=$(echo "${response}" | awk -F'"' '{print $2}' | awk -F',' '{print $1}')
+ [ -z "$ipv4_dns1" ] && {
+ ipv4_dns1="${public_dns1_ipv4}"
+ }
+
+ local ipv4_dns2=$(echo "${response}" | awk -F'"' '{print $4}' | awk -F',' '{print $1}')
+ [ -z "$ipv4_dns2" ] && {
+ ipv4_dns2="${public_dns2_ipv4}"
+ }
+
+ local ipv6_dns1=$(echo "${response}" | awk -F'"' '{print $2}' | awk -F',' '{print $2}')
+ [ -z "$ipv6_dns1" ] && {
+ ipv6_dns1="${public_dns1_ipv6}"
+ }
+
+ local ipv6_dns2=$(echo "${response}" | awk -F'"' '{print $4}' | awk -F',' '{print $2}')
+ [ -z "$ipv6_dns2" ] && {
+ ipv6_dns2="${public_dns2_ipv6}"
+ }
+
+ dns="{
+ \"dns\":{
+ \"ipv4_dns1\":\"$ipv4_dns1\",
+ \"ipv4_dns2\":\"$ipv4_dns2\",
+ \"ipv6_dns1\":\"$ipv6_dns1\",
+ \"ipv6_dns2\":\"$ipv6_dns2\"
+ }
+ }"
+
+ echo "$dns"
+}
+
#获取拨号模式
# $1:AT串口
# $2:平台
@@ -29,8 +82,13 @@ fibocom_get_mode()
local platform="$2"
at_command="AT+GTUSBMODE?"
- local mode_num=$(sh ${SCRIPT_DIR}/modem_at.sh $at_port $at_command | grep "+GTUSBMODE:" | sed 's/+GTUSBMODE: //g' | sed 's/\r//g')
+ local mode_num=$(sh ${SCRIPT_DIR}/modem_at.sh ${at_port} ${at_command} | grep "+GTUSBMODE:" | sed 's/+GTUSBMODE: //g' | sed 's/\r//g')
+ if [ -z "$mode_num" ]; then
+ echo "unknown"
+ return
+ fi
+
#获取芯片平台
if [ -z "$platform" ]; then
local modem_number=$(uci -q get modem.@global[0].modem_number)
@@ -88,7 +146,7 @@ fibocom_get_mode()
mode="$mode_num"
;;
esac
- echo "$mode"
+ echo "${mode}"
}
#设置拨号模式
@@ -97,6 +155,7 @@ fibocom_get_mode()
fibocom_set_mode()
{
local at_port="$1"
+ local mode_config="$2"
#获取芯片平台
local platform
@@ -113,7 +172,7 @@ fibocom_set_mode()
local mode_num
case "$platform" in
"qualcomm")
- case "$2" in
+ case "$mode_config" in
"qmi") mode_num="32" ;;
# "gobinet") mode_num="32" ;;
"ecm") mode_num="18" ;;
@@ -124,7 +183,7 @@ fibocom_set_mode()
esac
;;
"unisoc")
- case "$2" in
+ case "$mode_config" in
"ecm") mode_num="34" ;;
"mbim") mode_num="40" ;;
"rndis") mode_num="38" ;;
@@ -133,7 +192,7 @@ fibocom_set_mode()
esac
;;
"mediatek")
- case "$2" in
+ case "$mode_config" in
# "mbim") mode_num="40" ;;
# "rndis") mode_num="40" ;;
"rndis") mode_num="41" ;;
@@ -146,8 +205,8 @@ fibocom_set_mode()
esac
#设置模组
- at_command="AT+GTUSBMODE=$mode_num"
- sh ${SCRIPT_DIR}/modem_at.sh $at_port "$at_command"
+ at_command="AT+GTUSBMODE=${mode_num}"
+ sh ${SCRIPT_DIR}/modem_at.sh ${at_port} "${at_command}"
}
#获取网络偏好
@@ -345,7 +404,7 @@ fibocom_get_sim_status()
{
local sim_status
case $1 in
- "") sim_status="unknown" ;;
+ "") sim_status="miss" ;;
*"ERROR"*) sim_status="miss" ;;
*"READY"*) sim_status="ready" ;;
*"SIM PIN"*) sim_status="MT is waiting SIM PIN to be given" ;;
@@ -413,7 +472,7 @@ fibocom_sim_info()
#IMSI(国际移动用户识别码)
at_command="AT+CIMI?"
- imsi=$(sh ${SCRIPT_DIR}/modem_at.sh ${at_port} ${at_command} | grep "+CIMI: " | awk -F' ' '{print $2}' | sed 's/"/g' | sed 's/\r//g')
+ imsi=$(sh ${SCRIPT_DIR}/modem_at.sh ${at_port} ${at_command} | grep "+CIMI: " | awk -F' ' '{print $2}' | sed 's/"//g' | sed 's/\r//g')
[ -z "$sim_number" ] && {
imsi=$(sh ${SCRIPT_DIR}/modem_at.sh ${at_port} ${at_command} | grep "+CIMI: " | awk -F'"' '{print $2}')
}
diff --git a/applications/luci-app-modem/root/usr/share/modem/modem_debug.sh b/applications/luci-app-modem/root/usr/share/modem/modem_debug.sh
index fe6a436..5a6bf30 100755
--- a/applications/luci-app-modem/root/usr/share/modem/modem_debug.sh
+++ b/applications/luci-app-modem/root/usr/share/modem/modem_debug.sh
@@ -72,5 +72,5 @@ dial_log()
#打印日志
local update_time=$(date +"%Y-%m-%d %H:%M:%S")
- echo "${update_time} Send AT command ${at_command} to modem" >> "${path}"
+ echo "[${update_time}] Send AT command ${at_command} to modem" >> "${path}"
}
\ No newline at end of file
diff --git a/applications/luci-app-modem/root/usr/share/modem/modem_network_task.sh b/applications/luci-app-modem/root/usr/share/modem/modem_network_task.sh
index 4a7e8c4..7133ad0 100755
--- a/applications/luci-app-modem/root/usr/share/modem/modem_network_task.sh
+++ b/applications/luci-app-modem/root/usr/share/modem/modem_network_task.sh
@@ -10,6 +10,59 @@ MODEM_RUNDIR="/var/run/modem"
#导入组件工具
source "${SCRIPT_DIR}/modem_debug.sh"
+#重设网络接口
+# $1:AT串口
+# $4:连接定义
+# $5:模组序号
+reset_network_interface()
+{
+ local at_port="$1"
+ local define_connect="$2"
+ local modem_no="$3"
+
+ local interface_name="wwan_5g_${modem_no}"
+ local interface_name_ipv6="wwan6_5g_${modem_no}"
+
+ #获取IPv4地址
+ at_command="AT+CGPADDR=${define_connect}"
+ local ipv4=$(at ${at_port} ${at_command} | grep "+CGPADDR: " | awk -F',' '{print $2}' | sed 's/"//g')
+ #输出日志
+ # echo "[$(date +"%Y-%m-%d %H:%M:%S")] Get Modem new IPv4 address : ${ipv4}" >> "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
+
+ #获取DNS地址
+ dns=$(fibocom_get_dns ${at_port} ${define_connect})
+ local ipv4_dns1=$(echo "${dns}" | jq -r '.dns.ipv4_dns1')
+ local ipv4_dns2=$(echo "${dns}" | jq -r '.dns.ipv4_dns2')
+ #输出日志
+ echo "[$(date +"%Y-%m-%d %H:%M:%S")] Get Modem IPv4 DNS1: ${ipv4_dns1}" >> "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
+ echo "[$(date +"%Y-%m-%d %H:%M:%S")] Get Modem IPv4 DNS2: ${ipv4_dns2}" >> "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
+
+ #比较的网络接口中的IPv4地址
+ local ipv4_config=$(uci -q get network.${interface_name}.ipaddr)
+ if [ "$ipv4_config" == "$ipv4" ]; then
+ #输出日志
+ echo "[$(date +"%Y-%m-%d %H:%M:%S")] IPv4 address is the same as in the network interface, skip" >> "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
+ else
+ #输出日志
+ echo "[$(date +"%Y-%m-%d %H:%M:%S")] Reset network interface ${interface_name}" >> "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
+
+ #设置静态地址
+ uci set network.${interface_name}.proto='static'
+ uci set network.${interface_name}.ipaddr="${ipv4}"
+ uci set network.${interface_name}.netmask='255.255.255.0'
+ uci set network.${interface_name}.gateway="${ipv4%.*}.1"
+ uci set network.${interface_name}.peerdns='0'
+ uci -q del network.${interface_name}.dns
+ uci add_list network.${interface_name}.dns="${ipv4_dns1}"
+ uci add_list network.${interface_name}.dns="${ipv4_dns2}"
+ uci commit network
+ service network reload
+
+ #输出日志
+ echo "[$(date +"%Y-%m-%d %H:%M:%S")] Reset network interface successful" >> "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
+ fi
+}
+
#GobiNet拨号
# $1:AT串口
# $2:制造商
@@ -54,16 +107,14 @@ ecm_dial()
local define_connect="$3"
#激活
- local at_command="AT+CGACT=1,${define_connect}"
- #打印日志
- dial_log "${at_command}" "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
+ # local at_command="AT+CGACT=1,${define_connect}"
+ # #打印日志
+ # dial_log "${at_command}" "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
- at "${at_port}" "${at_command}"
-
- sleep 2s
+ # at "${at_port}" "${at_command}"
#拨号
- local at_command
+ at_command
if [ "$manufacturer" = "quectel" ]; then
at_command="AT+QNETDEVCTL=${define_connect},3,1"
elif [ "$manufacturer" = "fibocom" ]; then
@@ -76,6 +127,8 @@ ecm_dial()
dial_log "${at_command}" "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
at "${at_port}" "${at_command}"
+
+ sleep 2s
}
#RNDIS拨号
@@ -101,24 +154,7 @@ rndis_dial()
#激活并拨号
at "${at_port}" "${at_command}"
- #获取IPv4地址
- at_command="AT+CGPADDR=${define_connect}"
- local ipv4=$(at ${at_port} ${at_command} | grep "+CGPADDR: " | awk -F',' '{print $2}' | sed 's/"//g')
-
- #设置静态地址
- local ipv4_config=$(uci -q get network.${interface_name}.ipaddr)
- if [ "$ipv4_config" != "$ipv4" ]; then
- uci set network.${interface_name}.proto='static'
- uci set network.${interface_name}.ipaddr="$ipv4"
- uci set network.${interface_name}.netmask='255.255.255.0'
- uci set network.${interface_name}.gateway="${ipv4%.*}.1"
- uci commit network
- service network reload
-
- #启动网络接口
- ifup "wwan_5g_${modem_no}"
- ifup "wwan6_5g_${modem_no}"
- fi
+ sleep 3s
else
#拨号
ecm_dial "${at_port}" "${manufacturer}"
@@ -133,11 +169,11 @@ modemmanager_dial()
local interface_name="$1"
local define_connect="$2"
- #激活
- local at_command="AT+CGACT=1,${define_connect}"
- #打印日志
- dial_log "${at_command}" "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
- at "${at_port}" "${at_command}"
+ # #激活
+ # local at_command="AT+CGACT=1,${define_connect}"
+ # #打印日志
+ # dial_log "${at_command}" "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
+ # at "${at_port}" "${at_command}"
#启动网络接口
ifup "${interface_name}";
@@ -159,6 +195,7 @@ modem_network_task()
local platform=$(uci -q get modem.modem${modem_no}.platform)
local define_connect=$(uci -q get modem.modem${modem_no}.define_connect)
local interface_name="wwan_5g_${modem_no}"
+ local interface_name_ipv6="wwan6_5g_${modem_no}"
#重载配置(解决AT命令发不出去的问题)
# service modem reload
@@ -166,15 +203,21 @@ modem_network_task()
#IPv4地址缓存
local ipv4_cache
+ #输出日志
+ echo "[$(date +"%Y-%m-%d %H:%M:%S")] Start network task" >> "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
while true; do
#全局
local enable=$(uci -q get modem.@global[0].enable)
if [ "$enable" != "1" ]; then
+ #输出日志
+ echo "[$(date +"%Y-%m-%d %H:%M:%S")] The dialing configuration has been disabled, this network task quit" >> "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
break
fi
#单个模组
enable=$(uci -q get modem.${config_id}.enable)
if [ "$enable" != "1" ]; then
+ #输出日志
+ echo "[$(date +"%Y-%m-%d %H:%M:%S")] The modem has disabled dialing, this network task quit" >> "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
break
fi
@@ -182,23 +225,21 @@ modem_network_task()
local at_command="AT+CGPADDR=${define_connect}"
local ipv4=$(at ${at_port} ${at_command} | grep "+CGPADDR: " | awk -F'"' '{print $2}')
- if [ -z "$ipv4" ] || [[ "$ipv4" = *"0.0.0.0"* ]] || [ "$ipv4" != "$ipv4_cache" ]; then
+ if [ -z "$ipv4" ]; then
- if [ -z "$ipv4" ]; then
- #输出日志
- echo "$(date +"%Y-%m-%d %H:%M:%S") redefine connect" >> "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
- service network modem
- sleep 1s
- else
- #缓存当前IP
- ipv4_cache="${ipv4}"
- #输出日志
- echo "$(date +"%Y-%m-%d %H:%M:%S") Modem${modem_no} current IP : ${ipv4}" >> "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
- fi
+ [ "$mode" = "modemmanager" ] && {
+ #拨号工具为modemmanager时,不需要重新设置连接定义
+ continue
+ }
#输出日志
- echo "$(date +"%Y-%m-%d %H:%M:%S") check or redial" >> "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
-
+ echo "[$(date +"%Y-%m-%d %H:%M:%S")] Unable to get IPv4 address" >> "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
+ echo "[$(date +"%Y-%m-%d %H:%M:%S")] Redefine connect to ${define_connect}" >> "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
+ service modem reload
+
+ #输出日志
+ echo "[$(date +"%Y-%m-%d %H:%M:%S")] Modem dial" >> "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
+ #拨号(针对获取IPv4返回为空的模组)
case "$mode" in
"gobinet") gobinet_dial "${at_port}" "${manufacturer}" "${define_connect}" ;;
"ecm") ecm_dial "${at_port}" "${manufacturer}" "${define_connect}" ;;
@@ -206,8 +247,48 @@ modem_network_task()
"modemmanager") modemmanager_dial "${interface_name}" "${define_connect}" ;;
*) ecm_dial "${at_port}" "${manufacturer}" "${define_connect}" ;;
esac
- fi
+ elif [[ "$ipv4" = *"0.0.0.0"* ]]; then
+
+ #输出日志
+ echo "[$(date +"%Y-%m-%d %H:%M:%S")] Modem${modem_no} current IPv4 address : ${ipv4}" >> "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
+
+ #输出日志
+ echo "[$(date +"%Y-%m-%d %H:%M:%S")] Modem dial" >> "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
+ #拨号
+ case "$mode" in
+ "gobinet") gobinet_dial "${at_port}" "${manufacturer}" "${define_connect}" ;;
+ "ecm") ecm_dial "${at_port}" "${manufacturer}" "${define_connect}" ;;
+ "rndis") rndis_dial "${at_port}" "${manufacturer}" "${platform}" "${define_connect}" "${modem_no}" ;;
+ "modemmanager") modemmanager_dial "${interface_name}" "${define_connect}" ;;
+ *) ecm_dial "${at_port}" "${manufacturer}" "${define_connect}" ;;
+ esac
+
+ elif [ "$ipv4" != "$ipv4_cache" ]; then
+
+ #第一次缓存IP为空时不输出日志
+ [ -n "$ipv4_cache" ] && {
+ #输出日志
+ echo "[$(date +"%Y-%m-%d %H:%M:%S")] Modem${modem_no} IPv4 address has changed" >> "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
+ }
+
+ #输出日志
+ echo "[$(date +"%Y-%m-%d %H:%M:%S")] Modem${modem_no} current IPv4 address : ${ipv4}" >> "${MODEM_RUNDIR}/modem${modem_no}_dial.cache"
+
+ #缓存当前IP
+ ipv4_cache="${ipv4}"
+
+ #重新设置网络接口(广和通FM350-GL)
+ if [ "$manufacturer" = "fibocom" ] && [ "$platform" = "mediatek" ]; then
+ reset_network_interface "${at_port}" "${define_connect}" "${modem_no}"
+ fi
+
+ [ "$mode" != "modemmanager" ] && {
+ #重新启动网络接口
+ ifup "${interface_name}"
+ ifup "${interface_name_ipv6}"
+ }
+ fi
sleep 5s
done
}
diff --git a/applications/luci-app-modem/root/usr/share/modem/modem_util.sh b/applications/luci-app-modem/root/usr/share/modem/modem_util.sh
index e0ba591..6802765 100755
--- a/applications/luci-app-modem/root/usr/share/modem/modem_util.sh
+++ b/applications/luci-app-modem/root/usr/share/modem/modem_util.sh
@@ -59,7 +59,7 @@ m_modem_presets()
at "${at_port}" "${at_command}"
#PDP设置
- at_command="AT+CGDCONT=$define_connect,\"IPV4V6\",\"\""
+ at_command="AT+CGDCONT=${define_connect},\"IPV4V6\",\"\""
at "${at_port}" "${at_command}"
}
@@ -700,6 +700,7 @@ m_set_modem_port()
local mhi_hwip=$(find ${physical_path} -name mhi_hwip*)
if [ -n "$mhi_hwip" ]; then
all_port=$(find ${physical_path} -name wwan*)
+ all_port=$(echo "$all_port" | sed '1,2d')
else
all_port=$(find ${physical_path} -name mhi_*)
fi
diff --git a/applications/luci-app-modem/root/usr/share/modem/quectel.sh b/applications/luci-app-modem/root/usr/share/modem/quectel.sh
index 56b1380..df8e3c0 100755
--- a/applications/luci-app-modem/root/usr/share/modem/quectel.sh
+++ b/applications/luci-app-modem/root/usr/share/modem/quectel.sh
@@ -11,6 +11,59 @@ quectel_presets()
# sh "${SCRIPT_DIR}/modem_at.sh" "$at_port" "$at_command"
}
+#获取DNS
+# $1:AT串口
+# $2:连接定义
+quectel_get_dns()
+{
+ local at_port="$1"
+ local define_connect="$2"
+
+ [ -z "$define_connect" ] && {
+ define_connect="1"
+ }
+
+ local public_dns1_ipv4="223.5.5.5"
+ local public_dns2_ipv4="119.29.29.29"
+ local public_dns1_ipv6="2400:3200::1" #下一代互联网北京研究中心:240C::6666,阿里:2400:3200::1,腾讯:2402:4e00::
+ local public_dns2_ipv6="2402:4e00::"
+
+ #获取DNS地址
+ at_command="AT+GTDNS=${define_connect}"
+ local response=$(at ${at_port} ${at_command} | grep "+GTDNS: ")
+
+ local ipv4_dns1=$(echo "${response}" | awk -F'"' '{print $2}' | awk -F',' '{print $1}')
+ [ -z "$ipv4_dns1" ] && {
+ ipv4_dns1="${public_dns1_ipv4}"
+ }
+
+ local ipv4_dns2=$(echo "${response}" | awk -F'"' '{print $4}' | awk -F',' '{print $1}')
+ [ -z "$ipv4_dns2" ] && {
+ ipv4_dns2="${public_dns2_ipv4}"
+ }
+
+ local ipv6_dns1=$(echo "${response}" | awk -F'"' '{print $2}' | awk -F',' '{print $2}')
+ [ -z "$ipv6_dns1" ] && {
+ ipv6_dns1="${public_dns1_ipv6}"
+ }
+
+ local ipv6_dns2=$(echo "${response}" | awk -F'"' '{print $4}' | awk -F',' '{print $2}')
+ [ -z "$ipv6_dns2" ] && {
+ ipv6_dns2="${public_dns2_ipv6}"
+ }
+
+ dns="{
+ \"dns\":{
+ \"ipv4_dns1\":\"$ipv4_dns1\",
+ \"ipv4_dns2\":\"$ipv4_dns2\",
+ \"ipv6_dns1\":\"$ipv6_dns1\",
+ \"ipv6_dns2\":\"$ipv6_dns2\"
+ }
+ }"
+
+ echo "$dns"
+}
+
#获取拨号模式
# $1:AT串口
# $2:平台
@@ -20,7 +73,12 @@ quectel_get_mode()
local platform="$2"
at_command='AT+QCFG="usbnet"'
- local mode_num=$(sh ${SCRIPT_DIR}/modem_at.sh $at_port $at_command | grep "+QCFG:" | sed 's/+QCFG: "usbnet",//g' | sed 's/\r//g')
+ local mode_num=$(sh ${SCRIPT_DIR}/modem_at.sh ${at_port} ${at_command} | grep "+QCFG:" | sed 's/+QCFG: "usbnet",//g' | sed 's/\r//g')
+
+ if [ -z "$mode_num" ]; then
+ echo "unknown"
+ return
+ fi
#获取芯片平台
if [ -z "$platform" ]; then