@@ -79,7 +79,6 @@ std::set<user_credential_slot_changed_callback_t> user_credential_slot_changed_c
7979std::set<user_credential_slot_message_callback_t > user_credential_slot_message_callback;
8080}
8181
82-
8382// ///////////////////////////////////////////////////////////////////////////
8483// Callbacks
8584// ///////////////////////////////////////////////////////////////////////////
@@ -112,6 +111,17 @@ void send_message_to_mqtt(sl_log_level level, const std::string &message)
112111 }
113112}
114113
114+ // ///////////////////////////////////////////////////////////////////////////
115+ // Helpers
116+ // ///////////////////////////////////////////////////////////////////////////
117+ std::string get_credential_type_debug_str (user_credential_type_t credential_type) {
118+ auto fmt = boost::format (" Credential Type %1% (%2%)" )
119+ % cred_type_get_enum_value_name (credential_type)
120+ % static_cast <unsigned int >(credential_type);
121+
122+ return fmt.str ();
123+ }
124+
115125// ///////////////////////////////////////////////////////////////////////////
116126// Version & Attribute Creation
117127// ///////////////////////////////////////////////////////////////////////////
@@ -415,9 +425,9 @@ void trigger_get_credential(attribute_store::attribute &user_unique_id_node,
415425{
416426 sl_log_debug (LOG_TAG,
417427 " Trigger GET credential for user %d : "
418- " Credential type %d , credential slot %d" ,
428+ " Credential type %s , credential slot %d" ,
419429 user_unique_id_node.reported <user_credential_user_unique_id_t >(),
420- credential_type,
430+ get_credential_type_debug_str ( credential_type). c_str () ,
421431 credential_slot);
422432 user_unique_id_node
423433 .emplace_node (ATTRIBUTE (CREDENTIAL_TYPE),
@@ -547,8 +557,8 @@ sl_status_t
547557{
548558 if (user_id != 0 && credential_type != 0 && credential_slot != 0 ) {
549559 sl_log_info (LOG_TAG,
550- " Credential Deleted. Type %d , Slot %d (User %d)" ,
551- credential_type,
560+ " Credential Deleted. Type %s , Slot %d (User %d)" ,
561+ get_credential_type_debug_str ( credential_type). c_str () ,
552562 credential_slot,
553563 user_id);
554564 // Delete the credential slot node
@@ -559,8 +569,8 @@ sl_status_t
559569 .slot_node .delete_node ();
560570 } else if (user_id != 0 && credential_type != 0 && credential_slot == 0 ) {
561571 sl_log_info (LOG_TAG,
562- " All credential type %d deleted for user %d." ,
563- credential_type,
572+ " All credential type %s deleted for user %d." ,
573+ get_credential_type_debug_str ( credential_type). c_str () ,
564574 user_id);
565575 for_each_credential_type_nodes_for_user (
566576 user_id_node,
@@ -584,8 +594,8 @@ sl_status_t
584594 });
585595 } else if (user_id == 0 && credential_type != 0 && credential_slot == 0 ) {
586596 sl_log_info (LOG_TAG,
587- " All credentials of type %d are deleted" ,
588- credential_type);
597+ " All credentials of type %s are deleted" ,
598+ get_credential_type_debug_str ( credential_type). c_str () );
589599 for_each_credential_type_nodes (
590600 endpoint_node,
591601 [&](attribute_store::attribute &credential_type_node) {
@@ -594,10 +604,10 @@ sl_status_t
594604 credential_type);
595605 } else {
596606 sl_log_critical (LOG_TAG,
597- " Invalid combination of user_id %d, credential_type %d and "
607+ " Invalid combination of user_id %d, credential_type %s and "
598608 " credential_slot %d for credential deletion" ,
599609 user_id,
600- credential_type,
610+ get_credential_type_debug_str ( credential_type). c_str () ,
601611 credential_slot);
602612 return SL_STATUS_FAIL;
603613 }
@@ -632,9 +642,9 @@ sl_status_t zwave_command_class_user_credential_credential_handle_report(
632642 auto credential_slot = parser.read_sequential <user_credential_slot_t >(2 );
633643
634644 sl_log_debug (LOG_TAG,
635- " Credential Report (%d). Type %d , Slot %d (User %d)" ,
645+ " Credential Report (%d). %s , Slot %d (User %d)" ,
636646 credential_report_type,
637- credential_type,
647+ get_credential_type_debug_str ( credential_type). c_str () ,
638648 credential_slot,
639649 user_id);
640650
@@ -650,9 +660,9 @@ sl_status_t zwave_command_class_user_credential_credential_handle_report(
650660 nodes.slot_node .delete_node ();
651661 sl_log_debug (LOG_TAG,
652662 " Cleaning temporary credential slot node : %d (credential "
653- " type %d , user %d)" ,
663+ " type %s , user %d)" ,
654664 credential_slot,
655- credential_type,
665+ get_credential_type_debug_str ( credential_type). c_str () ,
656666 user_id);
657667 } catch (const std::exception &e) {
658668 // Try again with reported attribute
@@ -666,9 +676,9 @@ sl_status_t zwave_command_class_user_credential_credential_handle_report(
666676 sl_log_debug (
667677 LOG_TAG,
668678 " Cleaning desired values of credential slot node : %d (credential "
669- " type %d , user %d)" ,
679+ " type %s , user %d)" ,
670680 credential_slot,
671- credential_type,
681+ get_credential_type_debug_str ( credential_type). c_str () ,
672682 user_id);
673683
674684 for (auto child: nodes.slot_node .children ()) {
@@ -718,11 +728,11 @@ sl_status_t zwave_command_class_user_credential_credential_handle_report(
718728 credential_type,
719729 credential_slot);
720730 case credential_report_type_t ::CREDENTIAL_UNCHANGED:
721- sl_log_info (LOG_TAG ,
722- " Credential Unchanged. Type %d, Slot %d (User %d) " ,
723- credential_type,
724- credential_slot,
725- user_id);
731+ send_message_to_mqtt (SL_LOG_INFO ,
732+ " Credential Unchanged. Type "
733+ + get_credential_type_debug_str ( credential_type)
734+ + " , Slot " + std::to_string (credential_slot)
735+ + " (User " + std::to_string ( user_id) + " ) " );
726736 return SL_STATUS_OK;
727737 // Update desired value if found, otherwise create the nodes
728738 case credential_report_type_t ::RESPONSE_TO_GET:
@@ -767,19 +777,19 @@ sl_status_t zwave_command_class_user_credential_credential_handle_report(
767777 case credential_report_type_t ::CREDENTIAL_ADD_REJECTED_LOCATION_OCCUPIED:
768778 sl_log_error (LOG_TAG,
769779 " Credential data rejected as it already exists : user %d, "
770- " credential type %d , credential slot %d" ,
780+ " credential type %s , credential slot %d" ,
771781 user_id,
772- credential_type,
782+ get_credential_type_debug_str ( credential_type). c_str () ,
773783 credential_slot);
774784 clean_up_pending_credentials_slot_nodes ();
775785 return SL_STATUS_OK;
776786 case credential_report_type_t ::CREDENTIAL_MODIFY_REJECTED_LOCATION_EMPTY:
777787 sl_log_error (
778788 LOG_TAG,
779789 " Credential data cannot be modified as it does not exists : user %d, "
780- " credential type %d , credential slot %d" ,
790+ " credential type %s , credential slot %d" ,
781791 user_id,
782- credential_type,
792+ get_credential_type_debug_str ( credential_type). c_str () ,
783793 credential_slot);
784794
785795 credential_type_node
@@ -790,9 +800,9 @@ sl_status_t zwave_command_class_user_credential_credential_handle_report(
790800 if (!credential_type_node.is_valid ()) {
791801 sl_log_debug (
792802 LOG_TAG,
793- " No credential type found for user %d, credential type %d " ,
803+ " No credential type found for user %d, credential type %s " ,
794804 user_id,
795- credential_type);
805+ get_credential_type_debug_str ( credential_type). c_str () );
796806 return SL_STATUS_OK;
797807 }
798808
@@ -808,10 +818,10 @@ sl_status_t zwave_command_class_user_credential_credential_handle_report(
808818 // Do nothing, the credential GET will clean up for us
809819 sl_log_warning (LOG_TAG,
810820 " Duplicate Credential (Already present for user %d, "
811- " credential type %d , "
821+ " credential type %s , "
812822 " credential slot %d)" ,
813823 user_id,
814- credential_type,
824+ get_credential_type_debug_str ( credential_type). c_str () ,
815825 credential_slot);
816826
817827 // So this is the fun part when we hunt down the faulty credential slot node
@@ -859,10 +869,10 @@ sl_status_t zwave_command_class_user_credential_credential_handle_report(
859869 sl_log_warning (
860870 LOG_TAG,
861871 " Credential data rejected as it doesn't respect manufacturer "
862- " security rules : user %d, credential type %d , "
872+ " security rules : user %d, credential type %s , "
863873 " credential slot %d" ,
864874 user_id,
865- credential_type,
875+ get_credential_type_debug_str ( credential_type). c_str () ,
866876 credential_slot);
867877 // This should contains the faulty credential
868878 clean_up_pending_credentials_slot_nodes ();
@@ -871,9 +881,9 @@ sl_status_t zwave_command_class_user_credential_credential_handle_report(
871881 sl_log_warning (
872882 LOG_TAG,
873883 " Credential data rejected as location is already assigned : user %d, "
874- " credential type %d , credential slot %d" ,
884+ " credential type %s , credential slot %d" ,
875885 user_id,
876- credential_type,
886+ get_credential_type_debug_str ( credential_type). c_str () ,
877887 credential_slot);
878888 // This should contains the faulty credential
879889 clean_up_pending_credentials_slot_nodes ();
@@ -1230,10 +1240,10 @@ sl_status_t zwave_command_class_user_credential_uuic_association_report(
12301240
12311241 send_message_to_mqtt (
12321242 SL_LOG_INFO,
1233- (boost::format (" Credential Slot %1% for type %2% (user %3%) moved to "
1243+ (boost::format (" Credential Slot %1% ( %2%) (user %3%) moved to "
12341244 " Credential slot %4% (user %5%)" )
12351245 % source_credential_slot
1236- % static_cast < unsigned int > (source_credential_type) % source_user_id
1246+ % cred_rule_get_enum_value_name (source_credential_type) % source_user_id
12371247 % destination_credential_slot % destination_user_id)
12381248 .str ());
12391249
@@ -1868,9 +1878,9 @@ sl_status_t
18681878 credential_type);
18691879 if (!credential_type_node.is_valid ()) {
18701880 sl_log_error (LOG_TAG,
1871- " Can't find Credential Type %d reported by Credential "
1881+ " Can't find Credential Type %s reported by Credential "
18721882 " Checksum Report" ,
1873- credential_type);
1883+ get_credential_type_debug_str ( credential_type). c_str () );
18741884 return SL_STATUS_FAIL;
18751885 }
18761886
0 commit comments