Hello Nordic!
I've been implementing some more commands in my endpoint handler but (I don't know how) it has stopped working. I have added the responses of the commands as shown in the code above but it just freezes the coordinator and makes the atribute reporting to stop. As a coordinator I am using a CC2531 with Zigbee2MQTT firmware flashed.
As a guide for coding I am using this two links:
https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_tz_v4.1.0%2Fgroup__ha__door__lock.html
The code I am using is as follows, I have only pasted a part of the code because the callback is huge, but I could provide it if its needed:
switch( cmd_info -> cluster_id )
{
case ZB_ZCL_CLUSTER_ID_DOOR_LOCK:
if( cmd_info->is_common_command )
{
TRACE_MSG(TRACE_ZCL2, "Skip general command %hd", (FMT__H, cmd_info->cmd_id));
}
else
{
if (cmd_info -> cmd_direction == ZB_ZCL_FRAME_DIRECTION_TO_SRV)
{
switch (cmd_info->cmd_id) {
case ZB_ZCL_CMD_DOOR_LOCK_LOCK_DOOR:
bsp_board_led_off(LED_AUXILIAR);
set_estado_cerradura(ZB_ZCL_ATTR_DOOR_LOCK_LOCK_STATE_LOCKED);
// MANDAMOS LA RESPUESTA DEL COMANDO
ZB_ZCL_DOOR_LOCK_SEND_LOCK_DOOR_RES(bufferRespuesta,
ZB_ZCL_PARSED_HDR_SHORT_DATA(cmd_info).source.u.short_addr,
ZB_APS_ADDR_MODE_16_ENDP_PRESENT,
ZB_ZCL_PARSED_HDR_SHORT_DATA(cmd_info).src_endpoint,
ZB_ZCL_PARSED_HDR_SHORT_DATA(cmd_info).dst_endpoint,
cmd_info->profile_id,
cmd_info->seq_number,
&status,
false);
cmd_processed = ZB_TRUE;
zb_buf_free(zigbeeBuffer);
//zb_buf_free(param);
zb_buf_free(bufferRespuesta);
return ZB_TRUE;
break;
case ZB_ZCL_CMD_DOOR_LOCK_UNLOCK_DOOR:
bsp_board_led_off(LED_AUXILIAR);
set_estado_cerradura(ZB_ZCL_ATTR_DOOR_LOCK_LOCK_STATE_UNLOCKED);
// MANDAMOS LA RESPUESTA DEL COMANDO
ZB_ZCL_DOOR_LOCK_SEND_UNLOCK_DOOR_RES(bufferRespuesta,
ZB_ZCL_PARSED_HDR_SHORT_DATA(cmd_info).source.u.short_addr,
ZB_APS_ADDR_MODE_16_ENDP_PRESENT,
ZB_ZCL_PARSED_HDR_SHORT_DATA(cmd_info).src_endpoint,
ZB_ZCL_PARSED_HDR_SHORT_DATA(cmd_info).dst_endpoint,
cmd_info->profile_id,
cmd_info->seq_number,
&status,
false);
cmd_processed = ZB_TRUE;
zb_buf_free(zigbeeBuffer);
//zb_buf_free(param);
zb_buf_free(bufferRespuesta);
return ZB_TRUE;
break;
}
}
}
break;
default:
TRACE_MSG(TRACE_ZCL1, "SRV role, cluster 0x%d is not supported", (FMT__D, cmd_info->cluster_id));
break;
}
return ZB_FALSE
Some strange issues I have came across:
- If I comment the response, the atribute reporting start working again. Can't figure out why, I need some explanation why.
- With the response uncommented, alhough the response is not sent, the atribute is set correctly but neither the response nor the atribute report is sent.
Cheers!