Try joining split uint64 uuid

This commit is contained in:
Jesse Hills 2022-09-29 11:05:55 +13:00
parent b61110c154
commit 8560a3611c
No known key found for this signature in database
GPG Key ID: BEAAE804EFD8E83A
3 changed files with 90 additions and 92 deletions

View File

@ -1199,20 +1199,19 @@ message BluetoothGATTGetServicesRequest {
}
message BluetoothGATTDescriptor {
string uuid = 1;
repeated uint64 uuid = 1;
uint32 handle = 2;
string description = 3;
}
message BluetoothGATTCharacteristic {
string uuid = 1;
repeated uint64 uuid = 1;
uint32 handle = 2;
uint32 properties = 3;
repeated BluetoothGATTDescriptor descriptors = 4;
}
message BluetoothGATTService {
string uuid = 1;
repeated uint64 uuid = 1;
uint32 handle = 2;
repeated BluetoothGATTCharacteristic characteristics = 3;
}

File diff suppressed because one or more lines are too long

View File

@ -13,6 +13,7 @@ from typing import (
Union,
cast,
)
import uuid
from .util import fix_float_single_double_conversion
@ -762,6 +763,11 @@ def _long_uuid(uuid: str) -> str:
).lower()
def _join_split_uuid(value: List[int]) -> str:
"""Convert a high/low uuid into a single string."""
return uuid.UUID(int=(value[0] << 64) | value[1]).__str__()
def _convert_bluetooth_le_service_uuids(value: List[str]) -> List[str]:
return [_long_uuid(v) for v in value]
@ -818,7 +824,7 @@ class BluetoothGATTRead(APIModelBase):
@dataclass(frozen=True)
class BluetoothGATTDescriptor(APIModelBase):
uuid: str = converter_field(default="", converter=_long_uuid)
uuid: str = converter_field(default="", converter=_join_split_uuid)
handle: int = 0
description: str = ""
@ -835,7 +841,7 @@ class BluetoothGATTDescriptor(APIModelBase):
@dataclass(frozen=True)
class BluetoothGATTCharacteristic(APIModelBase):
uuid: str = converter_field(default="", converter=_long_uuid)
uuid: str = converter_field(default="", converter=_join_split_uuid)
handle: int = 0
properties: int = 0
@ -856,7 +862,7 @@ class BluetoothGATTCharacteristic(APIModelBase):
@dataclass(frozen=True)
class BluetoothGATTService(APIModelBase):
uuid: str = converter_field(default="", converter=_long_uuid)
uuid: str = converter_field(default="", converter=_join_split_uuid)
handle: int = 0
characteristics: List[BluetoothGATTCharacteristic] = converter_field(
default_factory=list, converter=BluetoothGATTCharacteristic.convert_list