linxGnu / gosmpp

Smpp (3.4) Client Library for Go
Apache License 2.0
152 stars 59 forks source link

Opening the ShortMessage #143

Closed Hurtsich closed 3 months ago

Hurtsich commented 6 months ago

Hello, It's me again, we have another issue with the same mobile provider (i know -_-) This provider doesn't respect the standard encoding mapping (0 for GSM7, 1 for ASCII, etc...) We need to create a ShortMessage with a certain encoded message but in the payload we need to specify a different encoding.

With our recent exchanges, I propose two solutions:

laduchesneau commented 3 months ago

@Hurtsich Did you ever create the code for what you proposed ?

I also ran into this issue because of how the DCS is harcoded to a encoding in the library. For example, DCS 0 as per the spec is the default encoding of the SMSC, but in the gosmpp, DCS 0 means GSM encoding. The SMSC I connect too uses DCS 0 for latin-1, and when receiving a DeliverSM with DCS 0, the library isn't able to decode the message correctly.

goten4 commented 3 months ago

@Hurtsich : I think you can use the following constructor :

pdu.NewBinaryShortMessageWithEncoding(data, encoding)

Or simply use :

shortMessage.SetMessageDataWithEncoding(data, encoding)

In both cases, you will first have to encode the message yourself in the data.

Hurtsich commented 3 months ago

@laduchesneau Yeah, we forked the lib for this use cases. I can open a PR with the changes. I wanted to wait the answer of @linxGnu to open it, but i will do it sooner than later ;)

linxGnu commented 3 months ago

@Hurtsich Please feel free to make the PR and assign people here to review 👍

laduchesneau commented 3 months ago

I do like @goten4 solution, it works for me. I don't know why I didn't think of it before. (Merci @goten4)

User can pass their own encoding via CustomEncoding, and force what ever byte they want for DCS.

The user can retrieve the message with a predefine encoding

deliverSM.Message.GetMessageWithEncoding( data.UCS2 )

or with a custom encoding

deliverSM.Message.GetMessageWithEncoding( CustomEncoding )

or without encoding and fully handle message decoding on their end

deliverSM.Message.GetMessageData()
Hurtsich commented 3 months ago

Yeah, the way proposed by @goten4 works and it's already in the lib. My bad :/