forked from auracaster/bumble_mirror
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ff659383f9 | |||
| f06a35713f | |||
| 737abdc481 | |||
| 02eb4d2e1c |
+2
-2
@@ -580,10 +580,10 @@ class ServiceCapabilities:
|
||||
self.service_category = service_category
|
||||
self.service_capabilities_bytes = service_capabilities_bytes
|
||||
|
||||
def to_string(self, details: List[str] = []) -> str:
|
||||
def to_string(self, details: Optional[List[str]] = None) -> str:
|
||||
attributes = ','.join(
|
||||
[name_or_number(AVDTP_SERVICE_CATEGORY_NAMES, self.service_category)]
|
||||
+ details
|
||||
+ (details or [])
|
||||
)
|
||||
return f'ServiceCapabilities({attributes})'
|
||||
|
||||
|
||||
+3
-3
@@ -345,7 +345,7 @@ class Service(Attribute):
|
||||
uuid: Union[str, UUID],
|
||||
characteristics: List[Characteristic],
|
||||
primary=True,
|
||||
included_services: List[Service] = [],
|
||||
included_services: Iterable[Service] = (),
|
||||
) -> None:
|
||||
# Convert the uuid to a UUID object if it isn't already
|
||||
if isinstance(uuid, str):
|
||||
@@ -361,7 +361,7 @@ class Service(Attribute):
|
||||
uuid.to_pdu_bytes(),
|
||||
)
|
||||
self.uuid = uuid
|
||||
self.included_services = included_services[:]
|
||||
self.included_services = list(included_services)
|
||||
self.characteristics = characteristics[:]
|
||||
self.primary = primary
|
||||
|
||||
@@ -395,7 +395,7 @@ class TemplateService(Service):
|
||||
self,
|
||||
characteristics: List[Characteristic],
|
||||
primary: bool = True,
|
||||
included_services: List[Service] = [],
|
||||
included_services: Iterable[Service] = (),
|
||||
) -> None:
|
||||
super().__init__(self.UUID, characteristics, primary, included_services)
|
||||
|
||||
|
||||
@@ -442,14 +442,15 @@ class AICSService(TemplateService):
|
||||
)
|
||||
|
||||
super().__init__(
|
||||
[
|
||||
characteristics=[
|
||||
self.audio_input_state_characteristic, # type: ignore
|
||||
self.gain_settings_properties_characteristic, # type: ignore
|
||||
self.audio_input_type_characteristic, # type: ignore
|
||||
self.audio_input_status_characteristic, # type: ignore
|
||||
self.audio_input_control_point_characteristic, # type: ignore
|
||||
self.audio_input_description_characteristic, # type: ignore
|
||||
]
|
||||
],
|
||||
primary=False,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ from bumble import device
|
||||
from bumble import gatt
|
||||
from bumble import gatt_client
|
||||
|
||||
from typing import Optional
|
||||
from typing import Optional, Sequence
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Constants
|
||||
@@ -88,6 +88,7 @@ class VolumeControlService(gatt.TemplateService):
|
||||
muted: int = 0,
|
||||
change_counter: int = 0,
|
||||
volume_flags: int = 0,
|
||||
included_services: Sequence[gatt.Service] = (),
|
||||
) -> None:
|
||||
self.step_size = step_size
|
||||
self.volume_setting = volume_setting
|
||||
@@ -117,11 +118,12 @@ class VolumeControlService(gatt.TemplateService):
|
||||
)
|
||||
|
||||
super().__init__(
|
||||
[
|
||||
characteristics=[
|
||||
self.volume_state,
|
||||
self.volume_control_point,
|
||||
self.volume_flags,
|
||||
]
|
||||
],
|
||||
included_services=list(included_services),
|
||||
)
|
||||
|
||||
@property
|
||||
|
||||
+16
-6
@@ -30,10 +30,9 @@ from bumble.profiles.aics import (
|
||||
GainMode,
|
||||
AudioInputStatus,
|
||||
AudioInputControlPointOpCode,
|
||||
GAIN_SETTINGS_MAX_VALUE,
|
||||
GAIN_SETTINGS_MIN_VALUE,
|
||||
ErrorCode,
|
||||
)
|
||||
from bumble.profiles.vcp import VolumeControlService, VolumeControlServiceProxy
|
||||
|
||||
from .test_utils import TwoDevices
|
||||
|
||||
@@ -42,23 +41,34 @@ from .test_utils import TwoDevices
|
||||
# Tests
|
||||
# -----------------------------------------------------------------------------
|
||||
aics_service = AICSService()
|
||||
vcp_service = VolumeControlService(
|
||||
volume_setting=32, muted=1, volume_flags=1, included_services=[aics_service]
|
||||
)
|
||||
|
||||
|
||||
@pytest_asyncio.fixture
|
||||
async def aics_client():
|
||||
devices = TwoDevices()
|
||||
devices[0].add_service(aics_service)
|
||||
devices[0].add_service(vcp_service)
|
||||
|
||||
await devices.setup_connection()
|
||||
|
||||
assert devices.connections[0] is not None
|
||||
assert devices.connections[1] is not None
|
||||
assert devices.connections[0]
|
||||
assert devices.connections[1]
|
||||
|
||||
devices.connections[0].encryption = 1
|
||||
devices.connections[1].encryption = 1
|
||||
|
||||
peer = device.Peer(devices.connections[1])
|
||||
aics_client = await peer.discover_service_and_create_proxy(AICSServiceProxy)
|
||||
|
||||
vcp_client = await peer.discover_service_and_create_proxy(VolumeControlServiceProxy)
|
||||
|
||||
assert vcp_client
|
||||
included_services = await peer.discover_included_services(vcp_client.service_proxy)
|
||||
assert included_services
|
||||
aics_service_discovered = included_services[0]
|
||||
await peer.discover_characteristics(service=aics_service_discovered)
|
||||
aics_client = AICSServiceProxy(aics_service_discovered)
|
||||
|
||||
yield aics_client
|
||||
|
||||
|
||||
@@ -39,6 +39,9 @@ async def vcp_client():
|
||||
|
||||
await devices.setup_connection()
|
||||
|
||||
assert devices.connections[0]
|
||||
assert devices.connections[1]
|
||||
|
||||
# Mock encryption.
|
||||
devices.connections[0].encryption = 1
|
||||
devices.connections[1].encryption = 1
|
||||
|
||||
Reference in New Issue
Block a user