用 zigbee USB CC2531 读取数据

问题描述

我最近购买了 CC2531 Zigbee 接收器来构建家庭自动化项目并将小米设备连接到它。我买了一个Aqara温度传感器来测试。 我试图读取传感器通过 USB 端口发送到 Zigbee 接收器的数据。为此,我在 java 上编写了一个小程序,并在 python 上尝试了一个小程序来读取它,但没有得到我想要的结果。 java脚本如下:

const SerialPort = require('serialport')
const port = new SerialPort('/dev/tty.usbmodem14301',{baudRate: 57600,dataBits:8})
const Readline = SerialPort.parsers.Readline
const parser = new Readline()
port.pipe(parser)
parser.on('data',console.log)

port.on('readable',function () {
    console.log('Data:',port.read())
  })
  
  // Switches the port into "flowing mode"
  port.on('data',function (data) {
    console.log('Data:',data)
  })

我弄错了文本(带有传感器名称)和十六进制数组。我不确定是否需要进行某种解码才能解决此问题。我应该得到温度、压力、湿度等的值,但结果却一团糟......

结果:

 lumi.weather��i�D����UE
Data: <Buffer fe 1c 44 81 00 00 02 04 99 85 01 01 00 80 00 55 5a 12 00 00 08 18 45 0a 00 00 29 83 07 99 85 1d ad>
Data: <Buffer fe 1c 44 81 00 00 02 04 99 85 01 01 00 80 00 55 5a 12 00 00 08 18 45 0a 00 00 29 83 07 99 85 1d ad>
)�����D���~aF
Data: <Buffer fe 1c 44 81 00 00 05 04 99 85 01 01 00 7e 00 61 5a 12 00 00 08 18 46 0a 00 00 21 a1 19 99 85 1d 57>
Data: <Buffer fe 1c 44 81 00 00 05 04 99 85 01 01 00 7e 00 61 5a 12 00 00 08 18 46 0a 00 00 21 a1 19 99 85 1d 57>

关于如何解决这个问题的想法?谢谢

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)