4444static attribute_resolver_function_t resolve_secure_node_info = NULL ;
4545static attribute_resolver_function_t resolve_node_info = NULL ;
4646static attribute_resolver_callback_t on_nif_resolution_abort = NULL ;
47+ static attribute_resolver_callback_t on_secure_nif_resolution_abort = NULL ;
4748
4849static const zwave_controller_callbacks_t * controller_callbacks = NULL ;
4950
@@ -75,6 +76,8 @@ void attribute_resolver_set_resolution_give_up_listener_stub(
7576{
7677 if (ATTRIBUTE_ZWAVE_NIF == node_type ) {
7778 on_nif_resolution_abort = callback ;
79+ } else if (ATTRIBUTE_ZWAVE_SECURE_NIF == node_type ) {
80+ on_secure_nif_resolution_abort = callback ;
7881 }
7982}
8083
@@ -474,4 +477,78 @@ void test_on_nif_resolution_aborted()
474477 TEST_ASSERT_EQUAL (true, attribute_store_node_exists (nif_0_node ));
475478 on_nif_resolution_abort (nif_2_node );
476479 TEST_ASSERT_EQUAL (false, attribute_store_node_exists (nif_2_node ));
480+ }
481+
482+ void test_on_secure_nif_resolution_aborted ()
483+ {
484+ TEST_ASSERT_NOT_NULL (on_secure_nif_resolution_abort );
485+
486+ // Add 2 NIFs, one under endpoint 0 and one under endpoint 2
487+ zwave_endpoint_id_t endpoint_id_value = 0 ;
488+ attribute_store_node_t endpoint_0_node
489+ = attribute_store_emplace (node_id_node ,
490+ ATTRIBUTE_ENDPOINT_ID ,
491+ & endpoint_id_value ,
492+ sizeof (endpoint_id_value ));
493+ attribute_store_node_t secure_nif_0_node
494+ = attribute_store_add_node (ATTRIBUTE_ZWAVE_SECURE_NIF , endpoint_0_node );
495+ endpoint_id_value = 2 ;
496+ attribute_store_node_t endpoint_2_node
497+ = attribute_store_emplace (node_id_node ,
498+ ATTRIBUTE_ENDPOINT_ID ,
499+ & endpoint_id_value ,
500+ sizeof (endpoint_id_value ));
501+ attribute_store_node_t secure_nif_2_node
502+ = attribute_store_add_node (ATTRIBUTE_ZWAVE_SECURE_NIF , endpoint_2_node );
503+
504+ endpoint_id_value = 12 ;
505+ attribute_store_node_t endpoint_12_node
506+ = attribute_store_emplace (node_id_node ,
507+ ATTRIBUTE_ENDPOINT_ID ,
508+ & endpoint_id_value ,
509+ sizeof (endpoint_id_value ));
510+
511+ // Setup a NIF without it's Secure NIF counter part
512+ attribute_store_node_t secure_nif_12_node
513+ = attribute_store_add_node (ATTRIBUTE_ZWAVE_SECURE_NIF , endpoint_12_node );
514+ uint8_t command_class_list_u8 [] = {0x9F , 0x98 , 0x25 };
515+ uint8_t nif_length = sizeof (command_class_list_u8 );
516+ attribute_store_node_t nif_12_node
517+ = attribute_store_add_node (ATTRIBUTE_ZWAVE_NIF , endpoint_12_node );
518+ zwave_controller_get_highest_encapsulation_ExpectAndReturn (
519+ 0 ,
520+ ZWAVE_CONTROLLER_ENCAPSULATION_SECURITY_2_UNAUTHENTICATED );
521+ zwave_controller_encapsulation_scheme_greater_equal_ExpectAndReturn (
522+ ZWAVE_CONTROLLER_ENCAPSULATION_SECURITY_2_UNAUTHENTICATED ,
523+ ZWAVE_CONTROLLER_ENCAPSULATION_SECURITY_0 ,
524+ true);
525+ attribute_store_set_reported (nif_12_node , command_class_list_u8 , nif_length );
526+
527+ // Now check what happens when endpoint 0 NIF cannot be resolved:
528+ on_secure_nif_resolution_abort (secure_nif_0_node );
529+ TEST_ASSERT_EQUAL (true, attribute_store_node_exists (secure_nif_0_node ));
530+ on_secure_nif_resolution_abort (secure_nif_2_node );
531+ TEST_ASSERT_EQUAL (true, attribute_store_node_exists (secure_nif_2_node ));
532+
533+ on_secure_nif_resolution_abort (secure_nif_12_node );
534+ TEST_ASSERT_EQUAL (true, attribute_store_node_exists (nif_12_node ));
535+ TEST_ASSERT_EQUAL (true, attribute_store_node_exists (secure_nif_12_node ));
536+
537+ // We expect all command classes without 0x9F or 0x98
538+ uint8_t command_class_list_result_u8 [] = {0xff };
539+ uint8_t secure_nif_length_result = 0 ;
540+ uint8_t command_class_list_expected_u8 [] = {0x25 };
541+ uint8_t secure_nif_length_expected = sizeof (command_class_list_expected_u8 );
542+
543+ sl_status_t result
544+ = attribute_store_get_node_attribute_value (secure_nif_12_node ,
545+ REPORTED_ATTRIBUTE ,
546+ command_class_list_result_u8 ,
547+ & secure_nif_length_result );
548+
549+ TEST_ASSERT_EQUAL (secure_nif_length_expected , secure_nif_length_result );
550+ TEST_ASSERT_EQUAL (SL_STATUS_OK , result );
551+ TEST_ASSERT_EQUAL_UINT8_ARRAY (command_class_list_expected_u8 ,
552+ command_class_list_result_u8 ,
553+ secure_nif_length_expected );
477554}
0 commit comments