本文介绍了使用 AT 命令.响应编码和读取诺基亚手机的中文或阿拉伯文服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 AT 命令为 GSM 调制解调器开发应用程序.我在阅读 Unicode 消息或 ussd 示例时遇到问题:那 dcs=17 不是 7 或 15 或 72

I am developing an application for GSM Modems using AT commands. I have a problem reading Unicode messages or ussd example:that dcs=17 not 7 or 15 or 72

两年前,一直在寻找解决方案无果我通过使用中文手机找到了部分解决方案,手机可以读取中文编码但是所有诺基亚手机都不支持编解码器阿拉伯语或中文和服务反应出现难以理解的符号示例:

Two years ago, and I'm looking for a solution to no availI was able to find a partial solution through the use of Chinese phone where the phone can read Chinese codingBut all Nokia phones do not support the codec Arabic or ChineseAnd service responses appear incomprehensible symbolsExample:

+CUSD: 0,"ar??c
?J <10???@d@??? @0@??@D? ?Z?xb
@   $@?@?@Z@@?? @-@H?@???@b@@$? @3@h?P???@??(??",17

但是当你用手机显示中文回复服务100%正确我如何通过诺基亚手机或其他方式解决编码问题

But when you use the phone shows the Chinese response service correctly 100%How do I address coding through Nokia phones or other

推荐答案

AT 命令中用于字符串的字符集由 AT+CSCS 控制.默认值为 "GSM",它不能显示相对有限的字符集之外的任何内容.

The character set used for strings in AT commands is controlled by AT+CSCS. The default value is "GSM" which is not capable of displaying anything outside a relative limited set of characters.

在您的情况下,阅读阿拉伯语或中文 "UTF-8" 可能是最好的选择,尽管 "UCS-2" 也可以使用(需要虽然有点后期处理).

In your case, to read Arabic or Chinese "UTF-8" is probably the best choice, although "UCS-2" also can be used (will require a little post processing though).

您可以在下面看到所选字符集如何影响字符串.我一直把我在台湾生活时给我的中文老师的电话号码保存为中文的老师"(lǎo shī).此处删除了实际电话号码,但除此之外,以下是我手机回复的逐字副本:

Below you can see how the selected character set affects strings. I have kept the phone number to my Chinese teacher from when I lived in Taiwan, stored as "teacher" in Chinese (lǎo shī). The actual phone number is stripped out here, but otherwise the following is a verbatim copy of the responses from my phone:

$ echo at+cscs? | atinout - /dev/ttyACM0 -

+CSCS: "GSM"

OK
$ echo at+cpbr=403 | atinout - /dev/ttyACM0 -

+CPBR: 403,"",145,"??/M"

OK
$ echo at+cscs=? | atinout - /dev/ttyACM0 -

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

OK
$ echo 'at+cscs="UTF-8"' | atinout - /dev/ttyACM0 -

OK
$ echo at+cscs? | atinout - /dev/ttyACM0 -

+CSCS: "UTF-8"

OK
$ echo at+cpbr=403 | atinout - /dev/ttyACM0 -

+CPBR: 403,"",145,"老師/M"

OK
$ echo 'at+cscs="UCS2"; +cpbr=403' | atinout - /dev/ttyACM0 -

+CPBR: 403,"",145,"80015E2B002F004D"

OK
$ echo 'at+cscs=?' | atinout - /dev/ttyACM0 -

+CSCS: ("00470053004D","004900520041","0038003800350039002D0031","005500540046002D0038","0055004300530032")

OK
$ echo 'at+cscs="005500540046002D0038"' | atinout - /dev/ttyACM0 -

OK
$ echo 'at+cscs=?' | atinout - /dev/ttyACM0 -

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

OK

更新,在检查 27.007 后,+CUSD: <m>[,<str>,<dcs>] 未经请求的结果代码不是常规字符串,而是有自己的编码:


Update, upon checking 27.007, the string for the +CUSD: <m>[,<str>,<dcs>] unsolicited result code is not a regular string, but has its own encoding:

<str>: string type USSD-string (when <str> parameter is not given,
       network is not interrogated):
  - if <dcs> indicates that 3GPP TS 23.038 [25] 7 bit default alphabet is used:
      - if TE character set other than "HEX" (refer command Select TE Character
        Set +CSCS): MT/TA converts GSM alphabet into current TE character set
        according to rules of 3GPP TS 27.005 [24] Annex A
      - if TE character set is "HEX": MT/TA converts each 7-bit character of GSM
        alphabet into two IRA character long hexadecimal number (e.g. character
        Π (GSM 23) is presented as 17 (IRA 49 and 55))

  - if <dcs> indicates that 8-bit data coding scheme is used: MT/TA converts each
    8-bit octet into two IRA character long hexadecimal number (e.g. octet with
    integer value 42 is presented to TE as two characters 2A (IRA 50 and 65))

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

因此您必须先确定dcs是7位还是8位,然后根据上述进行解码.

You therefore have to first determine if dcs is 7 or 8 bit, and then decode according to the above.

PS,描述了USC2 0x81"格式这里.尽管在这种特殊情况下,它的行为不应与普通 UCS2 不同.

PS, the "USC2 0x81" format is described here. although it should not behave differently from plain UCS2 in this particular case.

这篇关于使用 AT 命令.响应编码和读取诺基亚手机的中文或阿拉伯文服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 18:59