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);