mirror of
https://github.com/google/bumble.git
synced 2026-05-08 03:58:01 +00:00
device.py: Update get_characteristics_by_uuid()
`get_characteristics_by_uuid()` now allows a UUID to be passed to the service param. This allows for users to easily query for a service uuid and characteristic uuid with one API.
This commit is contained in:
committed by
Alan Rosenthal
parent
0f19dd5263
commit
3389e3e1ed
@@ -27,6 +27,7 @@ import copy
|
||||
from dataclasses import dataclass, field
|
||||
from enum import Enum, IntEnum
|
||||
import functools
|
||||
import itertools
|
||||
import json
|
||||
import logging
|
||||
import secrets
|
||||
@@ -1172,8 +1173,20 @@ class Peer:
|
||||
return self.gatt_client.get_services_by_uuid(uuid)
|
||||
|
||||
def get_characteristics_by_uuid(
|
||||
self, uuid: core.UUID, service: Optional[gatt_client.ServiceProxy] = None
|
||||
self,
|
||||
uuid: core.UUID,
|
||||
service: Optional[Union[gatt_client.ServiceProxy, core.UUID]] = None,
|
||||
) -> List[gatt_client.CharacteristicProxy]:
|
||||
if isinstance(service, core.UUID):
|
||||
return list(
|
||||
itertools.chain(
|
||||
*[
|
||||
self.get_characteristics_by_uuid(uuid, s)
|
||||
for s in self.get_services_by_uuid(service)
|
||||
]
|
||||
)
|
||||
)
|
||||
|
||||
return self.gatt_client.get_characteristics_by_uuid(uuid, service)
|
||||
|
||||
def create_service_proxy(self, proxy_class: Type[_PROXY_CLASS]) -> _PROXY_CLASS:
|
||||
|
||||
Reference in New Issue
Block a user