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 Reply Children
Related