<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Best way to reset nrf52 after zigbee connection fails</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/80658/best-way-to-reset-nrf52-after-zigbee-connection-fails</link><description>Hi, What is in your opinion the best way to handle device reset after the Zigbee connection fails? 
 I want to archive behavior like so: after connection fails sleep for 10 minutes and reboot. 
 I was thinking about using a watchdog for the ZigBee thread</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 21 Oct 2021 12:39:01 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/80658/best-way-to-reset-nrf52-after-zigbee-connection-fails" /><item><title>RE: Best way to reset nrf52 after zigbee connection fails</title><link>https://devzone.nordicsemi.com/thread/335312?ContentTypeID=1</link><pubDate>Thu, 21 Oct 2021 12:39:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:55bfe199-fb0b-42c9-aa08-b903eff90208</guid><dc:creator>Marte Myrvold</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;In zigbee_app_utils.c there is a global variable&amp;nbsp;rejoin_attempt_cnt, which keeps track of the number of rejoin attempts. You can use this to track how many times it has tried, and if the number of rejoin attempts is too high, you reset the device in some way. In this case, you should also make sure the device has not joined a network with !ZB_JOINED(). However, for this you must make changes in the&amp;nbsp;&lt;span&gt;zigbee_app_utils.c file, as&amp;nbsp;rejoin_attempt_cnt is only available there. Another possibility if you do not want to make changes in this file is create a static rejoin_attempt_cnt in main.c, and override the&amp;nbsp;ZB_BDB_SIGNAL_STEERING signal in&amp;nbsp;zboss_signal_handler()&amp;nbsp;to count number of rejoin attempts there, before calling the default signal handler to handle the rest of ZB_BDB_SIGNAL_STEERING:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void zboss_signal_handler(zb_bufid_t bufid)
{
	zb_zdo_app_signal_hdr_t    *sig_hndler = NULL;
	zb_zdo_app_signal_type_t    sig = zb_get_app_signal(bufid, &amp;amp;sig_hndler);
	
	/* Update network status LED. */
	zigbee_led_status_update(bufid, ZIGBEE_NETWORK_STATE_LED);
	
	switch(sig) {
		case ZB_BDB_SIGNAL_STEERING:
			LOG_INF(&amp;quot;Rejoin attempt: %d&amp;quot;, rejoin_attempt_cnt);
			rejoin_attempt_cnt++;
			/* Call default signal handler.*/
			ZB_ERROR_CHECK(zigbee_default_signal_handler(bufid));
			break;
			
	...&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;As for how to reset the device to keep trying to rejoin you can use the function&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/zboss/3.8.0.1/group__zb__platform.html#gabcf4e45985ae18ec904a789a969df9e7"&gt;zb_reset()&lt;/a&gt;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Marte&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best way to reset nrf52 after zigbee connection fails</title><link>https://devzone.nordicsemi.com/thread/335044?ContentTypeID=1</link><pubDate>Wed, 20 Oct 2021 10:12:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:eb2898ab-cc36-4b29-be00-434d0aac601b</guid><dc:creator>naps</dc:creator><description>&lt;p&gt;Thank you very much for your answer.&lt;br /&gt;Clearing up ambiguities I&amp;#39;m talking about the behavior just after the start of the application.&lt;br /&gt;REJOIN_INTERVAL_MAX_S allows only to reconnect several times, and then it hangs. I don&amp;#39;t want such behaviour as in some cases it can brick our device.&lt;br /&gt;I would our application keep retrying (eventually after some sleep for energy consumption optimizations)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best way to reset nrf52 after zigbee connection fails</title><link>https://devzone.nordicsemi.com/thread/334208?ContentTypeID=1</link><pubDate>Thu, 14 Oct 2021 14:32:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a15145e7-b19c-4feb-b510-ec2240ca172e</guid><dc:creator>Marte Myrvold</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;With Zigbee connection fail, do you mean that the device is unable to join a network at start up, or that it leaves a network? In both cases the device will keep trying to join a network, so you should not have to reboot the device in order to make it join or rejoin networks. If you still want to reboot the best option would probably be to use the Zigbee stack signals.&lt;/p&gt;
&lt;p&gt;When a&amp;nbsp;device starts up it will try to join the network with a call to the function&amp;nbsp;start_network_rejoin(). This will start network steering, and will generate the stack signal&amp;nbsp;&lt;span&gt;ZB_BDB_SIGNAL_STEERING. The status of this signal indicates whether the device successfully joined/rejoined a network or not. If it did not join, the device will try again by once again calling&amp;nbsp;start_network_rejoin() and starting network steering. On leaving a network, the signal&amp;nbsp;ZB_ZDO_SIGNAL_LEAVE&amp;nbsp;is generated, and the stack will handle this by&lt;/span&gt;&lt;span&gt;&amp;nbsp;also calling on&amp;nbsp;start_network_rejoin() to try and rejoin a network, causing the device to start network steering again. If you want to implement some custom logic for these signals you can override this by handling the signal in the zboss_signal_handler() instead of the zigbee_default_signal_handler(). See&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.7.0/nrf/libraries/zigbee/zigbee_app_utils.html#zigbee-default-signal-handler"&gt;Zigbee default signal handler&lt;/a&gt;&amp;nbsp;for more information about how to do this.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
[quote user=""]Maybe in this case I should check in the zboss_signal_handler for reboot signal and if occurs handle the desired behavior. and if no pass&amp;nbsp;zb_bufid_t to&amp;nbsp;zigbee_default_signal_handler.[/quote]
&lt;p&gt;The signal ZB_BDB_SIGNAL_DEVICE_REBOOT indicates that the device has rebooted, and that it has network data stored in NVRAM from a network it was connected to before reboot. It will then try to rejoin the same network using the data stored in NVRAM. It&amp;nbsp;this is not a signal used to tell the device that it should reboot. You can also override this signal using&amp;nbsp;zboss_signal_handler() as I mentioned above.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;span&gt;Marte&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>