Example #1
0
    async def readDescriptor_(
        self, descriptor: CBDescriptor, use_cached=True
    ) -> NSData:
        if descriptor.value() is not None and use_cached is True:
            return descriptor.value()

        dUUID = descriptor.UUID().UUIDString()

        event = self._descriptor_read_events.get_cleared(dUUID)
        self.peripheral.readValueForDescriptor_(descriptor)
        await event.wait()

        return descriptor.value()
Example #2
0
    async def readDescriptor_(self,
                              descriptor: CBDescriptor,
                              use_cached=True) -> NSData:
        if descriptor.value() is not None and use_cached is True:
            return descriptor.value()

        dUUID = descriptor.UUID().UUIDString()
        self._descriptor_value_log[dUUID] = False

        self.peripheral.readValueForDescriptor_(descriptor)

        while not self._descriptor_value_log[dUUID]:
            await asyncio.sleep(0.01)

        return descriptor.value()