Skip to content

Commit e79e749

Browse files
gWaceysjanc
authored andcommitted
Add test BAP/BSRC/SCC/BV-38-C
- Add test BAP/BSRC/SCC/BV-38-C - Add bap_broadcast_source_setup_v2, includes broadcast_id Signed-off-by: Graham Wacey <graham.wacey@nordicsemi.no> Signed-off-by: Alexander Svensen <alexander.svensen@nordicsemi.no>
1 parent cf95eae commit e79e749

File tree

6 files changed

+110
-11
lines changed

6 files changed

+110
-11
lines changed

autopts/ptsprojects/stack/layers/bap.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ def __init__(self):
2525
def __init__(self):
2626
self.peers = {}
2727
self.ase_configs = []
28-
self.broadcast_id = 0x1000000 # Invalid Broadcast ID
28+
self.broadcast_id = None
29+
self.broadcast_id_2 = None
2930
self.broadcast_code = ''
31+
self.hdl_wid_114_cnt = 0
3032
self.event_queues = {
3133
defs.BTP_BAP_EV_DISCOVERY_COMPLETED: [],
3234
defs.BTP_BAP_EV_CODEC_CAP_FOUND: [],
@@ -55,6 +57,12 @@ def get_peer(self, addr_type, addr):
5557
def set_broadcast_code(self, broadcast_code):
5658
self.broadcast_code = broadcast_code
5759

60+
def set_broadcast_id(self, broadcast_id):
61+
self.broadcast_id = broadcast_id
62+
63+
def set_broadcast_id_2(self, broadcast_id):
64+
self.broadcast_id_2 = broadcast_id
65+
5866
def event_received(self, event_type, event_data_tuple):
5967
if event_type in self.event_handlers:
6068
self.event_handlers[event_type](*event_data_tuple)

autopts/ptsprojects/zephyr/bap.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
from autopts.pybtp.types import Addr, AdType, UUID, AdFlags
2525
from autopts.utils import ResultWithFlag
2626

27-
broadcast_code = '0102680553F1415AA265BBAFC6EA03B8'
27+
BROADCAST_CODE = '0102680553F1415AA265BBAFC6EA03B8'
28+
BROADCAST_ID = 0x123456
29+
BROADCAST_ID_2 = 0x234567
2830

2931

3032
def set_pixits(ptses):
@@ -52,7 +54,9 @@ def set_pixits(ptses):
5254
pts.set_pixit("BAP", "TSPX_iut_ATT_transport", "ATT Bearer on LE Transport")
5355
pts.set_pixit("BAP", "TSPX_VS_Codec_ID", "ffff")
5456
pts.set_pixit("BAP", "TSPX_VS_Company_ID", "ffff")
55-
pts.set_pixit("BAP", "TSPX_broadcast_code", broadcast_code)
57+
pts.set_pixit("BAP", "TSPX_broadcast_code", BROADCAST_CODE)
58+
pts.set_pixit("BAP", "TSPX_Broadcast_ID", BROADCAST_ID)
59+
pts.set_pixit("BAP", "TSPX_Broadcast_ID_2", BROADCAST_ID_2)
5660

5761
if len(ptses) < 2:
5862
return
@@ -72,7 +76,7 @@ def set_pixits(ptses):
7276
pts2.set_pixit("BAP", "TSPX_iut_ATT_transport", "ATT Bearer on LE Transport")
7377
pts2.set_pixit("BAP", "TSPX_VS_Codec_ID", "ffff")
7478
pts2.set_pixit("BAP", "TSPX_VS_Company_ID", "ffff")
75-
pts2.set_pixit("BAP", "TSPX_broadcast_code", broadcast_code)
79+
pts2.set_pixit("BAP", "TSPX_broadcast_code", BROADCAST_CODE)
7680

7781

7882
def test_cases(ptses):
@@ -124,9 +128,11 @@ def set_addr(addr):
124128
TestFunc(btp.core_reg_svc_bap),
125129
TestFunc(stack.ascs_init),
126130
TestFunc(stack.bap_init),
127-
TestFunc(lambda: stack.bap.set_broadcast_code(broadcast_code)),
131+
TestFunc(lambda: stack.bap.set_broadcast_code(BROADCAST_CODE)),
128132
TestFunc(lambda: set_addr(
129133
stack.gap.iut_addr_get_str())),
134+
TestFunc(lambda: stack.bap.set_broadcast_id(BROADCAST_ID)),
135+
TestFunc(lambda: stack.bap.set_broadcast_id_2(BROADCAST_ID_2)),
130136
]
131137

132138
pre_conditions_server = pre_conditions + [

autopts/pybtp/btp/bap.py

+42
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@
7474
'set_broadcast_code': (defs.BTP_SERVICE_ID_BAP, defs.BTP_BAP_CMD_SET_BROADCAST_CODE,
7575
CONTROLLER_INDEX),
7676
'bap_send_past': (defs.BTP_SERVICE_ID_BAP, defs.BTP_BAP_CMD_SEND_PAST, CONTROLLER_INDEX),
77+
'broadcast_source_setup_v2': (defs.BTP_SERVICE_ID_BAP, defs.BTP_BAP_CMD_BROADCAST_SOURCE_SETUP_V2,
78+
CONTROLLER_INDEX),
7779
}
7880

7981

@@ -166,6 +168,46 @@ def bap_broadcast_source_setup(
166168
return broadcast_id
167169

168170

171+
def bap_broadcast_source_setup_v2(
172+
broadcast_id, streams_per_subgroup, subgroups, coding_format, vid, cid,
173+
codec_ltvs, sdu_interval, framing, max_sdu, retransmission_number,
174+
max_transport_latency, presentation_delay):
175+
176+
logging.debug(f"{bap_broadcast_source_setup_v2.__name__}")
177+
178+
iutctl = get_iut()
179+
data = bytearray()
180+
data += int.to_bytes(broadcast_id, 3, 'little')
181+
data += struct.pack('B', streams_per_subgroup)
182+
data += struct.pack('B', subgroups)
183+
184+
# QoS Config
185+
data += int.to_bytes(sdu_interval, 3, 'little')
186+
data += struct.pack('B', framing)
187+
data += struct.pack('<H', max_sdu)
188+
data += struct.pack('B', retransmission_number)
189+
data += struct.pack('<H', max_transport_latency)
190+
data += int.to_bytes(presentation_delay, 3, 'little')
191+
192+
# Codec Config
193+
data += struct.pack('B', coding_format)
194+
data += struct.pack('<H', vid)
195+
data += struct.pack('<H', cid)
196+
codec_ltvs_len = len(codec_ltvs)
197+
data += struct.pack('B', codec_ltvs_len)
198+
if codec_ltvs_len:
199+
data += codec_ltvs
200+
201+
iutctl.btp_socket.send(*BAP['broadcast_source_setup_v2'], data=data)
202+
203+
tuple_data = bap_command_rsp_succ()[0]
204+
gap_settings = int.from_bytes(tuple_data[:4], 'little')
205+
broadcast_id = int.from_bytes(tuple_data[4:7], 'little')
206+
__gap_current_settings_update(gap_settings)
207+
208+
return broadcast_id
209+
210+
169211
def bap_broadcast_source_release(broadcast_id):
170212
logging.debug(f"{bap_broadcast_source_release.__name__}")
171213

autopts/pybtp/defs.py

+1
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,7 @@ def BIT(bit):
663663
BTP_BAP_CMD_MODIFY_BROADCAST_SRC = 0x16
664664
BTP_BAP_CMD_SET_BROADCAST_CODE = 0x17
665665
BTP_BAP_CMD_SEND_PAST = 0x18
666+
BTP_BAP_CMD_BROADCAST_SOURCE_SETUP_V2 = 0x19
666667
BTP_BAP_EV_DISCOVERY_COMPLETED = 0x80
667668
BTP_BAP_EV_CODEC_CAP_FOUND = 0x81
668669
BTP_BAP_EV_ASE_FOUND = 0x82

autopts/wid/bap.py

+24-6
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
from autopts.ptsprojects.testcase import MMI
2222
from autopts.pybtp import btp
2323
from autopts.pybtp.btp import pts_addr_get, pts_addr_type_get, ascs_add_ase_to_cis, lt2_addr_get, lt2_addr_type_get
24+
from autopts.pybtp.btp.btp import CONTROLLER_INDEX, btp_hdr_check, get_iut_method as get_iut, pts_addr_get, \
25+
pts_addr_type_get
2426
from autopts.pybtp.types import *
2527
from autopts.wid import generic_wid_hdl
2628

@@ -240,6 +242,7 @@ def hdl_wid_114(params: WIDParams):
240242
'BAP/BSRC/SCC/BV-30-C': '48_4_2',
241243
'BAP/BSRC/SCC/BV-31-C': '48_5_2',
242244
'BAP/BSRC/SCC/BV-32-C': '48_6_2',
245+
'BAP/BSRC/SCC/BV-38-C': '16_2_1',
243246
# Cases with 1 BIS:
244247
'BAP/BSRC/STR/BV-01-C': '8_1_1',
245248
'BAP/BSRC/STR/BV-02-C': '8_2_1',
@@ -276,6 +279,15 @@ def hdl_wid_114(params: WIDParams):
276279
'BAP/BSRC/STR/BV-33-C': '48_6_1',
277280
}
278281

282+
stack = get_stack()
283+
284+
if stack.bap.hdl_wid_114_cnt == 0:
285+
broadcast_id = stack.bap.broadcast_id
286+
elif stack.bap.hdl_wid_114_cnt == 1:
287+
broadcast_id = stack.bap.broadcast_id_2
288+
else:
289+
raise ValuError("hdl_wid_114 is not 0 or 1")
290+
279291
if params.test_case_name in configurations:
280292
qos_set_name = configurations[params.test_case_name]
281293
coding_format = 0x06
@@ -305,12 +317,15 @@ def hdl_wid_114(params: WIDParams):
305317

306318
presentation_delay = 40000
307319
subgroups = 1
308-
broadcast_id = btp.bap_broadcast_source_setup(
309-
streams_per_subgroup, subgroups, coding_format, vid, cid,
310-
codec_ltvs_bytes, *qos_config, presentation_delay)
311320

312-
stack = get_stack()
313-
stack.bap.broadcast_id = broadcast_id
321+
if params.test_case_name.startswith("BAP/BSRC/SCC/BV-38-C"):
322+
btp.bap_broadcast_source_setup_v2(broadcast_id, streams_per_subgroup, subgroups,
323+
coding_format, vid, cid, codec_ltvs_bytes,
324+
*qos_config, presentation_delay)
325+
else:
326+
broadcast_id = btp.bap_broadcast_source_setup(streams_per_subgroup, subgroups,
327+
coding_format, vid, cid, codec_ltvs_bytes,
328+
*qos_config, presentation_delay)
314329

315330
btp.bap_broadcast_adv_start(broadcast_id)
316331

@@ -325,6 +340,8 @@ def hdl_wid_114(params: WIDParams):
325340
# Buffer full
326341
pass
327342

343+
stack.bap.hdl_wid_114_cnt += 1
344+
328345
return True
329346

330347

@@ -2015,12 +2032,13 @@ def hdl_wid_380(_: WIDParams):
20152032
audio_locations, octets_per_frame,
20162033
frames_per_sdu)
20172034

2035+
broadcast_id = 0x123456
20182036
presentation_delay = 40000
20192037
streams_per_subgroup = 2
20202038
subgroups = 1
20212039
broadcast_id = btp.bap_broadcast_source_setup(
20222040
streams_per_subgroup, subgroups, coding_format, vid, cid,
2023-
codec_ltvs_bytes, *qos_config, presentation_delay)
2041+
codec_ltvs_bytes, *qos_config, presentation_delay, broadcast_id)
20242042

20252043
stack.bap.broadcast_id = broadcast_id
20262044

doc/btp_bap.txt

+24
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,30 @@ Commands and responses:
338338
In case of a success, the IUT continues processing the command
339339
asynchronously.
340340

341+
Opcode 0x19 - Broadcast Source Setup v2
342+
Controller Index: <controller id>
343+
Command parameters: Broadcast ID (3 octets)
344+
Streams Per Subgroup (1 octet)
345+
Subgroups (1 octet)
346+
Sdu Interval (3 octets)
347+
Framing (1 octet)
348+
Max SDU (2 octets)
349+
Retransmission Num (1 octet)
350+
Max Transport Latency (2 octets)
351+
Presentation Delay (3 octets)
352+
Coding Format (1 octet)
353+
VID (2 octets)
354+
CID (2 octets)
355+
LTVs length (1 octet)
356+
LTVs (varies)
357+
Response parameters: Current_Settings (4 Octets) (see btp_gap.txt)
358+
359+
This command is used to set up and configure a Broadcast Source
360+
with the given Codec Config, with the addition of a fixed broadcast ID.
361+
In case of an error, the error status response will be returned.
362+
In case of a success, the IUT continues processing the command
363+
asynchronously.
364+
341365
Events:
342366
Opcode 0x80 - Discover and Subscribe Completed event
343367

0 commit comments

Comments
 (0)