mirror of
https://github.com/google/bumble.git
synced 2026-05-08 03:58:01 +00:00
aics: make it a secondary service (#555)
* aics: make it a secondary service --------- Co-authored-by: zxzxwu <92432172+zxzxwu@users.noreply.github.com>
This commit is contained in:
@@ -442,14 +442,15 @@ class AICSService(TemplateService):
|
|||||||
)
|
)
|
||||||
|
|
||||||
super().__init__(
|
super().__init__(
|
||||||
[
|
characteristics=[
|
||||||
self.audio_input_state_characteristic, # type: ignore
|
self.audio_input_state_characteristic, # type: ignore
|
||||||
self.gain_settings_properties_characteristic, # type: ignore
|
self.gain_settings_properties_characteristic, # type: ignore
|
||||||
self.audio_input_type_characteristic, # type: ignore
|
self.audio_input_type_characteristic, # type: ignore
|
||||||
self.audio_input_status_characteristic, # type: ignore
|
self.audio_input_status_characteristic, # type: ignore
|
||||||
self.audio_input_control_point_characteristic, # type: ignore
|
self.audio_input_control_point_characteristic, # type: ignore
|
||||||
self.audio_input_description_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
|
||||||
from bumble import gatt_client
|
from bumble import gatt_client
|
||||||
|
|
||||||
from typing import Optional
|
from typing import Optional, Sequence
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# Constants
|
# Constants
|
||||||
@@ -88,6 +88,7 @@ class VolumeControlService(gatt.TemplateService):
|
|||||||
muted: int = 0,
|
muted: int = 0,
|
||||||
change_counter: int = 0,
|
change_counter: int = 0,
|
||||||
volume_flags: int = 0,
|
volume_flags: int = 0,
|
||||||
|
included_services: Sequence[gatt.Service] = (),
|
||||||
) -> None:
|
) -> None:
|
||||||
self.step_size = step_size
|
self.step_size = step_size
|
||||||
self.volume_setting = volume_setting
|
self.volume_setting = volume_setting
|
||||||
@@ -117,11 +118,12 @@ class VolumeControlService(gatt.TemplateService):
|
|||||||
)
|
)
|
||||||
|
|
||||||
super().__init__(
|
super().__init__(
|
||||||
[
|
characteristics=[
|
||||||
self.volume_state,
|
self.volume_state,
|
||||||
self.volume_control_point,
|
self.volume_control_point,
|
||||||
self.volume_flags,
|
self.volume_flags,
|
||||||
]
|
],
|
||||||
|
included_services=list(included_services),
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|||||||
@@ -30,10 +30,9 @@ from bumble.profiles.aics import (
|
|||||||
GainMode,
|
GainMode,
|
||||||
AudioInputStatus,
|
AudioInputStatus,
|
||||||
AudioInputControlPointOpCode,
|
AudioInputControlPointOpCode,
|
||||||
GAIN_SETTINGS_MAX_VALUE,
|
|
||||||
GAIN_SETTINGS_MIN_VALUE,
|
|
||||||
ErrorCode,
|
ErrorCode,
|
||||||
)
|
)
|
||||||
|
from bumble.profiles.vcp import VolumeControlService, VolumeControlServiceProxy
|
||||||
|
|
||||||
from .test_utils import TwoDevices
|
from .test_utils import TwoDevices
|
||||||
|
|
||||||
@@ -42,23 +41,34 @@ from .test_utils import TwoDevices
|
|||||||
# Tests
|
# Tests
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
aics_service = AICSService()
|
aics_service = AICSService()
|
||||||
|
vcp_service = VolumeControlService(
|
||||||
|
volume_setting=32, muted=1, volume_flags=1, included_services=[aics_service]
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@pytest_asyncio.fixture
|
@pytest_asyncio.fixture
|
||||||
async def aics_client():
|
async def aics_client():
|
||||||
devices = TwoDevices()
|
devices = TwoDevices()
|
||||||
devices[0].add_service(aics_service)
|
devices[0].add_service(vcp_service)
|
||||||
|
|
||||||
await devices.setup_connection()
|
await devices.setup_connection()
|
||||||
|
|
||||||
assert devices.connections[0] is not None
|
assert devices.connections[0]
|
||||||
assert devices.connections[1] is not None
|
assert devices.connections[1]
|
||||||
|
|
||||||
devices.connections[0].encryption = 1
|
devices.connections[0].encryption = 1
|
||||||
devices.connections[1].encryption = 1
|
devices.connections[1].encryption = 1
|
||||||
|
|
||||||
peer = device.Peer(devices.connections[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
|
yield aics_client
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,9 @@ async def vcp_client():
|
|||||||
|
|
||||||
await devices.setup_connection()
|
await devices.setup_connection()
|
||||||
|
|
||||||
|
assert devices.connections[0]
|
||||||
|
assert devices.connections[1]
|
||||||
|
|
||||||
# Mock encryption.
|
# Mock encryption.
|
||||||
devices.connections[0].encryption = 1
|
devices.connections[0].encryption = 1
|
||||||
devices.connections[1].encryption = 1
|
devices.connections[1].encryption = 1
|
||||||
|
|||||||
Reference in New Issue
Block a user