<?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>Handling data two times from one of the peripherals</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/37045/handling-data-two-times-from-one-of-the-peripherals</link><description>Hello, 
 I have been struggling with multilink uart example for a while. I have done 3 peripherals and one central communication but still I have some problems. I am using SDK 14.2.0 and 4 EYSHSNZWZ modules from Taiyo Yuden. 
 Central side sends data</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sat, 12 Jan 2019 08:12:59 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/37045/handling-data-two-times-from-one-of-the-peripherals" /><item><title>RE: Handling data two times from one of the peripherals</title><link>https://devzone.nordicsemi.com/thread/165280?ContentTypeID=1</link><pubDate>Sat, 12 Jan 2019 08:12:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:75967c8f-c34b-4b8f-a822-1cb68d12cce9</guid><dc:creator>arikyang</dc:creator><description>&lt;p&gt;I just figure out that somewhere call back ble_nus_c_on_ble_evt() twice cause this problem.&lt;/p&gt;
&lt;p&gt;One place I put in&amp;nbsp;ble_evt_handler(), but I can&amp;#39;t find another one.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Handling data two times from one of the peripherals</title><link>https://devzone.nordicsemi.com/thread/143553?ContentTypeID=1</link><pubDate>Thu, 09 Aug 2018 11:46:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dc307e68-6610-4db2-b5e8-a025ea3725a6</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Glad it worked!&lt;/p&gt;
&lt;p&gt;That is a good idea.&lt;/p&gt;
&lt;p&gt;I tried to leave most of the functions, and just comment them out and write the new call below, but I might have forgotten this some places.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Most of the changes were conn_handle and service/characteristic_handle related.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you want to get all the changes, you can use a diff-tool to compare the new&amp;nbsp;vs old main.c and ble_nus_c.c.&lt;/p&gt;
&lt;p&gt;I use this tool:&amp;nbsp;&lt;a href="http://meldmerge.org/"&gt;http://meldmerge.org/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Handling data two times from one of the peripherals</title><link>https://devzone.nordicsemi.com/thread/143533?ContentTypeID=1</link><pubDate>Thu, 09 Aug 2018 10:39:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:102bbeb1-6f6d-4405-89d8-35a54b8e7ddc</guid><dc:creator>Seyma Tutuncu</dc:creator><description>&lt;p&gt;Hi Edvin!&lt;/p&gt;
&lt;p&gt;I have just tried and it works. Every data comes as I send from peripherals.&lt;/p&gt;
&lt;p&gt;I&amp;nbsp;really appreciate you for your help, now I will look into your code and try to understand the parts that you added/changed.&lt;/p&gt;
&lt;p&gt;Thank you very much.&amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Handling data two times from one of the peripherals</title><link>https://devzone.nordicsemi.com/thread/143339?ContentTypeID=1</link><pubDate>Wed, 08 Aug 2018 10:50:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8dd48bb8-7855-4959-9264-b502726cfa26</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I have seen a few cases regarding conn_handles and nus_c + multilink, so I looked into it.&amp;nbsp;The issue is that the handles are not handled correctly. E.g. the notif_enable() function which is called in the DISCOVERY_COMPLETE event is different in lbs_c and nus_c.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I have been trying to get it to work for a while, and finally it worked, but I can&amp;#39;t say exactly which change I did that made it work.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The only changes I did was in main.c and ble_nus_c.c, so I have attached these. I am sorry, because I have removed some logging and added some logging, but you can clean it up if you like.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Try your project with the attached files, and let me know whether it works or not.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-e860b2f24a104e37a75b3a0e5f44131d/main.c"&gt;devzone.nordicsemi.com/.../main.c&lt;/a&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-e860b2f24a104e37a75b3a0e5f44131d/ble_5F00_nus_5F00_c.c"&gt;devzone.nordicsemi.com/.../ble_5F00_nus_5F00_c.c&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Handling data two times from one of the peripherals</title><link>https://devzone.nordicsemi.com/thread/143229?ContentTypeID=1</link><pubDate>Tue, 07 Aug 2018 13:00:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6054c23c-70a1-4192-b6cb-dac87650f67a</guid><dc:creator>Seyma Tutuncu</dc:creator><description>&lt;p&gt;Hello Edvin,&lt;/p&gt;
&lt;p&gt;Firstly, thank you for your attention. I am sorry that I didn&amp;#39;t send all files that you need. I applied your suggestion about on_hvx part, and now I can see which daha come from which conn handle. But still from&amp;nbsp; first conn handle (0x1) central can not receive data. From conn handle 0x2, central shows two times the data and conn handle 0x0 is ok.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Also I have controlled the code generation optimization settings and I saw that it is already disabled.&lt;/p&gt;
&lt;p&gt;Now I have controlled, compiled and attached the all folder, you can directly use it.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In Multilink_Example&amp;gt;examples you can see both peripheral and central that I use.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://www.dropbox.com/s/6z9xny6p7g1y8i6/Multilink_Example.rar?dl=0"&gt;File is here.&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/Multilink_5F00_Example.rar"&gt;devzone.nordicsemi.com/.../Multilink_5F00_Example.rar&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Handling data two times from one of the peripherals</title><link>https://devzone.nordicsemi.com/thread/143154?ContentTypeID=1</link><pubDate>Tue, 07 Aug 2018 08:12:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:11fab538-d454-489f-b3e2-c757147f7055</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I am not able to compile your project. I get a lot of weird compiling errors, but I suspect that it is because you have modified the ble_nus_c.c and ble_nus_c.h files, which does not originally have&amp;nbsp;BLE_NUS_C_ARRAY_DEF in SDK14.2.0.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Try to compile the project that you sent in a freshly unzipped SDK, and see what files that are missing. These are the files that I would need to compile.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Can you check one thing: Does the same behavior occur if you try to disable optimization? In SES you do this in project settings-&amp;gt;code-&amp;gt;code generation-&amp;gt;optimization level.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;It may be that the ble_nus_c.c does not pass the conn_handle correctly, since it is originally intended for only one connection (at least in SDK14.2.0).&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Can you try to add the conn_handle in the on_hvx() function in ble_nus_c.c.&lt;/p&gt;
&lt;p&gt;Change from:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void on_hvx(ble_nus_c_t * p_ble_nus_c, ble_evt_t const * p_ble_evt)
{
    // HVX can only occur from client sending.
    if (   (p_ble_nus_c-&amp;gt;handles.nus_tx_handle != BLE_GATT_HANDLE_INVALID)
        &amp;amp;&amp;amp; (p_ble_evt-&amp;gt;evt.gattc_evt.params.hvx.handle == p_ble_nus_c-&amp;gt;handles.nus_tx_handle)
        &amp;amp;&amp;amp; (p_ble_nus_c-&amp;gt;evt_handler != NULL))
    {
        ble_nus_c_evt_t ble_nus_c_evt;

        ble_nus_c_evt.evt_type = BLE_NUS_C_EVT_NUS_TX_EVT;
        ble_nus_c_evt.p_data   = (uint8_t *)p_ble_evt-&amp;gt;evt.gattc_evt.params.hvx.data;
        ble_nus_c_evt.data_len = p_ble_evt-&amp;gt;evt.gattc_evt.params.hvx.len;

        p_ble_nus_c-&amp;gt;evt_handler(p_ble_nus_c, &amp;amp;ble_nus_c_evt);
        NRF_LOG_DEBUG(&amp;quot;Client sending data.&amp;quot;);
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;to:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void on_hvx(ble_nus_c_t * p_ble_nus_c, ble_evt_t const * p_ble_evt)
{
    // HVX can only occur from client sending.
    if (   (p_ble_nus_c-&amp;gt;handles.nus_tx_handle != BLE_GATT_HANDLE_INVALID)
        &amp;amp;&amp;amp; (p_ble_evt-&amp;gt;evt.gattc_evt.params.hvx.handle == p_ble_nus_c-&amp;gt;handles.nus_tx_handle)
        &amp;amp;&amp;amp; (p_ble_nus_c-&amp;gt;evt_handler != NULL))
    {
        ble_nus_c_evt_t ble_nus_c_evt;

        ble_nus_c_evt.conn_handle = p_ble_nus_c-&amp;gt;conn_handle;
        ble_nus_c_evt.evt_type = BLE_NUS_C_EVT_NUS_TX_EVT;
        ble_nus_c_evt.p_data   = (uint8_t *)p_ble_evt-&amp;gt;evt.gattc_evt.params.hvx.data;
        ble_nus_c_evt.data_len = p_ble_evt-&amp;gt;evt.gattc_evt.params.hvx.len;

        p_ble_nus_c-&amp;gt;evt_handler(p_ble_nus_c, &amp;amp;ble_nus_c_evt);
        NRF_LOG_DEBUG(&amp;quot;Client sending data.&amp;quot;);
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Handling data two times from one of the peripherals</title><link>https://devzone.nordicsemi.com/thread/143062?ContentTypeID=1</link><pubDate>Mon, 06 Aug 2018 14:29:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:efa2100b-0b85-41a6-87b5-15eb84a3878f</guid><dc:creator>Seyma Tutuncu</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Link for the central&amp;nbsp; project file is&amp;nbsp;&lt;a href="https://www.dropbox.com/s/iwefhkhg7h661yt/ble_app_multilink_central.rar?dl=0"&gt;here&lt;/a&gt;. Also I added the .rar file. I use only EYSHSNZWZ board, there isn&amp;#39;t any other specific HW. I have only changed the pins for LEDs and there is not any other difference, I think you can use it.&lt;/p&gt;
&lt;p&gt;Thank you.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/0474.ble_5F00_app_5F00_multilink_5F00_central.rar"&gt;devzone.nordicsemi.com/.../0474.ble_5F00_app_5F00_multilink_5F00_central.rar&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Handling data two times from one of the peripherals</title><link>https://devzone.nordicsemi.com/thread/143017?ContentTypeID=1</link><pubDate>Mon, 06 Aug 2018 12:20:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:595545d1-a0a9-4685-a0ac-4362ea7ac732</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Is it possible to send the central project? Do you use any special HW, such as sensors? Or can I replicate this on the regular DK?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Handling data two times from one of the peripherals</title><link>https://devzone.nordicsemi.com/thread/142629?ContentTypeID=1</link><pubDate>Thu, 02 Aug 2018 13:10:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9847e271-5f66-449b-bfef-732ec974d282</guid><dc:creator>Seyma Tutuncu</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I get the data as 1234512345 while I am sending 12345.&lt;/p&gt;
&lt;p&gt;Only from one connection handle I get this.&lt;/p&gt;
&lt;p&gt;For example:&lt;/p&gt;
&lt;p&gt;From conn handle 0; I send 00 00 00 15 0A, then central gets&amp;nbsp;&amp;nbsp;&lt;span&gt;00 00 00 15 0A.&amp;nbsp;I see &amp;quot;Uartttan data alindi&amp;quot; part one time. This is OK.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;From conn handle 2; I send&amp;nbsp;&amp;nbsp;&lt;span&gt;00 00 00 16 0A, then central gets 00 00 00 16 0A&amp;nbsp;00 00 00 16 0A.&amp;nbsp;I see &amp;quot;Uartttan data alindi&amp;quot; part&amp;nbsp;two times.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;From conn handle 1; I send&amp;nbsp;00 00 00 17 0A, then central gets nothing. I don&amp;#39;t see&amp;nbsp;&amp;quot;Uartttan data alindi&amp;quot;. After I reset conn handle 1, then it becomes conn handle 3, after that I send&amp;nbsp;00 00 00 17 0A then central get&amp;nbsp;00 00 00 17 0A. This time&amp;nbsp;I see &amp;quot;Uartttan data alindi&amp;quot; part one time.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;To conclude; handle 1 needs resetting to get data from central, and from conn handle 2, I get always 2 bytes consecutively.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I didn&amp;#39;t use the&amp;nbsp;ECHOBACK_BLE_UART_DATA, I removed it. Both central and peripherals.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I will consider what you say.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;By the way, I have changed&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;NRF_LOG_INFO(&amp;quot;Uartttan data alindi.) part to &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;NRF_LOG_INFO(&amp;quot;Uartttan data alindi. conn_handle= %d&amp;quot;, p_ble_nus_evt-&amp;gt;conn_handle);&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;and I always see&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt; 0&amp;gt; &amp;lt;info&amp;gt; app: Uartttan data alindi.conn_handle= 0&lt;br /&gt; 0&amp;gt; &amp;lt;info&amp;gt; app: Uartttan data alindi.conn_handle= 0&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;br /&gt; 0&amp;gt; &amp;lt;info&amp;gt; app: Uartttan data alindi.conn_handle= 0&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;br /&gt; 0&amp;gt; &amp;lt;info&amp;gt; app: Uartttan data alindi.conn_handle= 0&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;br /&gt; 0&amp;gt; &amp;lt;info&amp;gt; app: Uartttan data alindi.conn_handle= 0&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;from every connection handle. I get two times for handle 2, and one time for handle 0. But for every handle it says conn handle 0. I didn&amp;#39;t understand. Because at first central assigns handles correctly at the time of connection.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Handling data two times from one of the peripherals</title><link>https://devzone.nordicsemi.com/thread/142546?ContentTypeID=1</link><pubDate>Thu, 02 Aug 2018 08:51:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dc724e84-05ed-4ebf-9b87-be110915240f</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Do you get two events, or do you get twice the length on the data?&lt;/p&gt;
&lt;p&gt;e.g.:&lt;/p&gt;
&lt;p&gt;data = 1234512345 or data = 1122334455?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;What does the log look like when you send one message from the device with conn handle 2?&lt;/p&gt;
&lt;p&gt;Do you get the line: &amp;quot;Receiving data&amp;quot; two times?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Can you also try to add, in your BLE_NUS_C_EVT_NUS_TX_EVT event:&lt;/p&gt;
&lt;p&gt;NRF_LOG_INFO(&amp;quot;Uartttan data alindi. conn_handle= %d&amp;quot;, p_ble_nus_evt-&amp;gt;conn_handle);&lt;/p&gt;
&lt;p&gt;to see that you are not actually connected to the same device twice?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I assume that you have the same project/.hex-file on all the peripherals? Do you? do you have any #define&amp;nbsp;ECHOBACK_BLE_UART_DATA in your peripheral project?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>