This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

ZCL Tunneling - RequestTunnel not received

I am trying to establish a tunnel from ZigBee client to ZigBee server on nRF52840 using "nRF5 SDK for Thread and Zigbee v4.1.0".

Starting with the examples "examples\zigbee\light_control\light_bulb" (server) and "light_switch" (client) a HA_DIMMABLE_LIGHT_ENDPOINT connection gets established.

Establishing a tunnel fails, the server does not even receive the RequestTunnel message (on ZB_ZCL_TUNNELING_SEND_REQUEST_TUNNEL)  though from my point of view, the server is set up correctly. Is there any example code available showing how to utilize ZigBee ZCL Smart Energy Tunneling?

This is how the server is set up:

#define TUNNELING_ENDPOINT_ID 11
#define TUNNELING_PROFILE_ID 0x10a
#define TUNNELING_DEVICE_ID 0x500
ZB_ZCL_DECLARE_TUNNELING_ATTRIB_LIST(tunneling_attr_list, &m_dev_ctx.tunneling_attr.close_tunnel_timeout);
zb_zcl_cluster_desc_t tunneling_clusters[]={
    ZB_ZCL_CLUSTER_DESC(ZB_ZCL_CLUSTER_ID_TUNNELING,
        ZB_ZCL_ARRAY_SIZE(tunneling_attr_list, zb_zcl_attr_t),
        tunneling_attr_list,
        ZB_ZCL_CLUSTER_SERVER_ROLE,
        MANUF_CODE)
};
zb_af_simple_desc_1_1_t simple_desc_tunnel={
    TUNNELING_ENDPOINT_ID,
    TUNNELING_PROFILE_ID,
    TUNNELING_DEVICE_ID,
    1, 0,
    1, 0,
    { ZB_ZCL_CLUSTER_ID_TUNNELING }
};
ZB_AF_DECLARE_ENDPOINT_DESC(tunneling_ep, TUNNELING_ENDPOINT_ID,
    TUNNELING_PROFILE_ID, 0, NULL,
    ZB_ZCL_ARRAY_SIZE(tunneling_clusters, zb_zcl_cluster_desc_t), tunneling_clusters,
    &simple_desc_tunnel,
    0, NULL, 0, NULL);
ZBOSS_DECLARE_DEVICE_CTX_2_EP(dimmable_light_ctx, dimmable_light_ep, tunneling_ep);
...
ZB_AF_REGISTER_DEVICE_CTX(&dimmable_light_ctx);
ZB_ZCL_CLUSTER_ID_TUNNELING_SERVER_ROLE_INIT();
ZB_AF_SET_ENDPOINT_HANDLER(TUNNELING_ENDPOINT_ID,
  zb_tunnel_endpoint_handler); // <---- zb_tunnel_endpoint_handler never gets invoked upon client RequestTunnel

How the client is set up:

#define TUNNELING_ENDPOINT_ID 11
#define TUNNELING_PROFILE_ID 0x10a
#define TUNNELING_DEVICE_ID 0x500
#define TUNNELING_PROTOCOL_ID 200
zb_zcl_cluster_desc_t tunneling_clusters[]={
    ZB_ZCL_CLUSTER_DESC(ZB_ZCL_CLUSTER_ID_TUNNELING,
        0, NULL,
        ZB_ZCL_CLUSTER_CLIENT_ROLE,
        TUNNELING_MANUF_CODE)
};
zb_af_simple_desc_1_1_t simple_desc_tunnel={
    TUNNELING_ENDPOINT_ID,
    TUNNELING_PROFILE_ID,
    TUNNELING_DEVICE_ID,
    1, 0,
    0, 1,
    { ZB_ZCL_CLUSTER_ID_TUNNELING }
};
ZB_AF_DECLARE_ENDPOINT_DESC(tunneling_ep, TUNNELING_ENDPOINT_ID,
    TUNNELING_PROFILE_ID, 0, NULL,
    ZB_ZCL_ARRAY_SIZE(tunneling_clusters, zb_zcl_cluster_desc_t), tunneling_clusters,
    &simple_desc_tunnel,
    0, NULL, 0, NULL);
ZBOSS_DECLARE_DEVICE_CTX_2_EP(dimmer_switch_ctx, dimmer_switch_ep, tunneling_ep);

static void tunnel_request(zb_bufid_t bufid)
{
    ZB_ZCL_TUNNELING_SEND_REQUEST_TUNNEL(bufid,
        m_device_ctx.bulb_params.short_addr,
        ZB_APS_ADDR_MODE_16_ENDP_PRESENT,
        TUNNELING_ENDPOINT_ID,
        LIGHT_SWITCH_ENDPOINT, // <--- With TUNNELING_ENDPOINT_ID, tunnel_request_cb does not get invoked!
        TUNNELING_PROFILE_ID,
        ZB_ZCL_DISABLE_DEFAULT_RESPONSE,
        tunnel_request_cb, // <---- tunnel_request_cb gets invoked!
        TUNNELING_PROTOCOL_ID,
        MANUF_CODE,
        ZB_FALSE,
        100);
}
...
ZB_AF_REGISTER_DEVICE_CTX(&dimmer_switch_ctx);
ZB_ZCL_CLUSTER_ID_TUNNELING_CLIENT_ROLE_INIT();
ZB_AF_SET_ENDPOINT_HANDLER(TUNNELING_ENDPOINT_ID, zb_tunnel_endpoint_handler);

Parents
  • In the meantime I found out that profile ID ought to be HA:

    #define TUNNELING_PROFILE_ID ZB_AF_HA_PROFILE_ID

    With this, RequestTunnel seems working, client side request tunnel callback gets invoked and server receives ZB_ZCL_TUNNELING_CLI_CMD_REQUEST_TUNNEL as expected.

    Question is, why does profile ID have to be HA (even ZB_AF_SE_PROFILE_ID does not work)?

    At this point, transfer data fails in both directions with RET_ERROR as already described here. Is there any progress what may cause this error?

    zb_uint8_t *data=(zb_uint8_t*)"Testdata";
    NRF_LOG_INFO("Transfer data: %d/%d", tunnel_id, strlen((char*)data));
    zb_ret_t zb_err_code=ZB_ZCL_TUNNELING_CLIENT_SEND_TRANSFER_DATA(bufid, TUNNELING_ENDPOINT_ID, TUNNELING_PROFILE_ID,
    		ZB_ZCL_DISABLE_DEFAULT_RESPONSE, tunnel_send_transfer_data_cb,
    		tunnel_id, strlen((char*)data), data);
    ZB_ERROR_CHECK(zb_err_code);
    

Reply
  • In the meantime I found out that profile ID ought to be HA:

    #define TUNNELING_PROFILE_ID ZB_AF_HA_PROFILE_ID

    With this, RequestTunnel seems working, client side request tunnel callback gets invoked and server receives ZB_ZCL_TUNNELING_CLI_CMD_REQUEST_TUNNEL as expected.

    Question is, why does profile ID have to be HA (even ZB_AF_SE_PROFILE_ID does not work)?

    At this point, transfer data fails in both directions with RET_ERROR as already described here. Is there any progress what may cause this error?

    zb_uint8_t *data=(zb_uint8_t*)"Testdata";
    NRF_LOG_INFO("Transfer data: %d/%d", tunnel_id, strlen((char*)data));
    zb_ret_t zb_err_code=ZB_ZCL_TUNNELING_CLIENT_SEND_TRANSFER_DATA(bufid, TUNNELING_ENDPOINT_ID, TUNNELING_PROFILE_ID,
    		ZB_ZCL_DISABLE_DEFAULT_RESPONSE, tunnel_send_transfer_data_cb,
    		tunnel_id, strlen((char*)data), data);
    ZB_ERROR_CHECK(zb_err_code);
    

Children
  • The ZB_AF_SE_PROFILE_ID / ZB_AF_HA_PROFILE_ID wasn't mentioned before now. Where are you using it? Perhaps you are trying to add this profile to the light_switch endpoint? If so, I believe they need to be on the same profile ID.

    jen said:
    At this point, transfer data fails in both directions with RET_ERROR as already described here. Is there any progress what may cause this error?

     

     Is this something I can reproduce on my side with 2x nRF52840 DKs? 

     If so, can you please zip the two projects that you are using to test this on? It is not easy to say what's wrong only from your snippets. From where do you get the bufid, how is the tunnel_send_transfer_data_cb set up, what is your tunnel_id? 

Related