Include Bluetooth connection slot allocations in connections free message (#1038)

This commit is contained in:
J. Nick Koston 2025-01-27 17:09:39 -10:00 committed by GitHub
parent 13c71fc52c
commit a7758314f1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 165 additions and 159 deletions

View File

@ -1404,6 +1404,7 @@ message BluetoothConnectionsFreeResponse {
uint32 free = 1; uint32 free = 1;
uint32 limit = 2; uint32 limit = 2;
repeated uint64 allocated = 3;
} }
message BluetoothGATTErrorResponse { message BluetoothGATTErrorResponse {

File diff suppressed because one or more lines are too long

View File

@ -521,7 +521,8 @@ class APIClient:
return partial(self._unsub_bluetooth_advertisements, unsub_callback) return partial(self._unsub_bluetooth_advertisements, unsub_callback)
def subscribe_bluetooth_connections_free( def subscribe_bluetooth_connections_free(
self, on_bluetooth_connections_free_update: Callable[[int, int], None] self,
on_bluetooth_connections_free_update: Callable[[int, int, list[int]], None],
) -> Callable[[], None]: ) -> Callable[[], None]:
return self._get_connection().send_message_callback_response( return self._get_connection().send_message_callback_response(
SubscribeBluetoothConnectionsFreeRequest(), SubscribeBluetoothConnectionsFreeRequest(),

View File

@ -71,10 +71,10 @@ def on_bluetooth_le_advertising_response(
def on_bluetooth_connections_free_response( def on_bluetooth_connections_free_response(
on_bluetooth_connections_free_update: Callable[[int, int], None], on_bluetooth_connections_free_update: Callable[[int, int, list[int]], None],
msg: BluetoothConnectionsFreeResponse, msg: BluetoothConnectionsFreeResponse,
) -> None: ) -> None:
on_bluetooth_connections_free_update(msg.free, msg.limit) on_bluetooth_connections_free_update(msg.free, msg.limit, list(msg.allocated))
def on_bluetooth_gatt_notify_data_response( def on_bluetooth_gatt_notify_data_response(

View File

@ -1858,15 +1858,19 @@ async def test_subscribe_bluetooth_connections_free(
client, connection, transport, protocol = api_client client, connection, transport, protocol = api_client
connections = [] connections = []
def on_bluetooth_connections_free(free: int, limit: int) -> None: def on_bluetooth_connections_free(
connections.append((free, limit)) free: int, limit: int, allocated: list[int]
) -> None:
connections.append((free, limit, allocated))
unsub = client.subscribe_bluetooth_connections_free(on_bluetooth_connections_free) unsub = client.subscribe_bluetooth_connections_free(on_bluetooth_connections_free)
await asyncio.sleep(0) await asyncio.sleep(0)
response: message.Message = BluetoothConnectionsFreeResponse(free=2, limit=3) response: message.Message = BluetoothConnectionsFreeResponse(
free=2, limit=3, allocated=[1234, 5678]
)
mock_data_received(protocol, generate_plaintext_packet(response)) mock_data_received(protocol, generate_plaintext_packet(response))
assert connections == [(2, 3)] assert connections == [(2, 3, [1234, 5678])]
unsub() unsub()