@@ -326,13 +326,38 @@ static bool is_mucr_supported(attribute_store_node_t endpoint_node)
326
326
static sl_status_t zwave_command_class_user_code_number_get (
327
327
attribute_store_node_t node , uint8_t * frame , uint16_t * frame_length )
328
328
{
329
- (void )node ; // unused.
329
+ attribute_store_node_t endpoint_node
330
+ = attribute_store_get_first_parent_with_type (node , ATTRIBUTE_ENDPOINT_ID );
331
+ attribute_store_node_t version_node
332
+ = attribute_store_get_first_child_by_type (endpoint_node ,
333
+ ATTRIBUTE (VERSION ));
334
+ // We need to check the version of the supporting node:
335
+ zwave_cc_version_t supporting_node_version = 0 ;
336
+ attribute_store_get_reported (version_node ,
337
+ & supporting_node_version ,
338
+ sizeof (supporting_node_version ));
339
+
340
+ if (supporting_node_version == 0 ) {
341
+ // Wait to know the supporting node version
342
+ * frame_length = 0 ;
343
+ return SL_STATUS_IS_WAITING ;
344
+ }
345
+
346
+ if (supporting_node_version == 1 ) {
347
+ ZW_USERS_NUMBER_GET_FRAME * get_frame
348
+ = (ZW_USERS_NUMBER_GET_FRAME * )frame ;
349
+ get_frame -> cmdClass = COMMAND_CLASS_USER_CODE ;
350
+ get_frame -> cmd = USERS_NUMBER_GET ;
351
+ * frame_length = sizeof (ZW_USERS_NUMBER_GET_FRAME );
352
+ }
353
+ else {
330
354
// This is a static payload.
331
355
ZW_USERS_NUMBER_GET_V2_FRAME * get_frame
332
356
= (ZW_USERS_NUMBER_GET_V2_FRAME * )frame ;
333
357
get_frame -> cmdClass = COMMAND_CLASS_USER_CODE_V2 ;
334
358
get_frame -> cmd = USERS_NUMBER_GET_V2 ;
335
359
* frame_length = sizeof (ZW_USERS_NUMBER_GET_V2_FRAME );
360
+ }
336
361
return SL_STATUS_OK ;
337
362
}
338
363
@@ -378,8 +403,8 @@ static sl_status_t zwave_command_class_user_code_get(
378
403
* frame_length = 0 ;
379
404
return SL_STATUS_ALREADY_EXISTS ;
380
405
}
381
- frame [0 ] = COMMAND_CLASS_USER_CODE_V2 ;
382
- frame [1 ] = USER_CODE_GET_V2 ;
406
+ frame [0 ] = COMMAND_CLASS_USER_CODE ;
407
+ frame [1 ] = USER_CODE_GET ;
383
408
frame [2 ] = (uint8_t )user_id ;
384
409
* frame_length = 3 ;
385
410
return SL_STATUS_OK ;
@@ -540,7 +565,30 @@ static sl_status_t zwave_command_class_user_code_admin_code_get(
540
565
static sl_status_t zwave_command_class_user_code_keypad_mode_get (
541
566
attribute_store_node_t node , uint8_t * frame , uint16_t * frame_length )
542
567
{
543
- (void )node ; // unused.
568
+ attribute_store_node_t endpoint_node
569
+ = attribute_store_get_first_parent_with_type (node , ATTRIBUTE_ENDPOINT_ID );
570
+ attribute_store_node_t version_node
571
+ = attribute_store_get_first_child_by_type (endpoint_node ,
572
+ ATTRIBUTE (VERSION ));
573
+ // We need to check the version of the supporting node:
574
+ zwave_cc_version_t supporting_node_version = 0 ;
575
+ attribute_store_get_reported (version_node ,
576
+ & supporting_node_version ,
577
+ sizeof (supporting_node_version ));
578
+
579
+ if (supporting_node_version == 0 ) {
580
+ // Wait to know the supporting node version
581
+ * frame_length = 0 ;
582
+ return SL_STATUS_IS_WAITING ;
583
+ }
584
+
585
+ if (supporting_node_version == 1 ) {
586
+ sl_log_warning (LOG_TAG , "Keypad Mode attribute found for v1 node. Deleting" );
587
+ attribute_store_delete_node (node );
588
+ * frame_length = 0 ;
589
+ return SL_STATUS_ALREADY_EXISTS ;
590
+ }
591
+
544
592
zwave_minimum_frame_t * get_frame = (zwave_minimum_frame_t * )frame ;
545
593
get_frame -> command_class = COMMAND_CLASS_USER_CODE_V2 ;
546
594
get_frame -> command = USER_CODE_KEYPAD_MODE_GET_V2 ;
@@ -560,6 +608,30 @@ static sl_status_t zwave_command_class_user_code_keypad_mode_get(
560
608
static sl_status_t zwave_command_class_user_code_keypad_mode_set (
561
609
attribute_store_node_t node , uint8_t * frame , uint16_t * frame_length )
562
610
{
611
+ attribute_store_node_t endpoint_node
612
+ = attribute_store_get_first_parent_with_type (node , ATTRIBUTE_ENDPOINT_ID );
613
+ attribute_store_node_t version_node
614
+ = attribute_store_get_first_child_by_type (endpoint_node ,
615
+ ATTRIBUTE (VERSION ));
616
+ // We need to check the version of the supporting node:
617
+ zwave_cc_version_t supporting_node_version = 0 ;
618
+ attribute_store_get_reported (version_node ,
619
+ & supporting_node_version ,
620
+ sizeof (supporting_node_version ));
621
+
622
+ if (supporting_node_version == 0 ) {
623
+ // Wait to know the supporting node version
624
+ * frame_length = 0 ;
625
+ return SL_STATUS_IS_WAITING ;
626
+ }
627
+
628
+ if (supporting_node_version == 1 ) {
629
+ sl_log_warning (LOG_TAG , "Keypad mode attribute found for v1 node. Deleting" );
630
+ attribute_store_delete_node (node );
631
+ * frame_length = 0 ;
632
+ return SL_STATUS_ALREADY_EXISTS ;
633
+ }
634
+
563
635
ZW_USER_CODE_KEYPAD_MODE_SET_V2_FRAME * set_frame
564
636
= (ZW_USER_CODE_KEYPAD_MODE_SET_V2_FRAME * )frame ;
565
637
set_frame -> cmdClass = COMMAND_CLASS_USER_CODE_V2 ;
@@ -653,8 +725,8 @@ static sl_status_t zwave_command_class_user_code_set(
653
725
& user_id_status ,
654
726
sizeof (user_id_status ));
655
727
656
- frame [0 ] = COMMAND_CLASS_USER_CODE_V2 ;
657
- frame [1 ] = USER_CODE_SET_V2 ;
728
+ frame [0 ] = COMMAND_CLASS_USER_CODE ;
729
+ frame [1 ] = USER_CODE_SET ;
658
730
frame [2 ] = (uint8_t )user_id ;
659
731
frame [3 ] = user_id_status ;
660
732
if (user_id_status == 0 ) {
@@ -788,8 +860,8 @@ static sl_status_t zwave_command_class_user_code_delete_all(
788
860
if (supporting_node_version == 1 ) {
789
861
ZW_USER_CODE_SET_4BYTE_FRAME * set_frame
790
862
= (ZW_USER_CODE_SET_4BYTE_FRAME * )frame ;
791
- set_frame -> cmdClass = COMMAND_CLASS_USER_CODE_V2 ;
792
- set_frame -> cmd = USER_CODE_SET_V2 ;
863
+ set_frame -> cmdClass = COMMAND_CLASS_USER_CODE ;
864
+ set_frame -> cmd = USER_CODE_SET ;
793
865
set_frame -> userIdentifier = 0 ;
794
866
set_frame -> userIdStatus = 0 ;
795
867
set_frame -> userCode1 = 0 ;
0 commit comments