Commit 010e2b59a81dff2e05236f9177fe5277262e0483

Authored by Adhidarma Hadiwinoto
1 parent fdeb6c99c1
Exists in master

MODEM-TESTER: config.modem_tester.commands

Showing 1 changed file with 23 additions and 1 deletions Side-by-side Diff

... ... @@ -55,6 +55,7 @@ async function writeToPortDelayed(data, ms) {
55 55 return result;
56 56 }
57 57  
  58 +/*
58 59 function isNotBlacklistedCommand(command) {
59 60 let [, cmd] = (command || '').trim().split('+');
60 61 cmd = (cmd || '').replace(/=.*$/, '');
... ... @@ -63,6 +64,7 @@ function isNotBlacklistedCommand(command) {
63 64 || !config.modem_tester.skip_commands
64 65 || (config.modem_tester.skip_commands.indexOf(cmd) < 0);
65 66 }
  67 +*/
66 68  
67 69 port = new SerialPort(config.modem.device, { baudRate: 115200 }, async (err) => {
68 70 if (err) {
... ... @@ -71,12 +73,32 @@ port = new SerialPort(config.modem.device, { baudRate: 115200 }, async (err) =&gt;
71 73 }
72 74  
73 75 await writeToPortDelayed('AT\r');
  76 +
  77 + /*
74 78 if (isNotBlacklistedCommand('CGSN')) await writeToPortDelayed('AT&F\r', 2000);
75 79 if (isNotBlacklistedCommand('CGSN')) await writeToPortDelayed('AT+CGSN\r', 2000);
76 80 if (isNotBlacklistedCommand('CIMI')) await writeToPortDelayed('AT+CIMI\r', 2000);
77 81 if (isNotBlacklistedCommand('CSQ')) await writeToPortDelayed('AT+CSQ\r', 2000);
78 82 if (isNotBlacklistedCommand('COPS?')) await writeToPortDelayed('AT+COPS?\r', 2000);
79   - if (isNotBlacklistedCommand('CMGD')) await writeToPortDelayed('AT+CMGD=0,4\r', 2000);
  83 + // if (isNotBlacklistedCommand('CMGD')) await writeToPortDelayed('AT+CMGD=0,4\r', 2000);
  84 + */
  85 +
  86 + let commands;
  87 + if (config && config.modem_tester && config.modem_tester.commands) {
  88 + ({ commands } = config.modem_tester);
  89 + } else {
  90 + commands = [
  91 + 'AT&F\r',
  92 + 'AT+CGSN\r',
  93 + 'AT+CIMI\r',
  94 + 'AT+CSQ\r',
  95 + 'AT+COPS?\r',
  96 + ];
  97 + }
  98 +
  99 + commands.forEach((cmd) => {
  100 + writeToPortDelayed(cmd, 2000);
  101 + });
80 102 });
81 103  
82 104 if (config && config.modem_tester && config.modem_tester.parser === 'regex') {