Skip to content

Commit

Permalink
iv index update bi test case fix
Browse files Browse the repository at this point in the history
  • Loading branch information
m-alperen-sener committed Sep 20, 2024
1 parent 61d1d01 commit 2b5541e
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 4 deletions.
26 changes: 25 additions & 1 deletion autopts/pybtp/btp/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ def mesh_input_string(string):
iutctl.btp_socket.send_wait_rsp(*MESH['input_str'], data=data)


def mesh_iv_update_test_mode(enable):
def mesh_iv_update_test_mode(enable, auto_disable = False):
logging.debug("%s", mesh_iv_update_test_mode.__name__)

iutctl = get_iut()
Expand All @@ -500,6 +500,11 @@ def mesh_iv_update_test_mode(enable):
else:
data = bytearray(struct.pack("<B", 0x00))

if auto_disable:
data.extend(bytearray(struct.pack("<B", 0x01)))
else:
data.extend(bytearray(struct.pack("<B", 0x00)))

iutctl.btp_socket.send_wait_rsp(*MESH['iv_update_test_mode'], data=data)

stack = get_stack()
Expand Down Expand Up @@ -2067,6 +2072,23 @@ def mesh_blob_lost_target_ev(mesh, data, data_len):

stack.mesh.blob_lost_target = True

def mesh_snb_received_ev(mesh, data, data_len):
logging.debug("%s %r %r", mesh_snb_received_ev.__name__, data, data_len)

hdr_fmt = '<BH'

(flags, iv_idx) = struct.unpack_from(hdr_fmt, data, 0)
logging.info(f'Flags: {flags}, iv_idx: {iv_idx}')

def mesh_prb_received_ev(mesh, data, data_len):
logging.debug("%s %r %r", mesh_prb_received_ev.__name__, data, data_len)

hdr_fmt = '<BH'

(flags, iv_idx) = struct.unpack_from(hdr_fmt, data, 0)
logging.info(f'Flags: {flags}, iv_idx: {iv_idx}')


MESH_EV = {
defs.MESH_EV_OUT_NUMBER_ACTION: mesh_out_number_action_ev,
defs.MESH_EV_OUT_STRING_ACTION: mesh_out_string_action_ev,
Expand All @@ -2085,4 +2107,6 @@ def mesh_blob_lost_target_ev(mesh, data, data_len):
defs.MESH_EV_PROV_NODE_ADDED: mesh_prov_node_added_ev,
defs.MESH_EV_MODEL_RECV: mesh_model_recv_ev,
defs.MESH_EV_BLOB_LOST_TARGET: mesh_blob_lost_target_ev,
defs.MESH_EV_SNB: mesh_snb_received_ev,
defs.MESH_EV_PRB: mesh_prb_received_ev,
}
3 changes: 3 additions & 0 deletions autopts/pybtp/defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,9 @@ def BIT(bit):
MESH_EV_PROV_NODE_ADDED = 0x8e
MESH_EV_MODEL_RECV = 0x8f
MESH_EV_BLOB_LOST_TARGET = 0x90
MESH_EV_SNB = 0x91
MESH_EV_PRB = 0x92

MMDL_READ_SUPPORTED_COMMANDS = 0x01
MMDL_GEN_ONOFF_GET = 0x02
MMDL_GEN_ONOFF_SET = 0x03
Expand Down
21 changes: 18 additions & 3 deletions autopts/wid/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -820,12 +820,19 @@ def hdl_wid_90(_: WIDParams):
return bool(stack.mesh.is_provisioned.data)


def hdl_wid_94(_: WIDParams):
def hdl_wid_94(params: WIDParams):
"""
Implements: IUT_SEND_SECURE_NETWORK_BEACON_WITH_FLAGS
description: Please order IUT to send a secure network beacon with Key
Refresh Flag set to %d and IV Update Flag set to %d
"""

cases = ['MESH/NODE/IVU/BI-01','MESH/NODE/IVU/BI-07']
for case in cases:
if case in params.test_case_name:
logging.info(f">>>>>>>>>>>>>> turn off test mode {case}")
btp.mesh_iv_update_test_mode(False)

return True


Expand Down Expand Up @@ -1049,7 +1056,7 @@ def hdl_wid_220(_: WIDParams):
return True


def hdl_wid_221(_: WIDParams):
def hdl_wid_221(param: WIDParams):
"""
Implements: IUT_READY_FOR_UPDATE_IN_PROGRESS_SECURE_NETWORK_BEACON
description: The Lower Tester will advertise a new Secure Network beacon
Expand All @@ -1058,8 +1065,16 @@ def hdl_wid_221(_: WIDParams):
"""
stack = get_stack()

auto_disable = False

test_cases = ['MESH/NODE/IVU/BI-01', 'MESH/NODE/IVU/BI-07']
for case in test_cases:
if case in param.test_case_name:
auto_disable = True
break

if not stack.mesh.is_iv_test_mode_enabled.data:
btp.mesh_iv_update_test_mode(True)
btp.mesh_iv_update_test_mode(True, auto_disable)
return True


Expand Down

0 comments on commit 2b5541e

Please sign in to comment.