Hi,
I'm evaluating the performance of the Zigbee protocol implementation on the nRF connect SDK using nRF52840dk:s. nRF connect SDK 1.7.0, ZBOSS I'm not sure where to find but assumes latest as I write this (oct 2021). Windows 10.
I want to send data between devices for this purpose and have configured one DK as a ZED home automation profile with a dimmer switch to be able to send level control commands.
The receiving side is configured as a ZC with a level controllable output cluster end that the ZED discovers and sends to.
My send procedure in the ZED is: when found partner address and EP, allocate buffer using zb_buf_get_out_delayed(callback). In the callback, send command using ZB_ZCL_LEVEL_CONTROL_SEND_MOVE_TO_LEVEL_REQ(..., cb, ...) with params. In that cb, free buffer and ask for new using zb_buf_get_out_delayed(callback) again. Logging the time with timevals from sys/time.h reports around 15-20 ms for one send cycle without delays.
In the receiver ZC I use the zcl device cb to be notified about changes. It looks roughly like this:
static void zcl_device_cb(zb_bufid_t bufid)
{
zb_zcl_device_callback_param_t *device_cb_param =
ZB_BUF_GET_PARAM(bufid, zb_zcl_device_callback_param_t);
device_cb_param->status = RET_OK; //Set default response value
switch (device_cb_param->device_cb_id) {
case ZB_ZCL_LEVEL_CONTROL_SET_VALUE_CB_ID:
gettimeofday(&tv_stop, NULL);
received = device_cb_param->cb_param.level_control_set_value_param.new_value;
k_sem_give(&new_data_sem);
break;
}
}
I then use another thread to print the received data.
The problem: if I in the ZED allocate a new buffer and start a new send as soon as my callback from the previous send is called, packets are dropped in the receiver side (often up to ~80%) before they reach the application level. However, if I add a delay before I allocate a new buffer and send, more packages are received in the receiver. 7 ms seem to be enough for ~<1% packet loss (manually checked against my send counter).
I have set up wireshark to sniff the zigbee communication, and after the initial connection and discovery, I see an exchange of packages between the ZED and ZC, where they alter to send one package each to each other. Filtering on the package lengths, I can trace equal many packages of that length in either direction as I send in my test application, so I strongly suspect this is my level control messages. However, the ZC always responds to what the ZED sends, so no packages seem to be dropped in the 802.15.4 layers but somewhere in the receiving ZC before it reaches the application level and I can log them.
Screenshot from from wireshark showing a subset of the transactions between the ZC and ZED:

Does anyone have any idea why I can't receive all my messages without the delay? Since I use a semaphore to notify another thread it feels like I can't do the zcl device callback much more lightweight, so it should be able to free some buffer for the next receive in time, right?
