Commit 849b7bc125f454a1646bb1248777a137e8d0f54a
1 parent
c3326bd6f4
Exists in
master
MODEM-TESTER: skip commands
Showing 1 changed file with 14 additions and 5 deletions Side-by-side Diff
modem-tester.js
... | ... | @@ -36,6 +36,15 @@ async function writeToPortDelayed(data) { |
36 | 36 | return result; |
37 | 37 | } |
38 | 38 | |
39 | +function isNotBlacklistedCommand(command) { | |
40 | + let [, cmd] = (command || '').trim().split('+'); | |
41 | + cmd = cmd.replace(/=.*$/, ''); | |
42 | + return !config | |
43 | + && !config.modem_tester | |
44 | + && !config.modem_tester.skip_commands | |
45 | + && (config.modem_tester.skip_commands.indexOf(cmd) < 0); | |
46 | +} | |
47 | + | |
39 | 48 | port = new SerialPort(config.modem.device, { baudRate: 115200 }, async (err) => { |
40 | 49 | if (err) { |
41 | 50 | logger.warn(`Error opening modem. ${err}. Terminating modem ${config.modem.device}.`); |
... | ... | @@ -43,11 +52,11 @@ port = new SerialPort(config.modem.device, { baudRate: 115200 }, async (err) => |
43 | 52 | } |
44 | 53 | |
45 | 54 | await writeToPortDelayed('AT\r'); |
46 | - await writeToPort('AT+CGSN\r'); | |
47 | - await writeToPort('AT+CIMI\r'); | |
48 | - await writeToPort('AT+CSQ\r'); | |
49 | - await writeToPort('AT+COPS?\r'); | |
50 | - await writeToPort('AT+CMGD=0,4\r'); | |
55 | + if (isNotBlacklistedCommand('CGSN')) await writeToPort('AT+CGSN\r'); | |
56 | + if (isNotBlacklistedCommand('CIMI')) await writeToPort('AT+CIMI\r'); | |
57 | + if (isNotBlacklistedCommand('CSQ')) await writeToPort('AT+CSQ\r'); | |
58 | + if (isNotBlacklistedCommand('COPS?')) await writeToPort('AT+COPS?\r'); | |
59 | + if (isNotBlacklistedCommand('CMGD')) await writeToPort('AT+CMGD=0,4\r'); | |
51 | 60 | }); |
52 | 61 | |
53 | 62 | port.pipe(parserCRLF); |