forked from auracaster/bumble_mirror
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)
|
characteristics.append(self.gmap_role)
|
||||||
|
|
||||||
if ugg_features is not None:
|
if gmap_role & GmapRole.UNICAST_GAME_GATEWAY:
|
||||||
self.ugg_features = Characteristic(
|
self.ugg_features = Characteristic(
|
||||||
uuid=GATT_UGG_FEATURES_CHARACTERISTIC,
|
uuid=GATT_UGG_FEATURES_CHARACTERISTIC,
|
||||||
properties=Characteristic.Properties.READ,
|
properties=Characteristic.Properties.READ,
|
||||||
@@ -110,7 +110,7 @@ class GamingAudioService(TemplateService):
|
|||||||
)
|
)
|
||||||
characteristics.append(self.ugg_features)
|
characteristics.append(self.ugg_features)
|
||||||
|
|
||||||
if ugt_features is not None:
|
if gmap_role & GmapRole.UNICAST_GAME_TERMINAL:
|
||||||
self.ugt_features = Characteristic(
|
self.ugt_features = Characteristic(
|
||||||
uuid=GATT_UGT_FEATURES_CHARACTERISTIC,
|
uuid=GATT_UGT_FEATURES_CHARACTERISTIC,
|
||||||
properties=Characteristic.Properties.READ,
|
properties=Characteristic.Properties.READ,
|
||||||
@@ -119,7 +119,7 @@ class GamingAudioService(TemplateService):
|
|||||||
)
|
)
|
||||||
characteristics.append(self.ugt_features)
|
characteristics.append(self.ugt_features)
|
||||||
|
|
||||||
if bgs_features is not None:
|
if gmap_role & GmapRole.BROADCAST_GAME_SENDER:
|
||||||
self.bgs_features = Characteristic(
|
self.bgs_features = Characteristic(
|
||||||
uuid=GATT_BGS_FEATURES_CHARACTERISTIC,
|
uuid=GATT_BGS_FEATURES_CHARACTERISTIC,
|
||||||
properties=Characteristic.Properties.READ,
|
properties=Characteristic.Properties.READ,
|
||||||
@@ -128,7 +128,7 @@ class GamingAudioService(TemplateService):
|
|||||||
)
|
)
|
||||||
characteristics.append(self.bgs_features)
|
characteristics.append(self.bgs_features)
|
||||||
|
|
||||||
if bgr_features is not None:
|
if gmap_role & GmapRole.BROADCAST_GAME_RECEIVER:
|
||||||
self.bgr_features = Characteristic(
|
self.bgr_features = Characteristic(
|
||||||
uuid=GATT_BGR_FEATURES_CHARACTERISTIC,
|
uuid=GATT_BGR_FEATURES_CHARACTERISTIC,
|
||||||
properties=Characteristic.Properties.READ,
|
properties=Characteristic.Properties.READ,
|
||||||
|
|||||||
@@ -36,7 +36,10 @@ from .test_utils import TwoDevices
|
|||||||
# Tests
|
# Tests
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
gmas_service = GamingAudioService(
|
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,
|
ugg_features=UggFeatures.UGG_MULTISINK,
|
||||||
ugt_features=UgtFeatures.UGT_SOURCE,
|
ugt_features=UgtFeatures.UGT_SOURCE,
|
||||||
bgr_features=BgrFeatures.BGR_MULTISINK,
|
bgr_features=BgrFeatures.BGR_MULTISINK,
|
||||||
@@ -68,7 +71,13 @@ async def gmap_client():
|
|||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_init_service(gmap_client: GamingAudioServiceProxy):
|
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.ugg_features.read_value() == UggFeatures.UGG_MULTISINK
|
||||||
assert await gmap_client.ugt_features.read_value() == UgtFeatures.UGT_SOURCE
|
assert await gmap_client.ugt_features.read_value() == UgtFeatures.UGT_SOURCE
|
||||||
assert await gmap_client.bgr_features.read_value() == BgrFeatures.BGR_MULTISINK
|
assert await gmap_client.bgr_features.read_value() == BgrFeatures.BGR_MULTISINK
|
||||||
|
|||||||
Reference in New Issue
Block a user