<?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>Max interval between BLE data send</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/26707/max-interval-between-ble-data-send</link><description>Hi, 
 I use NRF51822 + S130 + SDK12 platform, my device work in CENTRAL mode, I want send data to peripheral every 10ms, code like this: 
 while (1)
{
 while (m_free_tx_packet_count == 0)
 {
 //wait free send packet
 //m_free_tx_packet_count will</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 08 Nov 2017 15:43:44 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/26707/max-interval-between-ble-data-send" /><item><title>RE: Max interval between BLE data send</title><link>https://devzone.nordicsemi.com/thread/105036?ContentTypeID=1</link><pubDate>Wed, 08 Nov 2017 15:43:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5dcafeb5-c746-4dee-b8ce-f660f6ad56c6</guid><dc:creator>Ian</dc:creator><description>&lt;p&gt;Yes I agree with you and I was going to do that, i even wanna try another peer(maybe a Cypress demo board or Nordic NUC demo) if when i disabling all other code and the problem still exists.&lt;/p&gt;
&lt;p&gt;Anyway, I&amp;#39;ll do some test and debugging later as yo say. Thank&amp;#39;s a lot for your help and patience.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Max interval between BLE data send</title><link>https://devzone.nordicsemi.com/thread/105035?ContentTypeID=1</link><pubDate>Wed, 08 Nov 2017 15:29:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:70fded4b-4fe4-4b8f-8f05-debd4f2ba1c2</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;Well start with disabling all other code and just send arbitrary (random or some static pre-defined hardcoded string) data over NUS like that. It should go through very fast (if you are really using &amp;lt;25ms connection interval and some decent bandwidth setting). So the bug doesn&amp;#39;t need to come from the way how you use BLE layers but it can easily be in the way you occupy MCU by other tasks or in the way how you acquire the data you want to send over... so many options, no one can tell you without seeing what exactly you are doing in your code (and if it&amp;#39;s large project no one will spend the time even if you show it to us, the debugging is unfortunately yours... and the procedure is always pretty much the same although the way can be painful: isolate the code which does one thing perfectly as you want. Then go by very simple steps and see where it breaks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Max interval between BLE data send</title><link>https://devzone.nordicsemi.com/thread/105034?ContentTypeID=1</link><pubDate>Wed, 08 Nov 2017 15:25:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8ddbe1e6-92ea-4147-91b5-42e8bab8f426</guid><dc:creator>Ian</dc:creator><description>&lt;p&gt;I just call &lt;code&gt;ble_nus_c_string_send&lt;/code&gt; function, and wait BLE_EVT_TX_COMPLETE  event, i can&amp;#39;t imagine what  bug it would have...&lt;/p&gt;
&lt;p&gt;In case the SVC interrupt to be preempted and cause miss  BLE_EVT_TX_COMPLETE  event, i call &lt;code&gt;ble_nus_c_string_send&lt;/code&gt; even wait free tx packet timeout.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Max interval between BLE data send</title><link>https://devzone.nordicsemi.com/thread/105028?ContentTypeID=1</link><pubDate>Wed, 08 Nov 2017 15:17:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0ab4ad38-e2e6-4644-b61f-9dba25e67ea4</guid><dc:creator>Ian</dc:creator><description>&lt;p&gt;But that still doesn&amp;#39;t make sense. I refer to the examples in the SDK,and I didn&amp;#39;t find what&amp;#39;s wrong in my code&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Max interval between BLE data send</title><link>https://devzone.nordicsemi.com/thread/105033?ContentTypeID=1</link><pubDate>Wed, 08 Nov 2017 15:14:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:033a45c1-39ef-4f4e-9e3f-2fcfe5686ea1</guid><dc:creator>Ian</dc:creator><description>&lt;p&gt;My device doesn&amp;#39;t connect to iPhone in this case, it work in GAP Central role and the peer is also nrf51822 which work in GPA Peripheral role.  I guess was it  because I used two interrupts in my code. I use ADC and app_timer,  in ADC ISR,it restart the ADC conversion so i can get the ADC value continuously. In the app_timer ISR, I parse data received from UART and BLE then put the it to a FIFO.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Max interval between BLE data send</title><link>https://devzone.nordicsemi.com/thread/105030?ContentTypeID=1</link><pubDate>Wed, 08 Nov 2017 15:04:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8ff2f107-8695-4dbd-ad56-746adfaca779</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;Sorry but this doesn&amp;#39;t make sense. We all use Nordic Soft Device with similar connection parameters and we are achieving bandwidths of &amp;gt;kbps and latency &amp;lt;50ms even with iPhones. It more indicates bug in your code (or rather misunderstanding of how SD API works?)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Max interval between BLE data send</title><link>https://devzone.nordicsemi.com/thread/105031?ContentTypeID=1</link><pubDate>Wed, 08 Nov 2017 15:02:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f0135286-3e58-4734-9316-f2f32658e097</guid><dc:creator>Ian</dc:creator><description>&lt;p&gt;The parameters is used when my device work as GAP Central, although when it work as GAP Peripheral use the same parameters. iOS 11 has a BLE bug,and Apple company suggest use min interval 12ms and max 24ms to resolve it.&lt;/p&gt;
&lt;p&gt;I measure the time each part of code cost,and found the code wait m_free_tx_packet_count increase cost almost all the &amp;quot;delays&amp;quot; time. That means since &lt;code&gt;ble_nus_c_string_send&lt;/code&gt; function be called and return NRF_SUCCESS to receive BLE_EVT_TX_COMPLETE event cost over 400ms~ So i think that&amp;#39;s &amp;#39;SoftDevce&amp;#39; cost the time and there&amp;#39;s nothing i can do to reduce the time.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Max interval between BLE data send</title><link>https://devzone.nordicsemi.com/thread/105029?ContentTypeID=1</link><pubDate>Wed, 08 Nov 2017 14:39:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c6edc101-523e-420a-b96c-75925c9df978</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;But who gave you the idea that iOS device would use such low parameters?:) Standard iOS BLE apps (unless you sneak them as HID profile) use 30ms connection interval (when phone is GAP Central).&lt;/p&gt;
&lt;p&gt;Anyway the debugging is simple: you need to get some trace from the air and you should make some GPIO or UART debugging with logical analyzer to see some exact timing of certain events. And then by countless steps of adding and removing debug messages you will get there. I&amp;#39;m afraid there is nothing more we could suggest here unless someone wants to burn his time and debug your full code on his machine and test board...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Max interval between BLE data send</title><link>https://devzone.nordicsemi.com/thread/105032?ContentTypeID=1</link><pubDate>Wed, 08 Nov 2017 14:35:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1ab82d72-6d3c-4782-88e7-ae437abdf81c</guid><dc:creator>Ian</dc:creator><description>&lt;p&gt;I set the min interval to 11.25ms and the max interval is 23.75ms now, my device work at CENTRAL + PERIPHERAL mode,but the &amp;quot;delays&amp;quot; still over 400ms even my iphone don&amp;#39;t connect the device(means it just need process the link as BLE CENTRAL).The device and the peer are very close（less than 50cm），In my code, I just send datas very 10ms as you see. So I think there&amp;#39;s something wrong with that, but i can&amp;#39;t find out it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Max interval between BLE data send</title><link>https://devzone.nordicsemi.com/thread/105027?ContentTypeID=1</link><pubDate>Wed, 08 Nov 2017 14:23:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8e5d5a0d-0121-4e36-b5ef-2c8b48ab7ac3</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;It depends on your connection interval. In typical environment when both peers are close there should be very little packet loss (let&amp;#39;s say not more then 1%) so if you interval is 10ms or 50ms you should never see &amp;quot;delays&amp;quot; of 300ms. In the end truth is in &amp;quot;the air&amp;quot; so use radio analyzer or some cheap BLE sniffer to observe the connection and see a) what are actual parameters used and b) if you have unused bandwidth there or not.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Max interval between BLE data send</title><link>https://devzone.nordicsemi.com/thread/105026?ContentTypeID=1</link><pubDate>Wed, 08 Nov 2017 14:19:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a993be4c-cf5a-48d2-b39b-ec936be76b5f</guid><dc:creator>Ian</dc:creator><description>&lt;p&gt;Hi endnode,
Thank you for your reply.&lt;/p&gt;
&lt;p&gt;My system is just need low latency actually,so your reply is helpful. I checked my code over and over again to make sure that my code doesn&amp;#39;t cause  the delay,but I am still not sure, so i ask this question. Now i know BLE may cause this high latency it self,next I will try to change the connection parameters as you say,i hope this will work.&lt;/p&gt;
&lt;p&gt;Actually, I didn&amp;#39;t use &lt;code&gt;nrf_delay_xxx&lt;/code&gt; function in my main loop, i used &lt;code&gt;app_timer&lt;/code&gt;,I&amp;#39;m just trying to make the code look a little bit clearer，so i use &lt;code&gt;nrf_delay_ms(10)&lt;/code&gt; instead of &lt;code&gt;app_timer&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Last,thank you very much!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Max interval between BLE data send</title><link>https://devzone.nordicsemi.com/thread/105025?ContentTypeID=1</link><pubDate>Wed, 08 Nov 2017 09:25:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c0e535fb-43b7-4a58-a2d4-ccff9e214466</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;First of all it seems that you&amp;#39;ve picked wrong technology because BLE isn&amp;#39;t real-time, you don&amp;#39;t have direct control over timing on Link Layer and of course even if you would it&amp;#39;s a radio so there is always a danger of interference, full-spectrum noise or simply weak signal so packets will get lost.&lt;/p&gt;
&lt;p&gt;However if you are fine with these limitations and you still want to have &amp;quot;low latency&amp;quot; (I guess that&amp;#39;s what you are asking for: have some minimal - or at least controlled and constant - time between two packets reliably transported over the link) then you simply must make connection interval at certain range. If you have control over GAP Central side (Master) then it&amp;#39;s much easier because you can choose your interval and GAP Peripheral (Slave) should theoretically accept any of these. It may try to request change later or it may even terminate the connection (because it cannot/doesn&amp;#39;t want to operate with such connection parameters) but in most cases it should be OK. So you can go as low as 7.5ms, 10ms is indeed an option as well (basic unit is 1.25ms). Anyway on higher layers (starting from L2CAP and mainly (G)ATT which is normally the main API layer all apps use for data transport) you have very little chance to tight something directly to interval and events happening on Link Layer. You simply must push to the stack whatever you want to transport on the very next possible occasion and then just wait until you get call-back with one of &amp;quot;TX_COMPLETE&amp;quot; events signalling that it passed and you can go on.&lt;/p&gt;
&lt;p&gt;If you are not fine with this &lt;em&gt;&amp;quot;prepare for send and wait until it transparently happens on lower layer&amp;quot;&lt;/em&gt; model then I&amp;#39;m afraid BLE is not what you are looking for and you should go with some proprietary technology like ESB (but there you need custom radio stack on both sides indeed).&lt;/p&gt;
&lt;p&gt;Last remark: for the God&amp;#39;s sake never use &lt;code&gt;nrf_delay_xxx&lt;/code&gt; function in production application (except some dead-end debugging code) because that&amp;#39;s blocking call and you basically kill the MCU for given time! Use proper non-blocking timers based on RTC (like &lt;code&gt;app_timer&lt;/code&gt; library) which will just give you callback to the handler once expiring (and you can go on in your main process thread).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>