<?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>How to resolve mixed messages during BLE Indication</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/16353/how-to-resolve-mixed-messages-during-ble-indication</link><description>The task I am working on is sending a list of records from an nRF52832 chip to a central. Before sending the records, the total number of them should be sent, so the central device would know how many records it is expected to process. 
The communication</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 21 Sep 2016 09:31:27 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/16353/how-to-resolve-mixed-messages-during-ble-indication" /><item><title>RE: How to resolve mixed messages during BLE Indication</title><link>https://devzone.nordicsemi.com/thread/62538?ContentTypeID=1</link><pubDate>Wed, 21 Sep 2016 09:31:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:78285848-9aa1-480e-81cc-0930d08a095f</guid><dc:creator>Chengxin Ma</dc:creator><description>&lt;p&gt;Thanks for the explanation and suggestion. However I will suspend the testing until I have some free time to go into the details.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to resolve mixed messages during BLE Indication</title><link>https://devzone.nordicsemi.com/thread/62536?ContentTypeID=1</link><pubDate>Fri, 16 Sep 2016 14:35:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8dcebc59-b2b1-413d-a96f-626c8b6ed9d0</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;My suggestion is to check if the indication actually received on the phone&amp;#39;s app but is not updated to the text box. I know that we do use a timer to update the text box, so maybe the timer was stopped after we disconnect. And this could explain why it&amp;#39;s confirmed on the other side but not displayed on the phone side.&lt;/p&gt;
&lt;p&gt;The source code for nRF Connect is not available but you can check with your own app or our example app (nRFUART for example).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to resolve mixed messages during BLE Indication</title><link>https://devzone.nordicsemi.com/thread/62537?ContentTypeID=1</link><pubDate>Fri, 16 Sep 2016 12:26:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a882c354-fde9-47bb-bbd1-9cb0b0f71221</guid><dc:creator>Chengxin Ma</dc:creator><description>&lt;p&gt;The MAX and MIN connection interval are both set to be 7.5 ms, which is the minimal possible setting. As for the interval of the indication, I did not use a timer for that so as soon as the SoC get a confirmation from the central it will send the next piece of message.&lt;br /&gt;
I haven&amp;#39;t used nRFUART app, but tested with the PC version nRF Connect on Windows. Now it is less likely to miss the messages, but still sometimes the messages are not displayed.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to resolve mixed messages during BLE Indication</title><link>https://devzone.nordicsemi.com/thread/62533?ContentTypeID=1</link><pubDate>Thu, 15 Sep 2016 11:12:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a2641ee3-cc94-4e80-96f1-2ebd26fde349</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;(you can edit your question to add the screenshot in)
Please also let me know the connection interval and the interval you sent your indication. Have you tried to reproduce the issue using our nRFUART app for example ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to resolve mixed messages during BLE Indication</title><link>https://devzone.nordicsemi.com/thread/62535?ContentTypeID=1</link><pubDate>Thu, 15 Sep 2016 08:01:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:49c93d75-b96f-4e23-9a8f-75b7279c4904</guid><dc:creator>Chengxin Ma</dc:creator><description>&lt;p&gt;Hi Hung Bui, I am using Samsung Galaxy S6 as the central. (I want to add a screenshot but it seems it is not possible to do it in the comment.)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to resolve mixed messages during BLE Indication</title><link>https://devzone.nordicsemi.com/thread/62534?ContentTypeID=1</link><pubDate>Thu, 15 Sep 2016 07:25:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:da5d4cca-0f1d-4837-9fc2-9e73f7a270f1</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;It&amp;#39;s quite strange what you described that the central sent confirmation but didn&amp;#39;t display (send an event? ) back to the application on central. Which central device were you testing with ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to resolve mixed messages during BLE Indication</title><link>https://devzone.nordicsemi.com/thread/62532?ContentTypeID=1</link><pubDate>Wed, 14 Sep 2016 13:35:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:439021e7-fa90-4b28-aaae-dfb50a00a1b7</guid><dc:creator>Chengxin Ma</dc:creator><description>&lt;p&gt;@Hung Bui,
Thanks for the explanation.&lt;br /&gt;
As for the missing message, the problem now is that it is indeed sent and confirmed, but the central device simply did not display it. I think the code on the SoC is fine now, as I can get the confirmation for the missing message, and the base for updating the new value is the confirmation of the previous value.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to resolve mixed messages during BLE Indication</title><link>https://devzone.nordicsemi.com/thread/62531?ContentTypeID=1</link><pubDate>Wed, 14 Sep 2016 11:36:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e5d550f4-8344-46b1-9b96-ede3746109ce</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;&amp;quot;3A-3B-3C-3D-3E-3F&amp;quot; missing because it was queued and updated in the value of the characteristic but the indication has not been successfully received and confirmed. You should base on the confirmation event before you update the new value. So if &amp;quot;3A-3B-3C-3D-3E-3F&amp;quot; is not confirmed it should be resent when you connected again.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Can you explain further why sending full 6 bytes of the total number of records would solve (if it really solves) the problem of the missing message?&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;It&amp;#39;s pretty simple, if you have fixed size characteristic 6 bytes for example, and you call hvx command to update only 2 bytes, the other 4 bytes won&amp;#39;t change. The whole 6 bytes will be sent in the indication packet. And what the central receives are 6 bytes with 2 first bytes has new value and last 4 bytes have old value.
If you call hvx command with 6 bytes, the whole 6 bytes will be updated and you don&amp;#39;t have problem of mixing old and new value.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to resolve mixed messages during BLE Indication</title><link>https://devzone.nordicsemi.com/thread/62527?ContentTypeID=1</link><pubDate>Tue, 13 Sep 2016 15:28:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d4c3c290-931e-4a26-836f-c26f436bd5fb</guid><dc:creator>Chengxin Ma</dc:creator><description>&lt;p&gt;Hi @Hung Bui,
I agree with what you said about the cause of 00-4C-3C-3D-3E-3F. If I append 4 &amp;quot;00&amp;quot;&amp;#39;s to a 2-bytes value, that would mean 00-4C-3C-3D-3E-3F is changed to 00-4C-00-00-00-00, so the meassage sequence that I actually got would to be:&lt;/p&gt;
&lt;p&gt;00-50-00-00-00-00;&lt;br /&gt;
A0-B0-C0-D0-E0-F0;&lt;br /&gt;
1A-1B-1C-1D-1E-1F;&lt;br /&gt;
2A-2B-2C-2D-2E-2F;&lt;br /&gt;
// here comes a disconnection&lt;br /&gt;
00-4C-00-00-00-00;&lt;br /&gt;
4A-4B-4C-4D-4E-4F;&lt;br /&gt;
5A-5B-5C-5D-5E-5F;&lt;/p&gt;
&lt;p&gt;Based on such analysis, the message &amp;quot;3A-3B-3C-3D-3E-3F&amp;quot; is still missing. Can you explain further why sending full 6 bytes of the total number of records would solve (if it really solves) the problem of the missing message?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to resolve mixed messages during BLE Indication</title><link>https://devzone.nordicsemi.com/thread/62528?ContentTypeID=1</link><pubDate>Tue, 13 Sep 2016 15:03:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8a78212d-50ee-45fd-a3aa-4fe481b41a4c</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;@ChengxinMa: No, it maybe not about jumping over.
So the situation was :&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;The characteristic value was 3A-3B-3C-3D-3E-3F; when the connection was terminated. When you call sd_ble_gatts_hvx() the stack not only send the indication, but also update the value of the characteristic.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You are connected again, the value of the characteristic was still 3A-3B-3C-3D-3E-3F;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You called sd_ble_gatts_hvx() to update only the first 2 bytes with  00-4C, and the result is that the value of the characteristic will be 00-4C-3C-3D-3E-3F.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;00-4C-3C-3D-3E-3F will be send in the indication as it&amp;#39;s the value of the characteristic.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Please try to call sd_ble_gatts_hvx with full 6 bytes when you send the number of records (00-4C-00-00-00-00 for example ) .&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to resolve mixed messages during BLE Indication</title><link>https://devzone.nordicsemi.com/thread/62530?ContentTypeID=1</link><pubDate>Tue, 13 Sep 2016 13:38:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c202ea93-e4c6-44fe-9a8e-5c0d1a90fc49</guid><dc:creator>Chengxin Ma</dc:creator><description>&lt;p&gt;Taking &amp;quot;00-4C-3C-3D-3E-3F&amp;quot; into consideration, I think &amp;quot;00-4C&amp;quot; is the value to be sent, while &amp;quot;3C-3D-3E-3F&amp;quot; is the jumped over message and it &amp;quot;polluted&amp;quot; &amp;quot;00-4C&amp;quot;. So the problem is not only mixing messages up (which is now solved by setting attr_md.vlen to be 1), but also jumping over some messages upon disconnection.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to resolve mixed messages during BLE Indication</title><link>https://devzone.nordicsemi.com/thread/62529?ContentTypeID=1</link><pubDate>Tue, 13 Sep 2016 13:38:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:256b4853-52f0-4498-be81-95d11dfcb3f7</guid><dc:creator>Chengxin Ma</dc:creator><description>&lt;p&gt;Hi @Hung Bui,&lt;br /&gt;
Previously I did not explicitly set attr_md.vlen and I guess the value is by default 0, meaning that the length is fixed, right?&lt;br /&gt;
What I did just now is setting the value to be 1, so now the length becomes flexible. I did not meet the problem of mixed messages again, but got some other problems:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;using a phone as the central: the first expected message would be the total number of records, but it is sometimes jumped over -- the phone will receive the records directly.&lt;/li&gt;
&lt;li&gt;using a phone as the central: when a disconnection and recovery happens, some records are jumped over.&lt;/li&gt;
&lt;li&gt;using a Raspberry Pi to be the central: the first problem can be avoided, but the second one remains.&lt;/li&gt;
&lt;/ol&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to resolve mixed messages during BLE Indication</title><link>https://devzone.nordicsemi.com/thread/62526?ContentTypeID=1</link><pubDate>Tue, 13 Sep 2016 12:10:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:55d8038e-65df-4b6f-8f2b-d4596a2f0d88</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Cma,&lt;/p&gt;
&lt;p&gt;How did you define the characteristic ? Did you define it with variable length or fixed length (attr_md.vlen =0) ?
If you defined the characteristic with fixed length (says 6 bytes) and then when you call sd_ble_gatts_hvx() to update with only 2 bytes (00-4C) then the rest 4 bytes will not be updated and result in what you have seen with 00-4C-3C-3D-3E-3F&lt;/p&gt;
&lt;p&gt;Could you please check if you update with full 6 bytes 00-4C-00-00-00-00 would the issue remains ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>