<?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>Peer Manager silently drop Service Changed indications if an ATT MTU exchange was happening</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/46633/peer-manager-silently-drop-service-changed-indications-if-an-att-mtu-exchange-was-happening</link><description>Hello, 
 Using nRF5 SDK v15.3.0 Peer Manager drops Service Changed indications if an ATT MTU exchange is in progress, this hapens because function service_changed_cccd() in gatt_cache_manager.c allways returns NRF_ERROR_NOT_FOUND. 
 
 After some digging</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 20 Aug 2019 09:13:24 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/46633/peer-manager-silently-drop-service-changed-indications-if-an-att-mtu-exchange-was-happening" /><item><title>RE: Peer Manager silently drop Service Changed indications if an ATT MTU exchange was happening</title><link>https://devzone.nordicsemi.com/thread/204968?ContentTypeID=1</link><pubDate>Tue, 20 Aug 2019 09:13:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a580b31c-59d7-4739-a939-525d4051b07f</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;You will need to modify the&amp;nbsp;&lt;span&gt;service_changed_send_in_evt() to handle the&amp;nbsp;NRF_ERROR_INVALID_STATE case like in SDK 15.3.0. I.e., check if the invalid state error may have been caused by an ongoing MTU exchange and not assume it&amp;#39;s because CCCD is not set.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Update fix which I have quickly tested with SDK 15.2.0:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-efac567c1eef4611a08beac0449665cb/service_5F00_changed_5F00_fix.diff"&gt;devzone.nordicsemi.com/.../service_5F00_changed_5F00_fix.diff&lt;/a&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-efac567c1eef4611a08beac0449665cb/gatt_5F00_cache_5F00_manager.c"&gt;devzone.nordicsemi.com/.../gatt_5F00_cache_5F00_manager.c&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Peer Manager silently drop Service Changed indications if an ATT MTU exchange was happening</title><link>https://devzone.nordicsemi.com/thread/204634?ContentTypeID=1</link><pubDate>Mon, 19 Aug 2019 06:45:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:17bab53f-04bc-47b3-b4a2-a730a5f51835</guid><dc:creator>Bart Cerneels</dc:creator><description>&lt;p&gt;How can we work around this in the meantime without upgrading to 15.3.0 as I need to solve this in a bugfix release.&lt;br /&gt;The code snippet above does not apply.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Peer Manager silently drop Service Changed indications if an ATT MTU exchange was happening</title><link>https://devzone.nordicsemi.com/thread/204627?ContentTypeID=1</link><pubDate>Mon, 19 Aug 2019 06:30:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:514a0f53-26be-4af0-a22e-7166db77485d</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Yes, 15.2.0 had the same issue. The fix will be implemented in the next SDK release.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Peer Manager silently drop Service Changed indications if an ATT MTU exchange was happening</title><link>https://devzone.nordicsemi.com/thread/204582?ContentTypeID=1</link><pubDate>Sat, 17 Aug 2019 07:10:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:46d226a4-7d34-4585-9d32-f4462b862606</guid><dc:creator>Bart Cerneels</dc:creator><description>&lt;p&gt;I&amp;#39;m experiencing issues with SCI not being sent but I&amp;#39;m using SDK 15.2.0&lt;br /&gt;Is this a known issue in that release? The code above does not match&amp;nbsp;service_changed_send_in_evt() in&amp;nbsp;gatt_cache_manager.c.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Peer Manager silently drop Service Changed indications if an ATT MTU exchange was happening</title><link>https://devzone.nordicsemi.com/thread/185767?ContentTypeID=1</link><pubDate>Tue, 07 May 2019 14:06:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:95f8d833-debe-4537-90fb-dc92f3219ee4</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Thanks for confirming. I have reported this internally so it should be fixed for the next SDK release.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Peer Manager silently drop Service Changed indications if an ATT MTU exchange was happening</title><link>https://devzone.nordicsemi.com/thread/185724?ContentTypeID=1</link><pubDate>Tue, 07 May 2019 12:19:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:905307ce-0f24-46af-a3fd-9489f5a32584</guid><dc:creator>Karlis</dc:creator><description>&lt;p&gt;Thanks, with new&amp;nbsp;&lt;span&gt;service_changed_cccd() all works!&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Peer Manager silently drop Service Changed indications if an ATT MTU exchange was happening</title><link>https://devzone.nordicsemi.com/thread/185510?ContentTypeID=1</link><pubDate>Mon, 06 May 2019 13:20:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aa49b075-1420-4f14-b6ee-4f8b98acb053</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;It appears that the&amp;nbsp;service_changed_cccd() function is not implemented correctly, it returns not found even when the SC is present. I will report this internally. A temporary workaround is to add a break statement here in gatt_cache_manager.c (line ~382):&lt;/p&gt;
&lt;p&gt;case NRF_ERROR_INVALID_STATE:&lt;br /&gt; {&lt;br /&gt; uint16_t cccd;&lt;br /&gt; err_code = service_changed_cccd(conn_handle, &amp;amp;cccd);&lt;br /&gt; NRF_LOG_INFO(&amp;quot;err_code: 0x%x&amp;quot;, err_code);&lt;br /&gt; if ((err_code == NRF_SUCCESS) &amp;amp;&amp;amp; cccd)&lt;br /&gt; {&lt;br /&gt; // Possible ATT_MTU exchange ongoing.&lt;br /&gt; // Do nothing, treat as busy.&lt;br /&gt; break;&lt;br /&gt; }&lt;br /&gt; else&lt;br /&gt; {&lt;br /&gt; if (err_code != NRF_SUCCESS)&lt;br /&gt; {&lt;br /&gt; NRF_LOG_DEBUG(&amp;quot;Unexpected error when looking for service changed CCCD: %s&amp;quot;,&lt;br /&gt; nrf_strerror_get(err_code));&lt;br /&gt; }&lt;br /&gt; // CCCDs not enabled or an error happened. Drop indication.&lt;br /&gt;&amp;nbsp;--// Fallthrough.&lt;br /&gt; &lt;strong&gt;break;&lt;/strong&gt;&lt;br /&gt; }&lt;br /&gt; }&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Edit 5/7-19&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Please try to replace service_changed_cccd() with the one below instead of removing the fallthrough.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/**@brief Function for getting the value of the CCCD for the service changed characteristic.
 *
 * @details This function will search all system handles consecutively.
 *
 * @param[in]  conn_handle  The connection to check.
 * @param[out] p_cccd       The CCCD value of the service changed characteristic for this link.
 *
 * @return Any error from @ref sd_ble_gatts_value_get.
 */
static ret_code_t service_changed_cccd(uint16_t conn_handle, uint16_t * p_cccd)
{
    bool       sc_found = false;
    bool       generic_att_found = false;
    ble_gatts_attr_md_t attr_md;
    uint16_t   end_handle;
    ret_code_t err_code = sd_ble_gatts_initial_user_handle_get(&amp;amp;end_handle);
    ASSERT(err_code == NRF_SUCCESS);

    for (uint16_t handle = 1; handle &amp;lt; end_handle; handle++)
    {
        ble_uuid_t uuid;
        ble_gatts_value_t value = {.p_value = (uint8_t *)&amp;amp;uuid.uuid, .len = 2, .offset = 0};
        if (!generic_att_found)
        {
            err_code = sd_ble_gatts_value_get(conn_handle, handle, &amp;amp;value);
        }
        else
        {
            err_code = sd_ble_gatts_attr_get(handle, &amp;amp;uuid, NULL); 
        }

        if (err_code != NRF_SUCCESS)
        {
            return err_code;
        }
        else if (uuid.uuid == BLE_UUID_GATT)
        {
            generic_att_found = true;
        }
        else if (!sc_found &amp;amp;&amp;amp; (uuid.uuid == BLE_UUID_GATT_CHARACTERISTIC_SERVICE_CHANGED))
        {
            sc_found = true;
        }
        else if (sc_found &amp;amp;&amp;amp; (uuid.uuid == BLE_UUID_DESCRIPTOR_CLIENT_CHAR_CONFIG))
        {
            value.p_value = (uint8_t *)p_cccd;
            return sd_ble_gatts_value_get(conn_handle, handle, &amp;amp;value);
        }
    }
    return NRF_ERROR_NOT_FOUND;
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Peer Manager silently drop Service Changed indications if an ATT MTU exchange was happening</title><link>https://devzone.nordicsemi.com/thread/184820?ContentTypeID=1</link><pubDate>Thu, 02 May 2019 09:39:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:95b76d13-e9b1-43db-941f-0b98ae04154d</guid><dc:creator>Karlis</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Yes, if there no MTU exchange, there are no errors. Characteristic is enabled.&lt;/p&gt;
&lt;p&gt;And also if in&amp;nbsp;&lt;em&gt;gatt_cache_manager.c&lt;/em&gt;&lt;span&gt;&amp;nbsp;in function&amp;nbsp;&lt;em&gt;service_changed_send_in_evt&amp;nbsp;&lt;/em&gt;remove&amp;nbsp;&amp;quot;case NRF_ERROR_INVALID_STATE:&amp;quot; service changed indication works&amp;nbsp;for iOS. Only problem is in fact that it never droped for Android or central witch not enabled&amp;nbsp;service changed indication.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Peer Manager silently drop Service Changed indications if an ATT MTU exchange was happening</title><link>https://devzone.nordicsemi.com/thread/184803?ContentTypeID=1</link><pubDate>Thu, 02 May 2019 09:03:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1440a9e6-5cf2-42c5-9163-e01789139098</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Just to confirm,&amp;nbsp;are you not getting this error when there&amp;#39;s no MTU exchange? Also, have you enabled this characteristic in sdk_config.h. You can check if it&amp;#39;s present with the nRF connect app on Android.&amp;nbsp;&lt;/p&gt;
[quote user=""]Or handle associated with&amp;nbsp;&lt;span&gt;service changed&lt;/span&gt;&lt;span&gt;&amp;nbsp;cccd is allways the same and we can simply check if it exists?&lt;/span&gt;[/quote]
&lt;p&gt;Correct, it does not change since there are no optional system attributes above this characteristic.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>