文档首页/ IoT物联网/ 常见问题/ 二次开发/ 应用开发常见问题/ 订阅与推送/ 设备数据变化通知和批量设备数据变化通知的区别是什么
更新时间:2022-02-24 GMT+08:00

设备数据变化通知和批量设备数据变化通知的区别是什么

设备数据变化通知和批量设备数据变化通知接口都是订阅设备的数据变化,只是封装的数据格式不一样。

例如:一款水表设备有Battery和Connectivity两种服务类型,每次上报数据都会上报这两个服务的数据。
  • 如果订阅deviceDatachanged(设备数据变化通知),则物联网平台分两次将数据推送到应用服务器,第一次推送Battery服务数据,第二次推送Connectivity服务数据。例如:
    { "notifyType": "deviceDataChanged", "deviceId": "70a8d7cd-5ecd-4bda-a87c-afc16bd31bda", "gatewayId": "70a8d7cd-5ecd-4bda-a87c-afc16bd31bda", "requestId": null, "service": { "serviceId": "battery", "serviceType": "battery", "data": {"batteryLevel": 66}, "eventTime": "20170211T034003Z" }}
    {"notifyType": "deviceDataChanged","deviceId": "70a8d7cd-5ecd-4bda-a87c-afc16bd31bda", "gatewayId": "70a8d7cd-5ecd-4bda-a87c-afc16bd31bda","requestId": null, "service": { "serviceId": "Connectivity", "serviceType": "Connectivity", "data": { "signalStrength": 72, "cellId": 4022250974, "tac": 61374, "mnc": 91, "mcc": 235 }, "eventTime": "20170211T092317Z" }}
  • 如果订阅deviceDataschanged(批量设备数据变化通知),则物联网平台将两次服务的数据封装在一起发送到应用服务器。
    { "notifyType": "deviceDatasChanged", "requestId": null, "deviceId": "70a8d7cd-5ecd-4bda-a87c-afc16bd31bda",<br> "gatewayId": "70a8d7cd-5ecd-4bda-a87c-afc16bd31bda",<br> "services": [{ "serviceId": "battery", "serviceType": "battery", "data": { "batteryLevel": 66 }, "eventTime": "20170211T034003Z" }, { "serviceId": "Connectivity", "serviceType": "Connectivity","data": {"signalStrength": 72, "cellId": 4022250974, "tac": 61374, "mnc": 91, "mcc": 235 }, "eventTime": "20170211T034003Z" } ]}