作为上级订阅科达平台移动设备位置(GB28181 - MobilePosition)

Published: 2020-11-28

Tags: gb28181

本文总阅读量

前些天作为上级平台对接了科达平台,接收移动设备的GPS数据,没什么复杂的地方,主要是国标文档对于移动设备位置订阅描述较少,我写的上级发送的消息也少了些参数,以下是收发信令的记录。

1)上级向下级发送订阅指令(MobilePosition)

SUBSCRIBE sip:36010000002007000000@3601000000 SIP/2.0 
From: <sip:36000000002000000000@3600000000>;tag=b2fd6d88-78091323-16a8-6b1d92-413bc6e0-6b1d92 
To: <sip:36010000002007000000@3601000000> 
Call-ID: b2729f80-78091323-16a8-6b1d92-d72279b-6b1d92@3600000000 
CSeq: 1 SUBSCRIBE 
Via: SIP/2.0/UDP 192.168.3.36:5060;rport;branch=z9hG4bK-6b1d92-a26b857d-701253e9 
Expires: 3600 
Event: Catalog 
User-Agent: DemoUA 
Max-Forwards: 70 
Contact: <sip:36000000002000000000@192.168.3.36:5060> 
Content-Type: application/MANSCDP+xml 
Content-Length: 160 

<?xml version="1.0" ?> 
<Query> 
<CmdType>MobilePosition</CmdType> 
<SN>2289</SN> 
<DeviceID>36010000002007000000</DeviceID> 
<Interval>5</Interval> 
</Query> 

2)下级返回内容(订阅成功)

SIP/2.0 200 OK 
From: <sip:36000000002000000000@3600000000>;tag=b2fd6d88-78091323-16a8-6b1d92-413bc6e0-6b1d92 
To: <sip:36010000002007000000@3601000000>;tag=134ebcb8-1b041323-16a8-eb4-1162a3b3-eb4 
Call-ID: b2729f80-78091323-16a8-6b1d92-d72279b-6b1d92@3600000000 
CSeq: 1 SUBSCRIBE 
Expires: 3600 
User-Agent: DemoUA 
Via: SIP/2.0/UDP 192.168.3.36:5060;rport=5060;branch=z9hG4bK-6b1d92-a26b857d-701253e9 
Contact: <sip:36010000002007000000@192.168.42.37:5060> 
Content-Length: 0 

当有GPS数据时,下级平台会通过 NOTIFY 发送过来

3)下级推送实时点位的数据

NOTIFY sip:36000000002000000000@192.168.3.36:5060 SIP/2.0 
From: <sip:36010000002007000000@3601000000>;tag=134ebcb8-1b041323-16a8-eb4-1162a3b3-eb4 
To: <sip:36000000002000000000@3600000000>;tag=b2fd6d88-78091323-16a8-6b1d92-413bc6e0-6b1d92 
Call-ID: b2729f80-78091323-16a8-6b1d92-d72279b-6b1d92@3600000000 
CSeq: 17 NOTIFY 
Via: SIP/2.0/UDP 192.168.42.37:5060;rport;branch=z9hG4bK-eb5-397477-409d4b19 
Subscription-State: active 
Event: Catalog 
User-Agent: DemoUA 
Max-Forwards: 70 
Contact: <sip:36010000002007000000@192.168.42.37:5060> 
Content-Type: application/MANSCDP+xml 
Content-Length: 413 

<?xml version="1.0" ?> 
<Notify> 
<CmdType>MobilePosition</CmdType> 
<SN>3635</SN> 
<DeviceID>36010000002007000000</DeviceID> 
<GpsItemList Num="1"> 
<Item> 
<DeviceID>36010000001324000297</DeviceID> 
<Time>2020-11-25T19:22:04+08:00</Time> 
<Longitude>127.646050000000002</Longitude> 
<Latitude>39.7861040000000017</Latitude> 
<Direction>0</Direction> 
<Altitude>0</Altitude> 
</Item> 
</GpsItemList> 
</Notify> 

4)上级向下级返回200OK表示接收到 NOTIFY 通知

SIP/2.0 200 OK 
From: <sip:36010000002007000000@3601000000>;tag=134ebcb8-1b041323-16a8-eb4-1162a3b3-eb4 
To: <sip:36000000002000000000@3600000000>;tag=b2fd6d88-78091323-16a8-6b1d92-413bc6e0-6b1d92 
Call-ID: b2729f80-78091323-16a8-6b1d92-d72279b-6b1d92@3600000000 
CSeq: 17 NOTIFY 
User-Agent: DemoUA 
Via: SIP/2.0/UDP 192.168.42.37:5060;rport=5060;branch=z9hG4bK-eb5-397477-409d4b19 
Contact: <sip:36000000002000000000@192.168.3.36:5060> 
Content-Length: 0 

基本的信令就是这样,如下是一些补充说明。

  1. 如果发送订阅平台没有回复消息,说明信令参数不对,依照上边的信令核对,我之前的错误是少发送了 Contact 字段。

  2. 还有个需要注意的地方,发送订阅的时候,消息体的 DeviceID 字段填写下级平台的 ID,而不是要订阅的具体设备 ID,下级平台会把分配给上级的相关设备的 GPS 点位信息推送过来。

  3. 本次订阅的信令适用于科达(DemoUA),其它平台兼容性未知。