jackkum / node-pdu

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

No sure how to use setDcs #23

Open lipflip opened 3 years ago

lipflip commented 3 years ago

We need to set DCS SIM SPECIFIC MESSAGE.

We are now doing this:

`var DCS = pdu.getModule('PDU/DCS'); var scheme = new DCS(); scheme.setClass(DCS.CLASS_SIM_SPECIFIC_MESSAGE);

Submit.setDcs(scheme);`

Is this the correct way?

jackkum commented 3 years ago

Hello! Yes, it is correct.

Here more examples: https://github.com/jackkum/node-pdu/issues/13#issuecomment-377079019

lipflip commented 3 years ago

Thanks!

The problem we have is, for machine-to-machine communication (which is DCS CLASS_SIM_SPECIFIC_MESSAGE/CLASS_TERMINAL_EQUIPMENT), the text message is already a hex string.

So there is no need to do encode8Bit it in the Data object.

When we do a decode8Bit first, and then pass it to Data object, then the Data object sees it as a unicode text, which is not correct. And then it gives a wrong result.

For example this hex string (which does not need to be encoded again):

4D434750007B740700000000000000000000000000000000F6

when I decode this first (decode8Bit), and then pass it to Data, the Data object sees it as unicode and encodes it to this:

004D0043004700500000007B00740007000000000000000000000000000000000000000000000000000000000000000000F6

which is wrong, it need to be 4D434750007B740700000000000000000000000000000000F6.

I have solved this, by bypassing the _checkData function:

var Data = pdu.getModule('PDU/Data'); var data = new Data(Submit); data._data = decodedString; data._size = decodedString.length; data._unicode = false; data._prepareParts(); Submit.setData(data);

But not sure if there is a better way...

KillerJulian commented 1 year ago

Hello @lipflip, 👋 a new major version has just been released. Please check if your problem still exists. Update the problem description/logs if possible. Please give feedback.

Thank you!