when ZED leave the network, which function should be used to tell ZC ?
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.
hi Chen
do you have seen the below function of zstack
when the ZED reset to factory config, do it send a leave request(NLME_LeaveReq( &leaveReq ))?
is it same as ZDP_MgmtLeaveReq?
when i use ZDP_MgmtLeaveReq, does ZED need to wait ZDP_MgmtLeaveRsp before Reset to factory?
static void zclsampleXXX_BasicResetCB( void )
{
NLME_LeaveReq_t leaveReq;
//delete the user item
osal_nv_delete( ZONE_CIEADDRESS_AND_ENROLL_INFO, NV_CIEADDR_LEN+NV_EXTDATA_LEN);
// Set every field to 0
osal_memset( &leaveReq, 0, sizeof( NLME_LeaveReq_t ) );
// This will enable the device to rejoin the network after reset.
leaveReq.rejoin = TRUE;
// Set the NV startup option to force a "new" join. //3
zgWriteStartupOptions( ZG_STARTUP_SET, ZCD_STARTOPT_DEFAULT_NETWORK_STATE | ZCD_STARTOPT_DEFAULT_CONFIG_STATE );
// Leave the network, and reset afterwards
if ( NLME_LeaveReq( &leaveReq ) != ZSuccess )
{
// Couldn't send out leave; prepare to reset anyway
ZDApp_LeaveReset( FALSE );
}
// restart device
MT_SysCommandProcessing( aProcessCmd );
}
hi Chen
i would like to enrich the question as below
the ZED was preform as HA device, and there is a note as below in HA specific
is that mean i need to use all of those function (ZDP_MgmtLeaveReq and NLME_LeaveReq( &leaveReq ) )
Return to Factory Defaults
In support of a return to factory default capability, HA devices shall implement the ZDO Management Leave server service.
When invoked with a unicast address and the DeviceAddress set to NULL=0x00000000, the device shall implement a NWK Leave.
When invoked with a broadcast address and the DeviceAddress set to NULL=0x00000000, the device shall wait the broadcast timeout period to
allow the message to propagate through network, then the device shall implement a NWK Leave.
Prior to execution of the NWK Leave in either case, processing in the device shall ensure all operating parameters are reset to allow a reset to factory
defaults.
Hi Chen
when i only involved ZDP_MgmtLeaveReq(father_dstAddr, NLME_GetExtAddr(), FALSE,TRUE, 1) in zclXXXX_BasicResetCB function of ZED,
The ZC will receive a MgmtLeaveReq Msg in ZDO_MSG_CB
when i only involved the NLME_LeaveReq( &leaveReq ) in zclXXXX_BasicResetCB function of ZED,
The ZC can't catch anything of Leave request Msg
and if i open MT_SysCommandProcessing( aProcessCmd ); no matter i use ZDP_MgmtLeaveReq or NLME_LeaveReq in ZED
The ZC can't catch anything, it seems that ZED have not finish processed the Leave function then doing the factory reset....
static void zclConnectSwitch_BasicResetCB( void )
{
// ZDO Management Leave server service
zAddrType_t *father_dstAddr =NULL;
father_dstAddr->addrMode = (afAddrMode_t)(afAddr16Bit);
father_dstAddr->addr.shortAddr = NLME_GetCoordShortAddr();
ZDP_MgmtLeaveReq(father_dstAddr, NLME_GetExtAddr(), FALSE,TRUE, 1);
// Set the NV startup option to force a "new" join.
zgWriteStartupOptions( ZG_STARTUP_SET, ZCD_STARTOPT_DEFAULT_NETWORK_STATE | ZCD_STARTOPT_DEFAULT_CONFIG_STATE );
//NLME_LeaveReq_t leaveReq;
// Set every field to 0
//osal_memset( &leaveReq, 0, sizeof( NLME_LeaveReq_t ) );
// This will enable the device to rejoin the network after reset.
//leaveReq.rejoin = TRUE;
// Leave the network, and reset afterwards
// if ( NLME_LeaveReq( &leaveReq ) != ZSuccess )
// {
// // Couldn't send out leave; prepare to reset anyway
// ZDApp_LeaveReset( FALSE );
// }
// restart device
//MT_SysCommandProcessing( aProcessCmd );
}
there is nothing received by ZC? although i have registered the Mgmt_Leave_req ,adding MT_ZDO_FUNC and MT_ZDO_MGMT in compile option in the ZC