The stack does not take control of your device to make it decide to join a network; it does not know how often you wish to retry joining (as this will consume battery power and bandwidth) or if you wish to abort the joining process completely and leave the network to try a new scan, or try a new node type.
Basically, the process should happen like this in a typical application:
•Device calls emberNetworkInit() after reboot.
•If device was previously part of a network, NetworkInit returns EMBER_SUCCESS; otherwise, it returns EMBER_NOT_JOINED. However, even if EMBER_SUCCESS is returned it doesn’t guarantee that the end device will be in the EMBER_JOINED_NETWORK state immediately after completing this; it only means that the old settings were able to be recovered, and now the node must try to find a suitable parent device (router or coordinator with available space in child table) to adopt it again.
•If NetworkInit failed, need to try to join/form new network.
•If NetworkInit succeeded, application should expect a StackStatusHandler callback (generated by emberTick() after several milliseconds of looping through main loop): either EMBER_NETWORK_UP if original parent still remembers this end device, or EMBER_MOVE_FAILED if the original parent node doesn’t remember this end device (or is not available anymore).
•If StackStatusHandler callback was EMBER_NETWORK_UP, end device is back in the network and emberNetworkState() should reflect EMBER_JOINED_NETWORK, meaning that messages can be sent and received OK. If StackStatusHandler callback was EMBER_MOVE_FAILED, end device requires a new parent connection to participate in network; emberNetworkState() indicates EMBER_JOINED_NETWORK_NO_PARENT.
•Once end device enters EMBER_JOINED_NETWORK_NO_PARENT state, this can be solved in either of two ways: (1) try to poll (using emberPollForData()), which causes EMBER_ERR_FATAL return code but causes stack to immediately initiate automatic Rejoin to find a new parent on the existing network; (2) call emberFindAndRejoinNetwork(TRUE, 0) to force a rejoin of the same network on the same channel with same NWK encryption key.
•If Rejoin process begins from 1 or 2 above, StackStatusHandler callback should indicate EMBER_NETWORK_DOWN immediately (next emberTick() call) to signal that device is offline during rejoin process.
•After some time going through the main loop, StackStatusHandler callback should indicate either EMBER_NETWORK_UP (meaning new parent was found and device is back in network OK) or some other status (like EMBER_JOIN_FAILED) indicating that rejoin did not succeed; if rejoin fails, device will remain in EMBER_JOINED_NETWORK_NO_PARENT state.
So, as you will note from above, emberTick() doesn’t initiate any of the joining/rejoining/leaving process automatically; however, emberPollForData() will initiate a Rejoin automatically if you try to poll and there is no parent available (usually a result of the End Device Poll Timeout elapsing so that the end device is timed out of its parent’s child table).