|
65 | 65 | WRITE_UUID = "00000212-b2d1-43f0-9b88-960cebf8b91e" |
66 | 66 | READ_UUID = "00000213-b2d1-43f0-9b88-960cebf8b91e" |
67 | 67 | VERSION_UUID = "00000214-b2d1-43f0-9b88-960cebf8b91e" |
| 68 | +NAME_UUID = "00002a00-0000-1000-8000-00805f9b34fb" |
| 69 | +APPEARANCE_UUID = "00002a01-0000-1000-8000-00805f9b34fb" |
68 | 70 |
|
69 | 71 | if TYPE_CHECKING: |
70 | 72 | from tesla_fleet_api.tesla.tesla import Tesla |
@@ -216,6 +218,39 @@ async def _send(self, msg: RoutableMessage, requires: str, timeout: int = 2) -> |
216 | 218 | if resp.HasField(requires): |
217 | 219 | return resp |
218 | 220 |
|
| 221 | + async def query_name(self, strip_key=True): |
| 222 | + """Read the device name via GATT characteristic if available""" |
| 223 | + try: |
| 224 | + # Standard GATT Device Name characteristic (0x2A00) |
| 225 | + device_name = await self.client.read_gatt_char(NAME_UUID) |
| 226 | + device_name = device_name.decode('utf-8') |
| 227 | + if(strip_key): |
| 228 | + device_name = device_name.replace("🔑 ","") |
| 229 | + return device_name |
| 230 | + except Exception as e: |
| 231 | + LOGGER.error(f"Failed to read device name: {e}") |
| 232 | + return None |
| 233 | + |
| 234 | + async def query_appearance(self) -> bytearray: |
| 235 | + """Read the device appearance via GATT characteristic if available""" |
| 236 | + try: |
| 237 | + # Standard GATT Appearance characteristic (0x2A01) |
| 238 | + return await self.client.read_gatt_char(APPEARANCE_UUID) |
| 239 | + except Exception as e: |
| 240 | + LOGGER.error(f"Failed to read device appearance: {e}") |
| 241 | + return None |
| 242 | + |
| 243 | + async def query_version(self) -> int | None: |
| 244 | + """Read the device version via GATT characteristic if available""" |
| 245 | + try: |
| 246 | + # Custom GATT Version characteristic (0x2A02) |
| 247 | + device_version = await self.client.read_gatt_char(VERSION_UUID) |
| 248 | + # Convert the bytes to an integer |
| 249 | + if device_version and len(device_version) > 0: |
| 250 | + return int.from_bytes(device_version, byteorder='big') |
| 251 | + except Exception as e: |
| 252 | + LOGGER.error(f"Failed to read device version: {e}") |
| 253 | + return None |
219 | 254 |
|
220 | 255 | async def pair(self, role: Role = Role.ROLE_OWNER, form: KeyFormFactor = KeyFormFactor.KEY_FORM_FACTOR_CLOUD_KEY, timeout: int = 60): |
221 | 256 | """Pair the key.""" |
|
0 commit comments