Skip to content

Commit 9cf286e

Browse files
Thomasdjbrzr
authored andcommitted
SWPROT-9430: Update Get Node NLS State SAPI command
1 parent c7e3e2f commit 9cf286e

File tree

7 files changed

+25
-15
lines changed

7 files changed

+25
-15
lines changed

applications/zpc/components/zpc_stdin/src/zpc_stdin_command_handling.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -878,16 +878,16 @@ static sl_status_t handle_get_nls_state(const handle_args_t &arg)
878878
zwave_node_id_t node_id
879879
= static_cast<zwave_node_id_t>(std::stoi(arg[1].c_str(), nullptr, 10));
880880
uint8_t nls_state = 0;
881-
sl_status_t status = zwapi_get_node_nls(node_id, &nls_state);
881+
uint8_t nls_support = 0;
882+
sl_status_t status = zwapi_get_node_nls(node_id, &nls_state, &nls_support);
882883
if (SL_STATUS_OK == status)
883884
{
884-
// TODO: Add commented condition below once related SAPI command is updated
885-
status = zwave_store_nls_state(node_id, nls_state, REPORTED_ATTRIBUTE) /* || zwave_store_nls_support(node_id, nls_support, REPORTED_ATTRIBUTE) */;
885+
status = zwave_store_nls_state(node_id, nls_state, REPORTED_ATTRIBUTE) || zwave_store_nls_support(node_id, nls_support, REPORTED_ATTRIBUTE);
886886
if (SL_STATUS_OK != status) {
887887
dprintf(out_stream, "Unable to store NLS state for Node ID: %d\n", node_id);
888888
return SL_STATUS_FAIL;
889889
}
890-
dprintf(out_stream, "Node ID %d, NLS state: %d\n", node_id, nls_state);
890+
dprintf(out_stream, "Node ID %d, NLS Support: %d, NLS state: %d\n", node_id, nls_support, nls_state);
891891
return SL_STATUS_OK;
892892
}
893893
else

applications/zpc/components/zpc_stdin/test/zpc_stdin_test.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ void test_handle_nls()
334334
{
335335
sl_status_t state;
336336
uint8_t nls_state = false;
337+
uint8_t nls_support = false;
337338

338339
state = uic_stdin_handle_command("zwave_enable_nls");
339340
TEST_ASSERT_EQUAL(SL_STATUS_FAIL, state);
@@ -345,8 +346,9 @@ void test_handle_nls()
345346
state = uic_stdin_handle_command("zwave_get_nls_state");
346347
TEST_ASSERT_EQUAL(SL_STATUS_FAIL, state);
347348

348-
zwapi_get_node_nls_ExpectAndReturn(2, &nls_state, SL_STATUS_OK);
349+
zwapi_get_node_nls_ExpectAndReturn(2, &nls_state, &nls_support, SL_STATUS_OK);
349350
zwave_store_nls_state_ExpectAndReturn(2, nls_state, REPORTED_ATTRIBUTE, SL_STATUS_OK);
351+
zwave_store_nls_support_ExpectAndReturn(2, nls_support, REPORTED_ATTRIBUTE, SL_STATUS_OK);
350352
state = uic_stdin_handle_command("zwave_get_nls_state 2");
351353
TEST_ASSERT_EQUAL(SL_STATUS_OK, state);
352354
}

applications/zpc/components/zwave/zwave_transports/s2/src/zwave_s2_network.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,20 +139,22 @@ void zwave_s2_network_init()
139139
zwave_s2_log_security_keys(SL_LOG_INFO);
140140
#endif
141141

142+
uint8_t nls_support = 0;
142143
uint8_t nls_state = 0;
143144
zwave_node_id_t node_id = zwave_network_management_get_node_id();
144-
sl_status_t status = zwapi_get_node_nls(node_id, &nls_state);
145+
sl_status_t status = zwapi_get_node_nls(node_id, &nls_state, &nls_support);
145146
if (status != SL_STATUS_OK) {
146147
sl_log_error(LOG_TAG, "Unable to read NLS state for Node ID: %d\n", node_id);
147148
return;
148149
}
149150

151+
sl_log_info(LOG_TAG, "NLS support %s for Node ID: %d\n", nls_support == 1 ? "supported" : "not supported", node_id);
150152
sl_log_info(LOG_TAG, "NLS state %s for Node ID: %d\n", nls_state == 1 ? "active" : "not active", node_id);
151153

152154
S2_load_nls_state(s2_ctx, nls_state);
153-
status = zwave_store_nls_state(node_id, nls_state, REPORTED_ATTRIBUTE);
155+
status = zwave_store_nls_state(node_id, nls_state, REPORTED_ATTRIBUTE) || zwave_store_nls_support(node_id, nls_support, REPORTED_ATTRIBUTE);
154156
if (status != SL_STATUS_OK) {
155-
sl_log_error(LOG_TAG, "Unable to store NLS state in attribute store for Node ID: %d\n", node_id);
157+
sl_log_error(LOG_TAG, "Unable to store NLS state/support in attribute store for Node ID: %d\n", node_id);
156158
}
157159
}
158160

applications/zpc/components/zwave/zwave_transports/s2/test/zwave_s2_network_test.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ static void
7878
void test_s2_network_init()
7979
{
8080
uint8_t nls_state = false;
81+
uint8_t nls_support = false;
8182

8283
S2_destroy_Expect(s2_ctx);
8384
s2_inclusion_init_IgnoreAndReturn(true);
@@ -87,7 +88,7 @@ void test_s2_network_init()
8788

8889
zwapi_memory_get_buffer_IgnoreAndReturn(SL_STATUS_OK);
8990

90-
zwapi_get_node_nls_ExpectAndReturn(1, &nls_state, SL_STATUS_OK);
91+
zwapi_get_node_nls_ExpectAndReturn(1, &nls_state, &nls_support, SL_STATUS_OK);
9192
S2_load_nls_state_Ignore();
9293

9394
zwave_s2_network_init();

applications/zpc/components/zwave_api/include/zwapi_protocol_controller.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1051,7 +1051,7 @@ sl_status_t zwapi_enable_node_nls(const zwave_node_id_t nodeId);
10511051
* @param nodeId the node ID
10521052
*
10531053
*/
1054-
sl_status_t zwapi_get_node_nls(const zwave_node_id_t nodeId, uint8_t* nls_state);
1054+
sl_status_t zwapi_get_node_nls(const zwave_node_id_t nodeId, uint8_t* nls_state, uint8_t* nls_support);
10551055

10561056
/**
10571057
* @brief Get the NLS State of the nodes of a network in the controller NVM

applications/zpc/components/zwave_api/src/zwapi_protocol_controller.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,8 @@ sl_status_t zwapi_enable_node_nls(const zwave_node_id_t nodeId)
810810

811811
sl_status_t zwapi_get_node_nls(
812812
const zwave_node_id_t nodeId,
813-
uint8_t* nls_state)
813+
uint8_t* nls_state,
814+
uint8_t* nls_support)
814815
{
815816
uint8_t response_length = 0;
816817
uint8_t index = 0;
@@ -826,8 +827,9 @@ sl_status_t zwapi_get_node_nls(
826827

827828
if (send_command_status == SL_STATUS_OK && response_length > IDX_DATA)
828829
{
829-
*nls_state = response_buffer[IDX_DATA];
830-
return SL_STATUS_OK;
830+
*nls_support = response_buffer[IDX_DATA];
831+
*nls_state = response_buffer[IDX_DATA + 1];
832+
return SL_STATUS_OK;
831833
}
832834

833835
return SL_STATUS_FAIL;

applications/zpc/components/zwave_api/test/zwapi_protocol_controller_test.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,18 @@ void test_zwapi_enable_node_nls(void)
6565
void test_zwapi_get_node_nls(void)
6666
{
6767
zwave_node_id_t node_id = 2;
68+
uint8_t nls_supported = 1;
6869
uint8_t nls_enabled = 1;
6970
uint8_t response_buffer[] = {0x04 /* length = len(payload) + 3 */,
7071
0x01 /* type: response */,
7172
FUNC_ID_ZW_GET_NODE_NLS_STATE /* cmd */,
73+
nls_supported,
7274
nls_enabled /* payload */};
73-
uint8_t response_length = 4;
75+
uint8_t response_length = 5;
7476
uint8_t payload_buffer[] = {0x02};
7577
uint8_t payload_buffer_length = 1;
7678
uint8_t node_nls_state = 99;
79+
uint8_t node_nls_support = 99;
7780

7881
zwapi_session_send_frame_with_response_ExpectAndReturn(
7982
FUNC_ID_ZW_GET_NODE_NLS_STATE,
@@ -90,7 +93,7 @@ void test_zwapi_get_node_nls(void)
9093
zwapi_session_send_frame_with_response_ReturnThruPtr_response_len(
9194
&response_length);
9295

93-
TEST_ASSERT_EQUAL(SL_STATUS_OK, zwapi_get_node_nls(node_id, &node_nls_state));
96+
TEST_ASSERT_EQUAL(SL_STATUS_OK, zwapi_get_node_nls(node_id, &node_nls_state, &node_nls_support));
9497
TEST_ASSERT_EQUAL(nls_enabled, node_nls_state);
9598
}
9699

0 commit comments

Comments
 (0)