Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect 7bit-encode #21

Open
AdamSmid opened this issue Nov 21, 2019 · 11 comments
Open

Incorrect 7bit-encode #21

AdamSmid opened this issue Nov 21, 2019 · 11 comments

Comments

@AdamSmid
Copy link

Im using serialport-gsm together with node-pdu.
And I found that SMS length from my database queue is not equal with sms recivied on the phone.

I did some test, and in my country we are using some special characters "ěěščřřžýáí".
So if the SMS used these special characters node-pdu switch to use ALPHABET_UCS2 and it was OK.

But with simply sms without special characters with simple ASCII chars the function Helper.encode7Bit starts to return wrong length of text. Basically it was missing char at the end of each SMS PDU part.

I fixed it with increase length of return string

file: node-pdu/PDU/Helper.js
function: Helper.encode7Bit = function(text, alignBits)
return [len+1, ret]; };

@KillerJulian
Copy link
Collaborator

Hello @AdamSmid, 👋
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!

@lipflip
Copy link

lipflip commented Oct 31, 2023

Hi @AdamSmid

I also had this issue.

Just a long text without any special char, gives a wrong pdu part, after decode, a char is missing at the end.
Your fix in Helper.encode7Bit function did fix it for me.

@KillerJulian

Reproduce:

Hello, this is a long text to reproduce the issue that Adam Smid has provided, I am trying to reproduce this with success. I hope you guys have a good day today, make every day count in your live!

Returns two parts

C8329BFD6681E8E8F41C949E83C220F6DB7D06D1CB783A88FE06C9CB70F99B5C1F9741747419949ECFEB65101D1DA68382E4701B346DA7C92074780E82CBDFF634B94C668192A0701B4497E7D3EE3388FE06C9CB70F99B5C1F974174747A0EBAA7E968D0BC3E1E97E77317280942BFE16550FE5D079DEBF939081DB6974161D0F9FD2683C861

7910FD4D0EE759A076785D0695ED65791E440EE741E377DD4D07A5DDA0FCBB2E07B1D3F67208

If you send this to a modem (or just decompile with parse function)

You will see

Hello, this is a long text to reproduce the issue that Adam Smid has provided, I am trying to reproduce this with success. I hope you guys have a good d

y today, make every day count in your live

The letter a is missing.

The code return [len+1, ret]; in Helper class fixed the issue. But not sure if this is the good way to solve this?

The issue also exists in the new major version.

@lipflip
Copy link

lipflip commented Oct 31, 2023

Extra note: the fix return [len+1, ret]; is NOT ok.

The pdu string is not valid if we send it to the modem.

I could not find out why.
I guess something with the length/size that is being sent in the pdu string is not ok due to this change.

@AdamSmid
Copy link
Author

AdamSmid commented Nov 2, 2023

Im using this fix in production modem (16 sim cards) since 2019 and everything works.
I didnt find any better solution.

@KillerJulian
Copy link
Collaborator

I'm also not sure how best to solve the problem. Any other suggestions?
Can someone create a pull request?

@starak
Copy link

starak commented Nov 6, 2023

It is not a solution to the problem but rather a workaround. By inserting a Unicode zero-width space into the message, you can trigger a different encoding process.

const submit = new Submit(number, message += "\u200B");

@lipflip
Copy link

lipflip commented Nov 7, 2023

Im using this fix in production modem (16 sim cards) since 2019 and everything works. I didnt find any better solution.

I'm getting CMS error 21 when using this fix, which means the message is being rejected by the operator.

If I decode the pdu throught this site https://smspdu.benjaminerhart.com/ I see user data length is 161.

Not sure why is working on your modem

@lipflip
Copy link

lipflip commented Nov 7, 2023

Im using this fix in production modem (16 sim cards) since 2019 and everything works. I didnt find any better solution.

I'm getting CMS error 21 when using this fix, which means the message is being rejected by the operator.

If I decode the pdu throught this site https://smspdu.benjaminerhart.com/ I see user data length is 161.

Not sure why is working on your modem

@AdamSmid

can you please share your full code so that I can test this. Thanks

@KillerJulian
Copy link
Collaborator

If the 7 bit encoding causes so many problems (see other issues), does it make sense to refactor with cleaner and simpler code? Maybe there is a library that solves this problem? I have to admit, I'm not very familiar with the subject so far. 😅

@KillerJulian
Copy link
Collaborator

I invested some more time, but could not solve the problem. As I said before, I only have a limited insight into this library. Perhaps you have another solution or know someone who could solve this problem?

Feel free to commit on my branch fix/7bit/killerjulian.

Regards Julian

@KillerJulian KillerJulian pinned this issue Feb 3, 2024
@KillerJulian
Copy link
Collaborator

Reproduce:

Hello, this is a long text to reproduce the issue that Adam Smid has provided, I am trying to reproduce this with success. I hope you guys have a good day today, make every day count in your live!

Returns two parts
C8329BFD6681E8E8F41C949E83C220F6DB7D06D1CB783A88FE06C9CB70F99B5C1F9741747419949ECFEB65101D1DA68382E4701B346DA7C92074780E82CBDFF634B94C668192A0701B4497E7D3EE3388FE06C9CB70F99B5C1F974174747A0EBAA7E968D0BC3E1E97E77317280942BFE16550FE5D079DEBF939081DB6974161D0F9FD2683C861

7910FD4D0EE759A076785D0695ED65791E440EE741E377DD4D07A5DDA0FCBB2E07B1D3F67208

@lipflip Please provide a full code example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants