Skip to content

Commit

Permalink
device.py: Add discover_all() api
Browse files Browse the repository at this point in the history
  • Loading branch information
AlanRosenthal committed Jul 10, 2024
1 parent 0f19dd5 commit 8804758
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
18 changes: 3 additions & 15 deletions apps/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,21 +503,9 @@ async def discover_services(self):
self.show_error('not connected')
return

# Discover all services, characteristics and descriptors
self.append_to_output('discovering services...')
await self.connected_peer.discover_services()
self.append_to_output(
f'found {len(self.connected_peer.services)} services,'
' discovering characteristics...'
)
await self.connected_peer.discover_characteristics()
self.append_to_output('found characteristics, discovering descriptors...')
for service in self.connected_peer.services:
for characteristic in service.characteristics:
await self.connected_peer.discover_descriptors(characteristic)
self.append_to_output('discovery completed')

self.show_remote_services(self.connected_peer.services)
self.append_to_output('Service Discovery starting...')
await self.connected_peer.discover_all()
self.append_to_output('Service Discovery done!')

async def discover_attributes(self):
if not self.connected_peer:
Expand Down
9 changes: 9 additions & 0 deletions bumble/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -1133,6 +1133,15 @@ async def discover_descriptors(
async def discover_attributes(self) -> List[gatt_client.AttributeProxy]:
return await self.gatt_client.discover_attributes()

async def discover_all(self):
await self.discover_services()
for service in self.services:
await self.discover_characteristics(service=service)

for service in self.services:
for characteristic in service.characteristics:
await self.discover_descriptors(characteristic=characteristic)

async def subscribe(
self,
characteristic: gatt_client.CharacteristicProxy,
Expand Down

0 comments on commit 8804758

Please sign in to comment.