本文整理汇总了Python中bluepy.btle.DefaultDelegate.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python DefaultDelegate.__init__方法的具体用法?Python DefaultDelegate.__init__怎么用?Python DefaultDelegate.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bluepy.btle.DefaultDelegate
的用法示例。
在下文中一共展示了DefaultDelegate.__init__方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from bluepy.btle import DefaultDelegate [as 别名]
# 或者: from bluepy.btle.DefaultDelegate import __init__ [as 别名]
def __init__(self, gateway, config, connector_type):
super().__init__()
self.__connector_type = connector_type
self.__default_services = list(range(0x1800, 0x183A))
self.statistics = {'MessagesReceived': 0,
'MessagesSent': 0}
self.__gateway = gateway
self.__config = config
self.setName(self.__config.get("name",
'BLE Connector ' + ''.join(choice(ascii_lowercase) for _ in range(5))))
self._connected = False
self.__stopped = False
self.__previous_scan_time = time.time() - 10000
self.__previous_read_time = time.time() - 10000
self.__check_interval_seconds = self.__config['checkIntervalSeconds'] if self.__config.get(
'checkIntervalSeconds') is not None else 10
self.__rescan_time = self.__config['rescanIntervalSeconds'] if self.__config.get(
'rescanIntervalSeconds') is not None else 10
self.__scanner = Scanner().withDelegate(ScanDelegate(self))
self.__devices_around = {}
self.__available_converters = []
self.__notify_delegators = {}
self.__fill_interest_devices()
self.daemon = True
示例2: __notify_handler
# 需要导入模块: from bluepy.btle import DefaultDelegate [as 别名]
# 或者: from bluepy.btle.DefaultDelegate import __init__ [as 别名]
def __notify_handler(self, device, notify_handle, delegate=None):
class NotifyDelegate(DefaultDelegate):
def __init__(self):
DefaultDelegate.__init__(self)
self.device = device
self.data = {}
def handleNotification(self, handle, data):
self.data = data
log.debug('Notification received from device %s handle: %i, data: %s', self.device, handle, data)
if delegate is None:
delegate = NotifyDelegate()
device['peripheral'].withDelegate(delegate)
device['peripheral'].writeCharacteristic(notify_handle, b'\x01\x00', True)
if device['peripheral'].waitForNotifications(1):
log.debug("Data received: %s", delegate.data)
return delegate
示例3: __init__
# 需要导入模块: from bluepy.btle import DefaultDelegate [as 别名]
# 或者: from bluepy.btle.DefaultDelegate import __init__ [as 别名]
def __init__(self, scaling_output=True):
DefaultDelegate.__init__(self)
# holds samples until OpenBCIBoard claims them
self.samples = []
# detect gaps between packets
self.last_id = -1
self.packets_dropped = 0
# save uncompressed data to compute deltas
self.lastChannelData = [0, 0, 0, 0]
# 18bit data got here and then accelerometer with it
self.lastAcceleromoter = [0, 0, 0]
# when the board is manually set in the right mode (z to start, Z to stop)
# impedance will be measured. 4 channels + ref
self.lastImpedance = [0, 0, 0, 0, 0]
self.scaling_output = scaling_output
# handling incoming ASCII messages
self.receiving_ASCII = False
self.time_last_ASCII = timeit.default_timer()
示例4: __init__
# 需要导入模块: from bluepy.btle import DefaultDelegate [as 别名]
# 或者: from bluepy.btle.DefaultDelegate import __init__ [as 别名]
def __init__(
self,
worker,
mac: str,
name: str,
available: bool = False,
last_status_time: float = None,
message_sent: bool = True,
):
if last_status_time is None:
last_status_time = time.time()
self.worker = worker # type: BlescanmultiWorker
self.mac = mac.lower()
self.name = name
self.available = available
self.last_status_time = last_status_time
self.message_sent = message_sent
示例5: __init__
# 需要导入模块: from bluepy.btle import DefaultDelegate [as 别名]
# 或者: from bluepy.btle.DefaultDelegate import __init__ [as 别名]
def __init__(self):
information = {"Name": "BLE subscribe",
"Description": "Running this module you will be able to receive notifications of a certain BLE device.",
"privileges": "root",
"OS": "Linux",
"Author": "@josueencinar"}
# -----------name-----default_value--description--required?
options = {
'bmac': [None, 'Device address', True],
'type': ["random", "Device addr type", True]
}
options = {"bmac": Option.create(name="bmac", required=True),
"type": Option.create(name="type", value="random", required=True, description='Device addr type'),
"uuid": Option.create(name="uuid", required=True, description='Specific UUID for a characteristic'),
"data": Option.create(name="data", value="Test", required=True, description="Data to write"),
"encode": Option.create(name="encode", required=True, description='Choose data encode'),
"iface": Option.create(name="iface", value=0, description='Ble iface index (default to 0 for hci0)')
}
# Constructor of the parent class
super(HomeModule, self).__init__(information, options)
# Autocomplete set option with values
示例6: __init__
# 需要导入模块: from bluepy.btle import DefaultDelegate [as 别名]
# 或者: from bluepy.btle.DefaultDelegate import __init__ [as 别名]
def __init__(self):
information = {"Name": "BLE subscribe",
"Description": "Running this module you will be able to receive notifications when you write certain charactersitic",
"privileges": "root",
"OS": "Linux",
"Author": "@lucferbux"}
# -----------name-----default_value--description--required?
options = {"bmac": Option.create(name="bmac", required=True),
"type": Option.create(name="type", value="random", required=True, description='Type of device addr'),
"uuid-subscribe": Option.create(name="uuid", required=True, description='Specific UUID for the subscribe characteristic'),
"uuid-write": Option.create(name="uuid", required=True, description='Specific UUID for the write characteristic'),
"data": Option.create(name="data", value="Test", required=True, description="Data to write"),
"encode": Option.create(name="encode", required=True, description='Choose data encode'),
"iface": Option.create(name="iface", value=0, description='Ble iface index (default to 0 for hci0)')
}
# Constructor of the parent class
super(HomeModule, self).__init__(information, options)
# Autocomplete set option with values
示例7: __init__
# 需要导入模块: from bluepy.btle import DefaultDelegate [as 别名]
# 或者: from bluepy.btle.DefaultDelegate import __init__ [as 别名]
def __init__(self, mac=None, max_packets_skipped=15):
self._logger = logging.getLogger(self.__class__.__name__)
if not mac:
self.mac_address = _find_mac()
else:
self.mac_address = mac
self._logger.debug(
'Connecting to Ganglion with MAC address %s' % mac)
self.max_packets_skipped = max_packets_skipped
self._stop_streaming = threading.Event()
self._stop_streaming.set()
self.board_type = 'Ganglion'
atexit.register(self.disconnect)
self.connect()
示例8: __init__
# 需要导入模块: from bluepy.btle import DefaultDelegate [as 别名]
# 或者: from bluepy.btle.DefaultDelegate import __init__ [as 别名]
def __init__(self, show_warnings=False, *args, **kwargs):
"""Constructor.
Args:
show_warnings (bool, optional): If True shows warnings, if any, when
discovering devices not respecting the BlueSTSDK's advertising
data format, nothing otherwise.
"""
try:
super(_StoppableScanner, self).__init__(*args, **kwargs)
self._stop_called = threading.Event()
self._process_done = threading.Event()
with lock(self):
self._scanner = Scanner().withDelegate(_ScannerDelegate(show_warnings))
except BTLEException as e:
# Save details of the exception raised but don't re-raise, just
# complete the function.
import sys
self._exc = sys.exc_info()
示例9: __init__
# 需要导入模块: from bluepy.btle import DefaultDelegate [as 别名]
# 或者: from bluepy.btle.DefaultDelegate import __init__ [as 别名]
def __init__(self):
DefaultDelegate.__init__(self)
示例10: __init__
# 需要导入模块: from bluepy.btle import DefaultDelegate [as 别名]
# 或者: from bluepy.btle.DefaultDelegate import __init__ [as 别名]
def __init__(self, handle_map, mambo):
DefaultDelegate.__init__(self)
self.handle_map = handle_map
self.mambo = mambo
self.mambo._debug_print("initializing notification delegate", 10)
示例11: __init__
# 需要导入模块: from bluepy.btle import DefaultDelegate [as 别名]
# 或者: from bluepy.btle.DefaultDelegate import __init__ [as 别名]
def __init__(self, device):
DefaultDelegate.__init__(self)
self.device = device
示例12: __init__
# 需要导入模块: from bluepy.btle import DefaultDelegate [as 别名]
# 或者: from bluepy.btle.DefaultDelegate import __init__ [as 别名]
def __init__(self):
DefaultDelegate.__init__(self)
示例13: __init__
# 需要导入模块: from bluepy.btle import DefaultDelegate [as 别名]
# 或者: from bluepy.btle.DefaultDelegate import __init__ [as 别名]
def __init__(self, websocket, loop):
self.websocket = websocket
self.loop = loop
self.lock = threading.RLock()
self.notification_queue = queue.Queue()