jackkum / node-pdu

Creates and parses a SMS PDU strings
MIT License
16 stars 11 forks source link

Incorrect 7bit-encode #31

Closed borokovic closed 2 months ago

borokovic commented 11 months ago

Encode7bit produces incorrect for some strings. For example: *171*1*1*5*085767240000*123456# generates AAD82DA68AA962AA9A0A86ABDD6C37190D0683C15431D98C56B38D00 which should be AAD82DA68AA962AA9A0A86ABDD6C37190D0683C15431D98C56B38D1A

http://smstools3.kekekasvi.com/topic.php?id=288

KillerJulian commented 11 months ago

Thanks for the issue.

Please provide more information (e.g. a code example) to reproduce the error.

borokovic commented 11 months ago

Im using serialport-gsm together with node-pdu. const Enkoding = require("node-pdu/PDU/Helper"); const cmd = "*171*1*1*5*085767240000*123456#"; const perintah = Enkoding.encode7Bit(cmd); console.log(perintah); I tried using the new version, but my capabilities were limited

KillerJulian commented 7 months ago

I can achieve the desired result by appending a \r to your input:

const pdu = require('./dist/index');

const cmd = '*171*1*1*5*085767240000*123456#\r';
const perintah = pdu.utils.Helper.encode7Bit(cmd);

console.log(perintah);

The website uses a \r as padding character, whereby this library uses an @ as padding character when encoding:

grafik