Skip to content

Commit f85e716

Browse files
committed
qmodem-next: improve config flow to manually add modem-device
1 parent 5aaaa2e commit f85e716

File tree

5 files changed

+237
-10
lines changed

5 files changed

+237
-10
lines changed

application/qmodem/files/usr/share/qmodem/modem_scan.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,8 @@ validate_at_port()
288288
for at_port in $at_ports; do
289289
dev_path="/dev/$at_port"
290290
[ ! -e "$dev_path" ] && continue
291+
#disable at-daemon binding
292+
ubus call at-daemon close '{ "at_port": "'$dev_path'" }' 2>/dev/null
291293
res=$(fastat $dev_path "ATI")
292294
[ -z "$res" ] && continue
293295
!(echo "$res" | grep -qE 'OK|ATI') && continue
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
'use strict';
2+
'require baseclass';
3+
4+
return baseclass.extend({
5+
manufacturers: {
6+
quectel: 'Quectel',
7+
simcom: 'Simcom',
8+
sierra: 'Sierra Wireless',
9+
fibocom: 'Fibocom',
10+
meig: 'Meig',
11+
huawei: 'Huawei',
12+
neoway: 'Neoway',
13+
telit: 'Telit',
14+
nk: "Tom's Love"
15+
},
16+
platforms: {
17+
lte: 'LTE',
18+
lte12: 'LTE12',
19+
qualcomm: 'Qualcomm',
20+
mediatek: 'MediaTek',
21+
unisoc: 'Unisoc',
22+
intel: 'Intel'
23+
},
24+
modes: {
25+
ecm: 'ECM',
26+
mbim: 'MBIM',
27+
qmi: 'QMI',
28+
ncm: 'NCM',
29+
rndis: 'RNDIS'
30+
},
31+
disabled_features: {
32+
DialMode: 'Dial Mode',
33+
RatPrefer: 'Rat Prefer',
34+
IMEI: 'Set IMEI',
35+
NeighborCell: 'Neighbor Cell',
36+
LockBand: 'Lock Band',
37+
RebootModem: 'Reboot Modem',
38+
AtDebug: 'AT Debug'
39+
}
40+
});

luci/luci-app-qmodem-next/htdocs/luci-static/resources/view/qmodem/settings.js

Lines changed: 133 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
'require rpc';
66
'require ui';
77
'require poll';
8+
'require qmodem.modem_cfg as modemCfg';
89

910
var callSystemBoard = rpc.declare({
1011
object: 'system',
@@ -51,6 +52,11 @@ var callGetTtyPorts = rpc.declare({
5152
method: 'get_tty_ports'
5253
});
5354

55+
var callGetAvailableDevices = rpc.declare({
56+
object: 'qmodem',
57+
method: 'get_available_devices'
58+
});
59+
5460
return view.extend({
5561
load: function() {
5662
return Promise.all([
@@ -60,13 +66,15 @@ return view.extend({
6066
callGetUsbDevices(),
6167
callGetLeds(),
6268
callGetNetworkInterfaces(),
63-
callGetTtyPorts()
69+
callGetTtyPorts(),
70+
callGetAvailableDevices()
6471
]).then(L.bind(function(results) {
6572
this.pcieDevices = results[2] && results[2].devices ? results[2].devices : [];
6673
this.usbDevices = results[3] && results[3].devices ? results[3].devices : [];
6774
this.leds = results[4] && results[4].leds ? results[4].leds : [];
6875
this.networkInterfaces = results[5] && results[5].interfaces ? results[5].interfaces : [];
6976
this.ttyPorts = results[6] && results[6].ports ? results[6].ports : [];
77+
this.availableDevices = results[7] && results[7].devices ? results[7].devices : {};
7078
return results;
7179
}, this));
7280
},
@@ -185,30 +193,92 @@ return view.extend({
185193

186194
// Modem Configuration (Device Settings Only)
187195
s = m.section(form.GridSection, 'modem-device', _('Modem Devices'));
188-
s.addremove = true;
189-
s.anonymous = false;
196+
s.anonymous = true;
190197
s.sortable = true;
191198
s.modaltitle = L.bind(function(section_id) {
192199
var name = uci.get('qmodem', section_id, 'name');
193200
return _('Modem Device') + ': ' + (name || section_id);
194201
}, this);
195202

203+
// Use available devices from RPC call
204+
var availableDevices = this.availableDevices || {};
205+
206+
// Custom add handler
207+
s.addremove = true;
208+
s.handleAdd = function(ev, section_id) {
209+
var deviceKeys = Object.keys(availableDevices);
210+
if (deviceKeys.length === 0) {
211+
ui.addNotification(null, E('p', _('No devices available. Please scan for devices first.')), 'warning');
212+
return;
213+
}
214+
215+
var selectList = deviceKeys.map(function(key) {
216+
return E('option', { value: key }, availableDevices[key].label);
217+
});
218+
219+
ui.showModal(_('Add Modem Device'), [
220+
E('p', _('Select a device to configure:')),
221+
E('div', { 'class': 'cbi-section' }, [
222+
E('label', { 'class': 'cbi-value-title' }, _('Available Devices')),
223+
E('select', { 'id': 'device-select', 'class': 'cbi-input-select' }, selectList)
224+
]),
225+
E('div', { 'class': 'right' }, [
226+
E('button', {
227+
'class': 'btn cbi-button-neutral',
228+
'click': ui.hideModal
229+
}, _('Cancel')),
230+
E('button', {
231+
'class': 'btn cbi-button-positive',
232+
'click': L.bind(function() {
233+
var select = document.getElementById('device-select');
234+
var selectedKey = select.value;
235+
var deviceInfo = availableDevices[selectedKey];
236+
237+
// Create new section with selected device name
238+
var sid = uci.add('qmodem', 'modem-device', selectedKey);
239+
240+
// Set type and path automatically
241+
uci.set('qmodem', sid, 'data_interface', deviceInfo.type);
242+
uci.set('qmodem', sid, 'path', deviceInfo.path);
243+
244+
ui.hideModal();
245+
m.save().then(function() {
246+
window.location.reload();
247+
});
248+
}, this)
249+
}, _('Add'))
250+
])
251+
]);
252+
};
253+
196254
o = s.option(form.Flag, 'enabled', _('Enabled'));
197255
o.default = '1';
198256
o.editable = true;
257+
o.modalonly = true;
258+
259+
o = s.option(form.DummyValue, 'data_interface', _('Type'));
260+
o.editable = true;
261+
o.cfgvalue = function(section_id) {
262+
var type = uci.get('qmodem', section_id, 'data_interface') || '-';
263+
return type.toUpperCase();
264+
};
199265

200266
o = s.option(form.Flag, 'soft_reboot', _('Soft Reboot'));
201267
o.description = _('enable modem soft reboot');
202268
o.default = '0';
203269
o.rmempty = false;
204270
o.modalonly = true;
205271

206-
o = s.option(form.Value, 'name', _('Model Name'));
207-
o.placeholder = _('e.g.') + ' RG500Q';
208-
o.rmempty = false; o = s.option(form.Value, 'alias', _('Alias'));
209-
o.placeholder = _('e.g.') + ' Modem1'; o = s.option(form.Value, 'path', _('Device Path'));
272+
o = s.option(form.Value, 'name', _('Model Name'));
273+
o.placeholder = _('e.g.') + ' RG500Q';
274+
o.rmempty = false; o = s.option(form.Value, 'alias', _('Alias'));
275+
o.placeholder = _('e.g.') + ' Modem1';
276+
o.editable = true;
277+
278+
o = s.option(form.Value, 'path', _('Device Path'));
210279
o.placeholder = _('e.g.') + ' /sys/bus/usb/devices/1-1';
211-
o.rmempty = false; o = s.option(form.Value, 'at_port', _('AT Port'));
280+
o.rmempty = false;
281+
o.readonly = true; o = s.option(form.Value, 'at_port', _('AT Port'));
212282
o.placeholder = _('e.g.') + ' /dev/ttyUSB2';
213283
o.rmempty = false;
214284
if (this.ttyPorts && this.ttyPorts.length > 0) {
@@ -221,14 +291,68 @@ return view.extend({
221291
this.ttyPorts.forEach(function(port) {
222292
o.value(port.id, port.label);
223293
});
224-
} o = s.option(form.Value, 'override_at_port', _('Override AT Port'));
294+
} o = s.option(form.Value, 'override_at_port', _('Override AT Port'));
225295
o.placeholder = _('e.g.') + ' /dev/ttyUSB3';
226296
if (this.ttyPorts && this.ttyPorts.length > 0) {
227297
this.ttyPorts.forEach(function(port) {
228298
o.value(port.id, port.label);
229299
});
230300
} o = s.option(form.Flag, 'use_ubus', _('Use Ubus AT Daemon'));
231301
o.default = '0';
302+
303+
304+
// Additional modem configuration (modal only)
305+
//vendor
306+
o = s.option(form.ListValue, 'vendor', _('Vendor'));
307+
o.modalonly = true;
308+
o.optional = true;
309+
for (var key in modemCfg.manufacturers) {
310+
o.value(key, modemCfg.manufacturers[key]);
311+
}
312+
313+
o = s.option(form.ListValue, 'platform', _('Platform'));
314+
o.modalonly = true;
315+
o.optional = true;
316+
for (var key in modemCfg.platforms) {
317+
o.value(key, modemCfg.platforms[key]);
318+
}
319+
320+
o = s.option(form.DynamicList, 'modes', _('Supported Modes'));
321+
o.description = _('Supported driver modes (e.g., RNDIS/NCM/QMI/MBIM/ETH/PPP)');
322+
o.modalonly = true;
323+
o.optional = true;
324+
for (var key in modemCfg.modes) {
325+
o.value(key, modemCfg.modes[key]);
326+
}
327+
328+
o = s.option(form.DynamicList, 'disabled_features', _('Disabled Features'));
329+
o.description = _('Select features to disable for this modem.');
330+
o.modalonly = true;
331+
o.optional = true;
332+
for (var key in modemCfg.disabled_features) {
333+
o.value(key, modemCfg.disabled_features[key]);
334+
}
335+
336+
o = s.option(form.Value, 'wcdma_band', _('WCDMA Band'));
337+
o.placeholder = _('e.g.') + ' 1/2/5/8';
338+
o.modalonly = true;
339+
o.optional = true;
340+
341+
o = s.option(form.Value, 'lte_band', _('LTE Band'));
342+
o.placeholder = _('e.g.') + ' 1/3/5/7/8/20';
343+
o.modalonly = true;
344+
o.optional = true;
345+
346+
o = s.option(form.Value, 'nsa_band', _('NSA Band'));
347+
o.placeholder = _('e.g.') + ' 41/78';
348+
o.modalonly = true;
349+
o.optional = true;
350+
351+
o = s.option(form.Value, 'sa_band', _('SA Band'));
352+
o.placeholder = _('e.g.') + ' 78/79';
353+
o.modalonly = true;
354+
o.optional = true;
355+
232356
// ===========================================
233357
// Modem Slot Configuration
234358
// ===========================================

luci/luci-app-qmodem-next/po/zh_Hans/luci-app-qmodem-next.po

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2237,3 +2237,63 @@ msgstr "令牌"
22372237
# Source: view/qmodem/sms_forward.js:32
22382238
msgid "Warning"
22392239
msgstr "警告"
2240+
2241+
# Source: view/qmodem/settings.js:249
2242+
msgid "Add"
2243+
msgstr "添加"
2244+
2245+
# Source: view/qmodem/settings.js:219
2246+
msgid "Add Modem Device"
2247+
msgstr "添加模组设备"
2248+
2249+
# Source: view/qmodem/settings.js:222
2250+
msgid "Available Devices"
2251+
msgstr "可用设备"
2252+
2253+
# Source: view/qmodem/settings.js:328
2254+
msgid "Disabled Features"
2255+
msgstr "已禁用功能"
2256+
2257+
# Source: view/qmodem/settings.js:346
2258+
msgid "NSA Band"
2259+
msgstr "NSA频段"
2260+
2261+
# Source: view/qmodem/settings.js:211
2262+
msgid "No devices available. Please scan for devices first."
2263+
msgstr "无可用设备,请先扫描设备。"
2264+
2265+
# Source: view/qmodem/settings.js:313
2266+
msgid "Platform"
2267+
msgstr "平台"
2268+
2269+
# Source: view/qmodem/settings.js:351
2270+
msgid "SA Band"
2271+
msgstr "SA频段"
2272+
2273+
# Source: view/qmodem/settings.js:220
2274+
msgid "Select a device to configure:"
2275+
msgstr "请选择要配置的设备:"
2276+
2277+
# Source: view/qmodem/settings.js:329
2278+
msgid "Select features to disable for this modem."
2279+
msgstr "请选择要为此模组禁用的功能。"
2280+
2281+
# Source: view/qmodem/settings.js:320
2282+
msgid "Supported Modes"
2283+
msgstr "支持的模式"
2284+
2285+
# Source: view/qmodem/settings.js:321
2286+
msgid "Supported driver modes (e.g., RNDIS/NCM/QMI/MBIM/ETH/PPP)"
2287+
msgstr "支持的驱动模式(例如:RNDIS/NCM/QMI/MBIM/ETH/PPP)"
2288+
2289+
# Source: view/qmodem/settings.js:259
2290+
msgid "Type"
2291+
msgstr "类型"
2292+
2293+
# Source: view/qmodem/settings.js:306
2294+
msgid "Vendor"
2295+
msgstr "厂商"
2296+
2297+
# Source: view/qmodem/settings.js:336
2298+
msgid "WCDMA Band"
2299+
msgstr "WCDMA频段"

luci/luci-app-qmodem-next/root/usr/share/rpcd/acl.d/luci-app-qmodem-next.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
"get_usb_devices",
3232
"get_leds",
3333
"get_network_interfaces",
34-
"get_tty_ports"
34+
"get_tty_ports",
35+
"get_available_devices"
3536
],
3637
"qmodem_sms": [
3738
"list_sms",

0 commit comments

Comments
 (0)