Skip to content

Commit adde957

Browse files
koffessjanc
authored andcommitted
Updated functions to use new svc data set
Updated tests to use new sdc data set function. Also added tests for: TMAP/BMR/DDI/BV-01-C TMAP/UMR/DDI/BV-01-C TMAP/BMS/DDI/BV-01-C
1 parent 0b0d68b commit adde957

5 files changed

Lines changed: 77 additions & 72 deletions

File tree

autopts/ptsprojects/zephyr/cap.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#
1616

1717
"""CAP test cases"""
18+
import struct
1819

1920
from autopts.client import get_unique_name
2021
from autopts.ptsprojects.stack import SynchPoint, get_stack
@@ -23,8 +24,9 @@
2324
from autopts.ptsprojects.zephyr.ztestcase import ZTestCase, ZTestCaseSlave
2425
from autopts.pybtp import btp
2526
from autopts.pybtp.btp.cap import announcements
27+
from autopts.pybtp.btp.gap import gap_set_uuid16_svc_data
2628
from autopts.pybtp.defs import PACS_AUDIO_CONTEXT_TYPE_CONVERSATIONAL
27-
from autopts.pybtp.types import Addr, Context
29+
from autopts.pybtp.types import UUID, Addr, BAPAnnouncement, CAPAnnouncement, Context
2830
from autopts.utils import ResultWithFlag
2931

3032

@@ -147,12 +149,20 @@ def set_addr(addr):
147149
]
148150

149151
general_conditions = [
150-
TestFunc(announcements, adv_data, rsp_data, False, SINK_CONTEXTS, SOURCE_CONTEXTS),
152+
TestFunc(gap_set_uuid16_svc_data, adv_data, UUID.CAS,
153+
struct.pack('<B', CAPAnnouncement.GENERAL)),
154+
TestFunc(gap_set_uuid16_svc_data, adv_data, UUID.ASCS,
155+
struct.pack('<BHHB', BAPAnnouncement.GENERAL, SINK_CONTEXTS, SOURCE_CONTEXTS, 0)),
156+
TestFunc(announcements, adv_data),
151157
TestFunc(btp.gap_adv_ind_on, ad=adv_data, sd=rsp_data),
152158
]
153159

154160
targeted_conditions = [
155-
TestFunc(announcements, adv_data, rsp_data, True, SINK_CONTEXTS, SOURCE_CONTEXTS),
161+
TestFunc(gap_set_uuid16_svc_data, adv_data, UUID.CAS,
162+
struct.pack('<B', CAPAnnouncement.TARGETED)),
163+
TestFunc(gap_set_uuid16_svc_data, adv_data, UUID.ASCS,
164+
struct.pack('<BHHB', BAPAnnouncement.TARGETED, SINK_CONTEXTS, SOURCE_CONTEXTS, 0)),
165+
TestFunc(announcements, adv_data),
156166
TestFunc(btp.gap_adv_ind_on, ad=adv_data, sd=rsp_data),
157167
]
158168

autopts/ptsprojects/zephyr/hap.py

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@
1515

1616
"""HAP test cases"""
1717
import struct
18-
from enum import IntEnum
1918

2019
from autopts.client import get_unique_name
2120
from autopts.ptsprojects.stack import get_stack
2221
from autopts.ptsprojects.testcase import TestFunc
2322
from autopts.ptsprojects.zephyr.hap_wid import hap_wid_hdl
2423
from autopts.ptsprojects.zephyr.ztestcase import ZTestCase
2524
from autopts.pybtp import btp
25+
from autopts.pybtp.btp.gap import gap_set_uuid16_svc_data
2626
from autopts.pybtp.defs import HAS_TSPX_available_presets_indices, HAS_TSPX_unavailable_presets_indices
27-
from autopts.pybtp.types import Addr, AdType, Context
27+
from autopts.pybtp.types import UUID, Addr, AdType, BAPAnnouncement, CAPAnnouncement, Context
2828

2929
# Options aligned with the overlay-le-audio.conf options
3030
BTP_HAP_HA_OPTS_DEFAULT = (btp.defs.HAP_HA_OPT_PRESETS_DYNAMIC |
@@ -34,14 +34,6 @@
3434
btp.defs.HAP_HA_OPT_PRESETS_WRITABLE)
3535

3636

37-
class Uuid(IntEnum):
38-
ASCS = 0x184E
39-
BASS = 0x184F
40-
PACS = 0x1850
41-
BAAS = 0x1852
42-
CAS = 0x1853
43-
44-
4537
def set_pixits(ptses):
4638
"""Setup HAP profile PIXITS for workspace. Those values are used for test
4739
case if not updated within test case.
@@ -84,16 +76,7 @@ def set_pixits(ptses):
8476
pts.set_pixit("HAP", "TSPX_num_presets", str(num_presets))
8577

8678

87-
def announcements(advData, targeted):
88-
"""
89-
CAP General/Targeted Announcement
90-
"""
91-
advData[AdType.uuid16_svc_data] = [struct.pack('<HB', Uuid.CAS, 1 if targeted else 0)]
92-
"""
93-
BAP General/Targeted Announcement
94-
"""
95-
advData[AdType.uuid16_svc_data] += [struct.pack('<HBHHB', Uuid.ASCS, 1 if targeted else 0,
96-
Context.LIVE | Context.MEDIA, Context.LIVE, 0)]
79+
def set_member_rsi(advData, targeted):
9780
"""
9881
RSI
9982
"""
@@ -152,7 +135,10 @@ def test_cases(ptses):
152135
]
153136

154137
adv_conditions = [
155-
TestFunc(announcements, advData, True),
138+
TestFunc(gap_set_uuid16_svc_data, advData, UUID.CAS, struct.pack('<B', CAPAnnouncement.TARGETED)),
139+
TestFunc(gap_set_uuid16_svc_data, advData, UUID.ASCS, struct.pack('<BHHB', BAPAnnouncement.TARGETED,
140+
Context.LIVE | Context.MEDIA, Context.LIVE, 0)),
141+
TestFunc(set_member_rsi, advData, True),
156142
TestFunc(btp.gap_set_extended_advertising_on),
157143
TestFunc(btp.gap_adv_ind_on, ad=advData),
158144
]

autopts/ptsprojects/zephyr/tmap.py

Lines changed: 50 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
from autopts.ptsprojects.zephyr.tmap_wid import tmap_wid_hdl
2222
from autopts.ptsprojects.zephyr.ztestcase import ZTestCase
2323
from autopts.pybtp import btp
24-
from autopts.pybtp.types import UUID, Addr, AdType, Context
24+
from autopts.pybtp.btp.gap import gap_set_uuid16_svc_data
25+
from autopts.pybtp.types import UUID, Addr, AdType, BAPAnnouncement, CAPAnnouncement, Context, TMAPRole
2526

2627

2728
def set_pixits(ptses):
@@ -52,16 +53,8 @@ def set_pixits(ptses):
5253
pts.set_pixit("TMAP", "TSPX_TARGET_PHY", "LE_2M_PHY")
5354

5455

55-
def announcements(advData, targeted):
56-
"""
57-
CAS General/Targeted Announcement
58-
"""
59-
advData[AdType.uuid16_svc_data] = [struct.pack('<HB', int(UUID.CAS, 16), 1 if targeted else 0)]
60-
"""
61-
ASCS General/Targeted Announcement
62-
"""
63-
advData[AdType.uuid16_svc_data] += [struct.pack('<HBHHB', int(UUID.ASCS, 16), 1 if targeted else 0,
64-
Context.LIVE | Context.MEDIA, Context.LIVE, 0)]
56+
def adv_init(advData):
57+
advData[AdType.uuid16_svc_data] = []
6558

6659

6760
def test_cases(ptses):
@@ -108,19 +101,57 @@ def test_cases(ptses):
108101
TestFunc(stack.csip_init),
109102
]
110103

111-
adv_conditions = [
112-
TestFunc(announcements, advData, True),
104+
adv_end = [
113105
TestFunc(btp.gap_set_extended_advertising_on),
114106
TestFunc(btp.gap_adv_ind_on, ad=advData),
115107
]
116108

117109
custom_test_cases = [
118-
ZTestCase('TMAP', 'TMAP/UMR/ASC/BV-04-C', cmds=pre_conditions + adv_conditions,
119-
generic_wid_hdl=tmap_wid_hdl),
120-
ZTestCase('TMAP', 'TMAP/UMR/ASC/BV-05-C', cmds=pre_conditions + adv_conditions,
121-
generic_wid_hdl=tmap_wid_hdl),
122-
ZTestCase('TMAP', 'TMAP/UMR/ASC/BV-06-C', cmds=pre_conditions + adv_conditions,
123-
generic_wid_hdl=tmap_wid_hdl),
110+
ZTestCase('TMAP', 'TMAP/UMR/ASC/BV-04-C', cmds=pre_conditions + [
111+
TestFunc(adv_init, advData),
112+
TestFunc(gap_set_uuid16_svc_data, advData, UUID.CAS,
113+
struct.pack('<B', CAPAnnouncement.TARGETED)),
114+
TestFunc(gap_set_uuid16_svc_data, advData, UUID.ASCS,
115+
struct.pack('<BHHB', BAPAnnouncement.TARGETED,
116+
Context.LIVE | Context.MEDIA, Context.LIVE, 0))] +
117+
adv_end,
118+
generic_wid_hdl=tmap_wid_hdl),
119+
ZTestCase('TMAP', 'TMAP/UMR/ASC/BV-05-C', cmds=pre_conditions + [
120+
TestFunc(adv_init, advData),
121+
TestFunc(gap_set_uuid16_svc_data, advData, UUID.CAS,
122+
struct.pack('<B', CAPAnnouncement.TARGETED)),
123+
TestFunc(gap_set_uuid16_svc_data, advData, UUID.ASCS,
124+
struct.pack('<BHHB', BAPAnnouncement.TARGETED,
125+
Context.LIVE | Context.MEDIA, Context.LIVE, 0))] +
126+
adv_end,
127+
generic_wid_hdl=tmap_wid_hdl),
128+
ZTestCase('TMAP', 'TMAP/UMR/ASC/BV-06-C', cmds=pre_conditions + [
129+
TestFunc(adv_init, advData),
130+
TestFunc(gap_set_uuid16_svc_data, advData, UUID.CAS,
131+
struct.pack('<B', CAPAnnouncement.TARGETED)),
132+
TestFunc(gap_set_uuid16_svc_data, advData, UUID.ASCS,
133+
struct.pack('<BHHB', BAPAnnouncement.TARGETED,
134+
Context.LIVE | Context.MEDIA, Context.LIVE, 0))] +
135+
adv_end,
136+
generic_wid_hdl=tmap_wid_hdl),
137+
ZTestCase('TMAP', 'TMAP/BMR/DDI/BV-01-C', cmds=pre_conditions + [
138+
TestFunc(adv_init, advData),
139+
TestFunc(gap_set_uuid16_svc_data, advData, UUID.TMAP,
140+
struct.pack('<H', TMAPRole.BROADCAST_MEDIA_RECEIVER))] +
141+
adv_end,
142+
generic_wid_hdl=tmap_wid_hdl),
143+
ZTestCase('TMAP', 'TMAP/UMR/DDI/BV-01-C', cmds=pre_conditions + [
144+
TestFunc(adv_init, advData),
145+
TestFunc(gap_set_uuid16_svc_data, advData, UUID.TMAP,
146+
struct.pack('<H', TMAPRole.UNICAST_MEDIA_RECEIVER))] +
147+
adv_end,
148+
generic_wid_hdl=tmap_wid_hdl),
149+
ZTestCase('TMAP', 'TMAP/BMS/DDI/BV-01-C', cmds=pre_conditions + [
150+
TestFunc(adv_init, advData),
151+
TestFunc(gap_set_uuid16_svc_data, advData, UUID.TMAP,
152+
struct.pack('<H', TMAPRole.BROADCAST_MEDIA_SENDER))] +
153+
adv_end,
154+
generic_wid_hdl=tmap_wid_hdl),
124155
]
125156

126157
test_case_name_list = pts.get_test_case_list('TMAP')
@@ -130,7 +161,6 @@ def test_cases(ptses):
130161
for tc_name in test_case_name_list:
131162
instance = ZTestCase('TMAP', tc_name, cmds=pre_conditions,
132163
generic_wid_hdl=tmap_wid_hdl)
133-
134164
for custom_tc in custom_test_cases:
135165
if tc_name == custom_tc.name:
136166
instance = custom_tc

autopts/pybtp/btp/cap.py

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import binascii
1818
import logging
1919
import struct
20-
from enum import IntEnum
2120

2221
from autopts.ptsprojects.stack import get_stack
2322
from autopts.pybtp import btp, defs
@@ -27,36 +26,12 @@
2726
from autopts.pybtp.common import cap_btp
2827
from autopts.pybtp.types import AdType, BTPError, addr2btp_ba
2928

30-
31-
class Uuid(IntEnum):
32-
ASCS = 0x184E
33-
BASS = 0x184F
34-
PACS = 0x1850
35-
BAAS = 0x1852
36-
CAS = 0x1853
37-
38-
3929
CAP = cap_btp
4030

4131

42-
def announcements(adv_data, rsp_data, targeted, sink_contexts, source_contexts):
32+
def announcements(adv_data):
4333
"""Setup Announcements"""
4434

45-
# CAP General/Targeted Announcement
46-
adv_data[AdType.uuid16_svc_data] = [struct.pack('<HB', Uuid.CAS, 1 if targeted else 0)]
47-
48-
# BAP General/Targeted Announcement
49-
adv_data[AdType.uuid16_svc_data] += [
50-
struct.pack(
51-
"<HBHHB",
52-
Uuid.ASCS,
53-
1 if targeted else 0,
54-
sink_contexts,
55-
source_contexts,
56-
0,
57-
)
58-
]
59-
6035
# Generate the Resolvable Set Identifier (RSI)
6136
rsi = btp.cas_get_member_rsi()
6237
adv_data[AdType.rsi] = struct.pack('<6B', *rsi)

autopts/wid/cap.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@
2222
from autopts.pybtp import btp, defs
2323
from autopts.pybtp.btp import lt2_addr_get, lt2_addr_type_get, lt3_addr_get, lt3_addr_type_get, pts_addr_get, pts_addr_type_get
2424
from autopts.pybtp.btp.cap import announcements
25+
from autopts.pybtp.btp.gap import gap_set_uuid16_svc_data
2526
from autopts.pybtp.btp.pacs import pacs_set_available_contexts
2627
from autopts.pybtp.defs import AUDIO_METADATA_CCID_LIST, AUDIO_METADATA_STREAMING_AUDIO_CONTEXTS
27-
from autopts.pybtp.types import Addr, ASCSState, WIDParams
28+
from autopts.pybtp.types import UUID, Addr, ASCSState, BAPAnnouncement, CAPAnnouncement, WIDParams
2829
from autopts.wid import generic_wid_hdl
2930
from autopts.wid.bap import (
3031
BAS_CONFIG_SETTINGS,
@@ -1005,7 +1006,10 @@ def hdl_wid_421(params: WIDParams):
10051006
adv_data, rsp_data = {}, {}
10061007

10071008
# Set available contexts to 0
1008-
announcements(adv_data, rsp_data, True, 0, 0)
1009+
gap_set_uuid16_svc_data(adv_data, UUID.CAS, struct.pack('<B', CAPAnnouncement.TARGETED))
1010+
gap_set_uuid16_svc_data(adv_data, UUID.ASCS, struct.pack('<BHHB', BAPAnnouncement.TARGETED, 0, 0, 0))
1011+
1012+
announcements(adv_data)
10091013
btp.gap_adv_ind_on(ad=adv_data, sd=rsp_data)
10101014

10111015
# Set available contexts to 0

0 commit comments

Comments
 (0)