<?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>Lost packet on RX (Central-&amp;gt;Device)</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/75915/lost-packet-on-rx-central--device</link><description>Hi, 
 When working with Windows 10 laptop BLE we get sometimes a lost packet occurrence from Central (PC) to our BLE device. 
 We are using a Python Bleak based app on the Windows side. Our device is nRF52840 based. 
 Attached is a sniffer trace caught</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 08 Jun 2021 19:12:34 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/75915/lost-packet-on-rx-central--device" /><item><title>RE: Lost packet on RX (Central-&gt;Device)</title><link>https://devzone.nordicsemi.com/thread/314286?ContentTypeID=1</link><pubDate>Tue, 08 Jun 2021 19:12:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0e7bb467-1e0a-4716-9b34-4cfe874ae0c2</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;There are message sequence charts for both server and client in the softdevice specifications:&lt;/p&gt;
&lt;p&gt;GATT server:&amp;nbsp;&lt;br /&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s140.api.v7.2.0/group___b_l_e___g_a_t_t_s___m_s_c.html"&gt;https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s140.api.v7.2.0/group___b_l_e___g_a_t_t_s___m_s_c.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;GATT client:&amp;nbsp;&lt;br /&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s140.api.v7.2.0/group___b_l_e___g_a_t_t_c___m_s_c.html"&gt;https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s140.api.v7.2.0/group___b_l_e___g_a_t_t_c___m_s_c.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Lost packet on RX (Central-&gt;Device)</title><link>https://devzone.nordicsemi.com/thread/314134?ContentTypeID=1</link><pubDate>Tue, 08 Jun 2021 09:11:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:45ed6431-bcdc-49e8-9876-23fe7d06ec51</guid><dc:creator>Moshe Baker</dc:creator><description>&lt;p&gt;Hi Kenneth,&lt;/p&gt;
&lt;p&gt;Update - after changing implementation on SPI bus handling from polling to interrupt-driven, still issue persists. We thought it might be related to a performance issue due to SPI handling.&lt;/p&gt;
&lt;p&gt;the on_write() handle is as follow. you can see we check CRC and index as part of our protocol over the BLE write, and we get the index error here. I added logging in the blocks which are ot the main block to see if we get in there by mistake, but we don&amp;#39;t.&lt;/p&gt;
&lt;p&gt;Note: we are not using an OS. I thought of moving the BLE write handling to the main loop, but still, how will the Central be informed to &amp;quot;wait&amp;quot;?&lt;/p&gt;
&lt;p&gt;Question: how can we use the BLE write-with-response? I think we might use this to have a belter ACK mechanism, on each BLE write packet.&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;
&lt;p&gt;static void on_write(ble_am_t *p_am, ble_evt_t const *p_ble_evt)&lt;br /&gt;{&lt;br /&gt; ble_gatts_evt_write_t const *p_evt_write = &amp;amp;p_ble_evt-&amp;gt;evt.gatts_evt.params.write;&lt;br /&gt; ble_am_evt_t event = {.p_am = p_am};&lt;br /&gt; p_am-&amp;gt;conn_handle = p_ble_evt-&amp;gt;evt.gap_evt.conn_handle;&lt;/p&gt;
&lt;p&gt;// INFO Handle CCCD write (subscribe) for data_out_handle&lt;br /&gt; if ((p_evt_write-&amp;gt;handle == p_am-&amp;gt;data_out_handle.cccd_handle) &amp;amp;&amp;amp; (p_evt_write-&amp;gt;len == 2)) {&lt;br /&gt; nrfx_atomic_u32_store(&amp;amp;m_index_tx, 0);&lt;br /&gt; on_generic_sessions_cccd_write(p_am, p_evt_write, BLE_AM_EVENT_DATA_OUT_NOTIFICATION_STARTED,&lt;br /&gt; BLE_AM_EVENT_DATA_OUT_NOTIFICATION_STOPPED, &amp;amp;m_notify.data_out);&lt;br /&gt; NRF_LOG_INFO(&amp;quot;here 1&amp;quot;);&lt;/p&gt;
&lt;p&gt;// INFO Handle write for data_in_handle&lt;br /&gt; } else if ((p_evt_write-&amp;gt;handle == p_am-&amp;gt;data_in_handle.value_handle) &amp;amp;&amp;amp; (p_evt_write-&amp;gt;len &amp;gt; 0)) {&lt;/p&gt;
&lt;p&gt;uint32_t rec_index = uint32_decode(p_evt_write-&amp;gt;data);&lt;br /&gt; &lt;br /&gt; if (rec_index != rx_index)&lt;br /&gt; NRF_LOG_INFO(&amp;quot;BLE index error! rec_index: %d, %d&amp;quot;,rec_index, rx_index);&lt;br /&gt; &lt;br /&gt; rx_index++;&lt;/p&gt;
&lt;p&gt;uint32_t calc_crc = crc32_compute(p_evt_write-&amp;gt;data, p_evt_write-&amp;gt;len - sizeof(uint32_t), NULL);&lt;br /&gt; &lt;br /&gt; uint32_t rec_crc = uint32_decode(p_evt_write-&amp;gt;data + p_evt_write-&amp;gt;len - sizeof(uint32_t));&lt;br /&gt; if (rec_crc != calc_crc)&lt;br /&gt; NRF_LOG_INFO(&amp;quot;BLE CRC error! cal_crc: 0x%x, 0x%x&amp;quot;,calc_crc,rec_crc);&lt;/p&gt;
&lt;p&gt;event.type = BLE_AM_EVENT_DATA_IN_WRITE;&lt;br /&gt; event.params.p_data = (uint8_t *)p_evt_write-&amp;gt;data + sizeof(uint32_t);&lt;br /&gt; event.params.data_len = p_evt_write-&amp;gt;len - sizeof(uint32_t) - sizeof(uint32_t);&lt;br /&gt; //ble_write_ev = event;&lt;br /&gt; p_am-&amp;gt;event_handler(&amp;amp;event, NULL);&lt;/p&gt;
&lt;p&gt;} else {&lt;br /&gt; NRF_LOG_INFO(&amp;quot;here 2&amp;quot;);&lt;br /&gt; NRFX_LOG_WARNING(&amp;quot;%s unknown CCCD (0x%x)&amp;quot;, __func__, p_evt_write-&amp;gt;handle);&lt;br /&gt; }&lt;br /&gt;}&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Lost packet on RX (Central-&gt;Device)</title><link>https://devzone.nordicsemi.com/thread/313372?ContentTypeID=1</link><pubDate>Thu, 03 Jun 2021 11:15:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5350d5dc-9a23-4ba3-b313-9663b56c30d4</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;I think you just need to look at the handling of BLE_GATTS_EVT_WRITE events, maybe add some debug information to see it it&amp;#39;s possible you receive the &lt;span&gt;BLE_GATTS_EVT_WRITE&amp;nbsp;&lt;/span&gt;event but you somehow don&amp;#39;t buffer/handle the received data in your application.&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Lost packet on RX (Central-&gt;Device)</title><link>https://devzone.nordicsemi.com/thread/313356?ContentTypeID=1</link><pubDate>Thu, 03 Jun 2021 10:37:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c4bb73ca-71fe-4b4c-96c7-09708631454e</guid><dc:creator>Moshe Baker</dc:creator><description>&lt;p&gt;It happens sometimes. The 840 is also doing SPI transfers using polling. No flash usage. Thanks!&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Lost packet on RX (Central-&gt;Device)</title><link>https://devzone.nordicsemi.com/thread/313255?ContentTypeID=1</link><pubDate>Thu, 03 Jun 2021 06:18:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3f830d88-e0e0-4043-af84-ac244d007234</guid><dc:creator>daviddedwin</dc:creator><description>&lt;p&gt;The packet that was transmitted on the air at line number 201659 seems to have been acked by the peer. This means it was successfully received in a memory buffer on the nRF52840. This would typically mean that the code on the nRF52840 has to be reviewed.&lt;br /&gt;Is this happening consistently ? Is there a lot of processing on the 840 ? Lot of flash usaga etc ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Lost packet on RX (Central-&gt;Device)</title><link>https://devzone.nordicsemi.com/thread/313252?ContentTypeID=1</link><pubDate>Thu, 03 Jun 2021 06:04:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3465d034-3c3f-43b9-96dc-a183826407cf</guid><dc:creator>Moshe Baker</dc:creator><description>&lt;p&gt;Please respond ASAP as this is at customer site. Thank you!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>