Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""
if self._services is not None:
return self._services
logger.debug("Retrieving services...")
services = (
await cbapp.central_manager_delegate.connected_peripheral_delegate.discoverServices()
)
for service in services:
serviceUUID = service.UUID().UUIDString()
logger.debug(
"Retrieving characteristics for service {}".format(serviceUUID)
)
characteristics = await cbapp.central_manager_delegate.connected_peripheral_delegate.discoverCharacteristics_(
service
)
self.services.add_service(BleakGATTServiceCoreBluetooth(service))
for characteristic in characteristics:
cUUID = characteristic.UUID().UUIDString()
logger.debug(
"Retrieving descriptors for characteristic {}".format(cUUID)
)
descriptors = await cbapp.central_manager_delegate.connected_peripheral_delegate.discoverDescriptors_(
characteristic
)
self.services.add_characteristic(
BleakGATTCharacteristicCoreBluetooth(characteristic)