Categories
CDMA

CDMA MMS PUSH 彩信通知

这里用的模组是 via威盛的cdma。首先,设置短信通知格式:
AT+CNMI=2,1

用一cdma手机给模组发一条彩信,由于URL 链接较长,网络可能会连续发送多条(常见是 2 条)Wap Push 短信,应根据长短信标准拼接后再做进一步处理。

+CMT:”RAM”,4,186,”000002fdea020602069966084006010008a8000310f130018e0460001880
35000c2820c0008008fc02e11a4189185c1c1b1a58d85d1a5bdb8bdd9b990b9dd85c0b9b5b5ccb
5b595cdcd859d9402d21ebe12320a61113daddde108ccd5b19149040236420da1d1d1c0e8bcbcc4
c0b8c8ccd0b8c4ccdcb8c4c4e8e0c0e0c0bddd85ccbd113daddde108ccd5b1914904022016040c0a8
c02243600c4cccce4c8e0dcc4c8d0d40228003060907031436470a01400e06040d32cc1080″

+CMT:”RAM”,5,63,”000002fdea020602069966084006014c082d000310eb9001130088001880
35000850020000806023808a3dc003060907031436470a01400e06040d32cc1080″

分析一下第一条:

teleserviceId为65002,就可以判断这时一条彩信通知,GSM的是通过分析端口号来做判断。进一步分析,提取到 TP_UD为:

00 03 10 06 A0 01 85 04 18 00 10 01 1F 80 5C 23 48 31 23 0B 83 83 63 4B 1B 0B A34B 7B 71 7B B373 21 73 BB 0B 81 73 6B 6B 99 6B 6B 2B 9B 9B 0B 3B 28 05 A4 3D 7C 24 64 14 C2 227B 5B BB C2 1199 AB 63 22 92 08 04 6C 84 1B 43 A3 A3 81 D1 79 79 89 81 71 91 99 A1 71 89 99 B971 89 89 D1 C181 C1 81 7B BB 0B 99 7A 22 7B 5B BB C2 11 99 AB 63 22 92 08 04 40 2C 08 18 15 18 04 48 6C 01 8999 99 C9 91 C1 B9 89 91 A1 A8 04 50

Wap push短信 PDU 中的 User data,按照短信标准解析,前面部分是 Header信息,如 Msgid、Num_field 等,后面部分是 Chari 内容。Chari 内容需要再进一步解析,中国电信的 Wap Push 短信PDU 中的 User data 里的 Chari 也分为两部分,前半部分是 Header 信息,类似于 User data的 Header 信息,后面部分数据才是 WDP 数据,需要按照 WDP 协议(Wireless Datagram Protocol)进行解析。

WDP

Msg Indetifier:
SUBPARAMETER_ID        8       0000000
SUBPARAM_LEN     8       00000011
MESSAGE_TYPE     4       0001 (Deliver) /0010 (Submit)
MESSAGE_ID  16     -Generated –
HEADER_IND  1       0
RESERVED      3       000

User Data
SUBPARAMETER_ID        8       00000001
SUBPARAM_LEN     8       Number of Octets in this Sub Parameter, not including SUBPARAMETER_ID and SUBPARAM_LEN
MESSAGE_ENCODING   5       00000
MESSAGE_TYPE     0       Ignored
NUM_FIELDS  8       This field shall be set to the number of characters included in this subparameter.

CHARi      Variable   Characters. This shall include NUM_FIELDS occurrences of this field
RESERVED      0-7   All zeroes used for padding.

(This field shall contain the number of bits required to make the entire subparameter an integer number of octets in length.

CHARi
MSG_TYPE       8       00000000
TOTAL_SEGMENTS         8       Total  number of segments
SEGMENT_NUMBER       8       The Segment Number
DATAGRAM      (NUM_FIELDS – 3)*8         Segmented WDP Datagram

WDP Datagram Segment
SOURCE_PORT       16     Source Port
DESTINATION_PORT       16     Destination Port(2948)
DATA        N*8  N bytes of Data from the Layer above WDP

按照上面的格式,解析CHARI就是

00 02 00 23 F0 0B 84 69 06 24 61 70 70 6C 69 63 61 74 69 6F 6E 2F 76 6E 64 2E 77 61 70 2E 6D 6D73 2D 6D 65 73 73 61 67 65 00 B4 87 AF 84 8C 82 98 44 4F 6B 77 78 42 33 35 6C 6452 41 00 8D 9083 68 74 74 70 3A 2F 2F 31 30 2E 32 33 34 2E 31 33 37 2E 31 31 3A 38 30 38 30 2F77 61 73 2F 444F 6B 77 78 42 33 35 6C 64 52 41 00 88 05 81 03 02 A3 00 89 0D 80 31 33 33 39 3238 37 31 32 3435 00 8A

00 MSG_TYPE
02 TOTAL_SEGMENTS
00 SEGMENT_NUMBER
23 F0 SOURCE_PORT
0B 84 DESTINATION_PORT
69 06 24 61 70 70 6C 69 63 61 74 69 6F 6E 2F 76 6E 64 2E 77 61 70 2E 6D 6D73 2D 6D 65 73 73 61 67 65 00 B4 87 AF 84 8C 82 98 44 4F 6B 77 78 42 33 35 6C 6452 41 00 8D 9083 68 74 74 70 3A 2F 2F 31 30 2E 32 33 34 2E 31 33 37 2E 31 31 3A 38 30 38 30 2F77 61 73 2F 444F 6B 77 78 42 33 35 6C 64 52 41 00 88 05 81 03 02 A3 00 89 0D 80 31 33 33 39 3238 37 31 32 3435 00 8A DATA

这是第一条的 DATA,同样分析第二条的 TP_UD为:

00 03 10 06 A0 01 0A 00 40 00 10 0C 04 70 11 47 B8

CHARI为

00 02 01 80 8E 02 28 F7

DATA为80 8E 02 28 F7

和第一条合并起来,那么DATA就是

69 06 24 61 70 70 6C 69 63 61 74 69 6F 6E 2F 76 6E 64 2E 77
61 70 2E 6D 6D73 2D 6D 65 73 73 61 67 65 00 B4 87 AF 84 8C 82 98 44 4F 6B 77 78 42 33 35 6C 6452 41 00 8D 9083 68 74 74 70 3A 2F 2F 31 30 2E 32 33 34 2E 31 33 37 2E 31 31 3A 38 30 38 30 2F77 61 73 2F 444F 6B 77 78 42 33 35 6C 64 52 41 00 88 05 81 03 02 A3 00 89 0D 80 31 33 33 39 3238 37 31 32 3435 00 8A80 8E 02 28 F7

61 70 70 6C 69 63 61 74 69 6F 6E 2F 76 6E 64 2E 7761 70 2E 6D 6D73 2D 6D 65 73 73 61 67 65 00 == application/vnd.wap.mms-message

B4 87: Push Flags: 87
AF 84: X-Wap-Application: 04
8C 82: X-Mms-Message-Type: m-notification-ind
98 44 4F 6B 77 78 42 33 35 6C 6452 41 00   Transaction-ID: DOkwxB35ldRA
8D 90 : X-Mms-mms-version : 1.0
83 68 74 74 70 3A 2F 2F 31 30 2E 32 33 34 2E 31 33 37 2E 31 31 3A 38 30 38 30 2F77 61 73 2F 444F 6B 77 78 42 33 35 6C 64 52 41 00  Content-location:http://10.234.137.11:8080/DOkwxB35ldRA

88 05 81 03 02 A3 00 expirty:
89 0D 80 31 33 33 39 3238 37 31 32 3435  From: 1339287124
8A80  message-class:”personal”
8E 02 28 F7  message-size:

注: B4,AF,8C,98 等,是高位加1(0x80)之后的content type.