Skip to content

Commit

Permalink
* Enhance checks for getSimNumber, fixes zabsalahid#121
Browse files Browse the repository at this point in the history
  • Loading branch information
Apollon77 committed Dec 10, 2022
1 parent da3a733 commit a3fea7c
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions lib/functions/modem.js
Original file line number Diff line number Diff line change
Expand Up @@ -1289,20 +1289,28 @@ module.exports = function(SerialPort) {
if (newpart.startsWith('+CNUM')) {
let splitResult = newpart.split(',')
if (splitResult.length > 0 && splitResult[1]) {
const nameMatch = /"(.*?)"/g.exec(splitResult[0]);
const numberMatch = /"(.*?)"/g.exec(splitResult[1]);
return {
resultData: {
status: 'success',
request: 'getOwnNumber',
data: {
name: /"(.*?)"/g.exec(splitResult[0])[1],
number: /"(.*?)"/g.exec(splitResult[1])[1]
name: nameMatch ? nameMatch[1] : '',
number: numberMatch ? numberMatch[1] : ''
}
},
returnResult: true
}
} else {
// TODO what will happen here?
newpart === 'ERROR'
return {
resultData: {
status: 'ERROR',
request: 'getOwnNumber',
data: `Cannot Parse Sim Number response "${newpart}"`
},
returnResult: true
}
}
} else if (newpart.includes('ERROR')) {
return {
Expand Down

0 comments on commit a3fea7c

Please sign in to comment.