<?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>SD GATT procedure failed on Central device.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/99424/sd-gatt-procedure-failed-on-central-device</link><description>Hi All, 
 I am using NRF52840 in my project and working on SDK 17.0.2. I have one central device and 2 Peripherals. The peripherals are connected to the central properly after power ON. Now let&amp;#39;s say I Power OFF the central device for sometime. The peripherals</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 07 Jul 2023 14:33:17 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/99424/sd-gatt-procedure-failed-on-central-device" /><item><title>RE: SD GATT procedure failed on Central device.</title><link>https://devzone.nordicsemi.com/thread/435291?ContentTypeID=1</link><pubDate>Fri, 07 Jul 2023 14:33:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4b31bea8-b057-4c60-864a-1970a82d5847</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;It would help with sniffer logs but the error you see the same thing as mentioned &lt;a href="https://devzone.nordicsemi.com/support-private/support/310715"&gt;here&lt;/a&gt;. Check the solution mentioned there if that helps.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SD GATT procedure failed on Central device.</title><link>https://devzone.nordicsemi.com/thread/435120?ContentTypeID=1</link><pubDate>Fri, 07 Jul 2023 07:22:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fe19d6bd-49e8-4266-984b-23ef809b6488</guid><dc:creator>sne_333</dc:creator><description>&lt;p&gt;Hi , Can you please reply? Is there any way to implement reconnect mechanism?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SD GATT procedure failed on Central device.</title><link>https://devzone.nordicsemi.com/thread/432179?ContentTypeID=1</link><pubDate>Wed, 21 Jun 2023 06:41:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2882886e-c2d8-4567-909b-ce3c3b03259b</guid><dc:creator>sne_333</dc:creator><description>&lt;p&gt;Hi Susheel,&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Unfortunately I won&amp;#39;t be able to capture sniffer logs for some reason. I also feel that there is some issue with function &amp;quot;nrf_ble_scan_connect_with_target&amp;quot;.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void nrf_ble_scan_connect_with_target(nrf_ble_scan_t           const * const p_scan_ctx,
                                             ble_gap_evt_adv_report_t const * const p_adv_report)
{
    ret_code_t err_code;
    scan_evt_t scan_evt;

    // For readability.
    ble_gap_addr_t const        * p_addr        = &amp;amp;p_adv_report-&amp;gt;peer_addr;
    ble_gap_scan_params_t const * p_scan_params = &amp;amp;p_scan_ctx-&amp;gt;scan_params;
    ble_gap_conn_params_t const * p_conn_params = &amp;amp;p_scan_ctx-&amp;gt;conn_params;
    uint8_t                       con_cfg_tag   = p_scan_ctx-&amp;gt;conn_cfg_tag;

    // Return if the automatic connection is disabled.
    if (!p_scan_ctx-&amp;gt;connect_if_match)
    {
        return;
    }

    // Stop scanning.
    nrf_ble_scan_stop(); 

    memset(&amp;amp;scan_evt, 0, sizeof(scan_evt));

    // Establish connection.
    err_code = sd_ble_gap_connect(p_addr,
                                  p_scan_params,
                                  p_conn_params,
                                  con_cfg_tag);

    NRF_LOG_INFO(&amp;quot;Connecting&amp;quot;);

    scan_evt.scan_evt_id                    = NRF_BLE_SCAN_EVT_CONNECTING_ERROR;
    scan_evt.params.connecting_err.err_code = err_code;

    NRF_LOG_INFO(&amp;quot;Connection status: %d&amp;quot;, err_code);

    // If an error occurred, send an event to the event handler.
    if ((err_code != NRF_SUCCESS) &amp;amp;&amp;amp; (p_scan_ctx-&amp;gt;evt_handler != NULL))
    {
        p_scan_ctx-&amp;gt;evt_handler(&amp;amp;scan_evt);
    }

}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Here in this function&amp;nbsp;nrf_ble_scan_stop() is called. My doubt is when peripheral-1 is detected, the central goes into this function and&amp;nbsp;&lt;span&gt;nrf_ble_scan_stop() is called and it connects to peripheral-1. Now as&amp;nbsp;nrf_ble_scan_stop is called the central device does not look for the peripheral-2 and does not connect to it. Am I right?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks &amp;amp; Regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Snehal&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SD GATT procedure failed on Central device.</title><link>https://devzone.nordicsemi.com/thread/432176?ContentTypeID=1</link><pubDate>Wed, 21 Jun 2023 06:33:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6db12007-098f-4ac0-8da4-1be671dba771</guid><dc:creator>Susheel Nuguru</dc:creator><description>[quote user="snehal_2789"]Can we handle this? Can we set some interval somewhere so that connection to peripherals happen one by one?[/quote]
&lt;p&gt;When two devices are connected then the connection events will be multiplexed over time. Also it should not be possible to lose packets in a connection in BLE. So the main question here is that if the central 2 is transmitting the data in the connection2 and the peripheral2 is not able to process it or if the central2 is not able to transmit data at all?&lt;/p&gt;
&lt;p&gt;You need to see the sniffer log to get the answer to the above questions.&lt;/p&gt;
&lt;p&gt;If the central2 is transmitting data, then there is some issue with the context in which peripheral2 is processing data. Maybe there is a deadlock or peripheral1 data processing is startving peripheral2 data processing?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SD GATT procedure failed on Central device.</title><link>https://devzone.nordicsemi.com/thread/431888?ContentTypeID=1</link><pubDate>Tue, 20 Jun 2023 07:35:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:96f18233-c400-42ba-8b10-abd865e77587</guid><dc:creator>sne_333</dc:creator><description>&lt;p&gt;Hi Susheel,&lt;/p&gt;
&lt;p&gt;Actually I have identified the issue. I have set scan name filter in my central firmware. Name filter includes 2 peripheral devices. Now the problem is when the scanning starts, the central device scans both and tries to connect to both of them at a time. During this process some packets of one of the&amp;nbsp;peripheral device&amp;nbsp;&amp;nbsp;are lost and it doesn&amp;#39;t complete full cycle of connection due to this only pne peripheral is connected properly. In the central logs it shows me that&amp;nbsp;both peripherals initiated connection but no packets are received from the peripheral 2. I can see only peripheral 1 packets.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Can we handle this? Can we set some interval somewhere so that connection to peripherals happen one by one?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks &amp;amp; Regards,&lt;/p&gt;
&lt;p&gt;Snehal&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SD GATT procedure failed on Central device.</title><link>https://devzone.nordicsemi.com/thread/430346?ContentTypeID=1</link><pubDate>Mon, 12 Jun 2023 06:29:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d4dc01bc-29e4-4177-b9a2-7854005014d3</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;That is not easy to answer without knowing why the other peripheral does not connect. Do you have any error code when the central sends a connect request or is it just a connect request timed out?&lt;/p&gt;
&lt;p&gt;Are you sending the connect request from the central on receiving the adv packet or is there different logic on how you send the connect request?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SD GATT procedure failed on Central device.</title><link>https://devzone.nordicsemi.com/thread/430187?ContentTypeID=1</link><pubDate>Fri, 09 Jun 2023 10:26:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:faa2aa1f-87d8-4282-b843-c1bdc95cd4dc</guid><dc:creator>sne_333</dc:creator><description>&lt;p&gt;Hi Susheel,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;I have solved the GATT error. But still if there are 2 peripherals sometimes only one gets connected to the central. My configuration for central is as follows:-&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#define APP_BLE_OBSERVER_PRIO               3                                       /**&amp;lt; Application&amp;#39;s BLE observer priority. You shouldn&amp;#39;t need to modify this value. */
#define APP_BLE_CONN_CFG_TAG                1                                       /**&amp;lt; A tag identifying the SoftDevice BLE configuration. */

#define APP_ADV_INTERVAL                    300                                     /**&amp;lt; The advertising interval (in units of 0.625 ms. This value corresponds to 187.5 ms). */
#define APP_ADV_DURATION                    0                                       /**&amp;lt; The advertising duration (180 seconds) in units of 10 milliseconds. */

#define RTC_INTERVAL                        1000                                    /**&amp;lt; RTC interval (ms). */

#define MIN_CONN_INTERVAL                   MSEC_TO_UNITS(200, UNIT_1_25_MS)        /**&amp;lt; Minimum acceptable connection interval (0.4 seconds). */
#define MAX_CONN_INTERVAL                   MSEC_TO_UNITS(300, UNIT_1_25_MS)        /**&amp;lt; Maximum acceptable connection interval (0.65 second). */



#define SLAVE_LATENCY                       4                                       /**&amp;lt; Slave latency. */
#define CONN_SUP_TIMEOUT                    MSEC_TO_UNITS(5000, UNIT_10_MS)         /**&amp;lt; Connection supervisory time-out (4 seconds). */

#define FIRST_CONN_PARAMS_UPDATE_DELAY      5000                                    /**&amp;lt; Time from initiating event (connect or start of notification) to first time sd_ble_gap_conn_param_update is called (5 seconds). */
#define NEXT_CONN_PARAMS_UPDATE_DELAY       30000                                   /**&amp;lt; Time between each call to sd_ble_gap_conn_param_update after the first call (30 seconds). */
#define MAX_CONN_PARAMS_UPDATE_COUNT        3                                       /**&amp;lt; Number of attempts before giving up the connection parameter negotiation. */



#define NRF_BLE_SCAN_SCAN_INTERVAL 160
#define NRF_BLE_SCAN_SCAN_DURATION 0
#define NRF_BLE_SCAN_SCAN_WINDOW 80
#define NRF_BLE_SCAN_MIN_CONNECTION_INTERVAL 7.5
#define NRF_BLE_SCAN_MAX_CONNECTION_INTERVAL 30
#define NRF_BLE_SCAN_SLAVE_LATENCY 0
#define NRF_BLE_SCAN_SUPERVISION_TIMEOUT 4000
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Can we modify any config to get a stable connection from all peripherals?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SD GATT procedure failed on Central device.</title><link>https://devzone.nordicsemi.com/thread/425014?ContentTypeID=1</link><pubDate>Thu, 11 May 2023 07:10:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:42be0c08-cc7e-43b7-bdee-b654e5affde0</guid><dc:creator>sne_333</dc:creator><description>&lt;p&gt;Sorry Susheel I dont have sniffer.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SD GATT procedure failed on Central device.</title><link>https://devzone.nordicsemi.com/thread/425012?ContentTypeID=1</link><pubDate>Thu, 11 May 2023 07:05:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:41eb2b61-63d7-4733-9869-df2a5d4e887e</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Thanks Snehal,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Sniffer logs will help understand the problem better and faster.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SD GATT procedure failed on Central device.</title><link>https://devzone.nordicsemi.com/thread/424398?ContentTypeID=1</link><pubDate>Tue, 09 May 2023 04:07:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0f7c59bf-cb44-443c-a897-e1bfbc02adfd</guid><dc:creator>sne_333</dc:creator><description>&lt;p&gt;Hi Hieu,&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; I have attached the main and central file over here.&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/Gmain.c"&gt;devzone.nordicsemi.com/.../Gmain.c&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/2335.central.c"&gt;devzone.nordicsemi.com/.../2335.central.c&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The&amp;nbsp;gatt_error_handler handler is called from 2 functions from the service initialization file.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/service1.c"&gt;devzone.nordicsemi.com/.../service1.c&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The&amp;nbsp;request_err_code_handle is called in &amp;quot;request_process&amp;quot; &amp;amp; &amp;quot;queue_process&amp;quot; functions from where the error is seen in logs.&lt;/p&gt;
&lt;p&gt;Regarding logs I will capture it today and send you.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks &amp;amp; Regards,&lt;/p&gt;
&lt;p&gt;Snehal.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SD GATT procedure failed on Central device.</title><link>https://devzone.nordicsemi.com/thread/424376?ContentTypeID=1</link><pubDate>Mon, 08 May 2023 20:20:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:837205b5-9d1c-488c-b35e-64a09bc5c0c0</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;Hi Snehal,&lt;/p&gt;
&lt;p&gt;I see, I didn&amp;#39;t know the first connection work, and only the second one failed. Does this happen consistently?&lt;/p&gt;
&lt;p&gt;I think the issue likely lies at the other part of your code.&lt;/p&gt;
&lt;p&gt;I&amp;nbsp;wonder if perhaps your write attempts would always try to write to both peripherals. Meanwhile, right after connection of the second peripheral,&amp;nbsp;there are still setup activities, such as MTU Exchange and Connection Parameters negotiation, and that causes a write attempt to time out.&lt;/p&gt;
&lt;p&gt;However, without details, that is just speculation.&amp;nbsp;Of course, full source file would help, but&amp;nbsp;let&amp;#39;s&amp;nbsp;look at some&amp;nbsp;key points&amp;nbsp;first before we eventually get there. Could you please provide these pieces of information?&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;What the nrf_ble_gq** function call, which results in the error, is, and how is it called?&lt;/li&gt;
&lt;li&gt;As much details as possible about the timing of those functions in relation to the connected event&lt;/li&gt;
&lt;li&gt;Full log&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;By the way, not relevant to the issue, but the implementation of&amp;nbsp;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;gatt_evt_handler()&lt;/span&gt; that you took from the SDK is flawed because it would log &amp;quot;&lt;em&gt;ATT MTU exchange completed...&lt;/em&gt;&amp;quot; even for non-MTU events.&amp;nbsp;Perhaps you could update it after we are done with this issue.&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Hieu&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SD GATT procedure failed on Central device.</title><link>https://devzone.nordicsemi.com/thread/424205?ContentTypeID=1</link><pubDate>Mon, 08 May 2023 10:17:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:556f0ba4-74db-498c-a02d-efbe32c5bb54</guid><dc:creator>sne_333</dc:creator><description>&lt;p&gt;Hi Hieu,&lt;/p&gt;
&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;This error happens &lt;span&gt;during connection establishment. My Gatt initialization is as follows:-&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void gatt_evt_handler(nrf_ble_gatt_t * p_gatt, nrf_ble_gatt_evt_t const * p_evt)
{
    if ((m_conn_handle == p_evt-&amp;gt;conn_handle) &amp;amp;&amp;amp; (p_evt-&amp;gt;evt_id == NRF_BLE_GATT_EVT_ATT_MTU_UPDATED))
    {        
        sys_set_peripheral_mtu(p_evt-&amp;gt;params.att_mtu_effective - OPCODE_LENGTH - HANDLE_LENGTH);

        NRF_LOG_INFO(&amp;quot;Data len is set to 0x%X(%d)&amp;quot;, sys_get_peripheral_mtu(), sys_get_peripheral_mtu());
        NRF_LOG_PROCESS();
    }
    NRF_LOG_INFO(&amp;quot;ATT MTU exchange completed. central 0x%x peripheral 0x%x&amp;quot;,
                  p_gatt-&amp;gt;att_mtu_desired_central,
                  p_gatt-&amp;gt;att_mtu_desired_periph);
    NRF_LOG_PROCESS();
}



/**@brief Function for initializing the GATT module. */
static void gatt_init(void)
{
    ret_code_t err_code = nrf_ble_gatt_init(&amp;amp;m_gatt, gatt_evt_handler);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_ble_gatt_att_mtu_central_set(&amp;amp;m_gatt, NRF_SDH_BLE_GATT_MAX_MTU_SIZE);
    APP_ERROR_CHECK(err_code);
}
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;After successful&amp;nbsp;connection&amp;nbsp;the sensors&amp;nbsp;send the device status to the central.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Could it be that you initiate the write too early/before the connection is fully established, such as along with the function to connect?&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&amp;gt;&amp;gt; But then why does one sensor connect and the other fails?? If writes are performed too early then the central should get disconnected for both I guess.&lt;/p&gt;
&lt;p&gt;Also I have a scan filter in central firmware. It scans from the stored list of names to get connected to the devices nearby.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks &amp;amp; Regards,&lt;/p&gt;
&lt;p&gt;Snehal&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SD GATT procedure failed on Central device.</title><link>https://devzone.nordicsemi.com/thread/424200?ContentTypeID=1</link><pubDate>Mon, 08 May 2023 10:06:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:850c551d-04c3-4a86-8666-768d8c0bff39</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;Hi Snehal,&lt;/p&gt;
&lt;p&gt;How are you setting up the GATT Writes on your central?&lt;/p&gt;
&lt;p&gt;Does this error happen a while after the connection is established, or during connection establishment?&lt;/p&gt;
[quote user=""]00&amp;gt; &amp;lt;error&amp;gt; nrf_ble_gq: SD GATT procedure (2) failed on connection handle 1 with error: 0x0000000D.[/quote]
&lt;p&gt;This line says that &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/group__nrf__ble__gq.html#ga971f4059443852d6c070e9f48a2cb66d"&gt;a GATT Write procedure&lt;/a&gt; &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s140.api.v7.2.0/group__nrf__error.html#gaf3ac440fa84dedc1a80baab36da36f80"&gt;timed out&lt;/a&gt;. Do you have any idea what&amp;nbsp;write procedure is happening here?&lt;/p&gt;
&lt;p&gt;Could it be that you initiate the write too early/before the connection is fully established, such as along with the function to connect?&lt;/p&gt;
&lt;p&gt;Hieu&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>