设备上报二进制数据在云端配置JS脚本解析

匿名 (未验证) 提交于 2019-12-03 00:37:01
阿里云IoT控制台配置



1.1 开通阿里云IoT物联网套件


IoT物联网套件官网地址

1.2 创建高级版产品,选择数据透传





添加产品属性定义




属性名

标识符

数据类型

温度

temperature

float

湿度

humidity

float




定义payload二进制格式





2-5λ

6-9λ

9-13λ

00

5b0232e1

41200000

42b00000

command

requestId

temperature

humidity


2.设备端代码



2.1 package.json引入sdk

  1. {
  2. }



2.2 应用程序代码


  1. /**
  2. * node iot_raw_data.js
  3. */
  4. const mqtt = require('aliyun-iot-mqtt');
  5. const COMMAND_REPORT = 0x00;
  6. //设备属性
  7. const options = {
  8. };
  9. //建立连接
  10. const client = mqtt.getAliyunIotMqttClient(options);
  11. //属性上报的Topic
  12. const topic = `/sys/${options.productKey}/${options.deviceName}/thing/model/up_raw`;
  13. setInterval(function() {
  14. }, 5 * 1000);
  15. function getPostData() {
  16. }
  17. //uint8
  18. function buffer_uint8(value) {
  19. }
  20. //int32
  21. function buffer_int32(value) {
  22. }
  23. //float32
  24. function buffer_float32(value) {
  25. }



3. 云端数据解析脚本配置

原文链接

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!