Search code examples
c#smsgsmat-commandmodem

How to send Unicode message from a GSM device using AT command


I have an existing desktop application using C# .Net for sending and receiving messages using GSM device/modem. Everything is ok, but now I'm facing some problems:

1 - I can't send more than 160 characters in a message.

2 - I can't send Unicode messages (my language is Bengali). I have already tried to converting to hexadecimal, but it's sending another language.

This is what I've tried so far:

port.WriteLine("AT+CSCS=\"UCS2\"\n");
Thread.Sleep(100);
port.WriteLine("AT+CMGF=1"+Environment.NewLine);
Thread.Sleep(100);
port.WriteLine("AT+CMGS=\""+number+"\"");
Thread.Sleep(100);
port.WriteLine(message+char.ConvertFromUtf32(26)+Environment.NewLine);
Thread.Sleep(100);
port.Write(new byte[]{26},0,1);
Thread.Sleep(100);

Solution

  • First of all, you should never, never, never, never, never, never, never, never, never, never, ever use Thread.Sleep like that! And for AT+CMGS you must also properly wait for the ready-to-receive-payload response from the modem, see the first part of this answer.


    Regarding sms size, 160 characters is a limitation of the GSM network. It is possible to send "virtually" larger messages by splitting up the text and sending in multiple messages that is concatenated transparently on the receiving mobile phone so that it seems like it was one single message. This is called multi-part sms.

    You cannot send multi-part messages in text mode, you have to use PDU mode for that.


    After you run AT+CSCS="UCS2" every single string parameter must be encoded that way from then on, including switching to a different character encoding with AT+CSCS. In your case this applies to the <da> argument to AT+CMGS.