bluetooth - multi nRF52840如何连接rpi4?
问题描述
我想连接两个 nrf52840 设备和树莓派。连接到单个设备时,它工作正常。但是,当连接两个设备时,会发生错误并停止。
两个设备的 rx uuid 不同。
这是我的代码
def read_left_data(self):
left_thread = threading.Thread(target=self.left_data)
left_thread.start()
def left_data(self):
try:
left_adapter.start()
#left mac address : DF:BB:3A:13:EE:1D
#right mac address : C4:78:6A:80:D7:A7
left_device = left_adapter.connect('DF:BB:3A:13:EE:1D', address_type=pygatt.BLEAddressType.random)
#read value nordic tx uuid
while True:
#left tx uuid : 6e40ABCD-b5a3-f393-e0a9-e50e24dcca9e
#right tx uuid : 6e400003-b5a3-f393-e0a9-e50e24dcca9e
value = left_device.char_read("6e40ABCD-b5a3-f393-e0a9-e50e24dcca9e")
receive_data = hexlify(value) #get value
receive_data = receive_data.decode('utf-8') #remove hex 'b'
#do something with receive_data
如果我连接另一台设备,则会发生此错误并停止
Exception in thread Thread-3:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/usr/local/lib/python3.6/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "qttest_right.py", line 91, in rightData
value = rightDevice.char_read("6e40ABCD-b5a3-f393-e0a9-e50e24dcca9e")
File "/usr/local/lib/python3.6/site-packages/pygatt/backends/gatttool/device.py", line 17, in wrapper
return func(self, *args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/pygatt/backends/gatttool/device.py", line 40, in char_read
return self._backend.char_read(self, uuid, *args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/pygatt/backends/gatttool/gatttool.py", line 50, in wrapper
return func(self, *args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/pygatt/backends/gatttool/gatttool.py", line 593, in char_read
self.sendline('char-read-uuid %s' % uuid)
File "/usr/local/lib/python3.6/contextlib.py", line 88, in __exit__
next(self.gen)
File "/usr/local/lib/python3.6/site-packages/pygatt/backends/gatttool/gatttool.py", line 191, in event
self.wait(event, timeout)
File "/usr/local/lib/python3.6/site-packages/pygatt/backends/gatttool/gatttool.py", line 157, in wait
raise NotificationTimeout()
pygatt.exceptions.NotificationTimeout: None
我该如何解决这个错误?
解决方案
推荐阅读
- javascript - WDS Live Reloading 启用了两次
- java - 当(在Java中)不同类中存在同名的静态方法和实例方法时,我无法访问该方法
- airflow - Airflow - 获取任务的最后一个成功实例
- r - 如何在R中的三个条件下为两个指标创建带有散点的条形图
- postgresql - 多对一,其中一个可以是两个不同字段之一
- postman - 如何在 PostMan 中重命名环境?
- java - 基于列表创建动态模板化消息
- python - Python - 在包含 NaN 的列/列表上使用 if-else 进行列表理解
- javascript - 通过Javascript对象的递归循环
- javascript - 如果JS返回函数中不为空或null