mirror of
https://github.com/esphome/aioesphomeapi.git
synced 2025-03-20 14:49:54 +01:00
Change BLE advertisement data to bytes (#262)
This commit is contained in:
parent
abf59f2d9d
commit
c5779b3e17
@ -87,6 +87,8 @@ message HelloRequest {
|
||||
// Not strictly necessary to send but nice for debugging
|
||||
// purposes.
|
||||
string client_info = 1;
|
||||
uint32 api_version_major = 2;
|
||||
uint32 api_version_minor = 3;
|
||||
}
|
||||
|
||||
// Confirmation of successful connection request.
|
||||
@ -1146,7 +1148,8 @@ message SubscribeBluetoothLEAdvertisementsRequest {
|
||||
|
||||
message BluetoothServiceData {
|
||||
string uuid = 1;
|
||||
repeated uint32 data = 2 [packed=true];
|
||||
repeated uint32 legacy_data = 2 [packed=true]; // Removed in api version 1.7
|
||||
bytes data = 3; // Added in api version 1.7
|
||||
}
|
||||
message BluetoothLEAdvertisementResponse {
|
||||
option (id) = 67;
|
||||
|
File diff suppressed because one or more lines are too long
@ -190,6 +190,8 @@ class APIConnection:
|
||||
"""Step 4 in connect process: send hello and get api version."""
|
||||
hello = HelloRequest()
|
||||
hello.client_info = self._params.client_info
|
||||
hello.api_version_major = 1
|
||||
hello.api_version_minor = 7
|
||||
try:
|
||||
resp = await self.send_message_await_response(hello, HelloResponse)
|
||||
except TimeoutAPIError as err:
|
||||
|
@ -778,7 +778,7 @@ def _convert_bluetooth_le_service_data(
|
||||
if isinstance(value, dict):
|
||||
return value
|
||||
|
||||
return {_long_uuid(v.uuid): bytes(v.data) for v in value} # type: ignore
|
||||
return {_long_uuid(v.uuid): bytes(v.data if v.data else v.legacy_data) for v in value} # type: ignore
|
||||
|
||||
|
||||
def _convert_bluetooth_le_manufacturer_data(
|
||||
@ -786,7 +786,8 @@ def _convert_bluetooth_le_manufacturer_data(
|
||||
) -> Dict[int, bytes]:
|
||||
if isinstance(value, dict):
|
||||
return value
|
||||
return {int(v.uuid, 16): bytes(v.data) for v in value} # type: ignore
|
||||
# v.data if v.data else v.legacy_data is backwards compatable with ESPHome devices before 2022.10.0
|
||||
return {int(v.uuid, 16): bytes(v.data if v.data else v.legacy_data) for v in value} # type: ignore
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@ -819,7 +820,7 @@ class BluetoothGATTRead(APIModelBase):
|
||||
address: int = 0
|
||||
handle: int = 0
|
||||
|
||||
data: bytes = b""
|
||||
data: bytes = field(default_factory=bytes)
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
|
Loading…
Reference in New Issue
Block a user