交互流程
设备登录
设备向平台注册,平台对设备的身份进行认证。
端口:5682; payload数据格式:二进制application/octet-stream
• 服务解出注册报文中的imei,判断imei信息合法后,向设备返回2.01注册成功。
• 服务校验参数(Uri-Path、EPN等)失败,返回 4.00 Bad Request
• 服务校验imei信息非法,返回4.03 Forbidden
• 根据lifetime值设定设备生命周期,若未携带lt,则默认为86400s
接口说明:
Operation | CoAP Method | URI | Success | Failure |
Register | POST | /t/r?ep={endpointname}<={lifetime} | 2.01 Created | 4.00 Bad Request, 4.03 Forbidden |
CoAP-mapping:
Options:
参数名 | 参数位置 | 可选/必选 | 说明 |
Path | Uri-Path | 必选 | /t/r |
ep | Uri-Query | 必选(string) | Endpoint name: 1. {imei} 2. urn:imei:{imei} 3. urn:imei-imsi:{imei}-{imsi} |
lt | Uri-Query | 可选(long) | 生命周期,范围0~86400s。默认为86400 |
心跳保活
设备向平台更新周期。
• 端口:5682;平台每收到一条上行报文(数据上报、指令下发响应等),更新定时器
• Update报文为可选报文,仅用于刷新生命周期时长
• 服务首先解出注册报文中的lifetime,向设备返回2.04更新成功。
• 服务校验参数(Uri-Path等)失败或设备未在线,向设备返回4.04 Not Found:
Operation | CoAP Method | URI | Success | Failure |
Update | POST | /rd/{ep} | 2.04 Changed | 4.04 Not Found |
CoAP-mapping:
Options:
参数名 | 参数位置 | 可选/必选 | 说明 |
Location-Path | Uri-Path | 必选 | 设备更新时携带的设备标识 必须为: /rd/{ep} |
lt | Uri-Query | 可选(long) | 生命周期,范围0~86400s。默认为86400 |
设备登出
设备主动下线,AEP需要将设备的状态变更为离线。
端口:5682;
• 服务删除成功后,向设备返回2.02删除成功。
• 服务校验参数(Uri-Path等)失败或设备未在线,向设备返回4.04 Not Found
接口说明:
Operation | CoAP Method | URI | Success | Failure |
De-register | DELETE | /rd/{ep} | 2.02 Deleted | 4.00 Bad Request, 4.04 Not Found |
CoAP-mapping
Options:
参数名 | 参数位置 | 可选/必选 | 说明 |
Location-Path | Uri-Path | 必选 | 设备去注册时携带的设备标识必须为: /rd/{ep} |
数据上报
设备在平台完成注册以后,平台会自动订阅 path 资源 /t/d。订阅完成后,设备可主动上报资源信息,AEP负责将这些数据转换成统一格式,推送北向应用。
端口:5682; payload数据格式:二进制application/octet-stream
• 设备回复2.05content。token与订阅报文token保持一致。对于NON报文无需回复,CON报文回复空ACK。
• AEP根据token解析报文失败,返回RST
服务 > DEVICE 订阅接口说明 :
Operation | CoAP Method | Path | Success | Failure |
Observe | GET with Observe option = 0 | /t/d | 2.05 Content with Observe option=0 | 4.00 Bad Request, 4.04 Not Found, 4.05 Method Not Allowed |
DEVICE > 服务数据上报接口说明(token与observe保持一致)
Operation | CoAP Method | Path | Success | Failure |
Notify | Asynchronous Response 2.05 with Observe option = {id} | ACK Empty | RST |
CoAP-mapping
Payload:
参数 | 位置 | 必选/可选 | 类型 | 说明 |
Payload | Payload | 必选 | Binary | 上行业务数据 |
下行指令
端口:5682;payload数据格式:二进制application/octet-stream
指令下发write指令post请求,并回复ACK。
服务 > DEVICE指令下发接口说明:
操作 | CoAP 方法 | 参数 | 成功 | 失败 |
Write | POST Content Format | /t/d | ACK 2.04 changed | 4.00 Bad Request 4.04 Not Found 4.05 Method Not Allowed 4.15 Unsupported content format |
CoAP-mapping
Options:
参数名 | 参数位置 | 可选/必选 | 说明 |
Path | Uri-Path | 必选 | 设备传输业务数据时携带的设备标识 必须为: /t/d |
Payload:
参数 | 位置 | 必选/可选 | 类型 | 说明 |
payload | Payload | 必选 | Binary | 下行业务数据 |
DEVICE > 服务指令下发响应接口说明:
端口:5682;payload数据格式:二进制application/octet-stream
• 设备回复2.05content。token与订阅报文token保持一致。对于NON报文无需回复,CON报文回复空ACK。
• 服务校验参数token失败,返回 RST
Operation | CoAP Method | Path | Success | Failure |
Notify | Asynchronous Response 2.05 | ACK Empty | RST |
CoAP-mapping
Payload:
参数 | 位置 | 必选/可选 | 类型 | 说明 |
payload | Payload | 必选 | Binary | 响应业务数据 |