Commit bc541e414d4bc724fd3ea85ebe6480e2ed524565
1 parent
2a8f20eb79
Exists in
master
modemInfo
Showing 1 changed file with 9 additions and 6 deletions Side-by-side Diff
lib/modem.js
... | ... | @@ -14,8 +14,10 @@ const mutex = require('./mutex'); |
14 | 14 | const common = require('./common'); |
15 | 15 | const sms = require('./sms'); |
16 | 16 | |
17 | -let imsi; | |
18 | -let signalStrength; | |
17 | +const modemInfo = { | |
18 | + imsi: null, | |
19 | + signalStrength: null, | |
20 | +}; | |
19 | 21 | |
20 | 22 | const port = new SerialPort(config.modem.device, { baudRate: 115200 }); |
21 | 23 | |
... | ... | @@ -82,8 +84,8 @@ parserReadLine.on('data', (data) => { |
82 | 84 | logger.verbose(`* IN: ${data}`); |
83 | 85 | if (data) { |
84 | 86 | if (data.indexOf('+CSQ: ') === 0) { |
85 | - signalStrength = common.extractValueFromReadLineData(data); | |
86 | - logger.info(`Signal strength: ${signalStrength}`); | |
87 | + modemInfo.signalStrength = common.extractValueFromReadLineData(data); | |
88 | + logger.info(`Signal strength: ${modemInfo.signalStrength}`); | |
87 | 89 | } else if (data.indexOf('+CMTI: ') === 0) { |
88 | 90 | onIncomingSMS(data); |
89 | 91 | } |
... | ... | @@ -99,8 +101,8 @@ async function readIMSI() { |
99 | 101 | const parserReadIMSI = new ParserDelimiter({ delimiter: DELIMITER_WAIT_FOR_OK }); |
100 | 102 | parserReadIMSI.on('data', (data) => { |
101 | 103 | if (data) { |
102 | - imsi = data.toString().trim(); | |
103 | - logger.info(`IMSI: ${imsi}`); | |
104 | + modemInfo.imsi = data.toString().trim(); | |
105 | + logger.info(`IMSI: ${modemInfo.imsi}`); | |
104 | 106 | } |
105 | 107 | |
106 | 108 | mutex.releaseLockWaitForOK(); |
... | ... | @@ -175,4 +177,5 @@ function init() { |
175 | 177 | |
176 | 178 | init(); |
177 | 179 | |
180 | +exports.modemInfo = modemInfo; | |
178 | 181 | exports.sendSMS = sendSMS; |