Commit b77537954016b76f0e03f3f8f2a90d68c6e3a76a
1 parent
890ade1c41
Exists in
master
queryIMSI
Showing 2 changed files with 23 additions and 1 deletions Side-by-side Diff
lib/modem-commands.js
... | ... | @@ -73,3 +73,21 @@ exports.queryIMEI = function queryIMEI() { |
73 | 73 | await writeToPort('AT+CGSN\r'); |
74 | 74 | }); |
75 | 75 | }; |
76 | + | |
77 | +exports.queryIMSI = function queryIMSI() { | |
78 | + return new Promise(async (resolve) => { | |
79 | + const parser = new ParserRegex({ regex: parsers.PARSER_WAIT_FOR_OK_OR_ERROR_REGEX }); | |
80 | + parser.on('data', (data) => { | |
81 | + logger.verbose('INCOMING', { parser: 'parserIMSI', data: data.toString() }); | |
82 | + port.unpipe(parser); | |
83 | + mutex.unlock(MUTEX_COMMAND, 'queryIMSI'); | |
84 | + modemInfo.imsi = data.toString().trim(); | |
85 | + resolve(modemInfo.imsi); | |
86 | + }); | |
87 | + | |
88 | + await mutex.lock(MUTEX_COMMAND, 'queryIMSI'); | |
89 | + | |
90 | + port.pipe(parser); | |
91 | + await writeToPort('AT+CIMI\r'); | |
92 | + }); | |
93 | +}; |
modem-tester.js
... | ... | @@ -51,7 +51,6 @@ port = new SerialPort(config.modem.device, { baudRate: 115200 }, async (err) => |
51 | 51 | |
52 | 52 | const commands = [ |
53 | 53 | 'AT&FE0\r', |
54 | - 'AT+CIMI\r', | |
55 | 54 | 'AT+CMGF=0\r', |
56 | 55 | 'AT+CNMI=1,2,0,1,0\r', |
57 | 56 | ]; |
... | ... | @@ -75,8 +74,13 @@ port = new SerialPort(config.modem.device, { baudRate: 115200 }, async (err) => |
75 | 74 | |
76 | 75 | const imei = await modemCommands.queryIMEI(); |
77 | 76 | logger.info(`**** IMEI: ${imei}`); |
77 | + | |
78 | + const imsi = await modemCommands.queryIMSI(); | |
79 | + logger.info(`**** IMSI: ${imsi}`); | |
80 | + | |
78 | 81 | const cops = await modemCommands.queryCOPS(); |
79 | 82 | logger.info(`**** COPS: ${cops}`); |
83 | + | |
80 | 84 | const signalQuality = await modemCommands.querySignalQuality(); |
81 | 85 | logger.info(`**** Signal Quality: ${signalQuality}`); |
82 | 86 |