<?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>Zephyr characteristic value update every 50ms non-blocking</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/74913/zephyr-characteristic-value-update-every-50ms-non-blocking</link><description>Hello I&amp;#39;m using Zephyr and trying to update the characteristic value with interval of 50ms. The problem is that the android app nrf connect freezes after I start reading the values. The characteristic read turn off will not respond after. I&amp;#39;m using k_msleep</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 11 May 2021 10:22:08 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/74913/zephyr-characteristic-value-update-every-50ms-non-blocking" /><item><title>RE: Zephyr characteristic value update every 50ms non-blocking</title><link>https://devzone.nordicsemi.com/thread/309186?ContentTypeID=1</link><pubDate>Tue, 11 May 2021 10:22:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:626d8159-591c-4716-a045-e1e06e0aa3b0</guid><dc:creator>xproto</dc:creator><description>&lt;p&gt;I&amp;#39;m using vscode with platformio plugin. I edited this in the conn.h since I&amp;#39;m not sure why when calling the function I got errors.&lt;br /&gt;&lt;br /&gt;This functions&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/** @brief Initialize connection parameters
 *
 *  @param int_min  Minimum Connection Interval (N * 1.25 ms)
 *  @param int_max  Maximum Connection Interval (N * 1.25 ms)
 *  @param lat      Connection Latency
 *  @param to       Supervision Timeout (N * 10 ms)
 */
#define BT_LE_CONN_PARAM_INIT(int_min, int_max, lat, to) \
{ \
	.interval_min = (int_min), \
	.interval_max = (int_max), \
	.latency = (lat), \
	.timeout = (to), \
}

/** Helper to declare connection parameters inline
 *
 *  @param int_min  Minimum Connection Interval (N * 1.25 ms)
 *  @param int_max  Maximum Connection Interval (N * 1.25 ms)
 *  @param lat      Connection Latency
 *  @param to       Supervision Timeout (N * 10 ms)
 */
#define BT_LE_CONN_PARAM(int_min, int_max, lat, to) \
	((struct bt_le_conn_param[]) { \
		BT_LE_CONN_PARAM_INIT(int_min, int_max, lat, to) \
	 })
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;Edited this instead&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt; #define BT_LE_CONN_PARAM_DEFAULT BT_LE_CONN_PARAM(BT_GAP_INIT_CONN_INT_MIN, \
						  BT_GAP_INIT_CONN_INT_MAX, \
 						  0, 400)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;To this&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#define BT_LE_CONN_PARAM_DEFAULT BT_LE_CONN_PARAM(16, \
						  24, \
						  0, 400)&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;Now app characteristic notif on and off on app is responsive.&lt;br /&gt;&lt;br /&gt;You understand it right. So that&amp;#39;s how the k_sleep works. Thank you very much, it is clear now. I&amp;#39;ll stick with the&amp;nbsp; k_sleep for now.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr characteristic value update every 50ms non-blocking</title><link>https://devzone.nordicsemi.com/thread/309135?ContentTypeID=1</link><pubDate>Tue, 11 May 2021 08:04:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:889e49a5-d11a-43e3-a559-ad3f6e3c0ab0</guid><dc:creator>Susheel Nuguru</dc:creator><description>[quote user="xproto"]I didn&amp;#39;t set the connection interval. Looking at the zephyr docs this one is the default which is closer or equal.&amp;nbsp; What is the lowest setting I can set the conn interval? I&amp;#39;m just updating an int16_t value.[/quote]
&lt;p&gt;&amp;nbsp;When using SES you can see that for peripheral you can set few preferred connection interval like below&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/594x206/__key/communityserver-discussions-components-files/4/pastedimage1620719346475v1.png" /&gt;&lt;/p&gt;
&lt;p&gt;For central also you can configure the min and max conn intervals through the &lt;a href="https://docs.zephyrproject.org/latest/reference/bluetooth/connection_mgmt.html"&gt;connection management API&amp;nbsp;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="xproto"]So turn on and off notifications should function even during the duration of k_sleep?[/quote]
&lt;p&gt;&amp;nbsp;Not sure if i understand your question correct but the thread that has called k_sleep will be suspended for given amount of time. If you are turning on and off notifications from different thread, that will work as intended. If the notifications are turned on/off from the peer side during this k_sleep duration, then it is the LL_CONTROLLER that takes care of it, so you do not need to worry about what application threads are doing at that time&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr characteristic value update every 50ms non-blocking</title><link>https://devzone.nordicsemi.com/thread/309031?ContentTypeID=1</link><pubDate>Mon, 10 May 2021 14:40:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ff7b9615-5240-45a8-84c1-ee480299c084</guid><dc:creator>xproto</dc:creator><description>&lt;p&gt;Thank you for reply.&lt;br /&gt;&lt;br /&gt;1. I&amp;#39;ll look into this.&lt;br /&gt;&lt;br /&gt;2.&amp;nbsp;&lt;pre class="ui-code" data-mode="text"&gt;BT_LE_CONN_PARAM_DEFAULT
Default LE connection parameters: Connection Interval: 30-50 ms Latency: 0 Timeout: 4 s&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I didn&amp;#39;t set the connection interval. Looking at the zephyr docs this one is the default which is closer or equal.&amp;nbsp; What is the lowest setting I can set the conn interval? I&amp;#39;m just updating an int16_t value.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;k_msleep (which uses k_sleep) is not a blocking call.&lt;/pre&gt;&lt;br /&gt;So turn on and off notifications should function even during the duration of k_sleep?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr characteristic value update every 50ms non-blocking</title><link>https://devzone.nordicsemi.com/thread/308981?ContentTypeID=1</link><pubDate>Mon, 10 May 2021 12:53:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4ae3a4bf-5d2c-4ce2-90eb-733c314690cc</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;&lt;span&gt;k_msleep (which uses &lt;a href="https://docs.zephyrproject.org/latest/reference/kernel/threads/index.html#c.k_sleep"&gt;k_sleep&lt;/a&gt;) is not a blocking call.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;1) You can use &lt;a href="https://docs.zephyrproject.org/latest/reference/kernel/timing/timers.html"&gt;timer&lt;/a&gt; and update that in the timer callback function.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;2) Depends on your connection interval. 50ms can be too small if your connection interval is closer to that value .What are the connection interval you are using and what is the max data length you are using for the packets?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>