mirror of
https://github.com/google/bumble.git
synced 2026-05-10 04:18:03 +00:00
Add characteristics conditionally
Only adds a characteristic if the corresponding role has been set
This commit is contained in:
@@ -101,7 +101,7 @@ class GamingAudioService(TemplateService):
|
||||
)
|
||||
characteristics.append(self.gmap_role)
|
||||
|
||||
if ugg_features is not None:
|
||||
if gmap_role & GmapRole.UNICAST_GAME_GATEWAY:
|
||||
self.ugg_features = Characteristic(
|
||||
uuid=GATT_UGG_FEATURES_CHARACTERISTIC,
|
||||
properties=Characteristic.Properties.READ,
|
||||
@@ -110,7 +110,7 @@ class GamingAudioService(TemplateService):
|
||||
)
|
||||
characteristics.append(self.ugg_features)
|
||||
|
||||
if ugt_features is not None:
|
||||
if gmap_role & GmapRole.UNICAST_GAME_TERMINAL:
|
||||
self.ugt_features = Characteristic(
|
||||
uuid=GATT_UGT_FEATURES_CHARACTERISTIC,
|
||||
properties=Characteristic.Properties.READ,
|
||||
@@ -119,7 +119,7 @@ class GamingAudioService(TemplateService):
|
||||
)
|
||||
characteristics.append(self.ugt_features)
|
||||
|
||||
if bgs_features is not None:
|
||||
if gmap_role & GmapRole.BROADCAST_GAME_SENDER:
|
||||
self.bgs_features = Characteristic(
|
||||
uuid=GATT_BGS_FEATURES_CHARACTERISTIC,
|
||||
properties=Characteristic.Properties.READ,
|
||||
@@ -128,7 +128,7 @@ class GamingAudioService(TemplateService):
|
||||
)
|
||||
characteristics.append(self.bgs_features)
|
||||
|
||||
if bgr_features is not None:
|
||||
if gmap_role & GmapRole.BROADCAST_GAME_RECEIVER:
|
||||
self.bgr_features = Characteristic(
|
||||
uuid=GATT_BGR_FEATURES_CHARACTERISTIC,
|
||||
properties=Characteristic.Properties.READ,
|
||||
|
||||
@@ -36,7 +36,10 @@ from .test_utils import TwoDevices
|
||||
# Tests
|
||||
# -----------------------------------------------------------------------------
|
||||
gmas_service = GamingAudioService(
|
||||
gmap_role=GmapRole.UNICAST_GAME_GATEWAY,
|
||||
gmap_role=GmapRole.UNICAST_GAME_GATEWAY
|
||||
| GmapRole.UNICAST_GAME_TERMINAL
|
||||
| GmapRole.BROADCAST_GAME_RECEIVER
|
||||
| GmapRole.BROADCAST_GAME_SENDER,
|
||||
ugg_features=UggFeatures.UGG_MULTISINK,
|
||||
ugt_features=UgtFeatures.UGT_SOURCE,
|
||||
bgr_features=BgrFeatures.BGR_MULTISINK,
|
||||
@@ -68,7 +71,13 @@ async def gmap_client():
|
||||
# -----------------------------------------------------------------------------
|
||||
@pytest.mark.asyncio
|
||||
async def test_init_service(gmap_client: GamingAudioServiceProxy):
|
||||
assert await gmap_client.gmap_role.read_value() == GmapRole.UNICAST_GAME_GATEWAY
|
||||
assert (
|
||||
await gmap_client.gmap_role.read_value()
|
||||
== GmapRole.UNICAST_GAME_GATEWAY
|
||||
| GmapRole.UNICAST_GAME_TERMINAL
|
||||
| GmapRole.BROADCAST_GAME_RECEIVER
|
||||
| GmapRole.BROADCAST_GAME_SENDER
|
||||
)
|
||||
assert await gmap_client.ugg_features.read_value() == UggFeatures.UGG_MULTISINK
|
||||
assert await gmap_client.ugt_features.read_value() == UgtFeatures.UGT_SOURCE
|
||||
assert await gmap_client.bgr_features.read_value() == BgrFeatures.BGR_MULTISINK
|
||||
|
||||
Reference in New Issue
Block a user