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.

CC2538: Bypass device reset after devState == DEV_END_DEVICE_UNAUTH

Part Number: CC2538

Hello,

Due to real time complications, I want to remove the ZDApp_ResetTimerStart( MAX_DEVICE_UNAUTH_TIMEOUT ); in ZDApp:

      if ( ZG_SECURE_ENABLED && ( ZDApp_RestoreNwkKey( TRUE ) == false ) )
      {
        // wait for auth from trust center
        ZDApp_ChangeState( DEV_END_DEVICE_UNAUTH );
        
        // Start the reset timer for MAX UNAUTH time
        ZDApp_ResetTimerStart( MAX_DEVICE_UNAUTH_TIMEOUT );
      }

and instead of reseting the device, I want to keep on scanning for a network to join.

Can someone guide me on how to do this?

  • Hi Panagiotis,

    This is similar to the investigation from this E2E thread.  You can choose to create a create a different timer which either resets the device using SystemResetSoft without calling zgWriteStartupOptions (see the ZDO_DEVICE_RESET event from ZDApp) or reverts the device ZDApp state to devStartMode = MODE_REJOIN, _tmpRejoinState = true, and _NIB.nwkState = NWK_INIT (see the MODE_REJOIN devStartMode instance) to try the join process again.

    Regards,
    Ryan

  • I managed to fix it by writing this:

    if ( ZG_SECURE_ENABLED && ( ZDApp_RestoreNwkKey( TRUE ) == false ) )
    {
    // wait for auth from trust center
    ZDApp_ChangeState( DEV_END_DEVICE_UNAUTH );
    
    devStartMode = MODE_JOIN;
    _NIB.nwkState = NWK_INIT;
    ZDApp_ResetNwkKey(); // Clear up the old network key.
    // Clear the neighbor Table and network discovery tables.
    nwkNeighborInitTable();
    NLME_NwkDiscTerm();
    // setup a retry
    ZDApp_NetworkInit(10000);

    I have tested it with two coordinators. One with the same TC link key and one with a different. When I try to join the coordinator with the different TC key it enters the code above and restarts the dev state to DEV_NWK_DISC and after that when I try to join it to the coordinator with the same key, it joins as expected.

    I know that I have to make a timer to wait to see if the device successfully joins before executing the above code but for now I have made a temporary solution to see if it works.

    I have one more question. We have setted the device to be able to join a network for the first 30 minutes after the boot. Does any of the above code have any influence on the enable join timer? I mean that regardless what happens (except if the device joins the network) it will scan for a network to join for 30 minutes.

  • I do not expect the enable join timer to be affected, but given changes to ZDApp you should further test and verify your application.

    Regards,
    Ryan

  • Great!!!

    Thank you for your help!!!