Skip to content

Latest commit

 

History

History
 
 

iothub

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

原始数据上报格式

010304026C00883BF0

iothub将原始数据序列化成,在规则链中 msg就是以下数据。

{
  "rowdata": "010304026C00883BF0"
}

需要在规则链中通过函数键 进行解析脚本

/*直连设备:tempVal是产品物模型中所定义属性的标识符*/
var tempVal = msg.rowdata;
/*物模型温度标识符*/
msg.temperature = (parseInt('0x'+tempVal.substr(10, 4))*0.1).toFixed(2);
/*物模型湿度标识符*/
msg.humidity = (parseInt('0x'+tempVal.substr(6, 4))*0.1).toFixed(2);
return {msg: msg, metadata: metadata, msgType: msgType};

属性上报格式

{
   "attribute1": "value1",
   "attribute2": 0
}

遥测上报格式

{
  "ts": 1689837909000,
  "values": {
    "telemetry1": "value1",
    "telemetry2": 0
  }
}

如果边缘无法获取时间

{
    "telemetry1": "value1",
    "telemetry2": 0
}

网关子设备属性上报格式

devA 为设备标识

{
  "devA": {
    "attribute1": "value1",
    "attribute2": 0
  },
  "devB": {
    "attribute1": "value1",
    "attribute2": 0
  }
}

网关子设备遥测上报格式

devA 为设备标识

{
  "devA": {
      "ts": 1689837909000,
      "values": {
        "telemetry1": "value1",
        "telemetry2": 0
      }
    }
}

或者

{
  "devA": {
    "telemetry1": "value1",
    "telemetry2": 0
    }
}

网关子设备连接或断开上报格式

{
  "devA": "online",
  "devB": "offline"
}

命令下发,设备请求格式,

{
   "method": "restart",
   "params": {
      "firmware_address": "http://xxx.yyy.com",
      "version": "latest",
      "secret": "****",
      "http_method": "GET"
   }
}

属性下发 method: 'setAttributes'

命令响应的格式

{
  "method": "2343",
  "params": {
     "aa": "2"
   }
}