Add address_type to BluetoothLEAdvertisementResponse and BluetoothDeviceRequest (#320)

This commit is contained in:
J. Nick Koston 2022-11-28 18:00:27 -10:00 committed by GitHub
parent 073b564bb0
commit a937d9d85a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 97 additions and 87 deletions

View File

@ -1167,6 +1167,7 @@ message BluetoothLEAdvertisementResponse {
repeated string service_uuids = 4;
repeated BluetoothServiceData service_data = 5;
repeated BluetoothServiceData manufacturer_data = 6;
uint32 address_type = 7;
}
enum BluetoothDeviceRequestType {
@ -1185,6 +1186,8 @@ message BluetoothDeviceRequest {
uint64 address = 1;
BluetoothDeviceRequestType request_type = 2;
bool has_address_type = 3;
uint32 address_type = 4;
}
message BluetoothDeviceConnectionResponse {

File diff suppressed because one or more lines are too long

View File

@ -494,6 +494,7 @@ class APIClient:
disconnect_timeout: float = DEFAULT_BLE_DISCONNECT_TIMEOUT,
version: int = 1,
has_cache: bool = False,
address_type: Optional[int] = None,
) -> Callable[[], None]:
self._check_authenticated()
@ -522,7 +523,12 @@ class APIClient:
request_type = BluetoothDeviceRequestType.CONNECT
await self._connection.send_message_callback_response(
BluetoothDeviceRequest(address=address, request_type=request_type),
BluetoothDeviceRequest(
address=address,
request_type=request_type,
has_address_type=address_type is not None,
address_type=address_type or 0,
),
on_msg,
)

View File

@ -797,6 +797,7 @@ class BluetoothLEAdvertisement(APIModelBase):
address: int = 0
name: str = ""
rssi: int = 0
address_type: int = 0
service_uuids: List[str] = converter_field(
default_factory=list, converter=_convert_bluetooth_le_service_uuids