<?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>Duplicate and then dropped notification</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/8386/duplicate-and-then-dropped-notification</link><description>Hi, 
 I&amp;#39;m working on a sensor application that sends out fairly large quantities of data via BLE notifications. I understand how bluetooth works and have read and followed the advice at : 
 devzone.nordicsemi.com/.../ 
 and 
 devzone.nordicsemi.com</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 27 Jul 2015 20:28:32 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/8386/duplicate-and-then-dropped-notification" /><item><title>RE: Duplicate and then dropped notification</title><link>https://devzone.nordicsemi.com/thread/30437?ContentTypeID=1</link><pubDate>Mon, 27 Jul 2015 20:28:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:60e633b8-c036-4d9e-9fe1-ed0a0ff8371b</guid><dc:creator>Campbell Young</dc:creator><description>&lt;p&gt;I&amp;#39;m using 8.0.2 of S130 with SDK 8.0. My transmission function isn&amp;#39;t reentrant and is called from both the main loop and the BLE_EVT_TX_COMPLETE event. Of course BLE_EVT_TX_COMPLETE is executed from an interrupt context. If  transmission is interrupted with a completion event then the same packet counter can be used twice (once in the interrupt, once outside of it). I noticed that this issue only occurs when the final notification isn&amp;#39;t full (i.e. all measurements have been consumed), which of course means a network buffer may be left free. Then, when normal execution resumes, a duplicate is sent.&lt;/p&gt;
&lt;p&gt;Simplest fix was to just pass a scheduler into &lt;code&gt;SOFTDEVICE_HANDLER_INIT&lt;/code&gt; so that events wouldn&amp;#39;t be invoked from an interrupt context. Also made my marshalling code for other events redundant, so win win.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Duplicate and then dropped notification</title><link>https://devzone.nordicsemi.com/thread/30436?ContentTypeID=1</link><pubDate>Mon, 27 Jul 2015 07:13:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b0d47077-c6e2-4040-8bf4-fd6997869d90</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;What SDK and SD are you using by the way - it may be important. I&amp;#39;m fairly out of ideas, what I&amp;#39;d probably do at this point is get a pointer to the end of used RAM and start writing the value of packetCounter after the end of the while loop to that memory creating a list of the bursts you queued up, if you find a point you get a double you can see what you queued, if there&amp;#39;s a burst in which you managed to queue 7 instead of 6 and it doubled the second to last and dropped the last, you may have found a bug.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Duplicate and then dropped notification</title><link>https://devzone.nordicsemi.com/thread/30435?ContentTypeID=1</link><pubDate>Mon, 27 Jul 2015 06:52:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:56fe9dfc-a3ec-438f-b1d6-fd454b64bbc2</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;Agreed that&amp;#39;s a new packet - you can see in the link layer the sequence number flips from 1 to 0 showing it&amp;#39;s the next one in the series and not a re-transmit. You did capture a retransmit back at 17800, wonder what happened there, wonder if it&amp;#39;s relevant.&lt;/p&gt;
&lt;p&gt;I can&amp;#39;t see a way through your code which could possibly enqueue the same sequence number twice and the data is the same between them, one point, same value, which seems unlikely (your data seems to change frame to frame) so that really does look like the same data twice . You only increment the sequence number if the hvx function reports success so I don&amp;#39;t see how you skip one either.&lt;/p&gt;
&lt;p&gt;Observation - the sequence which ends in a double send is 7 instead of 6 readings (although one is doubled), the next sequence is 6 again, so that seems complete. It looks like you queued 0d0e, got success, but 0d0d was sent twice and 0d0e dropped.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Duplicate and then dropped notification</title><link>https://devzone.nordicsemi.com/thread/30434?ContentTypeID=1</link><pubDate>Mon, 27 Jul 2015 04:55:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ae52d36e-d437-480e-9b38-184c452c09f1</guid><dc:creator>Campbell Young</dc:creator><description>&lt;p&gt;I&amp;#39;ve attached a Wireshark dump, with information included in the post (packet numbers, etc.). It doesn&amp;#39;t seem as though there are any failed deliveries, and the packet isn&amp;#39;t an exact duplicate. Weird. Thanks for your help, by the way.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Duplicate and then dropped notification</title><link>https://devzone.nordicsemi.com/thread/30433?ContentTypeID=1</link><pubDate>Mon, 27 Jul 2015 02:08:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:58bb3e09-cc64-4927-9059-1481bc1d9756</guid><dc:creator>Campbell Young</dc:creator><description>&lt;p&gt;I&amp;#39;ve got a dongle that appears to work with the sniffer, I&amp;#39;ll run it again later tonight and post the results.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Duplicate and then dropped notification</title><link>https://devzone.nordicsemi.com/thread/30432?ContentTypeID=1</link><pubDate>Mon, 27 Jul 2015 01:42:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9b0efc01-cf11-4787-b6e5-a0f2140d6821</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;Annoyingly the documentation on Packet Logger is 2 lines long so I don&amp;#39;t know what it does either. Don&amp;#39;t suppose you have another Nordic product you can run their BTLE sniffer on do you? Looks to me like that&amp;#39;s at the ATT level which rules out the &amp;#39;received-ACKed-ACK-not-received-retransmitted&amp;#39; possibility for the dupe. And looking harder at the code, unless sd_ble_gatts_hvx() is lying and returning success but still dropping the packet, which I have trouble believing, I don&amp;#39;t see how you get a sequence number gap unless the client is dropping it (which it&amp;#39;s allowed to do but I don&amp;#39;t see why it would)&lt;/p&gt;
&lt;p&gt;I&amp;#39;ll look at the code again later, but it seems right to me at this point.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Duplicate and then dropped notification</title><link>https://devzone.nordicsemi.com/thread/30431?ContentTypeID=1</link><pubDate>Mon, 27 Jul 2015 01:23:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:31ec8168-ffeb-4cb5-aea7-68141b22b441</guid><dc:creator>Campbell Young</dc:creator><description>&lt;p&gt;@RK It&amp;#39;s the output from PacketLogger (&lt;a href="https://developer.apple.com/library/mac/documentation/DeviceDrivers/Conceptual/Bluetooth/BT_Bluetooth_On_MOSX/BT_Bluetooth_On_MOSX.html)"&gt;developer.apple.com/.../BT_Bluetooth_On_MOSX.html)&lt;/a&gt; on Mac. Annoyingly, it doesn&amp;#39;t show any link-layer acknowledgements so I guess it&amp;#39;s closer to the ATT level (especially for the snippet I pasted). The actual payload data is shown after the Value: prefix.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Duplicate and then dropped notification</title><link>https://devzone.nordicsemi.com/thread/30430?ContentTypeID=1</link><pubDate>Mon, 27 Jul 2015 01:11:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f157aa70-1b4a-42ab-b3f0-87bfe09abb9e</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;What are you dumping in that log? Is that a raw packet trace, in which case I understand what&amp;#39;s going on, or is it a high level client showing received notifications at the ATT level which are given to an app in which case I don&amp;#39;t.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>