This project is read-only.

GSM encoding

Apr 24, 2013 at 8:40 PM
Hi there,
my name is Thomas and I'm new to the Jamaa discussions.
So far I did some basic implementation of Jamaa to send and receive SMS.
The current challenge I'm facing is an 'unsupported encoding' message for a Deliver_SM.
Within the PDU I receive, the data_encoding octet is set to 'f1' which is a 'GSM message class control 1111xxxx' encoding. How can I habdle this using Jamaa.
Help and/or directions highly appreciated.
Thank you
May 5, 2013 at 6:47 PM
Never mind,
figured it out. I successfully integrated a GSM 0.38 encoder into the core lib.
Jun 19, 2013 at 8:38 AM
How did you figured it out please help me. I am facing this issue too.
I am trying to send sms in urdu and arabic language. But they are receiving in the form of random characters, I have tried ASCII, UCS2 format but they are not working.
Please help.
Jun 19, 2013 at 12:39 PM
Good morning,
I don't really know which encoding you need to send in urdu or arabic, this is what you would have to figure out yourself. I'd try to send an SMS from your phone to your receiver and then figure out which encoding they have, so you can reversely identify which encoding you need.
The encoding as such is an octet within the SM_DELIVER part of the PDU. Jamaa SMPP has a class in Smpp.Net.Lib which is called DataCoding and contains most of the possible encoding octets a PDU could contain, but it doesn't support all of them. If I remember correctly, the DataCoding class contains already a GSM_MessageClass_0=0xf0, so the class itself knows about the GSM encoding, but GSM encoding wasn't supported by the library. I also had to add GSM_MessageClass_1=0xf1 as some of my MO messages came with the F1 encoding octet.
So once you identified the encoding needed (means octet) and that encoding is in class DataEncoding, then you just need to do 2 more things: you need to provide the corresponding encoder and you need to make the encoder available in the library.
I simply put a GSMEncoding class in the Util namespace of the library. That class inherits from System.Text.Encoding, it contains 2 dictionaries to encode and decode and overrides a few methods to get byte arrays, char arrays and their respective counts.
Once you have such an encoding class for the encoding you need, you need to make that available in SMPPEncodingUtil.cs which is in the same namespace. Add your new encoder in 4 places: GetBytesFromCString, GetCStringFromBytes, GetBytesFromString, GetStringFromBytes.
Now you are finished in adding a new codepage into the library.
I hope that helps.
Please let me know which codepages you have to implement, so I know in case I run in the same situation.
Jun 19, 2013 at 1:18 PM
Edited Jun 19, 2013 at 1:19 PM
@Thomas, Thanks for the reply. It seems that for sending arabic and urdu characters in sms, I need unicode scheme. But where can I find the encoder for unicode scheme. Since i am novice to SMPP programming...and i don't know in detail about this PDU's and other stuff. Please help.
Does GSM 0.38 encoder supports arabic and urdu characters?
Jun 19, 2013 at 1:58 PM
Unicode is already supported by Jamaa (alias UCS2).
I understand you talk about sending ams to a mobile device which means you need to pick the correct encoding while sending a message (my input above was mostly related to receiving a message).
In this case it depends if you use the JAMAA client or if you use the library directly.
I use the JAMAA client and here is where you need to make sure you use the right encoding for sending messages as the client will use a 'default' which is SMSC (alias 0) if you don't specify differently. There are different ways to set the encoding: per SmppConnectionProperties.DefaultEncoding (try to set here UCS2), which means per default all messages will be sent using UCS2. Or on a per message basis by setting in SubmitSM.SetMessageText the proper DataCoding.

Regarding the PDU: it really helps you a lot if you get more familiar with PDU's. I had no clue either 6 months ago, and needed to learn, but it's actually fun. There is a website which will help you understand SMPP as such much better:
GSM 0.38 does not support arabic characters as far as i know.

Go ahead and try setting UCS2 as encoding when sending and see what happens.
Jun 19, 2013 at 2:13 PM
Edited Jun 19, 2013 at 2:20 PM
This is what i am doing...

properties.DefaultEncoding = JamaaTech.Smpp.Net.Lib.DataCoding.UCS2;

TextMessage msg = new TextMessage();
      msg.DestinationAddress = "099999999999"; 
            msg.SourceAddress = "BLM"; 
            msg.Text = "اردو ایس ایم ایس";
            msg.RegisterDeliveryNotification = true; 
            if(client.ConnectionState != SmppConnectionState.Connected)
           client.SendMessage(msg, 1000);
The above code does not works....The message recieved on my mobile contains Japanese characters. But as you can see there is no japanese in the string.
Please guide me a little about this. Do i need to convert this string to Unicode before sending message or not.
Jun 19, 2013 at 2:43 PM
I have tried to encode string to unicode before sending. But after converting to unicode this string becomes like this ???? ???? ??? ??
Please help
Jun 19, 2013 at 4:10 PM
where did u set the encoding to unicode?
are you able to send a message from your phone to your server and log the PDU received?
Jun 20, 2013 at 1:17 AM
Please see my third last comment. In line number 2, i have set data coding to unicode (ucs2). But it results in japanese characters.
Jun 20, 2013 at 7:04 AM
Even I have set all 4 occurrences of




in the file


As mentioned in this discussion.

But its still not working :(
Jun 24, 2013 at 1:28 PM
Good morning,
I have been away from my computer for a bit. Sorry for the late answer. Assuming your problem is still not solved.
Reading also your other post, you stated that you use non-mobile phone clients to see your message and it displays only '???'.
Once you use the BigEndianUnicode, are you sure, the clients you display the message with, decode correctly? Di you ever send a message to a real arabic cell phone?
You might have a problem on the other end, if you don't use a real cell phone.
It would help if you specify a bit more your current setup (sender and receiver).
Jun 24, 2013 at 2:14 PM
Thanks for the reply thomas, My problem is resolved. Actually there was a bug in Jamaa library. It allows us to encode message body in unicode or other encoding schemes but it was not changing encoding parameter in pdu header accordingly. Encoding value for PDU header was hard coded to ASCII.
Since i was encoding message body in unicode format but header was reflecting it as ASCII encoding scheme due to which SMSC server was not able to decode it properly.

Inshort, I have added this line in SetMessageText method of SendSmPDU class....

vDataCoding = dataCoding;