1)国标推送过来的每一个目录可能有多个设备
2)每一个目录推送信息都需要进行200 OK回复
3)海康推送过来的目录总数可能跟实际的推送设备数量不一致(有的时候还把目录当作设备推送过来),需要设置一个超时接收的标志,目前超时60秒收取不到数据,说明接收完成
关键字段的描述:
1 CivilCode 行政区域的划分编码
2 ParentID 当前设备或者目录挂载的上一级目录的国标编码
3 DeviceID 可能是一个设备,或者是一个目录,需要根据是否存在一个ParentID编码跟DeviceID一致,来判断是否是设备或者目录,如果有一致的,肯定是目录
4 SumNum 每一次推送一条目录都会携带总数
5 Parental 当为设备时,是否有子设备(必选) 1 有, 0 没有,目前在对接海康的平台时候,发现同步的所有数据都是0,不符合标准规范
查询目录
1)发送目录查询请求
MESSAGE sip:35101000002997318110@35.241.211.110:5061 SIP/2.0
Via: SIP/2.0/UDP 192.168.0.10:5060;rport;branch=z9hG4bK192489696
From: <sip:44000000002020180329@192.168.0.10:5060>;tag=811373956
To: <sip:35101000002997318110@35.241.211.110:5061>
Call-ID: 1540337722
CSeq: 20 MESSAGE
Content-Type: Application/MANSCDP+xml
Max-Forwards: 70
User-Agent: eXosip/4.1.0
Content-Length: 204
<?xml version="1.0" encoding="gb2312" ?>
<Query>
<CmdType>Catalog</CmdType>
<SN>5</SN>
<DeviceID>35101000002997318110</DeviceID>
<StartTime>0</StartTime>
<EndTime>0</EndTime>
</Query>
2)接收到对方目录个数的回复报文
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.0.10:5060;branch=z9hG4bK192489696;received=35.241.246.10;rport=5060
Call-ID: 1540337722
From: <sip:44000000002020180329@192.168.0.10:5060>;tag=811373956
To: <sip:35101000002997318110@35.241.211.110:5061>;tag=772563ee2e054cd2812d2e23e2172400-1615445883534
CSeq: 20 MESSAGE
Content-Length: 0
MESSAGE sip:44000000002020180329@35.241.246.10:5060;transport=udp SIP/2.0
Via: SIP/2.0/UDP 35.241.211.110:5061;branch=z9hG4bK-373238-775d171575e6fdef4707dd4316d5b53d;X-HwDim=4
Call-ID: bf2825ab4e4053336a6e506e270a0d84@35.241.211.110
From: <sip:35101000002997318110@3510100000>;tag=9ab1ad68b947424c879b668b9ac5b698-1615445883538
To: <sip:44000000002020180329@4400000000>
CSeq: 1 MESSAGE
Max-Forwards: 70
Content-Length: 190
Content-Type: application/MANSCDP+xml
<?xml version="1.0" encoding="GB2312"?>
<Response>
<CmdType>Catalog</CmdType>
<SN>5</SN>
<DeviceID>35101000002997318110</DeviceID>
<Result>OK</Result>
<SumNum>0</SumNum>
</Response>
3)提供下海康平台例子
MESSAGE sip:33050000002000000012@41.228.8.60:7100 SIP/2.0
Via: SIP/2.0/UDP 41.230.75.1:5061;rport;branch=z9hG4bK2957606948
From: <sip:33050200002000000844@41.230.75.1:5061>;tag=2346286137
To: <sip:33050000002000000012@41.228.8.60:7100>
Call-ID: 2153272097
CSeq: 20 MESSAGE
Content-Type: Application/MANSCDP+xml
Max-Forwards: 70
User-Agent: eXosip/4.1.0
Content-Length: 150
<?xml version="1.0" encoding="gb2312" ?>
<Query>
<CmdType>Catalog</CmdType>
<SN>6</SN>
<DeviceID>33050000002000000012</DeviceID>
</Query>
SIP/2.0 200 OK
Via: SIP/2.0/UDP 41.230.75.1:5061;rport=5061;branch=z9hG4bK2957606948
From: <sip:33050200002000000844@41.230.75.1:5061>;tag=2346286137
To: <sip:33050000002000000012@41.228.8.60:7100>;tag=0887FA0A-A8F5-4346-943D-39D66C13C33E
Call-ID: 2153272097
CSeq: 20 MESSAGE
User-Agent: NcgV5.11.100
Content-Length: 0
MESSAGE sip:33050200002000000844@41.230.75.1:5061 SIP/2.0
Via: SIP/2.0/UDP 41.228.8.60:7100;rport;branch=z9hG4bK212ADCDF-06A1-E940-9E23-C373B06645F3
From: <sip:33050000002000000012@41.228.8.60:7100>;tag=A4665D54-B756-154D-9BEE-8D723DA1341B
To: <sip:33050200002000000844@41.230.75.1:5061>
Call-ID: AEF9A275-D6D9-D847-9BCF-1B0C044D9E67
CSeq: 5649200 MESSAGE
Max-Forwards: 70
User-Agent: NcgV5.11.100
Content-Length: 417
Content-Type: Application/MANSCDP+xml
<?xml version="1.0" encoding="GB2312"?>
<Response>
<CmdType>Catalog</CmdType>
<SN>6</SN>
<DeviceID>33050000002000000012</DeviceID>
<SumNum>18410</SumNum>
<DeviceList Num="1">
<Item>
<DeviceID>3305</DeviceID>
<Name>......</Name>
<ParentID>33050000002000000012</ParentID>
<CatalogType>0</CatalogType>
<OperateType>ADD</OperateType>
<CivilCode>33050000002000000012</CivilCode>
<Info />
</Item>
</DeviceList>
</Response>
SIP/2.0 200 OK
Via: SIP/2.0/UDP 41.228.8.60:7100;rport=7100;branch=z9hG4bK212ADCDF-06A1-E940-9E23-C373B06645F3
From: <sip:33050000002000000012@41.228.8.60:7100>;tag=A4665D54-B756-154D-9BEE-8D723DA1341B
To: <sip:33050200002000000844@41.230.75.1:5061>;tag=1453318000
Call-ID: AEF9A275-D6D9-D847-9BCF-1B0C044D9E67
CSeq: 5649200 MESSAGE
User-Agent: eXosip/4.1.0
Content-Length: 0
查询目录指令<CmdType>Catalog</CmdType>
查询结果<SumNum>0</SumNum>
订阅目录指令SUBSCRIBE sip:35101000002997318110@35.241.211.110:5061
SIP/2.0 200 OK
Via: SIP/2.0/UDP 35.241.211.110:5061;branch=z9hG4bK-373238-775d171575e6fdef4707dd4316d5b53d;X-HwDim=4
From: <sip:35101000002997318110@3510100000>;tag=9ab1ad68b947424c879b668b9ac5b698-1615445883538
To: <sip:44000000002020180329@4400000000>;tag=540338482
Call-ID: bf2825ab4e4053336a6e506e270a0d84@35.241.211.110
CSeq: 1 MESSAGE
User-Agent: eXosip/4.1.0
Content-Length: 0
SUBSCRIBE sip:35101000002997318110@35.241.211.110:5061 SIP/2.0
Via: SIP/2.0/UDP 192.168.0.10:5060;rport;branch=z9hG4bK28594425
From: <sip:44000000002020180329@192.168.0.10:5060>;tag=1263727637
To: <sip:35101000002997318110@35.241.211.110:5061>
Call-ID: 1480690566
CSeq: 20 SUBSCRIBE
Contact: <sip:44000000002020180329@192.168.0.10:5060>
Content-Type: Application/MANSCDP+xml
Max-Forwards: 70
User-Agent: eXosip/4.1.0
Expires: 3600
Event: presence
Content-Length: 204
<?xml version="1.0" encoding="gb2312" ?>
<Query>
<CmdType>Catalog</CmdType>
<SN>6</SN>
<DeviceID>35101000002997318110</DeviceID>
<StartTime>0</StartTime>
<EndTime>0</EndTime>
</Query>
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.0.10:5060;branch=z9hG4bK28594425;received=35.241.246.10;rport=5060
Call-ID: 1480690566
From: <sip:44000000002020180329@192.168.0.10:5060>;tag=1263727637
To: <sip:35101000002997318110@35.241.211.110:5061>;tag=eec60c77a8034ca09fd5c88ad9da6e7d-1615445883555
CSeq: 20 SUBSCRIBE
Expires: 3600
Contact: <sip:35101000002997318110@35.241.211.110:5061>
Content-Length: 157
Content-Type: application/MANSCDP+xml
<?xml version="1.0" encoding="GB2312"?>
<Response><CmdType>Catalog</CmdType><SN>6</SN><DeviceID>35101000002997318110</DeviceID><Result>OK</Result></Response>NOTIFY sip:44000000002020180329@35.241.246.10:5060;transport=udp SIP/2.0
Via: SIP/2.0/UDP 35.241.211.110:5061;branch=z9hG4bKtk4vq6piwwwkpiutxstk6663k
Call-ID: 1480690566
From: <sip:35101000002997318110@35.241.211.110:5061>;tag=eec60c77a8034ca09fd5c88ad9da6e7d-1615445883555
To: <sip:44000000002020180329@192.168.0.10:5060>;tag=1263727637
CSeq: 1 NOTIFY
Max-Forwards: 70
Contact: <sip:35101000002997318110@35.241.211.110:5061>
Event: presence
Subscription-State: active;expires=600;retry-after=1
Content-Length: 0
SIP/2.0 200 OK
Via: SIP/2.0/UDP 35.241.211.110:5061;branch=z9hG4bKtk4vq6piwwwkpiutxstk6663k
From: <sip:35101000002997318110@35.241.211.110:5061>;tag=eec60c77a8034ca09fd5c88ad9da6e7d-1615445883555
To: <sip:44000000002020180329@192.168.0.10:5060>;tag=1263727637
Call-ID: 1480690566
CSeq: 1 NOTIFY
User-Agent: eXosip/4.1.0
Content-Length: 0
MESSAGE sip:44000000002020180329@35.241.246.10:5060;transport=udp SIP/2.0
Via: SIP/2.0/UDP 35.241.211.110:5061;branch=z9hG4bK-373238-f79114399169f1aa613da74199c9f7ec;X-HwDim=4
Call-ID: 2f5f3e3f90f0cdddb5c6c216eab81e5b@35.241.211.110
From: <sip:35101000002997318110@3510100000>;tag=6ac552cdc128498cbd256250462345c1-1615445899114
To: <sip:44000000002020180329@4400000000>
CSeq: 1 MESSAGE
Max-Forwards: 70
Content-Length: 155
Content-Type: application/MANSCDP+xml
<?xml version="1.0" encoding="GB2312"?>
<Notify><CmdType>Keepalive</CmdType><SN>8</SN><DeviceID>35101000002997318110</DeviceID><Status>OK</Status></Notify>SIP/2.0 200 OK
Via: SIP/2.0/UDP 35.241.211.110:5061;branch=z9hG4bK-373238-f79114399169f1aa613da74199c9f7ec;X-HwDim=4
From: <sip:35101000002997318110@3510100000>;tag=6ac552cdc128498cbd256250462345c1-1615445899114
To: <sip:44000000002020180329@4400000000>;tag=2141818961
Call-ID: 2f5f3e3f90f0cdddb5c6c216eab81e5b@35.241.211.110
CSeq: 1 MESSAGE
User-Agent: eXosip/4.1.0
Content-Length: 0