Python Can';我不明白为什么我';我没有收到通知

Python Can';我不明白为什么我';我没有收到通知,python,linux,bluetooth-lowenergy,btle,Python,Linux,Bluetooth Lowenergy,Btle,我从未收到来自6E400006-B5A3-F393-E0A9-e50e24dca9e的通知。我必须通过将0x01写入特性6E400009-B5A3-F393-E0A9-e50e24dca9e来启用传感器。我在用电话 使用LightBlue iOS应用程序验证服务和特征。日志: 21:58:33.956 — Characteristic (6E400009-B5A3-F393-E0A9-E50E24DCCA9E) wrote new value: <01> 21:58:33.999 —

我从未收到来自6E400006-B5A3-F393-E0A9-e50e24dca9e的通知。我必须通过将
0x01
写入特性6E400009-B5A3-F393-E0A9-e50e24dca9e来启用传感器。我在用电话

使用LightBlue iOS应用程序验证服务和特征。日志:

21:58:33.956 — Characteristic (6E400009-B5A3-F393-E0A9-E50E24DCCA9E) wrote new value: <01>
21:58:33.999 — Characteristic (6E400009-B5A3-F393-E0A9-E50E24DCCA9E) read: (null)
21:58:39.339 — Characteristic (6E400006-B5A3-F393-E0A9-E50E24DCCA9E) notified: <06020341 090000>
21:58:39.849 — Characteristic (6E400006-B5A3-F393-E0A9-E50E24DCCA9E) notified: <06020338 090000>
21:58:40.329 — Characteristic (6E400006-B5A3-F393-E0A9-E50E24DCCA9E) notified: <0602033f 090000>
21:58:40.840 — Characteristic (6E400006-B5A3-F393-E0A9-E50E24DCCA9E) notified: <06020338 090000>
21:58:41.349 — Characteristic (6E400006-B5A3-F393-E0A9-E50E24DCCA9E) notified: <0602033a 090000>
21:58:33.956-特征(6E400009-B5A3-F393-E0A9-E50E24DCA9E)写入了新值:
21:58:33.999-特征(6E400009-B5A3-F393-E0A9-E50E24DCA9E)读取:(空)
21:58:39.339-特性(6E400006-B5A3-F393-E0A9-E50E24DCA9E)通知:
21:58:39.849-特性(6E400006-B5A3-F393-E0A9-E50E24DCA9E)通知:
21:58:40.329-特性(6E400006-B5A3-F393-E0A9-E50E24DCA9E)通知:
21:58:40.840-特性(6E400006-B5A3-F393-E0A9-E50E24DCA9E)通知:
21:58:41.349-特性(6E400006-B5A3-F393-E0A9-E50E24DCA9E)通知:
从bluepy.btle导入UUID、外围设备、DefaultDelegate
导入时间
导入结构
类MyDelegate(DefaultDelegate):
定义初始化(自):
DefaultDelegate.\uuuuuu初始化\uuuuuuuuuuuuu(自)
def手动通知(自身、钱德尔、数据):
打印(钱德尔,数据)
#应收到来自6e400006-b5a3-f393-e0a9-E50E24DCA9E的通知
#连接到设备
打印('连接…')
dev=外围设备(“df:4c:cf:e7:9b:1f”)
#安装通知
dev.setDelegate(MyDelegate())
#获取传感器服务
sensorServices=dev.getServiceByUUID(UUID(“6E40000-B5A3-F393-E0A9-E50E24DCA9E”))
印刷(传感器服务)
#获取流特征
enableStreamCharacteristic=sensorServices.getCharacteristics(UUID('6E400009-B5A3-F393-E0A9-E50E24DCA9E'))[0]
打印(启用流特征)
#将0x01写入6e400009-b5a3-f393-e0a9-E50E24DCA9E

enableStreamCharacteristic.write(struct.pack(“您没有收到通知的原因是您需要首先为特定特征启用通知。请将此添加到代码中:

声明一些值,以便在必要时使用

notiOn = b"\0x1\x00"
notiOff = b"\0x1\x00"
在开始侦听通知之前,为发送通知的特征启用通知(在您的情况下,可能是6e400001-6e400008之间的特征):

添加此代码后,应开始接收通知

Connecting...
Service <uuid=6e400000-b5a3-f393-e0a9-e50e24dcca9e handleStart=9 handleEnd=65535>
Characteristic <6e400009-b5a3-f393-e0a9-e50e24dcca9e>
Waiting...
notiOn = b"\0x1\x00"
notiOff = b"\0x1\x00"
yourCharacteristicDesc = yourCharacteristic.getDescriptors()[0]
yourCharacteristicDesc.write(notifOn, withResponse=True)