Python bluepy.btle.DefaultDelegate.__init__() Examples
The following are 30
code examples of bluepy.btle.DefaultDelegate.__init__().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
bluepy.btle.DefaultDelegate
, or try the search function
.
Example #1
Source File: manager.py From BlueSTSDK_Python with BSD 3-Clause "New" or "Revised" License | 8 votes |
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()
Example #2
Source File: ble_connector.py From thingsboard-gateway with Apache License 2.0 | 6 votes |
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
Example #3
Source File: ganglion.py From pyOpenBCI with MIT License | 6 votes |
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()
Example #4
Source File: subscribe-and-write.py From HomePWN with GNU General Public License v3.0 | 6 votes |
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
Example #5
Source File: subscribe.py From HomePWN with GNU General Public License v3.0 | 6 votes |
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
Example #6
Source File: blescanmulti.py From bt-mqtt-gateway with MIT License | 6 votes |
def __init__(self, command_timeout, global_topic_prefix, **kwargs): from bluepy.btle import Scanner, DefaultDelegate class ScanDelegate(DefaultDelegate): def __init__(self): DefaultDelegate.__init__(self) def handleDiscovery(self, dev, isNewDev, isNewData): if isNewDev: _LOGGER.debug("Discovered new device: %s" % dev.addr) super(BlescanmultiWorker, self).__init__( command_timeout, global_topic_prefix, **kwargs ) self.scanner = Scanner().withDelegate(ScanDelegate()) self.last_status = [ BleDeviceStatus(self, mac, name) for name, mac in self.devices.items() ] _LOGGER.info("Adding %d %s devices", len(self.devices), repr(self))
Example #7
Source File: blescanmulti.py From bt-mqtt-gateway with MIT License | 6 votes |
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
Example #8
Source File: ganglion.py From OpenBCI_Python with MIT License | 6 votes |
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()
Example #9
Source File: ble_connector.py From thingsboard-gateway with Apache License 2.0 | 6 votes |
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
Example #10
Source File: le_scan.py From bluescan with GNU General Public License v3.0 | 5 votes |
def __init__(self): DefaultDelegate.__init__(self)
Example #11
Source File: scratch_link.py From bluepy-scratch-link with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __init__(self, major_class, minor_class): super().__init__() self.major_class = major_class self.minor_class = minor_class self.found_devices = {} self.done = False
Example #12
Source File: scratch_link.py From bluepy-scratch-link with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __init__(self, session, major_device_class, minor_device_class): threading.Thread.__init__(self) self.session = session self.major_device_class = major_device_class self.minor_device_class = minor_device_class self.cancel_discovery = False self.ping_time = None
Example #13
Source File: scratch_link.py From bluepy-scratch-link with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __init__(self, websocket, loop): super().__init__(websocket, loop) self.status = self.INITIAL self.sock = None self.bt_thread = None
Example #14
Source File: scratch_link.py From bluepy-scratch-link with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __init__(self, session): threading.Thread.__init__(self) self.session = session
Example #15
Source File: scratch_link.py From bluepy-scratch-link with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __init__(self, websocket, loop): super().__init__(websocket, loop) self.status = self.INITIAL self.found_devices = [] self.device = None self.perip = None self.delegate = None
Example #16
Source File: ganglion.py From pyOpenBCI with MIT License | 5 votes |
def __init__(self, max_packets_skipped=15): DefaultDelegate.__init__(self) self.max_packets_skipped = max_packets_skipped self.last_values = [0, 0, 0, 0] self.last_id = -1 self.samples = [] self.start_time = datetime.datetime.now().strftime("%Y-%m-%d_%H%M%S") self._logger = logging.getLogger(self.__class__.__name__) self._wait_for_full_pkt = True
Example #17
Source File: ganglion.py From pyOpenBCI with MIT License | 5 votes |
def __init__(self, packet_id, channels_data, aux_data, init_time, board_type): self.id = packet_id self.channels_data = channels_data self.aux_data = aux_data self.start_time = init_time self.board_type = board_type
Example #18
Source File: manager.py From BlueSTSDK_Python with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __init__(self, show_warnings=False): """Constructor. Args: show_warnings (bool, optional): If True shows warnings, if any, when discovering devices that do not respect the BlueSTSDK's advertising data format, nothing otherwise. """ DefaultDelegate.__init__(self) self._logger = logging.getLogger('BlueSTSDK') self._show_warnings = show_warnings
Example #19
Source File: scratch_link.py From bluepy-scratch-link with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __init__(self, websocket, loop): self.websocket = websocket self.loop = loop self.lock = threading.RLock() self.notification_queue = queue.Queue()
Example #20
Source File: manager.py From BlueSTSDK_Python with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __init__(self): """Constructor. Raises: :exc:`Exception` is raised in case an instance of the same class has already been instantiated. """ # Raise an exception if an instance has already been instantiated. if self._INSTANCE is not None: raise Exception('An instance of \'Manager\' class already exists.') self._scanner = None """BLE scanner.""" self._is_scanning = False """Scanning status.""" self._discovered_nodes = [] """List of discovered nodes.""" self._thread_pool = ThreadPoolExecutor(Manager._NUMBER_OF_THREADS) """Pool of thread used to notify the listeners.""" self._scanner_thread = None """Stoppable-scanner object.""" self._listeners = [] """List of listeners to the manager changes. It is a thread safe list, so a listener can subscribe itself through a callback."""
Example #21
Source File: node.py From BlueSTSDK_Python with BSD 3-Clause "New" or "Revised" License | 5 votes |
def __init__(self, node): """Constructor. Args: node (:class:`blue_st_sdk.node.Node`): The node which sends notifications. """ DefaultDelegate.__init__(self) self._node = node self._logger = logging.getLogger('BlueSTSDK')
Example #22
Source File: bleConnection.py From pyparrot with MIT License | 5 votes |
def __init__(self, handle_map, minidrone, ble_connection): DefaultDelegate.__init__(self) self.handle_map = handle_map self.minidrone = minidrone self.ble_connection = ble_connection color_print("initializing notification delegate", "INFO")
Example #23
Source File: findMinidrone.py From pyparrot with MIT License | 5 votes |
def __init__(self): DefaultDelegate.__init__(self)
Example #24
Source File: switchbot_meter.py From python-host with Apache License 2.0 | 5 votes |
def __init__(self): DefaultDelegate.__init__(self)
Example #25
Source File: switchbot_meter.py From python-host with Apache License 2.0 | 5 votes |
def __init__( self ): DefaultDelegate.__init__(self) #print("Scanner inited")
Example #26
Source File: switchbot.py From python-host with Apache License 2.0 | 5 votes |
def __init__(self): DefaultDelegate.__init__(self)
Example #27
Source File: switchbot.py From python-host with Apache License 2.0 | 5 votes |
def __init__( self ): DefaultDelegate.__init__(self) #print("Scanner inited")
Example #28
Source File: switchbot_meter_py3.py From python-host with Apache License 2.0 | 5 votes |
def __init__(self): DefaultDelegate.__init__(self)
Example #29
Source File: subscribe-and-write.py From HomePWN with GNU General Public License v3.0 | 5 votes |
def __init__(self): DefaultDelegate.__init__(self)
Example #30
Source File: ganglion.py From OpenBCI_Python with MIT License | 5 votes |
def __init__(self, port=None, baud=0, filter_data=False, scaled_output=True, daisy=False, log=True, aux=False, impedance=False, timeout=2, max_packets_to_skip=20): # unused, for compatibility with Cyton v3 API self.daisy = False # these one are used self.log = log # print_incoming_text needs log self.aux = aux self.streaming = False self.timeout = timeout self.max_packets_to_skip = max_packets_to_skip self.scaling_output = scaled_output self.impedance = impedance # might be handy to know API self.board_type = "ganglion" print("Looking for Ganglion board") if port == None: port = self.find_port() self.port = port # find_port might not return string self.connect() self.streaming = False # number of EEG channels and (optionally) accelerometer channel self.eeg_channels_per_sample = 4 self.aux_channels_per_sample = 3 self.imp_channels_per_sample = 5 self.read_state = 0 self.log_packet_count = 0 self.packets_dropped = 0 self.time_last_packet = 0 # Disconnects from board when terminated atexit.register(self.disconnect)