当前位置: 首页>>代码示例>>Python>>正文


Python DefaultDelegate.__init__方法代码示例

本文整理汇总了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 
开发者ID:thingsboard,项目名称:thingsboard-gateway,代码行数:27,代码来源:ble_connector.py

示例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 
开发者ID:thingsboard,项目名称:thingsboard-gateway,代码行数:20,代码来源:ble_connector.py

示例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() 
开发者ID:openbci-archive,项目名称:OpenBCI_Python,代码行数:20,代码来源:ganglion.py

示例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 
开发者ID:zewelor,项目名称:bt-mqtt-gateway,代码行数:20,代码来源:blescanmulti.py

示例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 
开发者ID:ElevenPaths,项目名称:HomePWN,代码行数:27,代码来源:subscribe.py

示例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 
开发者ID:ElevenPaths,项目名称:HomePWN,代码行数:24,代码来源:subscribe-and-write.py

示例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() 
开发者ID:openbci-archive,项目名称:pyOpenBCI,代码行数:20,代码来源:ganglion.py

示例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() 
开发者ID:STMicroelectronics,项目名称:BlueSTSDK_Python,代码行数:21,代码来源:manager.py

示例9: __init__

# 需要导入模块: from bluepy.btle import DefaultDelegate [as 别名]
# 或者: from bluepy.btle.DefaultDelegate import __init__ [as 别名]
def __init__(self):
        DefaultDelegate.__init__(self) 
开发者ID:fO-000,项目名称:bluescan,代码行数:4,代码来源:le_scan.py

示例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) 
开发者ID:amymcgovern,项目名称:pymambo,代码行数:7,代码来源:Mambo.py

示例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 
开发者ID:creotiv,项目名称:MiBand2,代码行数:5,代码来源:base.py

示例12: __init__

# 需要导入模块: from bluepy.btle import DefaultDelegate [as 别名]
# 或者: from bluepy.btle.DefaultDelegate import __init__ [as 别名]
def __init__(self):
		DefaultDelegate.__init__(self) 
开发者ID:fr31b3u73r,项目名称:miThermoHygro,代码行数:4,代码来源:miThermoHygro.py

示例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() 
开发者ID:kawasaki,项目名称:bluepy-scratch-link,代码行数:7,代码来源:scratch_link.py


注:本文中的bluepy.btle.DefaultDelegate.__init__方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。