如何仅在值更新时才重复从BLE设备读取值(MacOS上的python)?

2024-04-29 02:41:49 发布

您现在位置:Python中文网/ 问答频道 /正文

作为标题,现在我可以从BLE设备获取值,如下代码所示:

class RobotDelegate(object):
...

def peripheral_didDiscoverCharacteristicsForService_error_(self, peripheral, service, error):
for characteristic in self.service.characteristics():
   if characteristic.UUID() == blebee_characteristic:
        self.characteristic = characteristic
        print ("self.characteristic.value = ", self.characteristic.value())
...

delegate = RobotDelegate()
manager = CBCentralManager.alloc()
manager.initWithDelegate_queue_options_(delegate, None, None)

AppHelper.runConsoleEventLoop()

我只能从我的BLE设备读取一次值。。。实际上,BLE设备可以在有人触摸时不断更新值,所以我想知道我应该如何实现这一点?谢谢。你知道吗


Tags: 代码selfnone标题objectvalueservicemanager