I have encountered my device enter into an infinite loop when NWK_DataReq is called for the same req twice without clearing it from the queue. I have added the following catch to prevent this:
void NWK_DataReq(NWK_DataReq_t *req)
{
req->state = NWK_DATA_REQ_STATE_INITIAL;
req->status = NWK_SUCCESS_STATUS;
req->frame = NULL;
nwkIb.lock++;
if (NULL == nwkDataReqQueue) {
req->next = NULL;
nwkDataReqQueue = req;
}
else if (nwkDataReqQueue==req){ //catch duplicate req
printf("double message \r\n");
}
else{
req->next = nwkDataReqQueue;
nwkDataReqQueue = req;
}
}
What I don't know yet is why this is happening, it seems that there shouldn't be a condition where NWK_DataReq is called twice on the same req frame. Also, would like input on whether it is dangerous to put this catch in there, whether I might lose data.