This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
I have 4 devices, a coordinator and 3 routers, and 2 routers have been joined by coordinator. ZDSECMGR_TC_DEVICE_MAX of the coordinator has been set to 2.
And I join the last router to the network. it is fail.
Now If I remove a router first(call ZDP_MgmtLeaveReq()), and then join the last router to network, it fail again.
Should I Need delete any infomation of coordinator by manualy?
Hi jianf hu,
If you are sending the frame from the coordinator, the rejoin flag must be set to 0.
Regards,
Thanks YiKai Chen.
In file ZDSecMgr.c, APSME_TCLinkKeyInit() created APSME_TCLKDevEntry_t items for every
device,
Did APSME_TCLKDevEntry_t items should be save the TCLK infomation?
I wrote follow code after call ZDP_MgmtLeaveReq().
uint16_t index = APSME_SearchTCLinkKeyEntry(exAddr, &found, NULL);
if(found == TRUE)
{
APSME_TCLKDevEntry_t TCLKDevEntry;
osal_memset(&TCLKDevEntry, 0x00, sizeof(APSME_TCLKDevEntry_t));
TCLKDevEntry.keyAttributes = ZG_DEFAULT_KEY;
osal_nv_write(index, 0, sizeof(APSME_TCLKDevEntry_t), &TCLKDevEntry);
TCLinkKeyFrmCntr[ZCD_NV_TCLK_TABLE_START - index].txFrmCntr = 0;
TCLinkKeyFrmCntr[ZCD_NV_TCLK_TABLE_START - index].rxFrmCntr = 0;
}
And I test my code, It work.
Should I need call APSME_EraseICEntry(&TCLKDevEntry.SeedShift_IcIndex), what will it do?
Hi jianf hu,
Thanks for the captures. There is no definition in the spec for what happens when the coordinator receives an Update Device command with status 0x02 Device Left like in your capture "removed one.psd". The function that you implemented will be useful to solve your problem but again since the behavior is not defined in the spec now an can be defined in the future there is a chanse that your implementation will not be compliant, just be aware of that.
There is a function called ZDSecMgrUpdateDeviceInd() in ZDSecMgr.c
void ZDSecMgrUpdateDeviceInd( ZDO_UpdateDeviceInd_t* ind ) { ZDSecMgrDevice_t device; device.nwkAddr = ind->devAddr; device.extAddr = ind->devExtAddr; device.parentAddr = ind->srcAddr; device.devStatus = DEV_SEC_INIT_STATUS; device.secure = FALSE; // Trust Center should identify the type of JOIN/REJOIN and // Transport the NWK key accordingly, it will only be transported for: // APSME_UD_STANDARD_UNSECURED_JOIN // OR APSME_UD_STANDARD_TRUST_CENTER_REJOIN if ( ind->status != APSME_UD_DEVICE_LEFT ) { if ( ind->status == APSME_UD_STANDARD_SECURED_REJOIN ) { device.devStatus &= ~DEV_SEC_INIT_STATUS; device.devStatus |= DEV_SEC_AUTH_STATUS; device.secure = TRUE; } else { #if (ZG_BUILD_COORDINATOR_TYPE) uint8 found; uint16 keyNvIndex; APSME_TCLKDevEntry_t TCLKDevEntry; keyNvIndex = APSME_SearchTCLinkKeyEntry(device.extAddr,&found, &TCLKDevEntry); //If found and it was verified, then allow it to join in a fresh state by erasing the key entry if((found == TRUE) && (TCLKDevEntry.keyAttributes == ZG_VERIFIED_KEY)) { TCLKDevEntry.keyAttributes = ZG_DEFAULT_KEY; //Increase the shift by one. Validate the maximum shift of the seed which is 15 TCLKDevEntry.SeedShift_IcIndex++; TCLKDevEntry.SeedShift_IcIndex &= 0x0F; TCLKDevEntry.rxFrmCntr = 0; TCLKDevEntry.txFrmCntr = 0; //Update the entry osal_nv_write(keyNvIndex,0,sizeof(APSME_TCLKDevEntry_t), &TCLKDevEntry ); } bdb_TCAddJoiningDevice(device.parentAddr,device.extAddr); #endif } ZDSecMgrDeviceJoin( &device ); } // PUT YOUR CODE HERE TO REMOVE THE KEY }
Is safer to put your code here because you are getting the indication that the device already left the network, this is better that put the code in the leave request.
I hope this helps,
Regards,
Thanks Jose Maria Alvarez.
There is a problem.
I executed my code at debug mode and put a breakpoint into ZDSecMgrUpdateDeviceInd(). But
the code is never get to there.
I register a zdo callback of Mgmt_Leave_rsp, and put my code into the callback, It work
too.
Can I use this way to implemented?
Hi jianf hu,
I just tested this by myself and I'm getting the breakpoint on ZDSecMgrUpdateDeviceInd() when Update Device is received on coordinator. You need to use this indication to remove the key since this is the confirmation for the device leave in this case.
Please use a fresh new project and test again, also please provide a new capture of the test.
Regards