1

I need help decoding this received response.

at
OK
+CUSD: 0,"ar@?$  @9@d? ?@ ???(d??)@@1pD?"?T?Hc@
                                           ?&  ?@D??? ?@??5 41 IA ?R",17

OK
+CUSD: 0,"ar?hb? ?'  10?@ ? ?hb@?J@@?@?? @f@??@?@S@d$@",17

I tried when dcs value was 72 on another network provider. but this one value 17 I don't understand. how to decode it?

after results :

AT+CSCS="UCS2"
OK        
at+cusd=1,"002a003100350030002a0032002a00330032003300390031002a00360039003100370037002a00310023",15

+CUSD: 0,"00610072003f00680062003f0020003f00270020002000310030003f00400020003f0020003f006800620040003f004a00400040003f0040003f003f0020004000660040003f003f0040003f004000530040006400240040",17
AT+CSMP?
+CSMP: 17,167,0,0

OK

by the way when i set my AT+CSCS="UTF-8" it report Error but it is reported back with this command AT+CSCS=?

samhightech
  • 91
  • 12

2 Answers2

1

The format of the response is according to 27.007:

+CUSD=[<n>[,<str>[,<dcs>]]]

Thus the third parameter is <dcs>. Its format is just deferred:

<dcs>: 3GPP TS 23.038 [25] Cell Broadcast Data Coding Scheme in integer format
(default 0)

In chapter "5 CBS Data Coding Scheme" in 23.038 it states These codings may also be used for USSD.

For 17, binary 0001 0001:

  • bit 7..4 Coding Group Bits = 0001
  • bit 3..0 = 0001 --> UCS2; message preceded by language indication

And it notes that

An MS not supporting UCS2 coding will present the two character language identifier followed by improperly interpreted user data.

which is exactly the case in your output (e.g. ar meaning arabic followed by garbage).

For 72, binary 0100 1000:

  • bit 7..4 Coding Group Bits = 01xx
  • bit 5 = 0 --> uncompressed,
  • bit 4 = 0 --> no class meaning
  • bit 3 & 2 = 1 & 0 --> UCS2 (16bit)

The "not supporting" part above might just be that you are using a limited character set encoding (PCCP437). In any case, unless your modem does not support UTF-8 you really should use that and not this PCCP437. Or you might use USC2. If your modem lacks both of those characters, you can try HEX (guessing on my part from what I saw when researching this answer, maybe you need to set the <dcs> parameter in AT+CSMP for this to work?).

Notice that after selecting UCS2 every string must be encoded that way, including switching to another character set, see this answer for an example.

Community
  • 1
  • 1
hlovdal
  • 26,565
  • 10
  • 94
  • 165
  • First I thought it has worked but it hasn't. I Still get the same response but in UCS2. So my problem still exist please help me. – samhightech Apr 26 '14 at 08:44
  • Could you update the question with the new commands and responses? Also, have you tried changing AT+CSMP (and what is the default value)? – hlovdal Apr 26 '14 at 10:05
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 str1 = SmsEngine.HexStr2UnicodeStr("002a003100350030002a0032002a00330032003300390031002a00360039003100370037002a00310023");
// str1 = "*150*2*32391*69177*1#"

Please also check UnicodeStr2HexStr()

Community
  • 1
  • 1
Behzad Ebrahimi
  • 992
  • 1
  • 16
  • 28
  • Please do it for me if you can and post the result in arabic? – samhightech Oct 01 '14 at 08:54
  • // at+cscs="UCS2" // at+cusd=1,"*150*2*88653*55555*1#",15 at+cusd=1,"002a003100350030002a0032002a00380038003600350033002a00350035003500350035002a00310023",15 +CUSD: 0,"0061007203A30068006200BF00F800A5002700F800200031003000F20040039400F9039B039800680062004003A600A5004A0040004000A3002000F900A1002000620040002800A5004000F2004000530040006400240040",17 – samhightech Oct 01 '14 at 08:55
  • String str2 = SmsEngine.HexStr2UnicodeStr("00610072003f00680062003f0020003f00270020002000310030003f00400020003f0020003f006800620040003f004a00400040003f0040003f003f0020004000660040003f003f0040003f004000530040006400240040"); // str2 = "ar?hb? ?' 10?@ ? ?hb@?J@@?@?? @f@??@?@S@d$@". It seems that your original message is encoded and that it is not plain text! – Behzad Ebrahimi Oct 02 '14 at 13:29