Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-23: Feature door lock get all pin codes #23

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7274,6 +7274,13 @@ export let ClusterTypeAttrs: any = {
isArray: false,
}
]
},
{
id: 128,
name: "GetAllPINCodes",
required: false,
fields: [
]
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,14 +316,14 @@ static void zigpc_command_mapper_publish_door_lock_getpin_code_response(
) {
std::string unid(zigpc_ucl::mqtt::build_unid(zigbee_eui64_to_uint(eui64)));

uic_mqtt_dotdot_door_lock_command_getpin_code_response_fields_t fields = {
uic_mqtt_dotdot_door_lock_command_get_pin_code_response_fields_t fields = {
(uint16_t) data->door_lock_getpin_code_response.userid,
(DrlkUserStatus) data->door_lock_getpin_code_response.user_status,
(DrlkUserType) data->door_lock_getpin_code_response.user_type,
(const char*) data->door_lock_getpin_code_response.code
};

uic_mqtt_dotdot_door_lock_publish_generated_getpin_code_response_command(
uic_mqtt_dotdot_door_lock_publish_generated_get_pin_code_response_command(
unid.c_str(),
endpoint_id,
&fields
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2269,6 +2269,54 @@ void zigpc_command_mapper_bygroup_door_lock_clear_allrfid_codes_handler(
0,
nullptr
);
/**
* @brief DotDot MQTT by-group handler for DoorLock/GetAllPINCodes command.
*
* @param group_id UCL group identifier.

*/
void zigpc_command_mapper_bygroup_door_lock_get_all_pin_codes_handler(
const dotdot_group_id_t group_id
) {




zigpc_command_mapper_send_multicast(
group_id,
ZIGPC_ZCL_FRAME_TYPE_CMD_TO_SERVER,
ZIGPC_ZCL_CLUSTER_DOOR_LOCK,
ZIGPC_ZCL_CLUSTER_DOOR_LOCK_COMMAND_GET_ALL_PIN_CODES,
0,
nullptr
);

}


}

/**
* @brief DotDot MQTT by-group handler for DoorLock/GetAllPINCodes command.
*
* @param group_id UCL group identifier.

*/
void zigpc_command_mapper_bygroup_door_lock_get_allpin_codes_handler(
const dotdot_group_id_t group_id
) {




zigpc_command_mapper_send_multicast(
group_id,
ZIGPC_ZCL_FRAME_TYPE_CMD_TO_SERVER,
ZIGPC_ZCL_CLUSTER_DOOR_LOCK,
ZIGPC_ZCL_CLUSTER_DOOR_LOCK_COMMAND_GET_ALLPIN_CODES,
0,
nullptr
);

}

Expand Down Expand Up @@ -4051,6 +4099,8 @@ sl_status_t zigpc_command_mapper_mqtt_bygroup_handlers_init(void)
uic_mqtt_dotdot_by_group_door_lock_getrfid_code_callback_set(zigpc_command_mapper_bygroup_door_lock_getrfid_code_handler);
uic_mqtt_dotdot_by_group_door_lock_clearrfid_code_callback_set(zigpc_command_mapper_bygroup_door_lock_clearrfid_code_handler);
uic_mqtt_dotdot_by_group_door_lock_clear_allrfid_codes_callback_set(zigpc_command_mapper_bygroup_door_lock_clear_allrfid_codes_handler);
uic_mqtt_dotdot_by_group_door_lock_get_allpin_codes_callback_set(zigpc_command_mapper_bygroup_door_lock_get_allpin_codes_handler);
uic_mqtt_dotdot_by_group_door_lock_get_all_pin_codes_callback_set(zigpc_command_mapper_bygroup_door_lock_get_all_pin_codes_handler);
uic_mqtt_dotdot_by_group_thermostat_write_attributes_callback_set(zigpc_command_mapper_bygroup_thermostat_write_attributes_handler);
uic_mqtt_dotdot_by_group_thermostat_setpoint_raise_or_lower_callback_set(zigpc_command_mapper_bygroup_thermostat_setpoint_raise_or_lower_handler);
uic_mqtt_dotdot_by_group_thermostat_set_weekly_schedule_callback_set(zigpc_command_mapper_bygroup_thermostat_set_weekly_schedule_handler);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4231,6 +4231,50 @@ sl_status_t zigpc_command_mapper_door_lock_clear_allrfid_codes_handler(
status = SL_STATUS_NOT_AVAILABLE;
}
return status;
* @brief DotDot MQTT translator handler for DoorLock/GetAllPINCodes command.
*
* @param unid Unify device identifier string
* @param endpoint Unify device endpoint identifier
* @param callback_type Callback type
* @return SL_STATUS_OK if callback_type == UIC_MQTT_DOTDOT_CALLBACK_TYPE_NORMAL and call is successful
* @return SL_STATUS_OK if callback_type == UIC_MQTT_DOTDOT_CALLBACK_TYPE_SUPPORT_CHECK and command is supported by the unid/endpoint
* @return SL_STATUS_NOT_AVAILABLE if callback_type == UIC_MQTT_DOTDOT_CALLBACK_TYPE_SUPPORT_CHECK and command is not supported by the unid/endpoint
*/
sl_status_t zigpc_command_mapper_door_lock_get_all_pin_codes_handler(
const dotdot_unid_t unid,
const dotdot_endpoint_id_t endpoint,
uic_mqtt_dotdot_callback_call_type_t callback_type
) {
sl_status_t status = SL_STATUS_NOT_AVAILABLE;

if (callback_type == UIC_MQTT_DOTDOT_CALLBACK_TYPE_SUPPORT_CHECK) {
status = zigpc_command_mapper_cluster_support_check(unid, endpoint, ZIGPC_ZCL_CLUSTER_DOOR_LOCK);
if (status != SL_STATUS_OK) {
status = SL_STATUS_NOT_AVAILABLE;
}
return status;
}




if (status == SL_STATUS_OK) {
zigpc_command_mapper_send_unicast(
unid,
endpoint,
ZIGPC_ZCL_FRAME_TYPE_CMD_TO_SERVER,
ZIGPC_ZCL_CLUSTER_DOOR_LOCK,
ZIGPC_ZCL_CLUSTER_DOOR_LOCK_COMMAND_get_all_pin_CODES,
0,
nullptr
);
}

// Always return SL_STATUS_OK if being called normally.
return status;
}

/**
}


Expand All @@ -4252,6 +4296,50 @@ sl_status_t zigpc_command_mapper_door_lock_clear_allrfid_codes_handler(
return SL_STATUS_OK;
}

/**
* @brief DotDot MQTT translator handler for DoorLock/GetAllPINCodes command.
*
* @param unid Unify device identifier string
* @param endpoint Unify device endpoint identifier
* @param callback_type Callback type
* @return SL_STATUS_OK if callback_type == UIC_MQTT_DOTDOT_CALLBACK_TYPE_NORMAL and call is successful
* @return SL_STATUS_OK if callback_type == UIC_MQTT_DOTDOT_CALLBACK_TYPE_SUPPORT_CHECK and command is supported by the unid/endpoint
* @return SL_STATUS_NOT_AVAILABLE if callback_type == UIC_MQTT_DOTDOT_CALLBACK_TYPE_SUPPORT_CHECK and command is not supported by the unid/endpoint
*/
sl_status_t zigpc_command_mapper_door_lock_get_allpin_codes_handler(
const dotdot_unid_t unid,
const dotdot_endpoint_id_t endpoint,
uic_mqtt_dotdot_callback_call_type_t callback_type
) {
sl_status_t status = SL_STATUS_OK;

if (callback_type == UIC_MQTT_DOTDOT_CALLBACK_TYPE_SUPPORT_CHECK) {
status = zigpc_command_mapper_cluster_support_check(unid, endpoint, ZIGPC_ZCL_CLUSTER_DOOR_LOCK);
if (status != SL_STATUS_OK) {
status = SL_STATUS_NOT_AVAILABLE;
}
return status;
}




if (status == SL_STATUS_OK) {
zigpc_command_mapper_send_unicast(
unid,
endpoint,
ZIGPC_ZCL_FRAME_TYPE_CMD_TO_SERVER,
ZIGPC_ZCL_CLUSTER_DOOR_LOCK,
ZIGPC_ZCL_CLUSTER_DOOR_LOCK_COMMAND_GET_ALLPIN_CODES,
0,
nullptr
);
}

// Always return SL_STATUS_OK if being called normally.
return SL_STATUS_OK;
}

/******************
* DotDot MQTT Command Handlers for Thermostat cluster
******************/
Expand Down Expand Up @@ -8054,6 +8142,12 @@ sl_status_t zigpc_command_mapper_register_dotdot_mqtt_handlers(void)
uic_mqtt_dotdot_door_lock_clear_allrfid_codes_callback_set(
zigpc_command_mapper_door_lock_clear_allrfid_codes_handler
);
uic_mqtt_dotdot_door_lock_get_allpin_codes_callback_set(
zigpc_command_mapper_door_lock_get_allpin_codes_handler
);
);
uic_mqtt_dotdot_door_lock_get_all_pin_codes_callback_set(
zigpc_command_mapper_door_lock_get_all_pin_codes_handler
uic_mqtt_dotdot_set_thermostat_write_attributes_callback(
zigpc_command_mapper_thermostat_write_attributes_handler
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,7 @@ typedef enum {
ZIGPC_ZCL_CLUSTER_DOOR_LOCK_COMMAND_CLEAR_ALLRFID_CODES_RESPONSE = 0x19,
ZIGPC_ZCL_CLUSTER_DOOR_LOCK_COMMAND_OPERATING_EVENT_NOTIFICATION = 0x20,
ZIGPC_ZCL_CLUSTER_DOOR_LOCK_COMMAND_PROGRAMMING_EVENT_NOTIFICATION = 0x21,
ZIGPC_ZCL_CLUSTER_DOOR_LOCK_COMMAND_GET_ALL_PIN_CODES = 0x80,
} zigpc_zcl_door_lock_command_type_t;

/*****************************************************************
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,34 @@
def zwDOOR_LOCK_OPERATION_DOOR_LOCK_MODE 0x6207
def zwDOOR_LOCK_CAPABILITIES_SUPPORTED_DOOR_COMPONENTS 0x6217

def zwDOOR_LOCK_CONFIGURATION_OPERATION_TYPE 0x6202
def zwDOOR_LOCK_CONFIGURATION_INSIDE_DOOR_HANDLES_STATE 0x6203
def zwDOOR_LOCK_CONFIGURATION_OUTSIDE_DOOR_HANDLES_STATE 0x6204
def zwDOOR_LOCK_CONFIGURATION_LOCK_TIMEOUT_MINUTES 0x6205
def zwDOOR_LOCK_CONFIGURATION_LOCK_TIMEOUT_SECONDS 0x6206

def zwDOOR_LOCK_OPERATION_INSIDE_DOOR_HANDLES_MODE 0x6208
def zwDOOR_LOCK_OPERATION_OUTSIDE_DOOR_HANDLES_MODE 0x6209
def zwDOOR_LOCK_OPERATION_DOOR_CONDITION 0x620A
def zwDOOR_LOCK_OPERATION_LOCK_TIMEOUT_MINUTES 0x620B
def zwDOOR_LOCK_OPERATION_LOCK_TIMEOUT_SECONDS 0x620C

// UserCode Zwave attributes
def zwUSER_CODE_DATA 0x6302
def zwUSER_CODE_NUMBER_OF_USERS 0x6303
def zwUSER_CODE_CAPABILITIES 0x6309
def zwUSER_CODE_SUPPORTED_FLAGS 0x630A
def zwUSER_CODE_SUPPORTED_USER_ID_STATUS_BITMASK 0x630B
def zwUSER_CODE_SUPPORTED_KEYPAD_MODES_BITMASK 0x630C
def zwUSER_CODE_SUPPORTED_KEYS_BITMASK 0x630D

def zwUSER_CODE_KEYPAD_MODE 0x630F

// ZigBee DoorLock attributes
def zbDOOR_LOCK_CLUSTER_LOCK_STATE 0x01010000
def zbDOOR_LOCK_CLUSTER_LOCK_TYPE 0x01010001
def zbDOOR_LOCK_ACTUATOR_ENABLED 0x01010002
def zbDOOR_LOCK_NUMBER_OF_PIN_USERS 0x01010012
// --------

// Zwave lock types
Expand Down Expand Up @@ -35,6 +59,8 @@ def zbDOOR_UNDEFINED 0xFF

scope 0 {

r'zbDOOR_LOCK_NUMBER_OF_PIN_USERS = r'zwUSER_CODE_DATA.zwUSER_CODE_NUMBER_OF_USERS

// Linking Zigbee Lock State to mapped ZWave Lock State
r'zbDOOR_LOCK_CLUSTER_LOCK_STATE =
if ( r'zwDOOR_LOCK_OPERATION_DOOR_LOCK_MODE == zwDOOR_UNSECURE_FOR_OUTSIDE ) zbDOOR_NOT_FULLY_LOCKED
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Custom Notification to DoorLock mappings
def zwNOTIFICATION_TYPE 0x7103
def zwNOTIFICATION_ACCESS_CONTROL_STATE 0x7105
def zwVALUE 0x7106

def zbDOOR_LOCK_CLUSTER_LOCK_STATE 0x01010000
def zbDOOR_LOCKED 0x01
def zbDOOR_UNLOCKED 0x02

def ACCESS_CONTROL 0x06
def ACCESS_CONTROL_TYPE 0xFF

def MANUAL_LOCK_OPERATION 0x01
def MANUAL_UNLOCK_OPERATION 0x02
def RF_LOCK_OPERATION 0x03
def RF_UNLOCK_OPERATION 0x04
def KEYPAD_LOCK_OPERATOIN 0x05
def KEYPAD_UNLOCK_OPERATOIN 0x06
def AUTO_LOCK_LOCKED_OPERATION 0x09
def UNLOCK_BY_RF_WITH_INVALID_USER_CODE 0x14
def LOCKED_BY_RF_WITH_INVALID_USER_CODE 0x15


scope 0 {

r'zbDOOR_LOCK_CLUSTER_LOCK_STATE =
if ( r'zwNOTIFICATION_TYPE[ACCESS_CONTROL].zwNOTIFICATION_ACCESS_CONTROL_STATE[ACCESS_CONTROL_TYPE].zwVALUE == MANUAL_LOCK_OPERATION ) zbDOOR_LOCKED
if ( r'zwNOTIFICATION_TYPE[ACCESS_CONTROL].zwNOTIFICATION_ACCESS_CONTROL_STATE[ACCESS_CONTROL_TYPE].zwVALUE == MANUAL_UNLOCK_OPERATION ) zbDOOR_UNLOCKED
if ( r'zwNOTIFICATION_TYPE[ACCESS_CONTROL].zwNOTIFICATION_ACCESS_CONTROL_STATE[ACCESS_CONTROL_TYPE].zwVALUE == RF_LOCK_OPERATION ) zbDOOR_LOCKED
if ( r'zwNOTIFICATION_TYPE[ACCESS_CONTROL].zwNOTIFICATION_ACCESS_CONTROL_STATE[ACCESS_CONTROL_TYPE].zwVALUE == RF_UNLOCK_OPERATION ) zbDOOR_UNLOCKED
if ( r'zwNOTIFICATION_TYPE[ACCESS_CONTROL].zwNOTIFICATION_ACCESS_CONTROL_STATE[ACCESS_CONTROL_TYPE].zwVALUE == KEYPAD_LOCK_OPERATOIN ) zbDOOR_LOCKED
if ( r'zwNOTIFICATION_TYPE[ACCESS_CONTROL].zwNOTIFICATION_ACCESS_CONTROL_STATE[ACCESS_CONTROL_TYPE].zwVALUE == KEYPAD_UNLOCK_OPERATOIN ) zbDOOR_UNLOCKED
if ( r'zwNOTIFICATION_TYPE[ACCESS_CONTROL].zwNOTIFICATION_ACCESS_CONTROL_STATE[ACCESS_CONTROL_TYPE].zwVALUE == AUTO_LOCK_LOCKED_OPERATION ) zbDOOR_LOCKED
if ( r'zwNOTIFICATION_TYPE[ACCESS_CONTROL].zwNOTIFICATION_ACCESS_CONTROL_STATE[ACCESS_CONTROL_TYPE].zwVALUE == UNLOCK_BY_RF_WITH_INVALID_USER_CODE ) zbDOOR_UNLOCKED
if ( r'zwNOTIFICATION_TYPE[ACCESS_CONTROL].zwNOTIFICATION_ACCESS_CONTROL_STATE[ACCESS_CONTROL_TYPE].zwVALUE == LOCKED_BY_RF_WITH_INVALID_USER_CODE ) zbDOOR_LOCKED
undefined

}
Loading