<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Zigbee communication failure</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/71980/zigbee-communication-failure</link><description>Hello Nordic! 
 I&amp;#39;ve been implementing some more commands in my endpoint handler but (I don&amp;#39;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</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 04 May 2021 20:10:17 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/71980/zigbee-communication-failure" /><item><title>RE: Zigbee communication failure</title><link>https://devzone.nordicsemi.com/thread/308246?ContentTypeID=1</link><pubDate>Tue, 04 May 2021 20:10:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c2d1cf20-ed58-4bdc-bd78-ab2e51ab479f</guid><dc:creator>Marjeris Romero</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I am sorry I didn&amp;#39;t come back to you on this one.&lt;/p&gt;
[quote user="mazis"]I have to avoid the ZCL callback because it wasn&amp;#39;t intercepting other commands such as Set Pin Code, Clear Pin Code and Get Pin Code and others. So I switched to an Endpoint Handler&amp;nbsp;which effectively intercepts all commands.&amp;nbsp;[/quote]
&lt;p&gt;Do you still need help registering your ZCL command handler override cb?&lt;/p&gt;
&lt;p&gt;There is a small guide on how to intercept ZCL commands and overriding the handling of ZCL commands in the infocenter:&lt;br /&gt;&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/sdk_tz_v4.1.0/using_zigbee__z_c_l.html?cp=7_3_3_4_1_8_1#process_zcl_cmd_implementing"&gt;https://infocenter.nordicsemi.com/topic/sdk_tz_v4.1.0/using_zigbee__z_c_l.html?cp=7_3_3_4_1_8_1#process_zcl_cmd_implementing&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Perhaps this will provide you with some help?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Marjeris&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zigbee communication failure</title><link>https://devzone.nordicsemi.com/thread/296552?ContentTypeID=1</link><pubDate>Fri, 26 Feb 2021 13:02:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:36e10291-e982-45b8-b101-d87eed169d76</guid><dc:creator>mazis</dc:creator><description>&lt;p&gt;Hello!&lt;/p&gt;
&lt;p&gt;Yes, I have checked the door_lock_nus example. In fact I am using it as a base for my code and I have modified a lot&amp;nbsp;the example.&lt;/p&gt;
&lt;p&gt;I have to avoid the ZCL callback because it wasn&amp;#39;t intercepting other commands such as Set Pin Code, Clear Pin Code and Get Pin Code and others. So I switched to an Endpoint Handler&amp;nbsp;which effectively intercepts all commands.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Anyway, I could use the ZCL callback but I would need to add some more callbacks, for the previous commands (set, clear and get). Is there any way to add more application callbacks for other commands?&lt;/p&gt;
&lt;p&gt;The callback code is looking something similar to this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;b_uint8_t ep_cb(zb_uint8_t param)
{
    zb_bufid_t zigbeeBuffer = param;
    zb_zcl_parsed_hdr_t *cmd_info = ZB_BUF_GET_PARAM(zigbeeBuffer, zb_zcl_parsed_hdr_t);
    zb_bool_t cmd_processed = ZB_FALSE;
    zb_uint8_t cmd_length = zb_buf_len(zigbeeBuffer);
    zb_uint8_t *payload = (zb_uint8_t*) zb_buf_begin(zigbeeBuffer);

    zb_uint8_t status = ZB_ZCL_STATUS_SUCCESS;
    //zb_bufid_t* bufferRespuesta = zb_buf_get_out();

    switch( cmd_info -&amp;gt; cluster_id )
    {
        case ZB_ZCL_CLUSTER_ID_DOOR_LOCK:
            if( cmd_info-&amp;gt;is_common_command )
            {
                TRACE_MSG(TRACE_ZCL2, &amp;quot;Skip general command %hd&amp;quot;, (FMT__H, cmd_info-&amp;gt;cmd_id));
            }
            else
            {
                if (cmd_info -&amp;gt; cmd_direction == ZB_ZCL_FRAME_DIRECTION_TO_SRV)
                {
                    if (ZB_ZCL_PARSED_HDR_SHORT_DATA(cmd_info).source.u.short_addr == 0x0000)
                    {
                       coordinadorInfo.short_address = ZB_ZCL_PARSED_HDR_SHORT_DATA(cmd_info).source.u.short_addr;
                       coordinadorInfo.source_endpoint = ZB_ZCL_PARSED_HDR_SHORT_DATA(cmd_info).src_endpoint;
                       coordinadorInfo.destination_endpoint = ZB_ZCL_PARSED_HDR_SHORT_DATA(cmd_info).dst_endpoint;
                       coordinadorInfo.profile_id = cmd_info -&amp;gt; profile_id;
                    }
                    switch (cmd_info-&amp;gt;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(zigbeeBuffer,
                                                               coordinadorInfo.short_address,
                                                               ZB_APS_ADDR_MODE_16_ENDP_PRESENT,
                                                               coordinadorInfo.source_endpoint,
                                                               coordinadorInfo.destination_endpoint,
                                                               coordinadorInfo.profile_id,
                                                               cmd_info-&amp;gt;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(zigbeeBuffer,
                                                                 coordinadorInfo.short_address,
                                                                 ZB_APS_ADDR_MODE_16_ENDP_PRESENT,
                                                                 coordinadorInfo.source_endpoint,
                                                                 coordinadorInfo.destination_endpoint,
                                                                 coordinadorInfo.profile_id,
                                                                 cmd_info-&amp;gt;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_SET_PIN_CODE:
                            bsp_board_led_off(LED_AUXILIAR);
                            // LEEMOS EL PAYLOAD DEL MENSAJE Y LO GUARDAMOS EN UNA CREDENCIAL TEMPORAL
                            tempCredencial.user_ID = (payload[1] &amp;lt;&amp;lt; 8) + payload[0];
                            tempCredencial.user_status = payload[2];
                            tempCredencial.user_type = payload[3];
                            for (int i = 0; i &amp;lt; payload[4]; i++)
                            {
                                tempCredencial.pin_code = (tempCredencial.pin_code &amp;lt;&amp;lt; 8) + payload[5 + i];
                            }
                            // SETEAMOS EL USUARIO QUE HEMOS LEIDO
                            set_pin_code(tempCredencial.user_ID,
                                         tempCredencial.user_status,
                                         tempCredencial.user_type,
                                         tempCredencial.pin_code);

                            // MANDAMOS LA RESPUESTA DEL COMANDO
                            ZB_ZCL_DOOR_LOCK_SET_PIN_CODE_RES(zigbeeBuffer,
                                                               coordinadorInfo.short_address,
                                                               ZB_APS_ADDR_MODE_16_ENDP_PRESENT,
                                                               coordinadorInfo.source_endpoint,
                                                               coordinadorInfo.destination_endpoint,
                                                               coordinadorInfo.profile_id,
                                                              cmd_info-&amp;gt;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_GET_PIN_CODE:
                            bsp_board_led_on(LED_AUXILIAR);
                            tempCredencial.user_ID = (payload[1] &amp;lt;&amp;lt; 8) + payload[0];
                            tempCredencial.pin_code = get_pin_code(tempCredencial.user_ID).pin_code;
                            // FIXME: HAY QUE PROBARLO
                            // RESPONDEMOS CON ESTA FUNCION
                            ZB_ZCL_DOOR_LOCK_GET_PIN_CODE_RES(zigbeeBuffer,
                                                               coordinadorInfo.short_address,
                                                               ZB_APS_ADDR_MODE_16_ENDP_PRESENT,
                                                               coordinadorInfo.source_endpoint,
                                                               coordinadorInfo.destination_endpoint,
                                                               coordinadorInfo.profile_id,
                                                              tempCredencial.user_ID,
                                                              tempCredencial.user_status,
                                                              tempCredencial.user_type,
                                                              tempCredencial.pin_code,
                                                              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_CLEAR_PIN_CODE:
                            bsp_board_led_off(LED_AUXILIAR);
                            // LEEMOS EL PAYLOAD Y LO GUARDAMOS COMO USER_ID
                            tempCredencial.user_ID = (payload[1] &amp;lt;&amp;lt; 8) + payload[0];
                            clear_pin_code(tempCredencial.user_ID);
                            ZB_ZCL_DOOR_LOCK_CLEAR_PIN_CODE_RES(zigbeeBuffer,
                                                               coordinadorInfo.short_address,
                                                               ZB_APS_ADDR_MODE_16_ENDP_PRESENT,
                                                               coordinadorInfo.source_endpoint,
                                                               coordinadorInfo.destination_endpoint,
                                                               coordinadorInfo.profile_id,
                                                                cmd_info-&amp;gt;seq_number,
                                                                status,
                                                                false);
                            cmd_processed = ZB_TRUE;
                            zb_buf_free(zigbeeBuffer);
                            //zb_buf_free(param);
                            // zb_buf_free(bufferRespuesta);
                            return ZB_TRUE;
                            break;

                        default:
                            //TRACE_MSG(TRACE_ZCL2, &amp;quot;Cluster command %hd, skip it&amp;quot;, (FMT__H, cmd_info-&amp;gt;cmd_id));
                            break;
                    }
                }
            }
            break;

        default:
            break;
    }
    //if (cmd_processed == ZB_TRUE)
    //{
    //    zb_buf_free(zigbeeBuffer);
    //    zb_buf_free(param);
    //}
    //zb_buf_free(bufferRespuesta);
    return cmd_processed;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The code has a lot of commented lines because I am terribly lost and I have been testing different approaches.&lt;/p&gt;
&lt;p&gt;Cheers!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zigbee communication failure</title><link>https://devzone.nordicsemi.com/thread/296539?ContentTypeID=1</link><pubDate>Fri, 26 Feb 2021 12:48:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:feed7f81-b200-4e85-ba8c-09c99e48e153</guid><dc:creator>Marjeris Romero</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Are you implementing a door lock with the door lock server cluster on the nRF side? Have you taken a look at our BLE/Zigbee door lock example?&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/sdk_tz_v4.1.0/zigbee_multi_dynamic_door_lock_nus_example.html"&gt;https://infocenter.nordicsemi.com/topic/sdk_tz_v4.1.0/zigbee_multi_dynamic_door_lock_nus_example.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;See how the ZCL callback function is implemented in the example:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/**@brief Callback function for handling ZCL commands.
 *
 * @param[in]   bufid   Reference to Zigbee stack buffer used to pass received data.
 */
static zb_void_t zcl_device_cb(zb_bufid_t bufid)
{
    zb_zcl_device_callback_param_t * p_device_cb_param = ZB_BUF_GET_PARAM(bufid, zb_zcl_device_callback_param_t);

    /* Set default response value. */
    p_device_cb_param-&amp;gt;status = RET_OK;

    switch (p_device_cb_param-&amp;gt;device_cb_id)
    {
        case ZB_ZCL_DOOR_LOCK_UNLOCK_DOOR_CB_ID:
            set_lock_state(ZB_ZCL_ATTR_DOOR_LOCK_LOCK_STATE_UNLOCKED);
            break;

        case ZB_ZCL_DOOR_LOCK_LOCK_DOOR_CB_ID:
            set_lock_state(ZB_ZCL_ATTR_DOOR_LOCK_LOCK_STATE_LOCKED);
            break;

        default:
            p_device_cb_param-&amp;gt;status = RET_ERROR;
            break;
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The only thing you should need to do is to intercept the command to set the status of the lock in your application, the response to the command should be send by the stack, see ZB_ZCL_DOOR_LOCK_LOCK_DOOR_CB_ID&amp;nbsp; and ZB_ZCL_DOOR_LOCK_UNLOCK_DOOR_CB_ID application callbacks.&lt;/p&gt;
&lt;p&gt;BR,&lt;/p&gt;
&lt;p&gt;Marjeris&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>