<?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>nRF52840 - SDK16 - s140 - Data Rate vs Range</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/69336/nrf52840---sdk16---s140---data-rate-vs-range</link><description>Hi everyone, 
 I am using a third party nRF52840 module and I have developed my own bluetooth application. I have implemented one characteristic for notifying data from the IMU. I have to notify data with a frequency of 100Hz (close to the 7.5s limit</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 15 Dec 2020 08:53:43 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/69336/nrf52840---sdk16---s140---data-rate-vs-range" /><item><title>RE: nRF52840 - SDK16 - s140 - Data Rate vs Range</title><link>https://devzone.nordicsemi.com/thread/284962?ContentTypeID=1</link><pubDate>Tue, 15 Dec 2020 08:53:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7a6742c8-b539-4d15-a83d-03e559f0c7b8</guid><dc:creator>Nikosant03</dc:creator><description>&lt;p&gt;Thank you for your great support!!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 - SDK16 - s140 - Data Rate vs Range</title><link>https://devzone.nordicsemi.com/thread/284807?ContentTypeID=1</link><pubDate>Mon, 14 Dec 2020 14:02:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5d5f19ad-6e7e-4cbc-b13f-51a1a629d232</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi Nick,&lt;/p&gt;
[quote user="Nikosant03"]By default the queue size is&amp;nbsp;BLE_GATTS_HVN_TX_QUEUE_SIZE_DEFAULT&amp;nbsp; 1 (ble_gatts.h). Meaning&amp;nbsp;that only one notification can be in queue? Basically I cannot buffer notifications and the&amp;nbsp;NRF_ERROR_RESOURCES will return right?[/quote]
&lt;p&gt;No, that is just the default value. The queue would be longer if you have configured a longer maximum event length when initializing the SoftDevice. See &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/28616/how-to-set-the-queue-size-of-notification/113427#113427"&gt;this post&lt;/a&gt;.&lt;/p&gt;
[quote user="Nikosant03"]To buffer the packets (lets say to buffer 2 packets) I have to increase the queue size&amp;nbsp;by calling the&amp;nbsp;&lt;strong&gt;sd_ble_cfg_set()&lt;/strong&gt; with &lt;strong&gt;BLE_CONN_CFG_GATTS&lt;/strong&gt; and&lt;strong&gt; ble_gatts_conn_cfg_t.hvn_tx_queue_size?&lt;/strong&gt;[/quote]
&lt;p&gt;That is not needed, given you configure the SoftDevice properly as suggested above.&lt;/p&gt;
[quote user="Nikosant03"]I can adjust the event length from&amp;nbsp;NRF_SDH_BLE_GAP_EVENT_LENGTH right? Is there any example of buffering notifications just for reference?[/quote]
&lt;p&gt;Yes, and no. You typically use the SoftDevice handler library, so you should configure the NRF_SDH_BLE_* macros properly, and that will configure the SoftDevice for you. So to adjust the event length, you adjust&amp;nbsp;NRF_SDH_BLE_GAP_EVENT_LENGTH.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 - SDK16 - s140 - Data Rate vs Range</title><link>https://devzone.nordicsemi.com/thread/284804?ContentTypeID=1</link><pubDate>Mon, 14 Dec 2020 13:47:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:767a96b1-9a6f-4c7e-b304-98bfaca2b044</guid><dc:creator>Nikosant03</dc:creator><description>&lt;p&gt;Thank you Einar!!&lt;/p&gt;
[quote userid="7377" url="~/f/nordic-q-a/69336/nrf52840---sdk16---s140---data-rate-vs-range/284760#284760"]and a new notification also in queue[/quote]
&lt;p&gt;By default the queue size is&amp;nbsp;BLE_GATTS_HVN_TX_QUEUE_SIZE_DEFAULT&amp;nbsp; 1 (ble_gatts.h). Meaning&amp;nbsp;that only one notification can be in queue? Basically I cannot buffer notifications and the&amp;nbsp;NRF_ERROR_RESOURCES will return right?&lt;/p&gt;
&lt;p&gt;To buffer the packets (lets say to buffer 2 packets) I have to increase the queue size&amp;nbsp;by calling the&amp;nbsp;&lt;strong&gt;sd_ble_cfg_set()&lt;/strong&gt; with &lt;strong&gt;BLE_CONN_CFG_GATTS&lt;/strong&gt; and&lt;strong&gt; ble_gatts_conn_cfg_t.hvn_tx_queue_size?&lt;/strong&gt;&lt;/p&gt;
[quote userid="7377" url="~/f/nordic-q-a/69336/nrf52840---sdk16---s140---data-rate-vs-range/284760#284760"]If the event length is long enough[/quote]
&lt;p&gt;I can adjust the event length from&amp;nbsp;NRF_SDH_BLE_GAP_EVENT_LENGTH right? Is there any example of buffering notifications just for reference?&lt;/p&gt;
[quote userid="7377" url="~/f/nordic-q-a/69336/nrf52840---sdk16---s140---data-rate-vs-range/284760#284760"]It might not be possible though, if for instance the packet length is so long that you cannot fit two packets in one event[/quote]
&lt;p&gt;The packet legth is 38bytes&lt;/p&gt;
&lt;p&gt;Sorry for the bunch of questions but I am relative new to BLE developing and I am trying to put the things i order :)&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 - SDK16 - s140 - Data Rate vs Range</title><link>https://devzone.nordicsemi.com/thread/284760?ContentTypeID=1</link><pubDate>Mon, 14 Dec 2020 11:41:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d02c1cfe-40d8-45cd-a330-ab8434ec9153</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi Nick,&lt;/p&gt;
[quote user="Nikosant03"]I am correct so far?[/quote]
&lt;p&gt;Yes, perfectly correct so far&amp;nbsp;&lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;
[quote user="Nikosant03"]I understand that reducing the connection interval will give some time for re-transmission but I cannot understand how buffering up notifications will help.[/quote]
&lt;p&gt;What I means is that if you have a connection interval of 10 ms and a notification interval of 10 ms, you normally get the notification out immediately&amp;quot;(or rather within 10 ms). but if we assume you get one packet loss, then for the next connection interval you will have the packet to be retransmitted, and a new notification also in queue, so that would be two. If the event length is long enough, and you have the packets buffered, and there is no packet loss, then you would get two packets through in this case, and you would be back on track. It might not be possible though, if for instance the packet length is so long that you cannot fit two packets in one event (I do not know enough to day)?&lt;/p&gt;
[quote user="Nikosant03"]With s140 you can buffer up to 6 packets, right?[/quote]
&lt;p&gt;There is no hard limit, though for old SoftDevices you could queue 1, 3 or 6 packets depending on configuration. If the event length is long (compared to the packet length), and you are able to queue more packets during the event length, you can get more packets through.&lt;/p&gt;
[quote user="Nikosant03"]Lastly, you said that I have to handle packet loss. Is there any example of that?[/quote]
&lt;p&gt;The stack handles that automatically. There will be retransmissions until is succeeds or there is a supervision timeout. My point was just that the stack cannot do magic, so the connection parameters and the number of packets /length of packets you try to get through has to work in the real world where (there will always be packet loss, and unless you control the environment like in an RF chamber or alone in the forest, this will be variable and unpredictable)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 - SDK16 - s140 - Data Rate vs Range</title><link>https://devzone.nordicsemi.com/thread/284749?ContentTypeID=1</link><pubDate>Mon, 14 Dec 2020 10:43:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ff213989-5d15-4d9f-9536-56d155b43d2a</guid><dc:creator>Nikosant03</dc:creator><description>&lt;p&gt;Thank you for your effort Einar,&lt;/p&gt;
&lt;p&gt;So, let me rephrase in order to confirm that I have understood correctly.&lt;/p&gt;
&lt;p&gt;When the&amp;nbsp;&lt;strong&gt;&lt;span&gt;sd_ble_gatts_hvx&lt;/span&gt;&lt;/strong&gt;&lt;span&gt;&amp;nbsp;is been called the payload (packet) is placed in sd buffer (ATT table) and remains there until the next connection interval.&amp;nbsp;Re-transmission occurs every connection interval.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;When a packet is transmitted, then a slot from the sd buffer is getting free and the&amp;nbsp;&lt;strong&gt;BLE_GATTS_EVT_HVN_TX_COMPLETE &lt;/strong&gt;event&amp;nbsp;is received. In case of unsuccessful transmission, the packet remains in sd buffer and a re-transmission of the same packet will be attempted on the next connection interval (so there is a shift in time). I&lt;/span&gt;f the buffer is getting full the&amp;nbsp;&lt;strong&gt;NRF_ERROR_RESOURCES&lt;/strong&gt;&amp;nbsp;error returns from&amp;nbsp;&lt;strong&gt;sd_ble_gatts_hvx.&amp;nbsp;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I am correct so far?&lt;/p&gt;
&lt;p&gt;I understand that reducing the connection interval will give some time for re-transmission but I cannot understand how buffering up notifications will help. With s140 you can buffer up to 6 packets, right?&lt;/p&gt;
&lt;p&gt;Let&amp;#39;s say that buffering 6 packets and for any reason the packets do not be transmitted..they will remain in sd buffer and a re-transmission will occur in the next connection interval, isn&amp;#39;t it? I know that I miss something.. :)&lt;/p&gt;
&lt;p&gt;Lastly, you said that I have to handle packet loss. Is there any example of that?&lt;/p&gt;
&lt;p&gt;Nick&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 - SDK16 - s140 - Data Rate vs Range</title><link>https://devzone.nordicsemi.com/thread/284690?ContentTypeID=1</link><pubDate>Mon, 14 Dec 2020 08:01:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b21e8de4-af2c-4b96-9a1c-72383adea6e8</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="Nikosant03"]You mean to send more than one packet in the same connection interval? [/quote]
&lt;p&gt;No, not in this case. Even&amp;nbsp;if you have time to send more packets per connection event, retransmissions always occur on the next connection event.&amp;nbsp;&lt;/p&gt;
[quote user="Nikosant03"]or in case that the packet is getting loss there is no time for retransmission? I want to send just one packet per conneciton interval.[/quote]
&lt;p&gt;Yes, that is the problem with your setup. As retransmissions occur on the next connection event, everything gets shifted. You must give some room for retransmissions.&lt;/p&gt;
[quote user="Nikosant03"]Given that I need to notify every 10ms what should be the connection parameters?[/quote]
&lt;p&gt;For this to work satisfactory in the real world you have to either use a shorter connection interval (not that much to go on, as 7.5 ms is the lowest possible), or buffer up notifications and send&amp;nbsp;multiple&amp;nbsp;per connection event after a retransmission to get back on track. This is up to you and which works best in your case, but you must design your system to handle packet loss as that will always happen from time to time, sometimes a lot, some times almost nothing (depending on factors such as distance, interference etc.).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 - SDK16 - s140 - Data Rate vs Range</title><link>https://devzone.nordicsemi.com/thread/284644?ContentTypeID=1</link><pubDate>Sun, 13 Dec 2020 09:04:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aef0326b-e813-4964-b2db-15379583d013</guid><dc:creator>Nikosant03</dc:creator><description>&lt;p&gt;Thank you for your responce Einar,&lt;/p&gt;
[quote userid="7377" url="~/f/nordic-q-a/69336/nrf52840---sdk16---s140---data-rate-vs-range/284441#284441"]then there will be less time for retransmissions[/quote]
&lt;p&gt;You mean to send more than one packet in the same connection interval? or in case that the packet is getting loss there is no time for retransmission? I want to send just one packet per conneciton interval.&lt;/p&gt;
&lt;p&gt;Given that I need to notify every 10ms what should be the connection parameters?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 - SDK16 - s140 - Data Rate vs Range</title><link>https://devzone.nordicsemi.com/thread/284441?ContentTypeID=1</link><pubDate>Fri, 11 Dec 2020 07:40:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bb50c587-f4c4-48e7-b197-c5fc5aecc34a</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="Nikosant03"]So, how is related the data rate with the range?[/quote]
&lt;p&gt;Physically, the range is the same regardless of notification frequency. The only difference is that if you notify with a higher frequency using the same connection parameters, then there will be less time for retransmissions (fewer attempts to get the packet through) before it causes problems. Under&amp;nbsp;challenging RF&amp;nbsp;conditions this could result make it seem like the range is lower.&lt;/p&gt;
&lt;p&gt;You have both a connection interval of 10 ms and send notifications every 10 ms. In general I would expect you would get a corresponding improvement if reduce the connection interval to the half, but you already use a very short interval. If that had been possible, it would have given the same effect as reducing notification frequency. The key here is that with your configuration, you do not have any time for retransmissions. As your connection interval is the same as your notification frequency, any retransmission will cause a delay of the&amp;nbsp;subsequent notifications, etc (retransmissions always happen on the next connection event). So your set of parameter cannot really work properly in a real world as it depends on never getting packet loss.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 - SDK16 - s140 - Data Rate vs Range</title><link>https://devzone.nordicsemi.com/thread/284409?ContentTypeID=1</link><pubDate>Thu, 10 Dec 2020 20:27:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f63c9f1a-bfdd-4d1c-9afe-05f0e22676cd</guid><dc:creator>Nikosant03</dc:creator><description>&lt;p&gt;Hi Einar and thank you for your answer!!&lt;/p&gt;
&lt;p&gt;I am not using coded PHY. My problem is that the higher the transmission frequency the less the range I achieve..&amp;nbsp; For example when notifying with a frequency of 100Hz (min and max connection interval are set to 10ms) I achieve around 4m range (before disconnection). When I downgrade the data rate, lets say to 10Hz&amp;nbsp;&lt;span&gt;&amp;nbsp;(min and max connection interval are set to 10ms)&lt;/span&gt; then the range is much much better (around 10m before disconnection). So, how is related the data rate with the range?&lt;/p&gt;
&lt;p&gt;P.S: When I say &amp;quot;&lt;span&gt;notifying&lt;/span&gt;&lt;span&gt;&amp;nbsp;with a frequency of 100Hz&amp;quot; I mean calling&amp;nbsp;sd_ble_gatts_hvx every 10ms &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 - SDK16 - s140 - Data Rate vs Range</title><link>https://devzone.nordicsemi.com/thread/284328?ContentTypeID=1</link><pubDate>Thu, 10 Dec 2020 12:55:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:40005f63-6df2-49d1-8165-202c6db8f2a2</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi Nick,&lt;/p&gt;
&lt;p&gt;In general, you could say that you would get longer range with lower data rate, if for instance using BLE long range (Coded PHY). In that case you would use more energy per data bit in order to increase range, using several techniques. That is not the case here, though.&lt;/p&gt;
&lt;p&gt;In your description you do not mention&amp;nbsp;anything about PHY, so I assume you always use the same PHY. In that case, the only relevant factor is that the less data you send, the more time there is to send retransmissions. So essentially you can loose more packets before noticing it on the application layer, but that is all.&lt;/p&gt;
&lt;p&gt;Einar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>