futomi / node-sms-pdu

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.
MIT License
16 stars 6 forks source link

RangeError [ERR_OUT_OF_RANGE]: The value of "offset" is out of range #9

Open rodney-vin opened 1 month ago

rodney-vin commented 1 month ago
const message = 'a'.repeat(200) // 140 bytes User Data per SMS

SmsPDU.generateSubmit('123456', message)

It causes Error:

RangeError [ERR_OUT_OF_RANGE]: The value of "offset" is out of range. It must be >= 0 and <= 47. Received 48
      at boundsError (internal/buffer.js:83:9)
      at Buffer.readUInt8 (internal/buffer.js:249:5)
      at SmsPduUserDataGsm0338.encode (packages/shonis-sw-a3-vsvw04-b01/node_modules/node-sms-pdu/lib/sms-pdu-user-data-gsm0338.js:418:24)
      at SmsPdu.generateSubmit (packages/shonis-sw-a3-vsvw04-b01/node_modules/node-sms-pdu/lib/sms-pdu.js:98:40)
rodney-vin commented 1 month ago

The reason is: sms-pdu-user-data-gsm0338.js: 384

// Set spare bits
      if (rbit_len === 7) {
        // Set to the 7-bit code of the CR control (also used as a padding filler)
        **septet_group.push(0x0D);**
      }

Remove this line, will fix this issue.

And not found others issues when runing regression testing that covers Short SMS and Concatenated SMS