From 215e5c191b59c10388186963a5b0b5efc5c140d2 Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Wed, 24 Apr 2024 10:00:26 +0200 Subject: [PATCH] zephyr: Update OTS support This adds dedicated service for testing OTS and updates errata list. --- autopts/bot/iut_config/zephyr.py | 11 ++- autopts/ptsprojects/stack/layers/__init__.py | 2 +- autopts/ptsprojects/stack/stack.py | 15 ++-- autopts/ptsprojects/zephyr/__init__.py | 2 +- autopts/ptsprojects/zephyr/ots.py | 85 ++++++++++++-------- autopts/ptsprojects/zephyr/ots_wid.py | 8 +- autopts/pybtp/btp/__init__.py | 2 +- autopts/pybtp/btp/btp.py | 9 ++- autopts/pybtp/btp/ots.py | 49 ++++++++--- autopts/pybtp/defs.py | 5 ++ autopts/wid/__init__.py | 2 +- autopts/wid/ots.py | 10 ++- doc/btp_ots.txt | 43 ++++++++++ doc/overview.txt | 1 + errata/zephyr.yaml | 39 ++------- 15 files changed, 184 insertions(+), 99 deletions(-) create mode 100644 doc/btp_ots.txt diff --git a/autopts/bot/iut_config/zephyr.py b/autopts/bot/iut_config/zephyr.py index a997f9729c..b4315c6680 100644 --- a/autopts/bot/iut_config/zephyr.py +++ b/autopts/bot/iut_config/zephyr.py @@ -136,13 +136,22 @@ ] }, + "ots_no_dir_list.conf": { + "overlay": { + 'CONFIG_BT_OTS_DIR_LIST_OBJ': 'n', + }, + "test_cases": [ + 'OTS/SR/OLE/BI-03-C', + ] + }, + "overlay-le-audio.conf": { "overlay": { # The overlay file exists in zephyr repo. Leave this empty. }, "test_cases": [ 'VOCS', 'VCS', 'AICS', 'IAS', 'PACS', 'ASCS', 'BAP', 'HAS', 'CSIS', 'MICP', - 'MICS', 'VCP', 'MCP', 'CAP', 'BASS', 'GMCS', 'CCP', 'HAP', 'TBS', 'GTBS', 'OTS', + 'MICS', 'VCP', 'MCP', 'CAP', 'BASS', 'GMCS', 'CCP', 'HAP', 'TBS', 'GTBS', 'TMAP', ] }, diff --git a/autopts/ptsprojects/stack/layers/__init__.py b/autopts/ptsprojects/stack/layers/__init__.py index 1af6fc90fd..adb4e1e374 100644 --- a/autopts/ptsprojects/stack/layers/__init__.py +++ b/autopts/ptsprojects/stack/layers/__init__.py @@ -38,6 +38,6 @@ from .csip import * from .tbs import * from .gtbs import * -from .ots import * from .tmap import * +from .ots import * # GENERATOR append 1 diff --git a/autopts/ptsprojects/stack/stack.py b/autopts/ptsprojects/stack/stack.py index bc385df660..74879f0338 100644 --- a/autopts/ptsprojects/stack/stack.py +++ b/autopts/ptsprojects/stack/stack.py @@ -51,6 +51,7 @@ "CSIP": 1 << defs.BTP_SERVICE_ID_CSIP, "TBS": 1 << defs.BTP_SERVICE_ID_TBS, "TMAP": 1 << defs.BTP_SERVICE_ID_TMAP, + "OTS": 1 << defs.BTP_SERVICE_ID_OTS, # GENERATOR append 1 } @@ -84,8 +85,8 @@ def __init__(self): self.csip = None self.tbs = None self.gtbs = None - self.ots = None self.tmap = None + self.ots = None # GENERATOR append 2 def is_svc_supported(self, svc): @@ -179,12 +180,12 @@ def tbs_init(self): def gtbs_init(self): self.gtbs = GTBS() - def ots_init(self): - self.ots = OTS() - def tmap_init(self): self.tmap = TMAP() + def ots_init(self): + self.ots = OTS() + # GENERATOR append 3 def cleanup(self): @@ -260,12 +261,12 @@ def cleanup(self): if self.gtbs: self.gtbs_init() - if self.ots: - self.ots_init() - if self.tmap: self.tmap_init() + if self.ots: + self.ots_init() + # GENERATOR append 4 diff --git a/autopts/ptsprojects/zephyr/__init__.py b/autopts/ptsprojects/zephyr/__init__.py index 60532bcba4..b97ceb4c65 100644 --- a/autopts/ptsprojects/zephyr/__init__.py +++ b/autopts/ptsprojects/zephyr/__init__.py @@ -45,8 +45,8 @@ import autopts.ptsprojects.zephyr.gmcs import autopts.ptsprojects.zephyr.tbs import autopts.ptsprojects.zephyr.gtbs -import autopts.ptsprojects.zephyr.ots import autopts.ptsprojects.zephyr.tmap +import autopts.ptsprojects.zephyr.ots # GENERATOR append 1 # Constants diff --git a/autopts/ptsprojects/zephyr/ots.py b/autopts/ptsprojects/zephyr/ots.py index fcff92499a..a8f467154b 100644 --- a/autopts/ptsprojects/zephyr/ots.py +++ b/autopts/ptsprojects/zephyr/ots.py @@ -1,7 +1,7 @@ # # auto-pts - The Bluetooth PTS Automation Framework # -# Copyright (c) 2023, Codecoup. +# Copyright (c) 2024, Codecoup. # # This program is free software; you can redistribute it and/or modify it # under the terms and conditions of the GNU General Public License, @@ -13,22 +13,13 @@ # more details. # -"""OTS test cases""" - -from autopts.pybtp import btp -from autopts.client import get_unique_name from autopts.ptsprojects.stack import get_stack from autopts.ptsprojects.testcase import TestFunc -from autopts.ptsprojects.zephyr.ots_wid import ots_wid_hdl from autopts.ptsprojects.zephyr.ztestcase import ZTestCase -from autopts.pybtp.types import IOCap, Addr -from queue import Queue - -queue = Queue() - - -def set_addr(addr): - queue.put(addr) +from autopts.pybtp import btp +from autopts.ptsprojects.zephyr.ots_wid import ots_wid_hdl +from autopts.client import get_unique_name +from autopts.pybtp.types import Addr def set_pixits(ptses): @@ -53,47 +44,77 @@ def set_pixits(ptses): pts.set_pixit("OTS", "TSPX_use_dynamic_pin", "FALSE") pts.set_pixit("OTS", "TSPX_delete_ltk", "TRUE") pts.set_pixit("OTS", "TSPX_security_enabled", "TRUE") + pts.set_pixit("OTS", "TSPX_iut_object_name", "Object 1 with very long name") + pts.set_pixit("OTS", "TSPX_iut_object_size_create", "100") + pts.set_pixit("OTS", "TSPX_iut_object_read_offset", "20") + pts.set_pixit("OTS", "TSPX_iut_object_write_offset", "20") + pts.set_pixit("OTS", "TSPX_iut_object_write_length", "20") def test_cases(ptses): - """Returns a list of OTS Server test cases""" + """ + Returns a list of OTS test cases + ptses -- list of PyPTS instances + """ pts = ptses[0] - pts_bd_addr = pts.q_bd_addr iut_device_name = get_unique_name(pts) stack = get_stack() + # Generic preconditions for all test case in the profile pre_conditions = [ TestFunc(btp.core_reg_svc_gap), TestFunc(stack.gap_init, iut_device_name), - TestFunc(btp.core_reg_svc_gatt), TestFunc(btp.gap_read_ctrl_info), - TestFunc(lambda: pts.update_pixit_param( - "OTS", "TSPX_bd_addr_iut", - stack.gap.iut_addr_get_str())), - TestFunc(lambda: set_addr( - stack.gap.iut_addr_get_str())), - TestFunc(btp.gap_set_io_cap, IOCap.display_only), + TestFunc(lambda: pts.update_pixit_param("OTS", "TSPX_bd_addr_iut", stack.gap.iut_addr_get_str())), TestFunc(btp.set_pts_addr, pts_bd_addr, Addr.le_public), + TestFunc(btp.core_reg_svc_gatt), TestFunc(stack.gatt_init), - TestFunc(btp.gap_set_conn), - TestFunc(btp.gap_set_gendiscov), - # OTS cannot be initialized as a primary service on zephyr. For now, for test - # purposes we initialize GMCS where OTS is secondary service. - TestFunc(btp.core_reg_svc_gmcs), - TestFunc(lambda: pts.update_pixit_param( - "OTS", "TSPX_iut_device_name_in_adv_packet_for_random_address", iut_device_name)), + TestFunc(btp.core_reg_svc_ots), TestFunc(stack.ots_init) ] + pre_conditions_props = [ + TestFunc(btp.otc_register_object, 0, "Object 1 with very long name", 0x01, 0xff, 100, 50) + + ] + + pre_conditions_no_props = [ + TestFunc(btp.otc_register_object, 0, "Object 1 with very long name", 0x01, 0x00, 100, 50) + ] + + custom_test_cases = [ + ZTestCase('OTS', 'OTS/SR/OAE/BI-06-C', + cmds=pre_conditions + pre_conditions_no_props, + generic_wid_hdl=ots_wid_hdl), + ZTestCase('OTS', 'OTS/SR/OAE/BI-07-C', + cmds=pre_conditions + pre_conditions_no_props, + generic_wid_hdl=ots_wid_hdl), + ZTestCase('OTS', 'OTS/SR/OAE/BI-08-C', + cmds=pre_conditions + pre_conditions_no_props, + generic_wid_hdl=ots_wid_hdl), + ZTestCase('OTS', 'OTS/SR/OAE/BI-09-C', + cmds=pre_conditions + pre_conditions_no_props, + generic_wid_hdl=ots_wid_hdl), + ZTestCase('OTS', 'OTS/SR/OLE/BI-03-C', + cmds=pre_conditions, + generic_wid_hdl=ots_wid_hdl), + ] + test_case_name_list = pts.get_test_case_list('OTS') tc_list = [] + # Use the same preconditions and MMI/WID handler for all test cases of the profile for tc_name in test_case_name_list: - instance = ZTestCase("OTS", tc_name, - cmds=pre_conditions, + instance = ZTestCase('OTS', tc_name, cmds=pre_conditions + pre_conditions_props, generic_wid_hdl=ots_wid_hdl) + + for custom_tc in custom_test_cases: + if tc_name == custom_tc.name: + instance = custom_tc + break + tc_list.append(instance) return tc_list diff --git a/autopts/ptsprojects/zephyr/ots_wid.py b/autopts/ptsprojects/zephyr/ots_wid.py index 87c518acd4..ce87f19ba7 100644 --- a/autopts/ptsprojects/zephyr/ots_wid.py +++ b/autopts/ptsprojects/zephyr/ots_wid.py @@ -1,7 +1,7 @@ # # auto-pts - The Bluetooth PTS Automation Framework # -# Copyright (c) 2023, Codecoup. +# Copyright (c) 2024, Codecoup. # # This program is free software; you can redistribute it and/or modify it # under the terms and conditions of the GNU General Public License, @@ -13,15 +13,15 @@ # more details. # + import logging +from autopts.pybtp.types import WIDParams from autopts.wid import generic_wid_hdl -from autopts.pybtp import btp -from autopts.ptsprojects.zephyr.iutctl import get_iut log = logging.debug def ots_wid_hdl(wid, description, test_case_name): log(f'{ots_wid_hdl.__name__}, {wid}, {description}, {test_case_name}') - return generic_wid_hdl(wid, description, test_case_name, [__name__, 'autopts.wid.ots']) \ No newline at end of file + return generic_wid_hdl(wid, description, test_case_name, [__name__, 'autopts.wid.ots']) diff --git a/autopts/pybtp/btp/__init__.py b/autopts/pybtp/btp/__init__.py index 1d0713b472..e26371ba92 100644 --- a/autopts/pybtp/btp/__init__.py +++ b/autopts/pybtp/btp/__init__.py @@ -43,6 +43,6 @@ from autopts.pybtp.btp.cap import * from autopts.pybtp.btp.csip import * from autopts.pybtp.btp.tbs import * -from autopts.pybtp.btp.ots import * from autopts.pybtp.btp.tmap import * +from autopts.pybtp.btp.ots import * # GENERATOR append 1 diff --git a/autopts/pybtp/btp/btp.py b/autopts/pybtp/btp/btp.py index c92b6c4393..c86d1cf3b9 100644 --- a/autopts/pybtp/btp/btp.py +++ b/autopts/pybtp/btp/btp.py @@ -39,6 +39,7 @@ LeAdv = namedtuple('LeAdv', 'addr_type addr rssi flags eir') CONTROLLER_INDEX = 0 +CONTROLLER_INDEX_NONE = 0xff def read_supp_svcs(): @@ -126,6 +127,8 @@ def read_supp_svcs(): defs.BTP_INDEX_NONE, defs.BTP_SERVICE_ID_TBS), "tmap_reg": (defs.BTP_SERVICE_ID_CORE, defs.CORE_REGISTER_SERVICE, defs.BTP_INDEX_NONE, defs.BTP_SERVICE_ID_TMAP), + "ots_reg": (defs.BTP_SERVICE_ID_CORE, defs.CORE_REGISTER_SERVICE, + defs.BTP_INDEX_NONE, defs.BTP_SERVICE_ID_OTS), # GENERATOR append 4 "read_supp_cmds": (defs.BTP_SERVICE_ID_CORE, defs.CORE_READ_SUPPORTED_COMMANDS, @@ -694,8 +697,6 @@ def core_reg_svc_tbs(): iutctl.btp_socket.send_wait_rsp(*CORE['tbs_reg']) -# GENERATOR append 1 - def core_reg_svc_ots(): logging.debug("%s", core_reg_svc_ots.__name__) @@ -703,6 +704,8 @@ def core_reg_svc_ots(): iutctl.btp_socket.send_wait_rsp(*CORE['ots_reg']) +# GENERATOR append 1 + def core_reg_svc_rsp_succ(): logging.debug("%s", core_reg_svc_rsp_succ.__name__) iutctl = get_iut() @@ -801,6 +804,7 @@ def init(get_iut_method): from .csip import CSIP_EV from .tbs import TBS_EV from .tmap import TMAP_EV +from .ots import OTS_EV # GENERATOR append 2 from autopts.pybtp.iutctl_common import set_event_handler @@ -839,6 +843,7 @@ def event_handler(hdr, data): defs.BTP_SERVICE_ID_CSIP: (CSIP_EV, stack.csip), defs.BTP_SERVICE_ID_TBS: (TBS_EV, stack.tbs), defs.BTP_SERVICE_ID_TMAP: (TMAP_EV, stack.tmap), + defs.BTP_SERVICE_ID_OTS: (OTS_EV, stack.ots), # GENERATOR append 3 } diff --git a/autopts/pybtp/btp/ots.py b/autopts/pybtp/btp/ots.py index 7e1233d481..792d1dde1e 100644 --- a/autopts/pybtp/btp/ots.py +++ b/autopts/pybtp/btp/ots.py @@ -1,7 +1,7 @@ # # auto-pts - The Bluetooth PTS Automation Framework # -# Copyright (c) 2023, Codecoup. +# Copyright (c) 2024, Codecoup. # # This program is free software; you can redistribute it and/or modify it # under the terms and conditions of the GNU General Public License, @@ -13,27 +13,50 @@ # more details. # -"""Wrapper around btp messages. The functions are added as needed.""" import binascii import logging import struct from autopts.pybtp import defs -from autopts.pybtp.btp.btp import CONTROLLER_INDEX, get_iut_method as get_iut, btp_hdr_check, pts_addr_get, \ - pts_addr_type_get -from autopts.pybtp.types import BTPError, addr2btp_ba +from autopts.pybtp.btp.btp import CONTROLLER_INDEX, CONTROLLER_INDEX_NONE, get_iut_method as get_iut, \ + btp_hdr_check +from autopts.pybtp.types import BTPError + +log = logging.debug + OTS = { + 'read_supported_cmds': (defs.BTP_SERVICE_ID_OTS, + defs.OTS_READ_SUPPORTED_COMMANDS, + CONTROLLER_INDEX_NONE), + 'register_object': (defs.BTP_SERVICE_ID_OTS, + defs.OTS_REGISTER_OBJECT, + CONTROLLER_INDEX), } -def address_to_ba(bd_addr_type=None, bd_addr=None): - data = bytearray() - bd_addr_ba = addr2btp_ba(pts_addr_get(bd_addr)) - bd_addr_type_ba = chr(pts_addr_type_get(bd_addr_type)).encode('utf-8') - data.extend(bd_addr_type_ba) - data.extend(bd_addr_ba) - return data +def otc_register_object(index, name, flags=0, props=0, alloc_size=0, current_size=0): + logging.debug(f"{otc_register_object.__name__}") + + data_ba = bytearray(struct.pack(' + Command parameters: + Response parameters: (variable) + + Each bit in response is a flag indicating if command with + opcode matching bit number is supported. Bit set to 1 means + that command is supported. Bit 0 is reserved and shall always + be set to 0. If specific bit is not present in response (less + than required bytes received) it shall be assumed that command + is not supported. + + In case of an error, the error response will be returned. + + Opcode 0x02 - Register Object command/response + + Controller Index: + Command parameters: Flags (1 octet) + Properties (4 octets) + Allocation_Size 4 octets) + Current_Size (4 octets) + Name_Length (1 octet) + Name (variable) + Response parameters: Object_ID (4 octets) + + This command is used to register new Object in OTS server with + specified parameters. Properties are OTS Object properties as per + specification. Allocation and current sizes defines Object sizes + as per specification. + + Possible values for the Flags parameter are a bit-wise or of + the following bits: + 0 = Skip Unsupported Properties + + In case of an error, the error response will be returned. diff --git a/doc/overview.txt b/doc/overview.txt index ce4667edce..55771421ad 100644 --- a/doc/overview.txt +++ b/doc/overview.txt @@ -113,4 +113,5 @@ ID Name 26 CAP Service 27 TBS Service 28 TMAP Service + 29 OTS Service # GENERATOR append 1 diff --git a/errata/zephyr.yaml b/errata/zephyr.yaml index 089a38029c..58c4fc1e1f 100644 --- a/errata/zephyr.yaml +++ b/errata/zephyr.yaml @@ -69,40 +69,11 @@ GTBS/SR/SPN/BV-08-C: Request ID 31633 GTBS/SR/SPN/BV-09-C: Request ID 31633 GTBS/SR/SPN/BV-10-C: Request ID 31633 GTBS/SR/SPN/BV-11-C: Request ID 31633 -OTS/SR/OME/BI-01-C: https://github.com/zephyrproject-rtos/zephyr/issues/66023 -OTS/SR/OC/BV-01-C: https://github.com/zephyrproject-rtos/zephyr/issues/66023 -OTS/SR/OTD/BI-01-C: https://github.com/zephyrproject-rtos/zephyr/issues/66023 -OTS/SR/OTD/BI-04-C: https://github.com/zephyrproject-rtos/zephyr/issues/66023 -OTS/SR/OTD/BI-05-C: https://github.com/zephyrproject-rtos/zephyr/issues/66023 -OTS/SR/DLO/BV-01-C: https://github.com/zephyrproject-rtos/zephyr/issues/66023 -OTS/SR/CR/BV-01-C: https://github.com/zephyrproject-rtos/zephyr/issues/66023 -OTS/SR/CR/BV-02-C: https://github.com/zephyrproject-rtos/zephyr/issues/66023 -OTS/SR/CR/BV-03-C: https://github.com/zephyrproject-rtos/zephyr/issues/66023 -OTS/SR/CR/BV-04-C: https://github.com/zephyrproject-rtos/zephyr/issues/66023 -OTS/SR/CR/BV-07-C: https://github.com/zephyrproject-rtos/zephyr/issues/66023 -OTS/SR/CR/BV-08-C: https://github.com/zephyrproject-rtos/zephyr/issues/66023 -OTS/SR/CW/BV-01-C: https://github.com/zephyrproject-rtos/zephyr/issues/66023 -OTS/SR/OASP/BV-01-C: https://github.com/zephyrproject-rtos/zephyr/issues/66023 -OTS/SR/OASP/BV-02-C: https://github.com/zephyrproject-rtos/zephyr/issues/66023 -OTS/SR/OASP/BV-03-C: https://github.com/zephyrproject-rtos/zephyr/issues/66023 -OTS/SR/OASP/BV-04-C: https://github.com/zephyrproject-rtos/zephyr/issues/66023 -OTS/SR/OASP/BV-05-C: https://github.com/zephyrproject-rtos/zephyr/issues/66023 -OTS/SR/OASP/BV-06-C: https://github.com/zephyrproject-rtos/zephyr/issues/66023 -OTS/SR/OAE/BI-01-C: https://github.com/zephyrproject-rtos/zephyr/issues/66023 -OTS/SR/OAE/BI-03-C: https://github.com/zephyrproject-rtos/zephyr/issues/66023 -OTS/SR/OAE/BI-04-C: https://github.com/zephyrproject-rtos/zephyr/issues/66023 -OTS/SR/OAE/BI-05-C: https://github.com/zephyrproject-rtos/zephyr/issues/66023 -OTS/SR/OAE/BI-06-C: https://github.com/zephyrproject-rtos/zephyr/issues/66023 -OTS/SR/OAE/BI-07-C: https://github.com/zephyrproject-rtos/zephyr/issues/66023 -OTS/SR/OAE/BI-08-C: https://github.com/zephyrproject-rtos/zephyr/issues/66023 -OTS/SR/OAE/BI-09-C: https://github.com/zephyrproject-rtos/zephyr/issues/66023 -OTS/SR/OAE/BI-12-C: https://github.com/zephyrproject-rtos/zephyr/issues/66023 -OTS/SR/OLSP/BV-01-C: https://github.com/zephyrproject-rtos/zephyr/issues/66023 -OTS/SR/OLSP/BV-02-C: https://github.com/zephyrproject-rtos/zephyr/issues/66023 -OTS/SR/OLE/BI-01-C: https://github.com/zephyrproject-rtos/zephyr/issues/66023 -OTS/SR/OLE/BI-03-C: https://github.com/zephyrproject-rtos/zephyr/issues/66023 -OTS/SR/OLE/BI-04-C: https://github.com/zephyrproject-rtos/zephyr/issues/66023 -OTS/SR/OLE/BI-05-C: https://github.com/zephyrproject-rtos/zephyr/issues/66023 + +OTS/SR/SGGIT/CHA/BV-15-C: https://github.com/zephyrproject-rtos/zephyr/issues/71754 +OTS/SR/CON/BV-03-C: https://github.com/zephyrproject-rtos/zephyr/issues/71754 +OTS/SR/OC/BV-01-C: https://github.com/zephyrproject-rtos/zephyr/issues/71754 + MESH/NODE/TNPT/BV-11-C: ES-24062 MESH/CL/DPROX/BV-02-C: ES-24237 MESH/CL/PROX/BV-11-C: ES-24124