设备订阅与应答

### 数据格式 <details><summary>设备端等待后台mqtt的请求</summary> <pre><code> { "deviceId":"xxxx", "function":"string", "messageId":"xxxx", "data":[{ json串,与function一一对应 }] } </code></pre></details> <details><summary>设备端执行成功后的应答格式</summary> <pre><code> { "output":{ "data":{ json对,与下发的对应 }, "msg":"success", "code":200 ###10000 是错误 }, "deviceId":"xxxx", "messageId":"xxx", "timestamp":1650942260058 } </code></pre></details> ### function列表项 --- |index|含义|function|data| data类型| |-|-|-|-| -| |1| 开锁| openLock| 标准格式 |json| |2| 关锁| closeLock| 标准格式 |json| |3|固件升级|systemFirmwareUpdate|标准格式| json| |4|升级副摄|ipcFirmwareUpdate| 标准格式 |json| |5|抓主摄图|getMainSnap| 标准格式 |json| |6|抓副摄图|getSecSnap| 标准格式 |json| |7|禁用机器|disable| 标准格式 |json| |8|启用机器|enable| 标准格式 |json| |9|出厂|sellOut| 标准格式 |json| |10|返厂|returnIn| 标准格式 |json| |11|设置图像亮度|setImagingBright| 标准格式 |json| |12|上传副摄录像|uploadAssVideo| 标准格式 |json| |13|重启机器|reboot| 标准格式 |json| |14|设置音量|modifyVolume| 标准格式 | json| |15|查询本地副摄录像名|queryAssFiles| ==预留== | ==预留== | |16|手动开始主摄录像|startMainVideoRecord| 标准格式 |json | |17|手动开始副摄录像|startSecVideoRecord| 标准格式 |json| ### 开锁 --- <details><summary>iot发送</summary> <pre><code> { "data":[ { "name":"time", ##系统下发指令的时间,设备会校验,超期的时间相应指令 "value":12 }, { "name":"eventId", ##开门事件 "value":%lld ##1519868547495739394 long long int }, { "name":"userType", ##用户类型 "value":1 }, { "name":"traceId", ##保留未用 "value":"2" }, { "name":"isRecordIng", ##本次开门是否需要录像 "value":"1" } ], "replyType":1, "function":"openLock", "messageId":"xx", "deviceId":"xxx" } ``` 用户类型枚举值: USER_TYPE_UNKNOW = 0, //"未知用户类型 USER_TYPE_NORMAL_USER = 1, // "普通用户" USER_TYPE_REPNISHMENT = 2, // "补货员" USER_TYPE_TEST = 3, // "管理平台测试" USER_TYPE_WECHAT_APPLET = 4, // "微信小程序1" ``` </code></pre></details> 正常设备不应答,通过/msg_send回复设备执行之后的状态 <para> 设备异常,根据设备端状态,返回开锁异常指令</para> 错误格式 见[设备端状态主动发布上报](https://easydoc.net/doc/49682055/Zg1UNdrz/1cw7rcxO) ### 关锁 --- - 锁通常设备自己会关的,这里用的情况不多 <details><summary>iot发送</summary> <pre><code> { "replyType":1, "function":"closeLock", "messageId":"xx", "deviceId":"xxx" } </code></pre></details> <details> <summary>设备不应答,通过/msg_send回复设备执行之后的状态</summary> <pre><code> { } </code></pre></details> ### 固件升级(主控+副摄) --- <details><summary>iot发送</summary> <pre><code> { "data":[ { "name":"manufacturersId", ##主控默认是6 副摄需要额外型号( 0 ,1,2,3) "value":6 }, { "name":"md5", ##升级包的md5值 "value":"f4c1971cc48bf7c4a5c5e9db6414370e" }, { "name":"uri", ##固件包位置 "value":"objectKey" ##oss的相对路径 } ], "replyType":1, "function":"systemFirmwareUpdate", #副摄这里function 需要改字段ipcFirmwareUpdate "messageId":"xx", "deviceId":"xxx" } </code></pre></details> <details><summary>设备应答/invoke-function/reply</summary> <pre><code> { "output":{ "data":"string", #自定义一串字符 "msg":"success", #错误"error" "code":200 #错误 非200 暂时只定义了10000 }, "deviceId":"xx", "messageId":"xx", "timestamp":1650942260058 } </code></pre></details> ### 抓图(主摄+副摄) --- <details><summary>iot发送</summary> <pre><code> { "data":[ { "name":"eventId", ##事件Id "value":12345657543245 }, { "name":"userType", ##用户类型 "value":1 } ], "replyType":1, "function":"getMainSnap", #副摄这里是getSecSnap "messageId":"xx", "deviceId":"xxx" } </code></pre></details> <details><summary>设备应答/invoke-function/reply</summary> <pre><code> { "output":{ "data":"string", #自定义一串字符 "msg":"success", #错误"error" "code":200 #错误 非200 暂时只定义了10000 }, "deviceId":"xx", "messageId":"xx", "timestamp":1650942260058 } </code></pre></details> <details><summary>图片对象异步上传完成走 oss回调通知</summary> <pre><code> </code></pre></details> ### 禁用/启用机器 出厂/返厂机器 重启 --- <details><summary>iot发送</summary> <pre><code> { "replyType":1, "function":"disable", #见上方列表 "messageId":"xx", "deviceId":"xxx" } </code></pre></details> <details><summary>设备应答/invoke-function/reply</summary> <pre><code> { "output":{ "data":"string", #自定义字符串 "msg":"success", #错误"error" "code":200 #错误 非200 暂时只定义了10000 }, "deviceId":"xx", "messageId":"xx", "timestamp":1650942260058 } </code></pre></details> ### 设置音量 --- <details><summary>iot发送</summary> <pre><code> { "data":[ { "name":"systemVolume", "value":1 # (0-100) } ], "replyType":1, "function":"modifyVolume", "messageId":"xx", "deviceId":"xxx" } </code></pre></details> <details><summary>设备应答/invoke-function/reply</summary> <pre><code> { "output":{ "data":{ "systemVolume":1 }, "msg":"success", #错误"error" "code":200 #错误 非200 暂时只定义了10000 }, "deviceId":"xx", "messageId":"xx", "timestamp":1650942260058 } </code></pre></details> ### 设置手动开始录像+录像时长(主摄+副摄) 返厂状态才生效 <summary>因为涉及到门开关的状态也会影响录像状态,所以这个功能启用的时候,门状态是不变的吧</summary> --- <details><summary>iot发送</summary> <pre><code> { "data":[ { "name":"recordTime", "value":5 # (3-300s) }, { "name":"userType", ##用户类型 "value":1 }, { "name":"eventId", ##事件Id "value":12345657543245 } ], "replyType":1, "function":"startMainVideoRecord", ##startSecVideoRecord "messageId":"xx", "deviceId":"xxx" } </code></pre></details> <details><summary>设备应答/invoke-function/reply</summary> <pre><code> { "output":{ "data":{ "systemVolume":1 }, "msg":"success", #错误"error" "code":200 #错误 非200 暂时只定义了10000 }, "deviceId":"xx", "messageId":"xx", "timestamp":1650942260058 } </code></pre></details> ### 设置图像亮度 (==用的不多==) --- <details><summary>iot发送</summary> <pre><code> { "data":[ { "name":"cameraIndex", "value":1 # 1主摄 2副摄 }, { "name":"brightness", "value":50 # 1-100 } ], "replyType":1, "function":"setImagingBright", "messageId":"xx", "deviceId":"xxx" } </code></pre></details> <details><summary>设备应答/invoke-function/reply</summary> <pre><code> { "output":{ "data":{ "cameraIndex":1, "brightness":50 }, "msg":"success", #错误"error" "code":200 #错误 非200 暂时只定义了10000 }, "deviceId":"xx", "messageId":"xx", "timestamp":1650942260058 } </code></pre></details> ### 主动拉取副摄录像 (根据事件id号来) --- <details><summary>iot发送</summary> <pre><code> { "data":[ { "name":"eventId", "value":12222 # 本地录像按照id号来管理,因此只要有eventId 即可拿到副摄 }, { "name":"objectType", #对象类型 "value":1 # 1 = 副摄录像 其他 = 预留 } ], "replyType":1, "function":"uploadAssVideo", "messageId":"xx", "deviceId":"xxx" } </code></pre></details> <details><summary>设备应答/invoke-function/reply</summary> <pre><code> { "output":{ "data":{ "cameraIndex":1, "brightness":50 }, "msg":"success", #错误"error" "code":200 #错误 非200 暂时只定义了10000 }, "deviceId":"xx", "messageId":"xx", "timestamp":1650942260058 } </code></pre></details> <details><summary>图片对象异步上传完成走 oss回调通知</summary> <pre><code> </code></pre></details>