3

I test some basic AT Command in Hyperterminal. The GSM modem response as per my command too. But problem is that it shows me the unreadable text. I use the following code :

AT
OK
AT+CUSD=1,"*247#",15
OK

+CUSD: 1,"0062004B006100730068000A00310020004D0032004D0020005400720061006E007300
6600650072000A0032002000440069007300620075007200730065000A00330020004D0079002000
62004B006100730068000A0034002000480065006C0070006C0069006E0065000A",72
AT+CUSD=1,"1",15
OK

AT+CUSD=1,"*247#",15 command should display

  1. Menu 1
  2. Menu 2
  3. Menu 3

Something like that. But it displayed the hexadecimal code which it unreadable. How can I get plain text ? Can anyone help Me ?

Behzad Ebrahimi
  • 992
  • 1
  • 16
  • 28
Drop Shadow
  • 845
  • 3
  • 12
  • 28

3 Answers3

1

Judging by information provided. Where when you send the +CUSD request with DCS (Data Coding Scheme) of 15. And the response from the Bkash service with DCS of 72. It looks like your modem does not support the encoding specified in the DCS from Bkash.

I found is fairly similar question and solution to this question. Try and ensure that +CSCS is set to something like IRA or GSM and see what happens then with your +CUSD responses.

Community
  • 1
  • 1
Matt Aldridge
  • 2,037
  • 16
  • 21
  • The `+CUSD` response is obviously UCS2 encoded. Decoding it gives `bKash\n1 M2M Transfer\n2 Disburse\n3 My bKash\n4 Helpline\n`. – hlovdal Jun 17 '14 at 07:35
  • I use that UCS2 encode but i didn't get that menu , I use the following code : AT OK AT+CSCS=? +CSCS: ("IRA","GSM","UCS2") OK AT+CSCS="UCS2" OK AT+CUSD=1,"*247#",15 OK +CUSD: 0,"0049006E00760061006C00690064002000530065007200760069006300650020004300 6F00640065",72 Can you please tell me where i did mistake ? @hlovdal – Drop Shadow Jun 17 '14 at 09:55
  • I already test IRA and GSM mode but still I facing that problem . @aldridmc – Drop Shadow Jun 17 '14 at 09:58
  • Its the right menu which I am searching for. Can you please tell me how can you get that menu ? @hlovdal – Drop Shadow Jun 17 '14 at 10:04
  • DCS is 72 which in my book means it's a "reserved coding group". Perhaps the modem is not able to correctly deal with this and fall back to UC2 decoding? – Matt Aldridge Jun 17 '14 at 10:57
  • @DropShadow Read the linked answer, the text encoding for the +CUSD response is not affected by `AT+CSCS`. – hlovdal Jun 17 '14 at 11:24
  • I read that answer but I am not clear. I want to see the response in plain text which is human readable. So what should i do ? How can I decode my response like you (bKash\n1 M2M Transfer\n2 Disburse\n3 My bKash\n4 Helpline\n) ? @hlovdal – Drop Shadow Jun 17 '14 at 12:32
1

Use the following functions to decode "UCS2" response data:

    public static String HexStr2UnicodeStr(String strHex)
    {
        byte[] ba = Hex2ByteArray(strHex);
        return HexBytes2UnicodeStr(ba);
    }

    public static String HexBytes2UnicodeStr(byte[] ba)
    {
        var strMessage = Encoding.BigEndianUnicode.GetString(ba, 0, ba.Length);
        return strMessage;
    }

for example:

String str2 = SmsEngine.HexStr2UnicodeStr("0062004B006100730068000A00310020004D0032004D0020005400720061006E0073006600650072000A0032002000440069007300620075007200730065000A00330020004D007900200062004B006100730068000A0034002000480065006C0070006C0069006E0065000A");
// str2 = "bKash\n1 M2M Transfer\n2 Disburse\n3 My bKash\n4 Helpline\n"

Please also check UnicodeStr2HexStr()

Community
  • 1
  • 1
Behzad Ebrahimi
  • 992
  • 1
  • 16
  • 28
0

Hi this code is something called PDU (Protocol Data Unit). To decode it is not straight forward. you need to understand the structure first.