<?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>Matter/Thread event indicating &amp;quot;ready to update status&amp;quot; and &amp;quot;status confirmed updated&amp;quot; ?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/108593/matter-thread-event-indicating-ready-to-update-status-and-status-confirmed-updated</link><description>Without really delving into the guts of the nrf boilerplate code, are there any sections or events that can inform the application that we are ready to establish connection with the edge router and another event that says &amp;quot;we have updated our status successfully</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 09 Apr 2024 12:47:05 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/108593/matter-thread-event-indicating-ready-to-update-status-and-status-confirmed-updated" /><item><title>RE: Matter/Thread event indicating "ready to update status" and "status confirmed updated" ?</title><link>https://devzone.nordicsemi.com/thread/477807?ContentTypeID=1</link><pubDate>Tue, 09 Apr 2024 12:47:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:92869873-99c2-46d7-8e43-9174cbdd91f8</guid><dc:creator>AMarch</dc:creator><description>&lt;p&gt;Some redirect, in the V2.6.0 version of the code base, this is now part of the common&amp;nbsp;&lt;br /&gt;void Board::DefaultMatterEventHandler(const ChipDeviceEvent *event, intptr_t /* unused */)&lt;/p&gt;
&lt;p&gt;in the&amp;nbsp;v2.6.0\nrf\samples\matter\common\src\board\board.cpp&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Matter/Thread event indicating "ready to update status" and "status confirmed updated" ?</title><link>https://devzone.nordicsemi.com/thread/470734?ContentTypeID=1</link><pubDate>Mon, 26 Feb 2024 12:54:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c869556f-bfff-4ad4-95f3-c52ce7791d0f</guid><dc:creator>Marte Myrvold</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;In our Thread samples we have a callback for when the Thread state changes, for example:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void on_thread_state_changed(otChangedFlags flags, struct openthread_context *ot_context,
				    void *user_data)
{
	if (flags &amp;amp; OT_CHANGED_THREAD_ROLE) {
		switch (otThreadGetDeviceRole(ot_context-&amp;gt;instance)) {
		case OT_DEVICE_ROLE_CHILD:
		case OT_DEVICE_ROLE_ROUTER:
		case OT_DEVICE_ROLE_LEADER:
			k_work_submit(&amp;amp;on_connect_work);
			is_connected = true;
			break;

		case OT_DEVICE_ROLE_DISABLED:
		case OT_DEVICE_ROLE_DETACHED:
		default:
			k_work_submit(&amp;amp;on_disconnect_work);
			is_connected = false;
			break;
		}
	}
}
static struct openthread_state_changed_cb ot_state_chaged_cb = {
	.state_changed_cb = on_thread_state_changed
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;This callback is registered with openthread_state_changed_cb_register():&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;openthread_state_changed_cb_register(openthread_get_default_context(), &amp;amp;ot_state_chaged_cb);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The Thread device role, given by otThreadGetDeviceRole(), should give you an indication of whether the device is connected to the network or not. Disabled means that the Thread stack is disabled, while detached means that the Thread stack is enabled but the device is currently not connected to a Thread network. Child, router and leader indicates that the device is connected to a network.&lt;/p&gt;
&lt;p&gt;In Matter, the ChipEventHandler() function will be called when the Thread state changes. You can use this to know when the device has changed role, and also whether the device is connected to a network or not. This is the relevant part of the function:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;case DeviceEventType::kThreadStateChange:
	sIsNetworkProvisioned = ConnectivityMgr().IsThreadProvisioned();
	sIsNetworkEnabled = ConnectivityMgr().IsThreadEnabled();&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;This should be implemented in the app_task.cpp file, see &lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/v2.5.2/samples/matter/light_switch/src/app_task.cpp#L422-L424"&gt;light_switch/src/app_task.cpp&lt;/a&gt; as an example.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Marte&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>