2121from autopts .ptsprojects .zephyr .tmap_wid import tmap_wid_hdl
2222from autopts .ptsprojects .zephyr .ztestcase import ZTestCase
2323from 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
2728def 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
6760def 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
0 commit comments