Reputation: 23
I am trying to setup a SIM800 to receive SMS messages from my alarm system and I got it working... almost.
When I send a SMS message from my phone, the SIM800 receives the message correctly in readable format. However, when the alarm system sends a sms, the SIM800 displays a long string containing hex numbers instead of the message.
Looking at the received hex string, I noticed that every second number was 0x00. I then tried to remove the extra 0x00's from the string and run it throug a hex to ascii converter, and then I could read the message correctly.
When I receive the message from the alarm system on my phone it is displayed correctly without any manual converting.
I have tried different settings of the AT+CMGF command and the AT+CSCS command on the SIM800, but nothing seems to solve the problem.
Is there some other AT commands that needs to be set?
Upvotes: 1
Views: 2719
Reputation: 776
The SIM800L seems to not always convert incoming messages to the expected encoding when receiving them, i.e. in my experience, when receiving a UCS2/UTF-16 encoded message that has characters outside the GSM charset, it displays it in UCS2 form instead of "GSM" and does not convert it, even when the coding scheme (AT+CSCS=?
) is set to "GSM"
.
I found that the most reliable way to receive messages in whatever source encoding is to set the SIM800L to UCS2 mode using
AT+CSCS="UCS2"
, then when receiving a message, convert it to a byte buffer from the ASCII hex sequence, then decode as UTF-16.
I.e. an incoming message example
is then notified by the modem as 006500780061006D0070006C0065
. Convert this to a byte sequence and decode as UTF-16BE
.
Upvotes: 1
Reputation: 11
There are two GMS encoding schemes, GSM 7-bit (which you are seeing as text because it is decoded for you by the SIM800) and UCS-2, which represents the most commonly used Latin and eastern characters in these two-byte characters.
The UCS-2 encodings are all identical to UTF-16 so you can decode using that. You know it's a UCS-2 message from the 'data coding scheme' entry in the SIM800 response to +CMGR.
You can find out more by searching for 'GSM 03.38 character encoding'.
Upvotes: 1