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
|
// Not strictly necessary to send but nice for debugging
|
||||||
// purposes.
|
// purposes.
|
||||||
string client_info = 1;
|
string client_info = 1;
|
||||||
|
uint32 api_version_major = 2;
|
||||||
|
uint32 api_version_minor = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Confirmation of successful connection request.
|
// Confirmation of successful connection request.
|
||||||
|
@ -1146,7 +1148,8 @@ message SubscribeBluetoothLEAdvertisementsRequest {
|
||||||
|
|
||||||
message BluetoothServiceData {
|
message BluetoothServiceData {
|
||||||
string uuid = 1;
|
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 {
|
message BluetoothLEAdvertisementResponse {
|
||||||
option (id) = 67;
|
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."""
|
"""Step 4 in connect process: send hello and get api version."""
|
||||||
hello = HelloRequest()
|
hello = HelloRequest()
|
||||||
hello.client_info = self._params.client_info
|
hello.client_info = self._params.client_info
|
||||||
|
hello.api_version_major = 1
|
||||||
|
hello.api_version_minor = 7
|
||||||
try:
|
try:
|
||||||
resp = await self.send_message_await_response(hello, HelloResponse)
|
resp = await self.send_message_await_response(hello, HelloResponse)
|
||||||
except TimeoutAPIError as err:
|
except TimeoutAPIError as err:
|
||||||
|
|
|
@ -778,7 +778,7 @@ def _convert_bluetooth_le_service_data(
|
||||||
if isinstance(value, dict):
|
if isinstance(value, dict):
|
||||||
return value
|
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(
|
def _convert_bluetooth_le_manufacturer_data(
|
||||||
|
@ -786,7 +786,8 @@ def _convert_bluetooth_le_manufacturer_data(
|
||||||
) -> Dict[int, bytes]:
|
) -> Dict[int, bytes]:
|
||||||
if isinstance(value, dict):
|
if isinstance(value, dict):
|
||||||
return value
|
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)
|
@dataclass(frozen=True)
|
||||||
|
@ -819,7 +820,7 @@ class BluetoothGATTRead(APIModelBase):
|
||||||
address: int = 0
|
address: int = 0
|
||||||
handle: int = 0
|
handle: int = 0
|
||||||
|
|
||||||
data: bytes = b""
|
data: bytes = field(default_factory=bytes)
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True)
|
||||||
|
|
Loading…
Reference in New Issue