Пример #1
0
    async def discover_characteristics(self, service: CBService) -> NSArray:
        future = self._event_loop.create_future()
        self._service_characteristic_discovered_futures[
            service.startHandle()] = future
        self.peripheral.discoverCharacteristics_forService_(None, service)
        await future

        return service.characteristics()
Пример #2
0
 async def _did_discover_characteristics_for_service(
         self, cbservice: CoreBluetooth.CBService,
         cbcharacteristics: List[CoreBluetooth.CBCharacteristic],
         error: Foundation.NSError):
     service_identifier = cbservice.UUID().UUIDString()
     service = self._services_by_identifier.get(service_identifier)
     if service is not None:
         service._did_discover_characteristics(cbcharacteristics, error)
Пример #3
0
 def did_discover_characteristics_for_service(self,
                                              peripheral: CBPeripheral,
                                              service: CBService,
                                              error: Optional[NSError]):
     future = self._service_characteristic_discovered_futures.get(
         service.startHandle())
     if not future:
         logger.debug(
             f"Unexpected event didDiscoverCharacteristicsForService for {service.startHandle()}"
         )
         return
     if error is not None:
         exception = BleakError(
             f"Failed to discover characteristics for service {service.startHandle()}: {error}"
         )
         future.set_exception(exception)
     else:
         logger.debug("Characteristics discovered")
         future.set_result(None)