本文整理汇总了Python中bluepy.btle.DefaultDelegate方法的典型用法代码示例。如果您正苦于以下问题:Python btle.DefaultDelegate方法的具体用法?Python btle.DefaultDelegate怎么用?Python btle.DefaultDelegate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bluepy.btle
的用法示例。
在下文中一共展示了btle.DefaultDelegate方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: connect
# 需要导入模块: from bluepy import btle [as 别名]
# 或者: from bluepy.btle import DefaultDelegate [as 别名]
def connect(self):
# Auto-discover device on first connection
if (self.MacAddr is None):
scanner = Scanner().withDelegate(DefaultDelegate())
searchCount = 0
while self.MacAddr is None and searchCount < 50:
devices = scanner.scan(0.1) # 0.1 seconds scan period
searchCount += 1
for dev in devices:
ManuData = dev.getValueText(255)
SN = parseSerialNumber(ManuData)
if (SN == self.SN):
self.MacAddr = dev.addr # exits the while loop on next conditional check
break # exit for loop
if (self.MacAddr is None):
print "ERROR: Could not find device."
print "GUIDE: (1) Please verify the serial number."
print " (2) Ensure that the device is advertising."
print " (3) Retry connection."
sys.exit(1)
# Connect to device
if (self.periph is None):
self.periph = Peripheral(self.MacAddr)
if (self.curr_val_char is None):
self.curr_val_char = self.periph.getCharacteristics(uuid=self.uuid)[0]
示例2: __init__
# 需要导入模块: from bluepy import btle [as 别名]
# 或者: from bluepy.btle import DefaultDelegate [as 别名]
def __init__(self, handler):
btle.DefaultDelegate.__init__(self)
self._handler = handler
示例3: __init__
# 需要导入模块: from bluepy import btle [as 别名]
# 或者: from bluepy.btle import DefaultDelegate [as 别名]
def __init__(self, light):
self.light = light
btle.DefaultDelegate.__init__(self)
示例4: getTag
# 需要导入模块: from bluepy import btle [as 别名]
# 或者: from bluepy.btle import DefaultDelegate [as 别名]
def getTag(self):
"""Scans for BT LE devices and returns the choosen keywords"""
self.count = 0
scanner = Scanner().withDelegate(DefaultDelegate())
devices = scanner.scan(self.scanTimeout)
for dev in devices:
if dev.addr == self.address.lower():
self.count = 1
if self.count > 0:
self.count = 0
return self.found
else:
return self.missing
示例5: scan_devices
# 需要导入模块: from bluepy import btle [as 别名]
# 或者: from bluepy.btle import DefaultDelegate [as 别名]
def scan_devices(self, delegate=DefaultDelegate, timeout=5):
devices = Scanner(self.iface).withDelegate(delegate()).scan(timeout=timeout)
return self._package_data_devices(devices)
示例6: __init__
# 需要导入模块: from bluepy import btle [as 别名]
# 或者: from bluepy.btle import DefaultDelegate [as 别名]
def __init__(self,callback):
self.callback = callback
btle.DefaultDelegate.__init__(self)
示例7: __init__
# 需要导入模块: from bluepy import btle [as 别名]
# 或者: from bluepy.btle import DefaultDelegate [as 别名]
def __init__(self,keypressed_callback,KPHANDLE):
self.keypressed_callback = keypressed_callback
self.keypressed_handle = KPHANDLE
btle.DefaultDelegate.__init__(self)
示例8: __init__
# 需要导入模块: from bluepy import btle [as 别名]
# 或者: from bluepy.btle import DefaultDelegate [as 别名]
def __init__(self, mac):
"""Initialize the connection."""
btle.DefaultDelegate.__init__(self)
self._conn = None
self._mac = mac
self._callbacks = {}
示例9: __init__
# 需要导入模块: from bluepy import btle [as 别名]
# 或者: from bluepy.btle import DefaultDelegate [as 别名]
def __init__(self, mac=None):
btle.DefaultDelegate.__init__(self)
self.services = Services(mac=get_myo(mac))
self.services.setDelegate(self)
self.emg_event_handlers = []
self.imu_event_handlers = []
self.sync_event_handlers = []
self.classifier_event_handlers = []
self.battery_event_handlers = []
示例10: __init__
# 需要导入模块: from bluepy import btle [as 别名]
# 或者: from bluepy.btle import DefaultDelegate [as 别名]
def __init__(self, dongle):
btle.DefaultDelegate.__init__(self)
self.dongle = dongle