From c9a159a0b36480bec64fe42165081f77840b2cdc Mon Sep 17 00:00:00 2001 From: Pavel Vasilyev Date: Wed, 21 Jun 2023 13:38:02 +0200 Subject: [PATCH] mesh: Add virtual address before using it Virtual address behavior has been changed in this PR: https://github.com/zephyrproject-rtos/zephyr/pull/57878 Now it requires label uuid to be added before any message can be sent and desired uuid should be passed to message context structure before sending a message to a virtual address. This change should fix MESH/NODE/NET/BV-02-C and MESH/NODE/TNPT/BV-05-C failing tests. For MESH/NODE/NET/BV-02-C the virtual address is added on hdl_wid_21 as PTS asks the stack to provide known virtual address. For MESH/NODE/TNPT/BV-05-C PTS gives the label uuid in the message, therefore we need to add this address first before sending a message to it. Corresponding PR to zephyrproject-rtos: https://github.com/zephyrproject-rtos/zephyr/pull/59486 Signed-off-by: Pavel Vasilyev --- autopts/pybtp/btp/mesh.py | 39 +++++++++++++++++++++++++++++++++++++++ autopts/pybtp/defs.py | 2 ++ autopts/wid/mesh.py | 19 ++++++++++++++++++- doc/btp_mesh_node.txt | 22 ++++++++++++++++++++++ 4 files changed, 81 insertions(+), 1 deletion(-) diff --git a/autopts/pybtp/btp/mesh.py b/autopts/pybtp/btp/mesh.py index 2e28241647..6ef1b4a9b2 100644 --- a/autopts/pybtp/btp/mesh.py +++ b/autopts/pybtp/btp/mesh.py @@ -253,6 +253,12 @@ "proxy_connect": (defs.BTP_SERVICE_ID_MESH, defs.MESH_PROXY_CONNECT, CONTROLLER_INDEX), + "va_add": (defs.BTP_SERVICE_ID_MESH, + defs.MESH_VA_ADD, + CONTROLLER_INDEX), + "va_del": (defs.BTP_SERVICE_ID_MESH, + defs.MESH_VA_DEL, + CONTROLLER_INDEX), } @@ -429,6 +435,39 @@ def mesh_net_send(ttl, src, dst, payload): iutctl.btp_socket.send_wait_rsp(*MESH['net_send'], data=data) +def mesh_va_add(label): + logging.debug("%s %r", mesh_va_add.__name__, label) + + label = binascii.unhexlify(label) + + if len(label) != 16: + raise BTPError("Label UUID length is invalid") + + data = bytearray(struct.pack("<")) + data.extend(label) + + iutctl = get_iut() + (rsp,) = iutctl.btp_socket.send_wait_rsp(*MESH['va_add'], data=data) + + (virtual_addr,) = struct.unpack_from(' + Command parameters: Label UUID (16 octets) + + This command is used to add a Label UUID to the stack. If + the Label UUID is already added, the reference will be + incremented. + + In case of an error, the error response will be returned. + + Opcode 0x4E - Virtual Address Delete + + Controller Index: + Command parameters: Label UUID (16 octets) + + This command is used to delete a Label UUID from the stack. + If the Label UUID was added before, the reference will be + decremented. + + In case of an error, the error response will be returned. + Opcode 0x48 - Config Key Refesh Phase Get Controller Index: