If an end device receives a ‘PAN access denied’ response to the rejoin request, it fails to return to sleep.
#define MAC_ASSOC_DENIED 2 /* PAN access denied */
It looks like the mac and network tasks continue to run and prevent the radio from going to sleep.
Setup
Z-Stack Home 1.2.2 running on CC2538.
-DREJOIN_BACKOFF=900000
-DREJOIN_POLL_RATE=440
-DREJOIN_SCAN=10000
How to create a ‘PAN access denied’ response
This response is created if the parent no longer has the child address in its associated device and network manager tables.
Build the coordinator with NWK_MAX_DEVICE_LIST=1.
This will limit the coordinator to having 2 end devices (#define NWK_MAX_DEVICES ( NWK_MAX_DEVICE_LIST + 1 ))
1. Join 2 end devices to the coordinator
2. Power down one device (Device #1)
3. Remove Device #1 from the coordinator table using the following calls.
ZDSecMgrAddrClear( addrEntry.extAddr );
AssocRemove( addrEntry.extAddr );
4. Join a third device
5. Power down all devices
6. Power up Device #1. It tries to rejoin but is rejected with "PAN access denied" response.
#define MAC_ASSOC_DENIED 2 /* PAN access denied */
Here is the log, with time stamp in tenths of seconds, showing the ZDO state change call backs.
0.0 ZDO St: 10 - NWK_ORPHAN
0.6 ZDO St: 2 - NWK_DISC
1.1 ZDO St: 15 - TC_REJOIN_ALL_CH
1.8 ZDO St: 2 - NWK_DISC
9.9 ZDO St: 14 - TC_REJOIN_CURR_CH
10.0 ZDO St: 12 - NWK_BACKOFF
11.7 ZDO St: 12 - NWK_BACKOFF
When the NWK_BACKOFF state is entered, the radio is on and drawing about 40 mA. Data request are being transmitted every 440 msec, which is the rejoin poll rate. The system remains stuck in this state and will keep sending the data requests forever.
I tried a few fixes, but nothing I do seems to be able to get it out of this state.
I called MAC_PwrOffReq(MAC_PWR_SLEEP_DEEP), but it returned the error code 0xe2 – ZmacDenied.
Calling NLME_SetPollRate(0), stops the data requests, but the radio remains on and data requests re-start after 5 minutes at the 440 msec poll rate.
The closest to a solution I have come is to add the following in ZDO_STATE change when the NWK_BACKOFF is reported:
NLME_SetPollRate(0)
uint8 rxOnIdle = false;
ZMacSetReq( ZMacRxOnIdle, &rxOnIdle );
This turns off the radio and normal sleep mode resumes. However, after 5 minutes, the rejoin poll rate starts up again. I have verified that NLME_SetPollRate( zgRejoinPollRate ) is not being called from ZDApp.c and this is the only instance of this call I see in the code.
The 'PAN access denied' response is probably quite rare. In fact I had never encountered it before this test. But, it appears that is not being handled correctly by the stack and I am hoping that someone out there may have come across it and have found a work around.
Thanks,

