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

ZB_GET_OUT_BUF issue with ZB_ZDO_* request

Hi,

It seems that I have an issue with ZB_GET_OUT_BUF following the zb_zdo_node_desc_req example.

After several calls (around 10) of ProcessNodeDescReq, I can't get a new ZB_GET_OUT_BUF even if I executed zb_free_buf in the node_desc_callback.

I need to restart the debugger (from SES) to make it work again.

It's like the buffer isn't really released so I'm not able to get a new one after several attempts, right?

Here's my code:

static void ZDO_ProcessNodeDescReq( char *pBuf )
{
    zb_buf_t *asdu;
    zb_zdo_node_desc_req_t *req;

    asdu = ZB_GET_OUT_BUF();
    if (!asdu) {
        NRF_LOG_RAW_INFO("asdu failed for NodeDescReq\n");
    } else {
        ZB_BUF_INITIAL_ALLOC(asdu, sizeof(zb_zdo_node_desc_req_t), req);
        memcpy(&req->nwk_addr, &pBuf[5], 2); // e.g. 0x0000
        zb_zdo_node_desc_req(ZB_REF_FROM_BUF(asdu), node_desc_callback);
    }
}

static void node_desc_callback(zb_uint8_t param)
{
  zb_buf_t *buf = ZB_BUF_FROM_REF(param);
  zb_uint8_t *zdp_cmd = ZB_BUF_BEGIN(buf);
  zb_zdo_node_desc_resp_t *resp = (zb_zdo_node_desc_resp_t*)(zdp_cmd);
  
  if (resp->hdr.status != ZB_ZDP_STATUS_SUCCESS)
  {
    NRF_LOG_RAW_INFO("---ZDO:NodeDescRsp: Error incorrect status/addr\n");
    zb_free_buf(buf);
    return; 
  }
 
  NRF_LOG_RAW_INFO("<--ZDO:NodeDescRsp: status=%hd addr=0x%x manufacturer_code=0x%x\n", resp->hdr.status, resp->hdr.nwk_addr, resp->node_desc.manufacturer_code);
  zb_free_buf(buf);
}

Thank you!

Parents
  • I have to say I'm a bit confused about the zigbee buffer process for request...

    There's different ways describing this process in the documentation and it's not clear which one to use :

    1. Under the Zigbee stack memory Programming principles, it is mentioned to use  ZB_GET_OUT_BUF_DELAYED() but none of the examples use this macro but ZB_GET_OUT_BUF() instead.
    2. Some examples use ZB_BUF_INITIAL_ALLOC to initialize the req structure and other use ZB_GET_BUF_PARAM

    I wonder what is the best practice to perform a ZDO Request ?
    As I mentioned in my first post, after several successful requests, the node_desc_callback is not triggered and further calls of ZB_GET_OUT_BUF issue an error.

    Thank you very much for your support.

Reply
  • I have to say I'm a bit confused about the zigbee buffer process for request...

    There's different ways describing this process in the documentation and it's not clear which one to use :

    1. Under the Zigbee stack memory Programming principles, it is mentioned to use  ZB_GET_OUT_BUF_DELAYED() but none of the examples use this macro but ZB_GET_OUT_BUF() instead.
    2. Some examples use ZB_BUF_INITIAL_ALLOC to initialize the req structure and other use ZB_GET_BUF_PARAM

    I wonder what is the best practice to perform a ZDO Request ?
    As I mentioned in my first post, after several successful requests, the node_desc_callback is not triggered and further calls of ZB_GET_OUT_BUF issue an error.

    Thank you very much for your support.

Children
No Data
Related