Python bluepy.btle.UUID Examples
The following are 7
code examples of bluepy.btle.UUID().
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
, or try the search function
.
Example #1
Source File: Mambo.py From pymambo with MIT License | 6 votes |
def _get_byte_str_from_uuid(self, uuid, byte_start, byte_end): """ Extract the specified byte string from the UUID btle object. This is an ugly hack but it was necessary because of the way the UUID object is represented and the documentation on the byte strings from Parrot. You give it the starting byte (counting from 1 since that is how their docs count) and the ending byte and it returns that as a string extracted from the UUID. It is assumed it happens before the first - in the UUID. :param uuid: btle UUID object :param byte_start: starting byte (counting from 1) :param byte_end: ending byte (counting from 1) :return: string with the requested bytes (to be used as a key in the lookup tables for services) """ uuid_str = format("%s" % uuid) idx_start = 2 * (byte_start - 1) idx_end = 2 * (byte_end) my_hex_str = uuid_str[idx_start:idx_end] return my_hex_str
Example #2
Source File: bleConnection.py From pyparrot with MIT License | 6 votes |
def _get_byte_str_from_uuid(self, uuid, byte_start, byte_end): """ Extract the specified byte string from the UUID btle object. This is an ugly hack but it was necessary because of the way the UUID object is represented and the documentation on the byte strings from Parrot. You give it the starting byte (counting from 1 since that is how their docs count) and the ending byte and it returns that as a string extracted from the UUID. It is assumed it happens before the first - in the UUID. :param uuid: btle UUID object :param byte_start: starting byte (counting from 1) :param byte_end: ending byte (counting from 1) :return: string with the requested bytes (to be used as a key in the lookup tables for services) """ uuid_str = format("%s" % uuid) idx_start = 2 * (byte_start - 1) idx_end = 2 * (byte_end) my_hex_str = uuid_str[idx_start:idx_end] return my_hex_str
Example #3
Source File: ble_connector.py From thingsboard-gateway with Apache License 2.0 | 5 votes |
def __new_device_processing(self, device): default_services_on_device = [service for service in self.__devices_around[device]['services'].keys() if int(service.split('-')[0], 16) in self.__default_services] log.debug('Default services found on device %s :%s', device, default_services_on_device) converter = BytesBLEUplinkConverter(self.__devices_around[device]['device_config']) converted_data = None for service in default_services_on_device: characteristics = [char for char in self.__devices_around[device]['services'][service].keys() if self.__devices_around[device]['services'][service][char][ 'characteristic'].supportsRead()] for char in characteristics: read_config = {'characteristicUUID': char, 'method': 'READ', } try: self.__check_and_reconnect(device) data = self.__service_processing(device, read_config) attribute = capitaliseName(UUID(char).getCommonName()) read_config['key'] = attribute read_config['byteFrom'] = 0 read_config['byteTo'] = -1 converter_config = [{"type": "attributes", "clean": False, "section_config": read_config}] for interest_information in converter_config: try: converted_data = converter.convert(interest_information, data) self.statistics['MessagesReceived'] = self.statistics['MessagesReceived'] + 1 log.debug(converted_data) except Exception as e: log.debug(e) except Exception as e: log.debug('Cannot process %s', e) continue if converted_data is not None: # self.__gateway.add_device(converted_data["deviceName"], {"connector": self}) self.__gateway.send_to_storage(self.get_name(), converted_data) self.statistics['MessagesSent'] = self.statistics['MessagesSent'] + 1
Example #4
Source File: read_waveplus.py From waveplus-reader with MIT License | 5 votes |
def __init__(self, SerialNumber): self.periph = None self.curr_val_char = None self.MacAddr = None self.SN = SerialNumber self.uuid = UUID("b42e2a68-ade7-11e4-89d3-123b93f75cba")
Example #5
Source File: scratch_link.py From bluepy-scratch-link with BSD 3-Clause "New" or "Revised" License | 5 votes |
def add_handle(self, serviceId, charId, handle): logger.debug(f"add handle for notification: {handle}") params = { 'serviceId': UUID(serviceId).getCommonName(), 'characteristicId': charId, 'encoding': 'base64' } self.handles[handle] = params
Example #6
Source File: scratch_link.py From bluepy-scratch-link with BSD 3-Clause "New" or "Revised" License | 5 votes |
def matches(self, dev, filters): """ Check if the found BLE device mathces the filters Scracth specifies. """ logger.debug(f"in matches {dev} {filters}") for f in filters: if 'services' in f: for s in f['services']: logger.debug(f"sevice to check: {s}") given_uuid = s logger.debug(f"given: {given_uuid}") service_class_uuid = dev.getValueText(self.ADTYPE_COMP_128B) logger.debug(f"adtype 128b: {service_class_uuid}") if not service_class_uuid: service_class_uuid = dev.getValueText(self.ADTYPE_COMP_16B) logger.debug(f"adtype 16b: {service_class_uuid}") if not service_class_uuid: continue dev_uuid = UUID(service_class_uuid) logger.debug(f"dev: {dev_uuid}") logger.debug(given_uuid == dev_uuid) if given_uuid == dev_uuid: logger.debug("match...") return True if 'name' in f or 'manufactureData' in f: logger.error("name/manufactureData filters not implemented") # TODO: implement other filters defined: # ref: https://github.com/LLK/scratch-link/blob/develop/Documentation/BluetoothLE.md return False
Example #7
Source File: scratch_link.py From bluepy-scratch-link with BSD 3-Clause "New" or "Revised" License | 5 votes |
def _get_service(self, service_id): with self.lock: service = self.perip.getServiceByUUID(UUID(service_id))