我正在尝试在Sensirion Smartgadget上使用温度更新通知。到目前为止,一切正常:通过轮询连接、读取数据。
我不知道如何在Sensirion Smartgadget上启用通知。我必须向哪个特征发送什么?
我找到的唯一文件是
this
第10页。
从现在起,我尝试了以下不起作用的方法:
from bluepy import btle
from bluepy.btle import Peripheral
class MyDelegate(btle.DefaultDelegate):
def __init__(self):
btle.DefaultDelegate.__init__(self)
def handleNotification(self, cHandle, data):
print('notification arrived')
p = Peripheral(myAddress, "random")
p.setDelegate( MyDelegate() )
svc = p.getServiceByUUID( "00002234-b38d-4985-720e-0f993a68ee41" )
ch = svc.getCharacteristics( "00002235-b38d-4985-720e-0f993a68ee41" )[0]
ch.write((1).to_bytes(1, byteorder='little'))
ch.write((1).to_bytes(2, byteorder='big'))
ch.write((1).to_bytes(2, byteorder='little'))
ch.write((2).to_bytes(1, byteorder='big'))
ch.write((2).to_bytes(1, byteorder='little'))
ch.write((2).to_bytes(2, byteorder='big'))
ch.write((2).to_bytes(2, byteorder='little'))
while True:
if p.waitForNotifications(1.0):
continue
print("Waiting...")