Forums - qca4020 zigbee persist not joining to network

3 posts / 0 new
Last post
qca4020 zigbee persist not joining to network
akshay.b
Join Date: 2 Aug 19
Posts: 62
Posted: Thu, 2020-09-10 06:58

Hello, 

When our router device is connected in network and there is a power failure on router side, we need our router to connect to its network automatically without the server inititing permit join request. To achieve this we are using zigbee persist API when the device is initialized.

Below is the code we have written referring QCLI_demo project:

int32_t Zigbee_Initialize()
{
int32_t Ret_Val;
qapi_Status_t Result;
uint64_t Extended_Address;
qbool_t UsePersist;
uint32_t PersistLength;
uint8_t *PersistData;
 
UsePersist = true;
/* Verify the ZigBee layer had not been initialized yet. */
if (ZigBee_Demo_Context.ZigBee_Handle == NULL)
{
Result = qapi_ZB_Initialize(&(ZigBee_Demo_Context.ZigBee_Handle), ZB_Event_CB, 0);
 
if ((Result == SUCCESS) && (ZigBee_Demo_Context.ZigBee_Handle != NULL))
{
 
if (UsePersist)
{
/* Attempt to load the persist data. */
Result = qapi_Persist_Initialize(&(ZigBee_Demo_Context.PersistHandle), ZIGBEE_PERSIST_DIRECTORY, ZIGBEE_PERSIST_PREFIX, ZIGBEE_PERSIST_SUFFIX, NULL, 0);
 
if (Result == QAPI_OK)
{
Result = qapi_Persist_Get(ZigBee_Demo_Context.PersistHandle, &PersistLength, &PersistData);
 
if (Result == QAPI_OK)
{
 
Result = qapi_ZB_Restore_Persistent_Data(ZigBee_Demo_Context.ZigBee_Handle, PersistData, PersistLength);
 
if (Result == QAPI_OK)
{
int i = 0;
while(i<PersistLength)
{
LOG_INFO("%x\n",PersistData[i]);
i++;
}
LOG_INFO("Persist Data Loaded.\n");
}
else
{
LOG_INFO("qapi_ZB_Restore_Persistent_Data %d\n", Result);
}
 
qapi_Persist_Free(ZigBee_Demo_Context.PersistHandle, PersistData);
 
}
else if (Result != QAPI_ERR_NO_ENTRY)
{
 
LOG_INFO("qapi_Persist_Get %d\n", Result);
}
 
/* If it got this far, register the persist data callback. */
Result = qapi_ZB_Register_Persist_Notify_CB(ZigBee_Demo_Context.ZigBee_Handle, ZB_Persist_Notify_CB, (uint32_t) (ZigBee_Demo_Context.PersistHandle));
 
if (Result != QAPI_OK)
{
LOG_INFO("qapi_ZB_Register_Persist_Notify_CB %d\n", Result);
}
}
else
{
LOG_INFO("qapi_Persist_Initialize %d\n", Result);
}
}
 
if (Result == QAPI_OK)
{
 
if (ZDP_Demo_StackInitialize(ZigBee_Demo_Context.ZigBee_Handle))
{
Result = qapi_ZB_Get_Extended_Address(ZigBee_Demo_Context.ZigBee_Handle, &Extended_Address);
if (Result == QAPI_OK)
{
LOG_INFO("ZigBee stack initialized.\n");
LOG_INFO("Extended Address: %08X%08X\n", (uint32_t) (Extended_Address >> 32), (uint32_t) Extended_Address);
}
else
{
LOG_INFO("qapi_ZB_Get_Extended_Address %d\n", Result);
Ret_Val = QCLI_STATUS_ERROR_E;
}
}
else
{
Ret_Val = QCLI_STATUS_ERROR_E;
}
}
else
{
LOG_INFO("Z DEBUG 15 + 1 ret = %d\n",Ret_Val);
LOG_INFO("qapi_ZB_ZDP_Register_Callback %d\n", Result);
Ret_Val = QCLI_STATUS_ERROR_E;
}
 
if (Ret_Val != QCLI_STATUS_SUCCESS_E)
{
qapi_ZB_Shutdown(ZigBee_Demo_Context.ZigBee_Handle);
ZigBee_Demo_Context.ZigBee_Handle = NULL;
if (ZigBee_Demo_Context.PersistHandle != NULL)
{
 
qapi_Persist_Cleanup(ZigBee_Demo_Context.PersistHandle);
}
}
}
else
{
 
LOG_ERROR("FAILED qapi_ZB_Initialize\n");
Ret_Val = FAILURE;
}
}
else
{
LOG_WARN("ZigBee stack already initialized.\n");
Ret_Val = FAILURE;
}
 
return (Ret_Val);
}
1) Firstly we are connecting device to network successfully.
 
2) Now, we reboot / re power the router device. It shows messsage Onboard: Persist Data Loaded. on terminal. 
 
3) Beacon starts and the device is not connecting, with persist data. What can be missing here?
 
4) We are using onboard_demo project and implemented above code in its Zigbee_Initialize() function.
 
Can we get a brief explination on how it is performed with any example, as there nothing given about zigbee persisit in document.
 
Thank you,
 
Regards,
Akshaay.
 
  • Up0
  • Down0
c_rpedad
Profile picture
Join Date: 18 Jun 18
Location: San Jose
Posts: 317
Posted: Thu, 2020-09-10 11:25

Kindly configure endpoint and add enddevice address to the co-ordinator after reboot.

//Reboot the Co-ordinator device
> zigbee initialize 1
> ZigBee ZCL CreateEndpoint 1 2 
> ZigBee AddDevice 3 000000fffe000001 12  // EndDevice Addr

Below are the commands I tried between two QCA4020 devices:
Clear any persist data (Zigbee ClearPersist)
Initialize zigbee stack with option 1 (1 uses persist data)
Then configure your network and let light bulb join network as normal steps
Once the quartz board can control light bulb, you can reboot quartz board or light bulb
After reset, do initialize 1 to load persist data. As below example.
At this moment, you just need to configure endpoint/adddevice, but no need to re-create network. 
Then quartz is back to control light bulb again. 
 
QCA4020 Zigbee Coordinator
zigbee initialize 1
Zigbee setbib 0x100f 1 4 0
zigbee form 1
zigbee permitjoin 
ZigBee ZCL CreateEndpoint 1 2 
ZigBee AddDevice 3 000000fffe000001 1  // EndDevice Addr
zigbee OnOff On 1 1 
 
//Reboot the device
zigbee initialize 1
ZigBee ZCL CreateEndpoint 1 2 
zigBee AddDevice 3 000000fffe000001 1  // EndDevice Addr
zigbee OnOff On 1 1 
zigbee OnOff Off 1 1 

 
QCA4020 Zigbee EndDevice
zigbee initialize 1
zigbee setextaddress 000000fffe000001
zigbee join 0 1
zigbee ZCL Createendpoint 1 1
 
//Reboot the device
zigbee initialize 1
zigbee ZCL Createendpoint 1 1


Kindly let us know if the above instructions works well for your use case.

  • Up0
  • Down0
akshay.b
Join Date: 2 Aug 19
Posts: 62
Posted: Fri, 2020-09-11 06:51

Thank you raja_pedada, this solved my issue.

  • Up0
  • Down0
or Register

Opinions expressed in the content posted here are the personal opinions of the original authors, and do not necessarily reflect those of Qualcomm Incorporated or its subsidiaries (“Qualcomm”). The content is provided for informational purposes only and is not meant to be an endorsement or representation by Qualcomm or any other party. This site may also provide links or references to non-Qualcomm sites and resources. Qualcomm makes no representations, warranties, or other commitments whatsoever about any non-Qualcomm sites or third-party resources that may be referenced, accessible from, or linked to this site.