Skip to content

Commit 6985a1d

Browse files
authored
Merge pull request #4 from Thomasdjb/feature-DoorLock-GetAllPINCodes
Patchs integration and feature
2 parents e7f155e + 306e06c commit 6985a1d

26 files changed

+277
-131
lines changed

applications/zigpc/components/command_mapper/zap-generated/src/zigpc_cmdmapper_gen_cmd_publish.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,14 +316,14 @@ static void zigpc_command_mapper_publish_door_lock_getpin_code_response(
316316
) {
317317
std::string unid(zigpc_ucl::mqtt::build_unid(zigbee_eui64_to_uint(eui64)));
318318

319-
uic_mqtt_dotdot_door_lock_command_getpin_code_response_fields_t fields = {
319+
uic_mqtt_dotdot_door_lock_command_get_pin_code_response_fields_t fields = {
320320
(uint16_t) data->door_lock_getpin_code_response.userid,
321321
(DrlkUserStatus) data->door_lock_getpin_code_response.user_status,
322322
(DrlkUserType) data->door_lock_getpin_code_response.user_type,
323323
(const char*) data->door_lock_getpin_code_response.code
324324
};
325325

326-
uic_mqtt_dotdot_door_lock_publish_generated_getpin_code_response_command(
326+
uic_mqtt_dotdot_door_lock_publish_generated_get_pin_code_response_command(
327327
unid.c_str(),
328328
endpoint_id,
329329
&fields

applications/zigpc/components/command_mapper/zap-generated/src/zigpc_command_mapper_bygroup_handlers.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2269,6 +2269,30 @@ void zigpc_command_mapper_bygroup_door_lock_clear_allrfid_codes_handler(
22692269
0,
22702270
nullptr
22712271
);
2272+
/**
2273+
* @brief DotDot MQTT by-group handler for DoorLock/GetAllPINCodes command.
2274+
*
2275+
* @param group_id UCL group identifier.
2276+
2277+
*/
2278+
void zigpc_command_mapper_bygroup_door_lock_get_all_pin_codes_handler(
2279+
const dotdot_group_id_t group_id
2280+
) {
2281+
2282+
2283+
2284+
2285+
zigpc_command_mapper_send_multicast(
2286+
group_id,
2287+
ZIGPC_ZCL_FRAME_TYPE_CMD_TO_SERVER,
2288+
ZIGPC_ZCL_CLUSTER_DOOR_LOCK,
2289+
ZIGPC_ZCL_CLUSTER_DOOR_LOCK_COMMAND_GET_ALL_PIN_CODES,
2290+
0,
2291+
nullptr
2292+
);
2293+
2294+
}
2295+
22722296

22732297
}
22742298

@@ -4076,6 +4100,7 @@ sl_status_t zigpc_command_mapper_mqtt_bygroup_handlers_init(void)
40764100
uic_mqtt_dotdot_by_group_door_lock_clearrfid_code_callback_set(zigpc_command_mapper_bygroup_door_lock_clearrfid_code_handler);
40774101
uic_mqtt_dotdot_by_group_door_lock_clear_allrfid_codes_callback_set(zigpc_command_mapper_bygroup_door_lock_clear_allrfid_codes_handler);
40784102
uic_mqtt_dotdot_by_group_door_lock_get_allpin_codes_callback_set(zigpc_command_mapper_bygroup_door_lock_get_allpin_codes_handler);
4103+
uic_mqtt_dotdot_by_group_door_lock_get_all_pin_codes_callback_set(zigpc_command_mapper_bygroup_door_lock_get_all_pin_codes_handler);
40794104
uic_mqtt_dotdot_by_group_thermostat_write_attributes_callback_set(zigpc_command_mapper_bygroup_thermostat_write_attributes_handler);
40804105
uic_mqtt_dotdot_by_group_thermostat_setpoint_raise_or_lower_callback_set(zigpc_command_mapper_bygroup_thermostat_setpoint_raise_or_lower_handler);
40814106
uic_mqtt_dotdot_by_group_thermostat_set_weekly_schedule_callback_set(zigpc_command_mapper_bygroup_thermostat_set_weekly_schedule_handler);

applications/zigpc/components/command_mapper/zap-generated/src/zigpc_command_mapper_handlers.cpp

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4231,6 +4231,50 @@ sl_status_t zigpc_command_mapper_door_lock_clear_allrfid_codes_handler(
42314231
status = SL_STATUS_NOT_AVAILABLE;
42324232
}
42334233
return status;
4234+
* @brief DotDot MQTT translator handler for DoorLock/GetAllPINCodes command.
4235+
*
4236+
* @param unid Unify device identifier string
4237+
* @param endpoint Unify device endpoint identifier
4238+
* @param callback_type Callback type
4239+
* @return SL_STATUS_OK if callback_type == UIC_MQTT_DOTDOT_CALLBACK_TYPE_NORMAL and call is successful
4240+
* @return SL_STATUS_OK if callback_type == UIC_MQTT_DOTDOT_CALLBACK_TYPE_SUPPORT_CHECK and command is supported by the unid/endpoint
4241+
* @return SL_STATUS_NOT_AVAILABLE if callback_type == UIC_MQTT_DOTDOT_CALLBACK_TYPE_SUPPORT_CHECK and command is not supported by the unid/endpoint
4242+
*/
4243+
sl_status_t zigpc_command_mapper_door_lock_get_all_pin_codes_handler(
4244+
const dotdot_unid_t unid,
4245+
const dotdot_endpoint_id_t endpoint,
4246+
uic_mqtt_dotdot_callback_call_type_t callback_type
4247+
) {
4248+
sl_status_t status = SL_STATUS_NOT_AVAILABLE;
4249+
4250+
if (callback_type == UIC_MQTT_DOTDOT_CALLBACK_TYPE_SUPPORT_CHECK) {
4251+
status = zigpc_command_mapper_cluster_support_check(unid, endpoint, ZIGPC_ZCL_CLUSTER_DOOR_LOCK);
4252+
if (status != SL_STATUS_OK) {
4253+
status = SL_STATUS_NOT_AVAILABLE;
4254+
}
4255+
return status;
4256+
}
4257+
4258+
4259+
4260+
4261+
if (status == SL_STATUS_OK) {
4262+
zigpc_command_mapper_send_unicast(
4263+
unid,
4264+
endpoint,
4265+
ZIGPC_ZCL_FRAME_TYPE_CMD_TO_SERVER,
4266+
ZIGPC_ZCL_CLUSTER_DOOR_LOCK,
4267+
ZIGPC_ZCL_CLUSTER_DOOR_LOCK_COMMAND_get_all_pin_CODES,
4268+
0,
4269+
nullptr
4270+
);
4271+
}
4272+
4273+
// Always return SL_STATUS_OK if being called normally.
4274+
return status;
4275+
}
4276+
4277+
/**
42344278
}
42354279
42364280
@@ -8101,6 +8145,9 @@ sl_status_t zigpc_command_mapper_register_dotdot_mqtt_handlers(void)
81018145
uic_mqtt_dotdot_door_lock_get_allpin_codes_callback_set(
81028146
zigpc_command_mapper_door_lock_get_allpin_codes_handler
81038147
);
8148+
);
8149+
uic_mqtt_dotdot_door_lock_get_all_pin_codes_callback_set(
8150+
zigpc_command_mapper_door_lock_get_all_pin_codes_handler
81048151
uic_mqtt_dotdot_set_thermostat_write_attributes_callback(
81058152
zigpc_command_mapper_thermostat_write_attributes_handler
81068153
);

applications/zigpc/components/zcl_util/zap-generated/include/zcl_definitions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ typedef enum {
479479
ZIGPC_ZCL_CLUSTER_DOOR_LOCK_COMMAND_CLEAR_ALLRFID_CODES_RESPONSE = 0x19,
480480
ZIGPC_ZCL_CLUSTER_DOOR_LOCK_COMMAND_OPERATING_EVENT_NOTIFICATION = 0x20,
481481
ZIGPC_ZCL_CLUSTER_DOOR_LOCK_COMMAND_PROGRAMMING_EVENT_NOTIFICATION = 0x21,
482-
ZIGPC_ZCL_CLUSTER_DOOR_LOCK_COMMAND_GET_ALLPIN_CODES = 0x80,
482+
ZIGPC_ZCL_CLUSTER_DOOR_LOCK_COMMAND_GET_ALL_PIN_CODES = 0x80,
483483
} zigpc_zcl_door_lock_command_type_t;
484484

485485
/*****************************************************************

applications/zpc/components/zcl_cluster_servers/src/user_code_cluster_server.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ sl_status_t user_code_cluster_server_init()
383383
// Register the callback for handling commands from IoT service
384384
uic_mqtt_dotdot_door_lock_setpin_code_callback_set(&set_pin_code_command);
385385
uic_mqtt_dotdot_door_lock_getpin_code_callback_set(&get_pin_code_command);
386-
uic_mqtt_dotdot_door_lock_get_allpin_codes_callback_set(&get_all_pin_codes_command);
386+
uic_mqtt_dotdot_door_lock_get_all_pin_codes_callback_set(&get_all_pin_codes_command);
387387
uic_mqtt_dotdot_door_lock_clearpin_code_callback_set(&clear_pin_code_command);
388388
uic_mqtt_dotdot_door_lock_clear_allpin_codes_callback_set(
389389
&clear_all_pin_codes_command);

applications/zpc/components/zwave_command_classes/src/zwave_command_class_user_code.c

Lines changed: 84 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -326,13 +326,38 @@ static bool is_mucr_supported(attribute_store_node_t endpoint_node)
326326
static sl_status_t zwave_command_class_user_code_number_get(
327327
attribute_store_node_t node, uint8_t *frame, uint16_t *frame_length)
328328
{
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 {
330354
// This is a static payload.
331355
ZW_USERS_NUMBER_GET_V2_FRAME *get_frame
332356
= (ZW_USERS_NUMBER_GET_V2_FRAME *)frame;
333357
get_frame->cmdClass = COMMAND_CLASS_USER_CODE_V2;
334358
get_frame->cmd = USERS_NUMBER_GET_V2;
335359
*frame_length = sizeof(ZW_USERS_NUMBER_GET_V2_FRAME);
360+
}
336361
return SL_STATUS_OK;
337362
}
338363

@@ -378,8 +403,8 @@ static sl_status_t zwave_command_class_user_code_get(
378403
*frame_length = 0;
379404
return SL_STATUS_ALREADY_EXISTS;
380405
}
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;
383408
frame[2] = (uint8_t)user_id;
384409
*frame_length = 3;
385410
return SL_STATUS_OK;
@@ -540,7 +565,30 @@ static sl_status_t zwave_command_class_user_code_admin_code_get(
540565
static sl_status_t zwave_command_class_user_code_keypad_mode_get(
541566
attribute_store_node_t node, uint8_t *frame, uint16_t *frame_length)
542567
{
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+
544592
zwave_minimum_frame_t *get_frame = (zwave_minimum_frame_t *)frame;
545593
get_frame->command_class = COMMAND_CLASS_USER_CODE_V2;
546594
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(
560608
static sl_status_t zwave_command_class_user_code_keypad_mode_set(
561609
attribute_store_node_t node, uint8_t *frame, uint16_t *frame_length)
562610
{
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+
563635
ZW_USER_CODE_KEYPAD_MODE_SET_V2_FRAME *set_frame
564636
= (ZW_USER_CODE_KEYPAD_MODE_SET_V2_FRAME *)frame;
565637
set_frame->cmdClass = COMMAND_CLASS_USER_CODE_V2;
@@ -653,8 +725,8 @@ static sl_status_t zwave_command_class_user_code_set(
653725
&user_id_status,
654726
sizeof(user_id_status));
655727

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;
658730
frame[2] = (uint8_t)user_id;
659731
frame[3] = user_id_status;
660732
if (user_id_status == 0) {
@@ -670,6 +742,8 @@ static sl_status_t zwave_command_class_user_code_set(
670742
}
671743

672744
*frame_length = 4 + user_code_size;
745+
attribute_store_undefine_desired(user_code_node);
746+
attribute_store_undefine_reported(user_code_node);
673747
return SL_STATUS_OK;
674748
}
675749

@@ -786,8 +860,8 @@ static sl_status_t zwave_command_class_user_code_delete_all(
786860
if (supporting_node_version == 1) {
787861
ZW_USER_CODE_SET_4BYTE_FRAME *set_frame
788862
= (ZW_USER_CODE_SET_4BYTE_FRAME *)frame;
789-
set_frame->cmdClass = COMMAND_CLASS_USER_CODE_V2;
790-
set_frame->cmd = USER_CODE_SET_V2;
863+
set_frame->cmdClass = COMMAND_CLASS_USER_CODE;
864+
set_frame->cmd = USER_CODE_SET;
791865
set_frame->userIdentifier = 0;
792866
set_frame->userIdStatus = 0;
793867
set_frame->userCode1 = 0;
@@ -980,15 +1054,15 @@ static void zwave_command_class_user_code_on_code_update(
9801054
}
9811055

9821056
if (attribute_store_is_desired_defined(updated_node) == false) {
983-
uic_mqtt_dotdot_door_lock_command_getpin_code_response_fields_t fields =
1057+
uic_mqtt_dotdot_door_lock_command_get_pin_code_response_fields_t fields =
9841058
{
9851059
.userid = (DrlkPINUserID) user_id,
9861060
.user_status = (DrlkUserStatus) user_status,
9871061
.user_type = (DrlkUserType) ZCL_DRLK_USER_TYPE_UNRESTRICTED_USER,
9881062
.code = pin_code
9891063
};
9901064

991-
uic_mqtt_dotdot_door_lock_publish_generated_getpin_code_response_command(
1065+
uic_mqtt_dotdot_door_lock_publish_generated_get_pin_code_response_command(
9921066
node_unid, endpoint_id, &fields);
9931067
}
9941068
}

components/uic_dotdot/dotdot-xml/DoorLock.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version="1.0"?>
2-
<!--
3-
Zigbee Alliance owns the copyright to the text and content displayed or
4-
included in this document (including in PDF, XML files and other formats) in
5-
all forms of media, which copyright is protected by the copyright laws of the
6-
United States and by international treaties. Full text of licensing terms
2+
<!--
3+
Zigbee Alliance owns the copyright to the text and content displayed or
4+
included in this document (including in PDF, XML files and other formats) in
5+
all forms of media, which copyright is protected by the copyright laws of the
6+
United States and by international treaties. Full text of licensing terms
77
applicable to this document can be found in the LICENSE.md file.
88
-->
99
<zcl:cluster xmlns:zcl="http://zigbee.org/zcl/clusters"

components/uic_dotdot/zap-generated/include/dotdot_cluster_command_id_definitions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@
189189
#define DOTDOT_DOOR_LOCK_CLEAR_ALLRFID_CODES_RESPONSE_COMMAND_ID (0x19)
190190
#define DOTDOT_DOOR_LOCK_OPERATING_EVENT_NOTIFICATION_COMMAND_ID (0x20)
191191
#define DOTDOT_DOOR_LOCK_PROGRAMMING_EVENT_NOTIFICATION_COMMAND_ID (0x21)
192-
#define DOTDOT_DOOR_LOCK_GET_ALLPIN_CODES_COMMAND_ID (0x80)
192+
#define DOTDOT_DOOR_LOCK_GET_ALL_PIN_CODES_COMMAND_ID (0x80)
193193

194194
// Commands for cluster: WindowCovering
195195
#define DOTDOT_WINDOW_COVERING_UP_OR_OPEN_COMMAND_ID (0x0)

components/uic_dotdot/zap-generated/readme_ucl_mqtt_reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16706,7 +16706,7 @@ mosquitto_sub -t 'ucl/by-unid/<UNID>/<EP>/DoorLock/GeneratedCommands/Programming
1670616706

1670716707
<br><br>
1670816708

16709-
\subsection door_lock_get_allpin_codes_cmd DoorLock/GetAllPINCodes Command
16709+
\subsection door_lock_get_all_pin_codes_cmd DoorLock/GetAllPINCodes Command
1671016710

1671116711
**MQTT Topic Pattern:**
1671216712

0 commit comments

Comments
 (0)