Skip to content

Commit 0bfee4c

Browse files
CopilotRonanB96
andcommitted
Refactor service classes to match characteristic architecture
- Remove @DataClass from BaseGattService and all concrete services - Add SIGServiceResolver for consistent resolution pattern - Add ServiceValidationConfig for validation parameters - Add __init__ and __post_init__ methods to BaseGattService - Make _info the single source of truth for uuid, name, summary - Add get_class_uuid() class method for resolution without instantiation - Refactor CustomBaseGattService with __init_subclass__ hook - Add class-level _info attribute support with SIG override validation - Add UnknownService class in base.py - Update device.py UnknownService to work with new architecture - Add is_sig_service() method to BluetoothUUID class - All 805 tests pass, formatting and linting clean Co-authored-by: RonanB96 <22995167+RonanB96@users.noreply.github.com>
1 parent 02a9b24 commit 0bfee4c

17 files changed

Lines changed: 310 additions & 89 deletions

src/bluetooth_sig/device/device.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,20 @@ def get_characteristic_info_by_name(self, name: CharacteristicName) -> Any | Non
6868
class UnknownService(BaseGattService):
6969
"""Generic service for unknown/unsupported UUIDs."""
7070

71+
def __init__(self, uuid: str | None = None) -> None:
72+
"""Initialize unknown service with optional UUID."""
73+
from ..types import ServiceInfo
74+
from ..types.uuid import BluetoothUUID
75+
76+
# Use provided UUID or a placeholder
77+
service_uuid = BluetoothUUID(uuid) if uuid else BluetoothUUID("00001234-0000-1000-8000-00805F9B34FB")
78+
info = ServiceInfo(
79+
uuid=service_uuid,
80+
name=f"Unknown Service ({service_uuid})",
81+
description="",
82+
)
83+
super().__init__(info=info)
84+
7185
@classmethod
7286
def get_expected_characteristics(cls) -> CharacteristicCollection:
7387
return {}

src/bluetooth_sig/gatt/services/automation_io.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@
22

33
from __future__ import annotations
44

5-
from dataclasses import dataclass
65
from typing import ClassVar
76

87
from ..characteristics.registry import CharacteristicName
98
from .base import BaseGattService
109

1110

12-
@dataclass
1311
class AutomationIOService(BaseGattService):
1412
"""Automation IO Service implementation.
1513

0 commit comments

Comments
 (0)