Skip to content

Commit

Permalink
Released v0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
futomi committed Oct 29, 2020
1 parent 4eddecd commit 47f5d5a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,8 @@ When a long message are divided into some segments, each segment requires 6 byte
---------------------------------------
## <a id="Release-Note">Release Note</a>

* v0.3.0 (2020-10-29)
* Added support for decoding (parsing) the alphanumeric representation of the origination address. (thanks to [@ingria](https://github.com/futomi/node-sms-pdu/issues/1))
* v0.2.0 (2020-02-23)
* Added the `reference` property in [the SMS-SUBMIT specific items](#sms-submit-specific-items), which means the message reference number.
* v0.1.1 (2020-02-21)
Expand Down
3 changes: 2 additions & 1 deletion lib/sms-pdu-user-data-gsm0338.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* Copyright (c) 2020, Futomi Hatano, All rights reserved.
* Released under the MIT license
* Date: 2020-02-21
* Date: 2020-10-29
* ---------------------------------------------------------------- */
'use strict';

Expand Down Expand Up @@ -255,6 +255,7 @@ class SmsPduUserDataGsm0338 {

}

text = text.replace(/\@$/, '');
return text;
}

Expand Down
23 changes: 15 additions & 8 deletions lib/sms-pdu.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* Copyright (c) 2020, Futomi Hatano, All rights reserved.
* Released under the MIT license
* Date: 2020-02-23
* Date: 2020-10-29
* ---------------------------------------------------------------- */
'use strict';
const mSmsPduUserDataGsm0338 = require('./sms-pdu-user-data-gsm0338.js');
Expand Down Expand Up @@ -592,21 +592,28 @@ class SmsPdu {
throw new Error('The length of the data is insufficient.');
}

let type = buf.readUInt8(1);
let international = (type === 0x91) ? true : false;
let address_type = buf.readUInt8(1);
let number_type = (address_type & 0b01110000) >>> 4;
let international = (number_type === 0b001) ? true : false;

let address = '';
for (let i = 2; i < len; i++) {
let hex = buf.slice(i, i + 1).toString('hex');
address += hex.substring(1, 2);
address += hex.substring(0, 1);
if (number_type === 0b101) {
// Alphanumeric, (coded according to GSM TS 03.38 7-bit default alphabet)
address = mSmsPduUserDataGsm0338.decode(buf.slice(2, len), 0);
} else {
for (let i = 2; i < len; i++) {
let hex = buf.slice(i, i + 1).toString('hex');
address += hex.substring(1, 2);
address += hex.substring(0, 1);
}
address = address.replace(/f$/, '');
}
address = address.replace(/f$/, '');

return {
length: len,
digit: digit,
international: international,
type: number_type,
address: address
};
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-sms-pdu",
"version": "0.2.0",
"version": "0.3.0",
"description": "The node-sms-pdu is a SMS-SUBMIT PDU (Packet Data Unit) generator and SMS-SUBMIT/DELIVER PDU parser. This module supports the GSM 7-bit default alphabet encoding and the UCS-2 16-bit alphabet encoding. Besides, it supports the Concatenated (or Multipart or Long) SMS.",
"main": "./lib/sms-pdu.js",
"files": [
Expand Down

0 comments on commit 47f5d5a

Please sign in to comment.