感谢支持
我们一直在努力

ARM Llinux系统移植3G拨号上网收发短信

一、      PPP移植

各项工作具体说明

向Linux内核添加3G模块的驱动(USB转串口驱动)和PPP协议的支持,然后编译内核并下载到开发板。当然如果之前已经移植好内核,那么只需要增加几个选项就可以,然后在编译内核就可以了,这个文档默认内核已经移植过,所以只讲与USB转串口驱动和PPP协议支持的几个选项。

[linuxidc@localhost linux-3.0]$ make menuconfig

1、USB的驱动要选这几个:

DeviceDrivers—→

USBsupport—→

<*>USB SerialConverter support–→

[*]USBGeneric Serial Driver

<*>USBdriver for GSM and CDMA modems

2、到此3G模块驱动添加完成,下面进行ppp协议支持的添加(下面所示的几个选项必选):

DeviceDrivers–→

Network devicesupport—→

<*> PPP (point-to-point protocol) support 
        [*]  PPP multilink support (EXPERIMENTAL)   
        <*>  PPP support for async serial ports     
        <*>  PPP support for sync tty ports         
      <*>  PPP Deflate compression             

 <*>  PPP BSD-Compress compression

完成了这些步骤以后就可以退出make menuconfig进行make编译内核了。然后再把生成的镜像文件下载到板子上重启开发板即可。然后就会发现在/dev/目录下生成ppp设备节点:

~ >: ls -l dev/ppp
crw-rw—-    1 root    root      108,  0 Mar 27 17:35 dev/ppp

ppp协议介绍

/***********************转载声明*********************************/

二、      usb_modeswitch移植

下载usbmode库:

[linuxidc@localhost fulinux]$ mkdir usbmode
[linuxidc@localhost fulinux]$ cd usbmode/

[linuxidc@localhost usbmode]$ wget http://pkgs.Fedoraproject.org/repo/pkgs/libusb1/libusb-1.0.0.tar.bz2/df2447c23750ef2b4a314200feacc2ee/libusb-1.0.0.tar.bz2

[linuxidc@localhost usbmode]$ wget http://jaist.dl.sourceforge.net/project/libusb/libusb-compat-0.1/libusb-compat-0.1.5/libusb-compat-0.1.5.tar.bz2

[linuxidc@localhost usbmode]$wget http://pkgs.fedoraproject.org/repo/pkgs/usb_modeswitch/usb-modeswitch-1.2.4.tar.bz2/dbd4ce7966d7b4a5a0604a8280f7164d/usb-modeswitch-1.2.4.tar.bz2

[linuxidc@localhost usbmode]$ wget http://www.draisberghof.de/usb_modeswitch/usb-modeswitch-data-20130607.tar.bz2

以上这些下载地址如果有失效的,搜索相应的文件下载,即可下载。

解压:

[linuxidc@localhost usbmode]$ tar xjf libusb-1.0.0.tar.bz2
[linuxidc@localhost usbmode]$ tar xjf libusb-compat-0.1.5.tar.bz2
[linuxidc@localhost usbmode]$ tar xjf usb-modeswitch-1.2.6.tar.bz2
[linuxidc@localhost usbmode]$ tar xjf usb-modeswitch-data-20130607.tar.bz2

编译libusb:

[linuxidc@localhost usbmode]$ mkdir install
[linuxidc@localhost usbmode]$ cd libusb-1.0.0

[linuxidc@localhost libusb-1.0.0]$ ./configure –prefix=/home/linuxidc/fulinux/usbmode/install/  –build=i686 –host=arm-linux  –disable-shared –enable-static    (注意有两–的前面有一个空格)

[linuxidc@localhost libusb-1.0.0]$ make

[linuxidc@localhost libusb-1.0.0]$ make install

[linuxidc@localhost libusb-1.0.0]$ ls ../install/
include  lib
[linuxidc@localhost libusb-1.0.0]$

编译usb_modeswitch:

[linuxidc@localhost usbmode]$ cd usb-modeswitch-1.2.6
[linuxidc@localhost usb-modeswitch-1.2.6]$ ls
[linuxidc@localhost usb-modeswitch-1.2.6]$ vim Makefile

CC          ?=/opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-gcc #addr fulinux
CFLAGS      += -Wall -l ../install/include-static #add by fulinux
LIBS        = -L ../install/lib/ -l usb -l usb-1.0-l pthread  #add by fulinux

[linuxidc@localhost libusb-1.0.0]$ cd ..
[linuxidc@localhost usbmode]$ export PKG_CONFIG_PATH=/home/linuxidc/fulinux/usbmode/install/lib/pkgconfig:$PKG_CONFIG_PATH

[linuxidc@localhost usbmode]$ cd libusb-compat-0.1.5
[linuxidc@localhost libusb-compat-0.1.5]$

[linuxidc@localhost libusb-compat-0.1.5]$ ./configure –prefix=/home/linuxidc/fulinux/usbmode/install/  –build=i686 –host=arm-linux –disable-shared –enable-static

[linuxidc@localhost libusb-compat-0.1.5]$ make

[linuxidc@localhost libusb-compat-0.1.5]$ make install

[linuxidc@localhost libusb-compat-0.1.5]$ ls ../install/
bin  include  lib
[linuxidc@localhost libusb-compat-0.1.5]$

编译usb_modeswitch:

[linuxidc@localhost libusb-compat-0.1.5]$ cd ../usb-modeswitch-1.2.4
[linuxidc@localhost usb-modeswitch-1.2.6]$ vim Makefile

CC          = /opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-gcc
CFLAGS      += -Wall -I ../install/include -static
LIBS        = -L ../install/lib -l usb -l usb-1.0 -l pthread

[linuxidc@localhost usb-modeswitch-1.2.4]$ make
[linuxidc@localhost usb-modeswitch-1.2.4]$ cp usb_modeswitch ../install/bin/

[linuxidc@localhost usb-modeswitch-1.2.4]$ cp usb_modeswitch /tftp/

上面用usb-modeswitch-1.2.6编译时发现有问题,有如下

[linuxidc@localhost usb-modeswitch-1.2.6]$ make
cc -o usb_modeswitch usb_modeswitch.c -Wall -I../install/include -static  -L /home/linuxidc/fulinux/usbmode/install/lib -l usb -l usb-1.0 -l pthread
/usr/bin/ld: skipping incompatible /home/linuxidc/fulinux/usbmode/install/lib/libusb.a when searching for -lusb
/usr/bin/ld: cannot find -lusb
collect2: ld returned 1 exit status
make: *** [usb_modeswitch] Error 1
[linuxidc@localhost usb-modeswitch-1.2.6]$

“incompatible”库和这个有冲突。建议使用。1.2.6一下的版本。

把usb-modeswitch-data-20130607下的usb_modeswitch.d中的所有文件都拷贝到开发板的etc/usb_modeswitch.d/目录:

[linuxidc@localhost usbmode]$ cd usb-modeswitch-data-20130607
[linuxidc@localhost usb-modeswitch-data-20130607]$ ls
40-usb_modeswitch.rules  ChangeLog  COPYING  gen-rules.tcl  Makefile  README  usb_modeswitch.d
[linuxidc@localhost usb-modeswitch-data-20130607]$ tar cjf usb_modeswitch.d.tar.bz2 usb_modeswitch.d/
[linuxidc@localhost usb-modeswitch-data-20130607]$ ls
40-usb_modeswitch.rules  ChangeLog  COPYING  gen-rules.tcl  Makefile  README  usb_modeswitch.d  usb_modeswitch.d.tar.bz2
[linuxidc@localhost usb-modeswitch-data-20130607]$ cp usb_modeswitch.d.tar.bz2 /tftp/
[linuxidc@localhost usb-modeswitch-data-20130607]$

把usb_modeswitch下载到开发板的/usr/sbin目录下,把usb_modeswitch.d下载开发板到/etc/目录下:

/usr/sbin >: tftp -gr usb_modeswitch 192.168.1.3
usb_modeswitch      100% |*******************************|  390k  0:00:00 ETA

/etc >: tftp -gr usb_modeswitch.d.tar.bz2 192.168.1.3
usb_modeswitch.d.tar 100% |*******************************|  8741  0:00:00 ETA

/etc >: tar xjf usb_modeswitch.d.tar.bz2

三、pppd和chat

交叉编译好工作源代码ppp-2.4.4,得到pppd和chat,解压源代码包,进入目录,进行交叉编译:

[linuxidc@localhost fulinux]$ mkdir ppp
[linuxidc@localhost fulinux]$ cd ppp/
[linuxidc@localhost ppp]$ wget ftp://ftp.samba.org/pub/ppp/ppp-2.4.4.tar.gz

[linuxidc@localhost ppp]$ tar zxf ppp-2.4.4.tar.gz
[linuxidc@localhost ppp]$ cd ppp-2.4.4

[linuxidc@localhost ppp-2.4.4]$ ./configure

[linuxidc@localhost chat]$ linux
[linuxidc@localhost chat]$ vim chat.c

1168    if (timeout_next) {
1169    timeout_next = 0;
1170   
1171    s = clean(s,0); /* add by fulinux */
1172   
1173    timeout = atoi(s);
1174   
1175    free(s);    /* add by fulinux */
1176   
1177    if (timeout <= 0)

[linuxidc@localhost chat]$ vim Makefile

INSTALL= install
CC=/opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-gcc #add by fulinux
all:    chat
chat:  chat.o
    $(CC) -static -o chat chat.o #add by fulinux

[linuxidc@localhost chat]$ cd ../pppd
[linuxidc@localhost pppd]$ vim auth.c

1316    ao->neg_upap = !refuse_pap /*&& (passwd[0] != 0 || get_pap_passwd(NULL))*/; /* add by fulinux*/

[linuxidc@localhost pppd]$ vim Makefile

 33 CC = /opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-gcc # add by fulinux

 46#MPPE=y

 51#FILTER=y

 68#PLUGIN=y

[linuxidc@localhost pppd]$ cd ..
[linuxidc@localhost ppp-2.4.4]$ make

make[1]: Leaving directory `/usr/local/src/linuxidc/fulinux/ppp/ppp-2.4.4/pppdump’
[linuxidc@localhost ppp-2.4.4]$ cd chat/
[linuxidc@localhost chat]$ ls
chat chat.8  chat.c  chat.o  Makefile  Makefile.linux  Makefile.sol2
[linuxidc@localhost chat]$ file chat
chat: ELF 32-bit LSB executable, ARM, version 1 (SYSV), statically linked, not stripped

[linuxidc@localhost chat]$ cd ..

[linuxidc@localhost ppp-2.4.4]$ cd pppd
[linuxidc@localhost pppd]$ file pppd
pppd: ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), not stripped
[linuxidc@localhost pppd]$

将交叉编译出来的这两个应用程序chat和pppd拷贝到开发板 /usr/sbin目录下,更改其属性为可执行文件。

[linuxidc@localhost chat]$ cp chat /tftp/

[linuxidc@localhost pppd]$ cp pppd /tftp/

在开发板中操作:

~ >: cd usr/sbin/
/usr/sbin >: tftp -gr chat 192.168.1.3
chat                100% |*******************************|  147k  0:00:00 ETA
/usr/sbin >: tftp -gr pppd 192.168.1.3
pppd                100% |*******************************|  621k  0:00:00 ETA
/usr/sbin >: chmod a+x chat
/usr/sbin >: chmod a+x pppd

配置拨号的脚文件

拨号上网需要的配置文件有3个:

wcdma,wcdma-chat-connect,wcdma-chat-disconnect(存放位置是开发板的/etc/ppp/peers)。

~ >: mkdir -p /etc/ppp/peers/

wcdma配置文件内容

# /etc/ppp/peers/wcdma
# This is pppd script for China liantong
# Usage: root>pppd call cdma

hide-password

noauth

connect ‘/usr/sbin/chat -s -v -f /etc/ppp/peers/wcdma-chat-connect’

disconnect ‘/usr/sbin/chat -s -v -f /etc/ppp/peers/wcdma-chat-disconnect’

debug

/dev/ttyUSB2

115200

defaultroute

noipdefault

novj

novjccomp

noccp

ipcp-accept-local

ipcp-accept-remote

local

lock

dump

nodetach

user”card”

password”card”

crtscts

remotename 3gppp

ipparam 3gppp

usepeerdns

wcdma-chat-connect配置文件内容

ABORT “BUSY”
ABORT “NO CARRIER”
ABORT “NO DIALTONE”
ABORT “ERROR”
ABORT “NO ANSWER”
TIMEOUT 120
“” AT
OK \rATZ
OK \rAT+CGDCONT=1,”IP”,”3gnet”,,0,0
OK-AT-OK ATDT*99#
CONNECT \d\c

wcdma-chat-disconnect配置文件内容

ABORT “ERROR”

ABORT “NO DIALTONE”

SAY “INSending break to the modem\n”

“”\k”

“”+++ATH”

SAY “\nGood bye\n”

还要添加一个域名解析的文件:

nameserver 4.2.2.2

nameserver 8.8.8.8

将上面的四个文件拷贝到/tftp目录下。

并下载到开发板相应的目录中去:

因为

lrwxrwxrwx    1 root    root            29 Apr 21  2013 resolv.conf -> /apps/etc/network/resolv.conf

所以:

/apps/etc/network >: tftp -gr resolv.conf 192.168.1.3
~ >: cd etc/ppp/peers/
/etc/ppp/peers >: ls
/etc/ppp/peers >: tftp -gr wcdma 192.168.1.3
/etc/ppp/peers >: tftp -gr wcdma-chat-disconnect 192.168.1.3
/etc/ppp/peers >: tftp -gr wcdma-chat-connect 192.168.1.3
/etc/ppp/peers >: ls
wcdma                  wcdma-chat-connect    wcdma-chat-disconnect

到这里PPP 移植就完成了。

到了这里大部分工作已经完成了,但是我们的开发板依然不能拨号,还需进一步修改和添加配置文件。

当我们的MF626插件中兴WCDMA USB调制解调器,Linux内核识别作为一个cd – rom。

scsi0 :usb-storage 1-1.4:1.0

scsi 0:0:0:0: CD-ROM            ZTE      USB SCSI CD-ROM  2.31 PQ: 0 ANSI: 2

现在我们需要使用usb_modeswitch切换3 g USB调制解调器来调制解调器(USB转换为seiral),对于usb_modeswitch使用libusb,libusb依赖于USB文件系统。所以我们在使用usb_modeswitch之前必须挂在usbfs,否则它不能检测USB设备。

添加中兴WCDMA现代usb_modeswitchMF626配置文件:

~ >: cd apps/
/apps >: vi zte_mf626.conf
#ZTE devices
 
DefaultVendor = 0x19d2
 
DefaultProduct= 0x2000
 
TargetVendor  = 0x19d2
 
TargetProdduct= “0001,0002,0015,0016,0017,0031,0052,0055,0063,0064,0066,0091,0108,0117,0128,0157,2002,2003”
 
 
MessageContent = “5553424312345678000000000000061e000000000000000000000000000000”
 
MessageContent2 = “5553424312345679000000000000061b000000020000000000000000000000”
 
MessageContent3 = “55534243123456702000000080000c85010101180101010101000000000000”
 
NeedResponse=1
~
/apps >: ls
etc            zte_mf626.conf
/apps >: usb_modeswitch -c /apps/zte_mf626.conf

Looking for target devices …
 No devices in target mode or class found
Looking for default devices …
 No devices in default mode found. Nothing to do. Bye.

这是因为usbfs文件系统没有挂在起来,所以使用usb_modeswitch之前要挂载它:
/apps >: mount -tusbfs usbfs /proc/bus/usb/

/apps >: mount
rootfs on / type rootfs (rw)
/dev/root on / type jffs2 (rw,relatime)
proc on /proc type proc (rw,relatime)
usbfs on /proc/bus/usb type usbfs (rw,relatime)
tmpfs on /dev type tmpfs (rw,relatime)
ramfs on /tmp type ramfs (rw,relatime)
sysfs on /sys type sysfs (rw,relatime)
devpts on /dev/pts type devpts (rw,relatime,mode=600)
ubi7:apps on /apps type ubifs (rw,sync,noatime)
/dev/mtdblock8 on /data type jffs2 (rw,sync,noatime)
/apps >:

~ >: ls proc/bus/usb/
001      devices

这样我usbfs就挂载起来了,但是如果重启开发板后,还得重新挂载,为了每次启动系统都能自动挂载,我们进行如下修改:

~ >: cd etc/

/etc >: vim fstab
# /etc/fstab: static file system information.
#
# <file system> <mount pt>    <type>  <options>        <dump> <pass>
/dev/root      /              ext2    rw,noauto        0      1
proc            /proc          proc    defaults          0      0
usbfs          /proc/bus/usb  usbfs    defaults          0      0
tmpfs          /dev          tmpfs    defaults          0      0
ramfs          /tmp          ramfs    defaults          0      0
sysfs          /sys          sysfs    defaults          0      0
~

现在的话就可以看到如下信息了:

~ >: usb_modeswitch -c /apps/zte_mf626.conf

Looking for target devices …
 No devices in target mode or class found
Looking for default devices …
  found matching product ID
  adding device
 Found device in default mode, class or configuration (1)
Accessing device 005 on bus 001 …
Getting the current device configuration …
 OK, got current device configuration (1)
Using interface number 0
Using endpoints 0x01 (out) and 0x81 (in)
Inquiring device details; driver will be detached …
Looking for active driver …
 OK, driver found; name unknown, limitation of libusb1
 OK, driver “unkown” detached

SCSI inquiry data (for identification)
————————-
  Vendor String: ZTE   
  Model String: USB SCSI CD-ROM
Revision String: 2.31
————————-

USB description data (for identification)
usb 1-1.1: usbfs: process 688 (usb_modeswitch) did not claim interface 0 before use
————————-
Manufacturer: ZTE,Incorporated
    Product: ZTE CDMA Technologies MSM
  Serial No.: 1234567890ABCDEF
————————-
Setting up communication with interface 0
Using endpoint 0x01 for message sending …
Trying to send message 1 to endpoint 0x01 …
 OK, message successfully sent
Reading the response to message 1 (CSW) …
 OK, response successfully read (13 bytes).
Trying to send message 2 to endpoint 0x01 …
 OK, message successfully sent
Reading the response to message 2 (CSW) …
 OK, response successfully read (13 bytes).
Trying to send message 3 to endpoint 0x01 …
 OK, message successfully sent
Reading the response to message 3 (CSW) …
 OK, response successfully read (0 bytes).
Resetting response endpoint 0x81
Resetting message endpoint 0x01
 Device is gone, skipping any further commands
-> Run lsusb to note any changes. Bye.

~ >: usb 1-1.1: USB disconnect, device number 5
usb 1-1.1: new full speed USB device number 6 using s3c2410-ohci
usb 1-1.1: New USB device found, idVendor=19d2, idProduct=0031
usb 1-1.1: New USB device strings: Mfr=2, Product=1, SerialNumber=3
usb 1-1.1: Product: ZTE CDMA Technologies MSM
usb 1-1.1: Manufacturer: ZTE,Incorporated
usb 1-1.1: SerialNumber: 1234567890ABCDEF
option 1-1.1:1.0: GSM modem (1-port) converter detected
usb 1-1.1: GSM modem (1-port) converter now attached to ttyUSB0
option 1-1.1:1.1: GSM modem (1-port) converter detected
usb 1-1.1: GSM modem (1-port) converter now attached to ttyUSB1
scsi3 : usb-storage 1-1.1:1.2
option 1-1.1:1.3: GSM modem (1-port) converter detected
usb 1-1.1: GSM modem (1-port) converter now attached to ttyUSB2
scsi 3:0:0:0: Direct-Access    ZTE      MMC Storage      2.31 PQ: 0 ANSI: 2
sd 3:0:0:0: Attached scsi generic sg0 type 0
sd 3:0:0:0: [sda] Attached SCSI removable disk

发送at命令:

~ >: microcom -s 115200 dev/ttyUSB2 (或者~ >: microcom -s 115200 dev/ttyUSB1)

at

OK

1,  查模块制造商:

at+cgmi
ZTE INCORPORATED

OK

2,  查GPRS模块型号:

at+cgmm
MF626

OK

3,  查模块版本:

at+cgmr
BD_TMOP673M3V1.0.1B07

OK

3,  查SIM卡是否在位:

at+cpin?
+CPIN: READY

OK

4,查GPRS模块信号强度,其中”,”前的数字为信号强度,如下面示例中的12为信号强度。

at+csq
+CSQ: 12,99

OK

若信号强度为99,则无效。我这里信号强度一般在20左右。

5,查SIM卡是否注册上网络,其中”,”后的值为SIM卡的注册状态,如下面示例中的1.

OK
at+creg?
+CREG: 0,5

OK
如果状态值为0,表示未注册;如果为1表示本地号码注册上;如果为2,表示正在搜索运营商注册,但没注册上;3表示拒绝注册;4,未知状态; 5, 漫游号码注册上。

6,查SIM卡运营商,如下面显示的”CHN-CUGSM”为中国联通的号码:

at+cops?
+COPS: 0,0,”China Mobile Communication Corp.”,0

OK
在UC864E模块上,使用AT+COPS?查询,则联通的号码将显示为”cmnet”,但在GTM900B/C, SIM5215上显示的是”CHN-CUGSM”. 中国移动的则为”China Mobile”,在现实的时候也有一些区别,例如在UC864E上中国移动显示为” China Mobile”,当中只有一个空格;而在GTM900B上则显示” China  Mobile”,当中有两个空格。但是这上面是China Mobile Communication Corp.

8, AT命令打电话,注意在拨的号码后面有个分号;

atd10086;

OK

 我不知道怎么通电话。

9,如果有电话到来时,则是串口上将收到RING字符串,这时我们可以使用ATA命令摘机,如果不想接听,可以使用ATH挂断;

 但是我没有接到RING。

10,在进行PPP拨号上网前,我们必须使用下面命令来设置APN:

中国移动:

AT+CGDCONT=1,”IP”,”cmnet”

OK

中国联通有两个APN:  uninet和3gnet, 如果给3G卡的话,可以设置APN为3gnet

AT+CGDCONT=1,”IP”,”uninet”

OK

AT+CGDCONT?

+CGDCONT:1,”IP”,”uninet”,”0.0.0.0″,0,0

OK

或设置APN为3gnet:

AT+CGDCONT=1,”IP”,”3gnet”

OK

AT+CGDCONT?

+CGDCONT:1,”IP”,”3gnet”,”0.0.0.0″,0,0

OK

短信相关命令:

设置短信格式为Text模式:

AT+CMGF=1 

OK

设置短信格式为PDU模式:

AT+CMGF=0

OK

设置短信中心号,一般不需要我们手动设置。

湖北联通的短信中心号设置如下:

AT+CSCA=”+8613010360500″

OK

湖北移动的短信中心号为:

AT+CSCA?

+CSCA: “+8613800270500”,145

OK

现在就可以进行拨号了:

如果遇到下面问题

/etc/ppp/peers >: pppd call wcdma
pppd: In file /etc/ppp/peers/wcdma: unrecognized option ‘user”card”‘

在文件wcdma中user和“card”中间有一个空格。

>:pppd call wcdma

pppdoptions in effect:

debug          # (from /etc/ppp/peers/wcdma)

nodetach                # (from /etc/ppp/peers/wcdma)

dump            # (from /etc/ppp/peers/wcdma)

noauth          # (from /etc/ppp/peers/wcdma)

usercard              # (from/etc/ppp/peers/wcdma)

password??????        # (from/etc/ppp/peers/wcdma)

remotename3gppp                # (from/etc/ppp/peers/wcdma)

/dev/ttyUSB2            # (from /etc/ppp/peers/wcdma)

115200          # (from /etc/ppp/peers/wcdma)

lock            # (from /etc/ppp/peers/wcdma)

connect/usr/sbin/chat -s -v -f /etc/ppp/peers/wcdma-chat-connect              # (from /etc/ppp/peers/wcdma)

disconnect/usr/sbin/chat -s -v -f /etc/ppp/peers/wcdma-chat-disconnect        # (from /etc/ppp/peers/wcdma)

crtscts        # (from /etc/ppp/peers/wcdma)

local          # (from /etc/ppp/peers/wcdma)

hide-password          # (from /etc/ppp/peers/wcdma)

novj            # (from /etc/ppp/peers/wcdma)

novjccomp              # (from /etc/ppp/peers/wcdma)

ipcp-accept-local              # (from /etc/ppp/peers/wcdma)

ipcp-accept-remote              # (from /etc/ppp/peers/wcdma)

ipparam3gppp          # (from/etc/ppp/peers/wcdma)

noipdefault            # (from /etc/ppp/peers/wcdma)

defaultroute            # (from /etc/ppp/peers/wcdma)

usepeerdns              # (from /etc/ppp/peers/wcdma)

noccp          # (from /etc/ppp/peers/wcdma)

abort on(BUSY)

abort on(NO CARRIER)

abort on(NO DIALTONE)

abort on(ERROR)

abort on(NO ANSWER)

timeoutset to 120 seconds

send(AT^M)

expect(OK)

AT^M^M

OK

 — got it

send(^MATZ^M)

expect(OK)

^M

ATZ^M^M

OK

 — got it

send(^MAT+CGDCONT=1,”IP”,”cmnet”,,0,0^M)

expect(OK)

^M

AT+CGDCONT=1,”IP”,”cmnet”,,0,0^M^M

OK

 — got it

send(ATDT*99#^M)

expect(CONNECT)

^M

ATDT*99#^M^M

CONNECT

 — got it

send (\d)

Serialconnection established.

usingchannel 1

Usinginterface ppp0

Connect:ppp0 <–> /dev/ttyUSB2

sent [LCPConfReq id=0x1 <asyncmap 0x0> <magic 0xfb2b5aaa> <pcomp><accomp>]

rcvd [LCPConfReq id=0x0 <asyncmap 0x0> <auth chap MD5> <magic0x172b914> <pcomp> <accomp>]

sent [LCPConfAck id=0x0 <asyncmap 0x0> <auth chap MD5> <magic0x172b914> <pcomp> <accomp>]

rcvd [LCPConfAck id=0x1 <asyncmap 0x0> <magic 0xfb2b5aaa> <pcomp><accomp>]

rcvd [LCPDiscReq id=0x1 magic=0x172b914]

rcvd[CHAP Challenge id=0x1 <bcbf3cbe363150861c15cffae8617331>, name =”UMTS_CHAP_SRVR”]

sent[CHAP Response id=0x1 <6fcce180826b52be7803fc7a4b601de5>, name = “card”]

rcvd[CHAP Success id=0x1 “”]

CHAPauthentication succeeded

CHAPauthentication succeeded

sent[IPCP ConfReq id=0x1 <addr 0.0.0.0><ms-dns1 0.0.0.0> <ms-dns3 0.0.0.0>]

rcvd[IPCP ConfNak id=0x1 <ms-dns1 10.11.12.13><ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins10.11.12.14>]

sent[IPCP ConfReq id=0x2 <addr 0.0.0.0><ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14>]

rcvd[IPCP ConfReq id=0x0]

sent[IPCP ConfNak id=0x0 <addr 0.0.0.0>]

rcvd[IPCP ConfNak id=0x2 <addr 10.218.148.212> <ms-dns1 211.137.58.20><ms-dns3 211.136.20.203>]

sent[IPCP ConfReq id=0x3 <addr 10.218.148.212> <ms-dns1 211.137.58.20><ms-dns3 211.136.20.203>]

rcvd[IPCP ConfReq id=0x1]

sent[IPCP ConfAck id=0x1]

rcvd[IPCP ConfAck id=0x3 <addr 10.218.148.212> <ms-dns1 211.137.58.20><ms-dns3 211.136.20.203>]

Could notdetermine remote IP address: defaulting to 10.64.64.64

local  IP address 10.218.148.212

remote IPaddress 10.64.64.64

primary  DNS address 211.137.58.20

secondaryDNS address 211.136.20.203

这样虽然拨号成功,但是它是在前台运行的,现在我们不能进行其他的任何操作,以前前台被它占领了,所以我们用pppd call wcdma $这个命令让它在后台运行,这样我们就可以在前台进行其他的操作了。

/etc/ppp/peers >: pppd call wcdma &
pppd options in effect:
debug          # (from /etc/ppp/peers/wcdma)
nodetach                # (from /etc/ppp/peers/wcdma)
dump            # (from /etc/ppp/peers/wcdma)
noauth          # (from /etc/ppp/peers/wcdma)
user card              # (from /etc/ppp/peers/wcdma)
password ??????        # (from /etc/ppp/peers/wcdma)
remotename 3gppp                # (from /etc/ppp/peers/wcdma)
/dev/ttyUSB2            # (from /etc/ppp/peers/wcdma)
115200          # (from /etc/ppp/peers/wcdma)
lock            # (from /etc/ppp/peers/wcdma)
connect /usr/sbin/chat -s -v -f /etc/ppp/peers/wcdma-chat-connect              # (from /etc/ppp/peers/wcdma)
disconnect /usr/sbin/chat -s -v -f /etc/ppp/peers/wcdma-chat-disconnect        # (from /etc/ppp/peers/wcdma)
crtscts        # (from /etc/ppp/peers/wcdma)
local          # (from /etc/ppp/peers/wcdma)
hide-password          # (from /etc/ppp/peers/wcdma)
novj            # (from /etc/ppp/peers/wcdma)
novjccomp              # (from /etc/ppp/peers/wcdma)
ipcp-accept-local              # (from /etc/ppp/peers/wcdma)
ipcp-accept-remote              # (from /etc/ppp/peers/wcdma)
ipparam 3gppp          # (from /etc/ppp/peers/wcdma)
noipdefault            # (from /etc/ppp/peers/wcdma)
defaultroute            # (from /etc/ppp/peers/wcdma)
usepeerdns              # (from /etc/ppp/peers/wcdma)
noccp          # (from /etc/ppp/peers/wcdma)
abort on (BUSY)
abort on (NO CARRIER)
abort on (NO DIALTONE)
abort on (ERROR)
abort on (NO ANSWER)
timeout set to 120 seconds
send (AT^M)
expect (OK)
AT^M^M
OK
 — got it

send (^MATZ^M)
expect (OK)
^M
ATZ^M^M
OK
 — got it

send (^MAT+CGDCONT=1,”IP”,”cmnet”,,0,0^M)
expect (OK)
^M
AT+CGDCONT=1,”IP”,”cmnet”,,0,0^M^M
OK
 — got it

send (ATDT*99#^M)
expect (CONNECT)
^M
ATDT*99#^M^M
CONNECT
 — got it

send (\d)
Serial connection established.
using channel 4
Using interface ppp0
Connect: ppp0 <–> /dev/ttyUSB2
sent [LCP ConfReq id=0x1 <asyncmap 0x0> <magic 0xa913b970> <pcomp> <accomp>]
rcvd [LCP ConfReq id=0x0 <asyncmap 0x0> <auth chap MD5> <magic 0x159ffde> <pcomp> <accomp>]
sent [LCP ConfAck id=0x0 <asyncmap 0x0> <auth chap MD5> <magic 0x159ffde> <pcomp> <accomp>]
rcvd [LCP ConfAck id=0x1 <asyncmap 0x0> <magic 0xa913b970> <pcomp> <accomp>]
rcvd [LCP DiscReq id=0x1 magic=0x159ffde]
rcvd [CHAP Challenge id=0x1 <3a9d31cd14b44974b0c8cd921ce63204>, name = “UMTS_CHAP_SRVR”]
sent [CHAP Response id=0x1 <1d26db27eacd007feabbdb56426234b6>, name = “card”]
rcvd [CHAP Success id=0x1 “”]
CHAP authentication succeeded
CHAP authentication succeeded
sent [IPCP ConfReq id=0x1 <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns3 0.0.0.0>]
rcvd [IPCP ConfNak id=0x1 <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0x2 <addr 0.0.0.0> <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14>]
rcvd [IPCP ConfNak id=0x2 <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0x3 <addr 0.0.0.0> <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14>]
rcvd [IPCP ConfNak id=0x3 <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0x4 <addr 0.0.0.0> <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14>]
rcvd [IPCP ConfNak id=0x4 <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0x5 <addr 0.0.0.0> <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14>]
rcvd [IPCP ConfNak id=0x5 <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0x6 <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0x6 <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0x7 <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0x7 <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0x8 <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0x8 <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0x9 <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0x9 <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0xa <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0xa <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0xb <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0xb <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0xc <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0xc <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0xd <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0xd <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0xe <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0xe <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0xf <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0xf <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0x10 <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0x10 <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0x11 <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0x11 <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0x12 <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0x12 <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0x13 <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0x13 <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0x14 <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0x14 <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0x15 <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0x15 <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0x16 <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0x16 <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0x17 <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0x17 <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0x18 <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0x18 <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0x19 <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0x19 <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0x1a <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0x1a <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0x1b <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0x1b <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0x1c <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0x1c <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0x1d <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0x1d <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0x1e <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0x1e <ms-dns1 10.11.12.13> <ms-dns3 10.11.12.14> <ms-wins 10.11.12.13> <ms-wins 10.11.12.14>]
sent [IPCP ConfReq id=0x1f <addr 0.0.0.0>]
rcvd [IPCP ConfReq id=0x0]
sent [IPCP ConfNak id=0x0 <addr 0.0.0.0>]
rcvd [IPCP ConfNak id=0x1f <addr 10.146.208.148>]
sent [IPCP ConfReq id=0x20]
rcvd [IPCP ConfReq id=0x1]
sent [IPCP ConfAck id=0x1]
rcvd [IPCP ConfNak id=0x20 <addr 10.146.208.148>]
sent [IPCP ConfReq id=0x21 <addr 10.146.208.148>]
rcvd [IPCP ConfAck id=0x21 <addr 10.146.208.148>]
Could not determine remote IP address: defaulting to 10.64.64.64
local  IP address 10.146.208.148
remote IP address 10.64.64.64
primary  DNS address 10.11.12.13
secondary DNS address 10.11.12.14

/etc/ppp/peers >:

三、          现在我们就来测试一下,看看能不能上网

ping 域名服务器4.2.2.2

/etc/ppp/peers >: ping 4.2.2.2 -I ppp0
PING 4.2.2.2 (4.2.2.2): 56 data bytes
64 bytes from 4.2.2.2: seq=0 ttl=50 time=2524.370 ms
64 bytes from 4.2.2.2: seq=1 ttl=50 time=1520.146 ms
64 bytes from 4.2.2.2: seq=2 ttl=50 time=693.452 ms
64 bytes from 4.2.2.2: seq=3 ttl=50 time=629.477 ms
64 bytes from 4.2.2.2: seq=4 ttl=50 time=644.438 ms
64 bytes from 4.2.2.2: seq=5 ttl=50 time=640.548 ms
64 bytes from 4.2.2.2: seq=6 ttl=50 time=632.466 ms
64 bytes from 4.2.2.2: seq=7 ttl=50 time=587.508 ms
64 bytes from 4.2.2.2: seq=8 ttl=50 time=565.546 ms
64 bytes from 4.2.2.2: seq=9 ttl=50 time=557.537 ms
64 bytes from 4.2.2.2: seq=10 ttl=50 time=554.518 ms

— 4.2.2.2 ping statistics —
11 packets transmitted, 11 packets received, 0% packet loss
round-trip min/avg/max = 554.518/868.182/2524.370 ms
/etc/ppp/peers >:

可以。

再ping一下百度网:

/etc/ppp/peers >: ping www.baidu.com -I ppp0
PING www.baidu.com (220.181.111.148): 56 data bytes
64 bytes from 220.181.111.148: seq=0 ttl=49 time=934.383 ms
64 bytes from 220.181.111.148: seq=1 ttl=49 time=391.010 ms
64 bytes from 220.181.111.148: seq=2 ttl=49 time=345.984 ms
64 bytes from 220.181.111.148: seq=3 ttl=49 time=301.072 ms
64 bytes from 220.181.111.148: seq=4 ttl=49 time=915.210 ms
64 bytes from 220.181.111.148: seq=5 ttl=49 time=390.039 ms
64 bytes from 220.181.111.148: seq=6 ttl=49 time=585.136 ms

— www.baidu.com ping statistics —
8 packets transmitted, 7 packets received, 12% packet loss
round-trip min/avg/max = 301.072/551.833/934.383 ms
/etc/ppp/peers >:

略有丢包。

最后登录一下水木年华bbs

ARM Llinux系统移植3G拨号上网收发短信

更多详情见请继续阅读下一页的精彩内容: http://www.linuxidc.com/Linux/2016-03/129579p2.htm

一、发送text格式的短信

给联通发text格式的短信:

~ >: microcom -s 115200 /dev/ttyUSB1

at

OK

设置短信格式为Text模式:

at+cmgf=1

OK

at+cmgs=”+861300711**** “

输入发送的内容:

> hello        (内容写完后按一下ctrl + z发送)                                     

+CMGS: 48

OK

给电信发text格式的短信:

~ >: microcom -s 115200 /dev/ttyUSB1

at

OK

设置短信格式为Text模式:

at+cmgf=1
OK

at+cmgs=”+861532736**** “

设置短信格式为Text模式:

> hello    (内容写完后按一下ctrl + z发送)

+CMGS: 48

二、发送PDU格式的短信

接收号码:+8613007110996
短信内容:工作愉快!
武汉中心号码:+8613800270500

1、短信中心号码处理:用字符串 addr 表示
a、将短信息中心号码去掉+号,看看长度是否为偶数,如果不是,最后添加F
    即 addr = “+8613800100500”
    => addr = “8613800270500F”
b、将奇数位和偶数位交换。
    => addr = “683108200705F0”
c、将短信息中心号码前面加上字符91,91是国际化的意思
    => addr = “91683108200705F0”
d、算出 addr 长度,结果除2,格式化成2位的16进制字符串,16 / 2 = 8 => “08”,并放到addr前面去。
    => addr = “0891683108200705F0”

2、手机号码处理:用字符串 phone
a、将手机号码去掉+号,看看长度是否为偶数,如果不是,最后添加F
    即 phone = “+8613007110996”
    => phone =  “8613007110996F”
b、将手机号码奇数位和偶数位交换。
    => phone =  “683100170199F6”

3、短信息部分处理:用字符串 msg 表示
a、转字符串转换为Unicode代码,转换方法为:

      下载一个汉字Unicode编码转换器,当输入“工作愉快!” 时

     

    转换为的是十进制24037 20316 24841 24555 65281 ,再利用计算器五个一转换,例如24037转换为十六进制的5DE5,

    最终转换为的十六进制连起来就是5DE54F5C61095FEBFF01 (转换在linux里可用iconv函数实现。)

b、将 msg 长度除2,保留两位16进制数,即 5DE54F5C61095FEBFF01 = 20 / 2 => “0A”,再加上 msg
    => msg = “0A5DE54F5C61095FEBFF01”

4、组合
a、手机号码前加上字符串 11000D91(1100:固定,0D:手机号码的长度,不算+号,十六进制表示,91:发送到手机为91,发送到小灵通为81)
    即 phone = “11000D91” + phone
    => 11000D91683100170199F6
b、手机号码后加上 000800 和刚才的短信息内容,000800也写死就可以了
    即 phone = phone + “000800” + msg
    即 11000D91683100170199F6 + 000800 + 0A5DE54F5C61095FEBFF01
=> phone = 11000D91683109423346F90008000A5DE54F5C61095FEBFF01
c、phone 长度除以2,格式化成2位的十进制数
    即 11000D91683100170199F60008000A5DE54F5C61095FEBFF01 => 50位 / 2 => 25

5、note = addr+phone ==> 0891683108200705F011000D91683100170199F60008000A5DE54F5C61095FEBFF01

5、所以要发送的内容为
发:AT
收:OK
发:AT+CMGF=0
收:OK
发:AT+CMGS=25
收:>
发:note —>  //”—>”为发送符(ctrl+z,十六进制0x1A)
收:+CMGS: 50

        OK

6、如果返回不是ERROR,恭喜你,发送成功了。如果返回+CMS ERROR: 304,说明格式还是有问题,要检查一下。

一、用text查看模式
下面的“发”是指我敲的命令,“收”是指回车后显示的信息包括其他接收的信息。
~ >: microcom -s 115200 /dev/ttyUSB1
发:at
收:OK

设置成文本模式读:
发:at+cmgf=1

收:OK

将信息保存在SIM卡中:

发:at+cpms=”SM”,”SM”,”SM”
收:+CPMS: 0,50,0,50,0,50

收:OK

等待接收短信。。。。。。

收到了会有这个提示信息:
收:+CMTI: “SM”,0

查看信息:
发:at+cmgl=”rec unread”
收:+CMGL: 0,”REC UNREAD”,”+8613135699576″,,”13/07/14,22:11:10+32″
收:4F60597D
经过一个unicode转换器4F60597D ===>你好

收:OK

二、PDU模式查看

下面取网上一个例子

假设终端收到的短信为:
+CMT: ,24

0891683108200205F0240D91683157121468F0000860800331220000044F60597D

现在的任务是逆编码,从而获得信息。
下面分析一下接收到的PDU数据:

(1)08 //信息中心号码的长度,将91+683108200205F0的长度除2,格式化成2位的16进制字符串所得

(2)91 //短信中心号码类型

(3)683108200205F0 //短信中心号码,转换方法前面有提到

    ==>+8613800220500

(4)24 //TPDU头字节

(5)0D //发送源号码长度,8613752141860的长度格式化为2位16进制所得

(6)91 //发送源号码类型

(7)683157121468F0 //发送源号码,发送端的号码为:
   
    ==>+8613752141860
   

(8)00 //协议标识 TP—PID

(9)08 //数据编码方案,08:中文编码,00为英文或数字,Bit No.7与Bit No.6

(10)608003312200 //日期时间,奇偶互换:06-08-30 13:22:00,有论坛上写接收到的是026080……就是前面有’02’,表示2006-08…但是我用不同的手机发送短信过来接收到的都是06,无法取得2006,不知道是发送方手机设置的问题还是哪里的问题,还在研究中.

(11)00 //时区

(12)04 //用户数据长度TP-UDL(TP-User-Data-Length),4F60597D的长度除2格式化为2位16进制数所得

 (13) 4F60597D //”你好”的UNICODE码:

在提供一个例子:

PDU模式查看

终端收到的短信提示信息:
+CMTI: “SM”,2

+CMGL: 2,0,,28
0891683108200705F4240D91685123377660F0000831704132305423084F60597D00200020

现在的任务是逆编码,从而获得信息。
下面分析一下接收到的PDU数据:

(1)08 //信息中心号码的长度,将91+683108200205F0的长度除2,格式化成2位的16进制字符串所得

(2)91 //短信中心号码类型

(3)683108200705F4 //短信中心号码,转换方法前面有提到

    ==>+8613800270504

(4)24 //TPDU头字节

(5)0D //发送源号码长度,8613752141860的长度格式化为2位16进制所得

(6)91 //发送源号码类型

(7)685123377660F0 //发送源号码,发送端的号码为:
   
    ==>+8615327367060
   

(8)00 //协议标识 TP—PID

(9)08 //数据编码方案,08:中文编码,00为英文或数字,Bit No.7与Bit No.6

(10)317041323054 //日期时间,奇偶互换:13-07-14 23:03:45,有论坛上写接收到的是026080……就是前面有’02’,表示2006-08…但是我用不同的手机发送短信过来接收到的都是06,无法取得2006,不知道是发送方手机设置的问题还是哪里的问题,还在研究中.

(11)23 //时区

(12)08 //用户数据长度TP-UDL(TP-User-Data-Length),4F60597D的长度除2格式化为2位16进制数所得

 (13) 4F60597D00200020 //”你好  ”有两个空格的UNICODE码:

四、查看已读信息
OK
at+cmgl=0
OK
at+cmgf=1
OK
at+cmgl=”rec read”
+CMGL: 0,”REC READ”,”+8613135699576″,,”13/07/14,22:11:10+32″
4F60597D
+CMGL: 1,”REC READ”,”+8615327367060″,,”13/07/14,23:00:50+32″
hello.good  work.
+CMGL: 2,”REC READ”,”+8615327367060″,,”13/07/14,23:03:45+32″
4F60597D00200020

OK
at+cmgl=1
ERROR
at+cmgf=0
OK
at+cmgl=1
+CMGL: 0,1,,24
0891683108200705F6240D91683131659975F6000831704122110123044F60597D
+CMGL: 1,1,,35
0891683108200705F6240D91685123377660F000003170413200052311E8329BFD769DDF6F3208747FCBD72E
+CMGL: 2,1,,28
0891683108200705F4240D91685123377660F0000831704132305423084F60597D00200020

本文永久更新链接地址:http://www.linuxidc.com/Linux/2016-03/129579.htm

赞(0) 打赏
转载请注明出处:服务器评测 » ARM Llinux系统移植3G拨号上网收发短信
分享到: 更多 (0)

听说打赏我的人,都进福布斯排行榜啦!

支付宝扫一扫打赏

微信扫一扫打赏