4

I am sending AT+CUSD command (to dial a ussd code) to a gsm modem. It is working fine. The response is also correct on the handset. But the response is in I think hex format or some encoding unknown to me:

GSM MODEM HARDWARE:

Nokia C6-01

Connected to laptop using USB cable. Usb mode: Nokia Suite

Commands for initializing the encoding:

AT+CSCS=?

+CSCS: ("UCS2","GSM","PCCP437","PCDN","IRA","8859-1","HEX","UTF-8")

AT+CSCS="IRA"

AT+CSCS?

+CSCS: "IRA"

Also tried:

AT+CSCS="GSM"
AT+CSCS="UTF-8"

Actual Ussd Command:

AT+CUSD=1,"*123#",15

Actual Response:

+CUSD: 1,"c47258e1ad7e7f477bb2c6781e0ec72785e691d36136481593cd54f6777d8c2ecb23e1313d6dfd3d36f7764fc26974720fa1b242f8fd161f9b9cc",1

OK

Expected Response:

AT+CUSD=1,"*123#",15

+CUSD: 1,"Dear Customer.... some response in english",1
Aqeel Ashiq
  • 1,988
  • 5
  • 24
  • 57

2 Answers2

5

Looks like an modem decoding issue. Should be fixed by making use of the standard IRA encoding of most modems.

Try using:

AT+CSCS="IRA"

And then try out the USSD command to get a response again.

As a side note you can output available encoding capabilities of your modem via:

AT+CSCS=?

USSD's are encoded either as 7-Bit GSM or UC2. To decode using 7-Bit take a look at 3GPP ETSI 03.38. To decode UC2 this is basically UTF-16 so 2 bytes defines a character.

Trying with 7-Bit:

C4    1 1000100     100 0100     D
72    01 110010     110 0101     e
58    010 11000     110 0001     a
E1    1110 0001     000 1010     <LF>
AD    10101 101     101 1110     ü
7E    011111 10     101 0101     U
7F    0111111 1     101 1111     §
47    0 1000111     011 1111     ?
7B    01 111011     100 0111     G

Dea<LF>üU§?G

Starts off good with 7-Bit but after 3 characters its just junk.

Trying with UC2 just produces junk.

Conclusion: Perhaps an specific issue with the modem being used (still would be useful to know which manufacturer model it is). Or how you are connected to the modem (considering the USSD string is not a valid hex string as it's of uneven length).

Matt Aldridge
  • 2,037
  • 16
  • 21
  • Same response even after setting. – Aqeel Ashiq May 04 '15 at 11:45
  • Can you execute the AT+CSCS=? command and show me what you get back? Also the manufacturer and model of your modem would be useful to have – Matt Aldridge May 04 '15 at 11:49
  • Hey, sir I have added the required commands. Please have look at my question again. – Aqeel Ashiq May 04 '15 at 12:31
  • Can you tell what is the encoding of the output string? So that I can process the output string in my code, to convert it to readable format – Aqeel Ashiq May 04 '15 at 13:39
  • The output string in it's current form isn't a valid anything. It's obviously a hex string but of 117 characters length. So it's uneven and therefore either you had some copy and paste issues or problems reading output from the modem itself. – Matt Aldridge May 04 '15 at 15:01
  • I have verified, there are no copy paste issues in response string – Aqeel Ashiq May 05 '15 at 09:38
  • Sir, How to convert it to readable form? This might give some clues into actual problem. – Aqeel Ashiq May 05 '15 at 10:28
  • Hello sir, I have added the hardware heading in my question. Please have another look. – Aqeel Ashiq May 06 '15 at 14:41
  • Ok that helps a little. Can you try setting the encoding to "HEX" and send again the USSD command and paste in the comment or question. – Matt Aldridge May 06 '15 at 15:34
  • Hello Sir, thanks for help in this. Please help me in another related question: http://stackoverflow.com/questions/30125721/how-to-write-a-atcusd-ussd-command-to-support-maximum-handsets – Aqeel Ashiq May 08 '15 at 14:16
  • I found out a very probable reason of the junk after the 3rd byte: the baud rate is detected inaccurate. When using auto-bauding, it doesn't just choose one of the standard baud rates. It can be anything. I had similar corruption after about 40 characters, getting progressively worse. After I issued `AT+IPR=9600` the corruption was gone and the message was clear. – Mark Jeronimus Oct 24 '18 at 11:26
1

the thread is a little old , but may be this will help people that come here!

The format is apparently in hex UC2, 16bit par character! so you should convert it back to a readable string! If you know how to program that's a simple task! create your function that do that! take every 4character! put them on $hex ==> convert them to a char! example in php! you do that with the two function chr(hexdec($hex)) like that! WELL FOR NO PROGRAMERS! give a look at this page online converter

there is too much and too much don't work! in all cases! this one is good! and more good than that! is that you can save the complet page in your pc! and use it when you are offline! they have made the implementation in javascript! and it's included! great!

well now for programmers! there is a function i have created in php! i was working on something! with AT Commands! and here i have created my own function! may be it will help you!

here is the file ! couldn't post it as code directly here! some not simple (identation thing!) => it's a doc file on my google drive

hope it's helpfull!!!

Community
  • 1
  • 1
Mohamed Allal
  • 17,920
  • 5
  • 94
  • 97