I've just spent about 2 hours trying to figure out why my rfWSN Concentrator example throws me into a system abort state when I use Easylink_abort() to enable me to cancel an Async Rx. I wanted to do this so that I could turn on/off RxAddress filtering.
I knew from the API docs I had to run the abort function to stop the Easylink_ReceiveAsync() command before I used any other Easylink API function. However, nothing in the API says that this would result in an rxDoneCallback() call in Easylink.c, which would then return an Easylink_Status_Aborted. Obviously the rxDoneCallback() in ConcentratorRadioTask.c interprets this as an invalid packet and posts a "RADIO_EVENT_INVALID_PACKET_RECEIVED" resulting in a system_abort().
The API documentation is pretty minimal unfortunately, neither of the two functions this concerns have any notes about this occurrence.
- Just to be sure, am I correct in what I believe the case to be here? If so, can we get it added to the documentation and pad it out a bit?
- Are there any conditions where you would actually want Easylink_Status_Aborted to be labelled as an invalid packet event?
Is it safe to add a clause to my rxDoneCallback() in ConcentratorRadioTask.c that would ignore this status, or is there another better way to ignore the callback from an Easylink_abort()? - And finally, this is the piece of code I am running to open/close my network within my concentratorRadioTaskFunction(). Because I'm new to Easylink I wanted to check I'm doing this correctly... Does it look okay?
(I already learned I have to do this in the task or the stack isn't persistent and it thinks EasyLink hasn't been initialised!)
/***************** Radio status management *****************/ /* If the PAN should be open */ if(events & RADIO_EVENT_OPEN_PAN) { if(EasyLink_abort() != EasyLink_Status_Success) { System_abort("EasyLink_abort failed"); } // NULL address disables the filter if(EasyLink_enableRxAddrFilter(NULL, NULL, NULL) != EasyLink_Status_Success) { System_abort("Failed to disable RxAddrFilter"); }else{ // Indicate open with Red LED PIN_setOutputValue(ledPinHandle, PAN_STATUS_LED, 1); } if(EasyLink_receiveAsync(rxDoneCallback, 0) != EasyLink_Status_Success) { System_abort("EasyLink_receiveAsync failed"); } } /* If the PAN should be closed */ if(events & RADIO_EVENT_CLOSE_PAN) { if(EasyLink_abort() != EasyLink_Status_Success) { System_abort("EasyLink_abort failed"); } // Filter out anything not directed at us if(EasyLink_enableRxAddrFilter((uint8_t*) &panFilterAddress, RADIO_ADDRESS_LENGTH, 1) != EasyLink_Status_Success) { System_abort("Failed to enable RxAddrFilter"); }else{ // Turn LED off PIN_setOutputValue(ledPinHandle, PAN_STATUS_LED, 0); } if(EasyLink_receiveAsync(rxDoneCallback, 0) != EasyLink_Status_Success) { System_abort("EasyLink_receiveAsync failed"); } }