<?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>Got an error (err_code is 18) when I started the non-connectable advertising at the event &amp;#39;BLE_GAP_EVT_CONNECTED&amp;#39;</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/106175/got-an-error-err_code-is-18-when-i-started-the-non-connectable-advertising-at-the-event-ble_gap_evt_connected</link><description>Hi, 
 In our project, our BLE peripheral device using NRF52833 would like to keep broadcasting its advertisement packet to the BLE central devices even while it is in an active BLE connection. 
 I am using the nRF5 SDK 17.1.0 and reference examples/ble_peripheral</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 04 Dec 2023 12:37:06 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/106175/got-an-error-err_code-is-18-when-i-started-the-non-connectable-advertising-at-the-event-ble_gap_evt_connected" /><item><title>RE: Got an error (err_code is 18) when I started the non-connectable advertising at the event 'BLE_GAP_EVT_CONNECTED'</title><link>https://devzone.nordicsemi.com/thread/458725?ContentTypeID=1</link><pubDate>Mon, 04 Dec 2023 12:37:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:09c5ca3a-adb5-4482-9ed8-9f6219e27e95</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Thanks for sharing!&lt;/p&gt;
&lt;p&gt;I did a diff, to see what was changed, and see that all needed was adding one line and slightly changing another line. So for anyone wanting to do the same:&lt;/p&gt;
&lt;p&gt;Store the advertising type at the beginning of ble_advertising_start() with&lt;/p&gt;
&lt;p&gt;&lt;code&gt;uint8_t properties_type = p_advertising-&amp;gt;adv_params.properties.type;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;then after initializing advertising parameters with default values instead of&lt;/p&gt;
&lt;p&gt;&lt;code&gt;p_advertising-&amp;gt;adv_params.properties.type = BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;you instead use the type stored from earlier:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;p_advertising-&amp;gt;adv_params.properties.type = properties_type;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;That way, you can still use the advertising module also for non-connectable advertising.&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Terje&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Got an error (err_code is 18) when I started the non-connectable advertising at the event 'BLE_GAP_EVT_CONNECTED'</title><link>https://devzone.nordicsemi.com/thread/458634?ContentTypeID=1</link><pubDate>Mon, 04 Dec 2023 01:54:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6eb8a4ce-98d3-47c4-bc27-6761ee7f4cce</guid><dc:creator>Terry</dc:creator><description>&lt;p&gt;I updated the code as below:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;uint32_t ble_advertising_start(ble_advertising_t * const p_advertising,                                      ble_adv_mode_t            advertising_mode){    uint32_t ret;    uint8_t properties_type = p_advertising-&amp;gt;adv_params.properties.type;    if (p_advertising-&amp;gt;initialized == false)    {        return NRF_ERROR_INVALID_STATE;    }    p_advertising-&amp;gt;adv_mode_current = advertising_mode;    memset(&amp;amp;p_advertising-&amp;gt;peer_address, 0, sizeof(p_advertising-&amp;gt;peer_address));    if (  ((p_advertising-&amp;gt;adv_modes_config.ble_adv_directed_high_duty_enabled) &amp;amp;&amp;amp; (p_advertising-&amp;gt;adv_mode_current == BLE_ADV_MODE_DIRECTED_HIGH_DUTY))        ||((p_advertising-&amp;gt;adv_modes_config.ble_adv_directed_enabled)           &amp;amp;&amp;amp; (p_advertising-&amp;gt;adv_mode_current == BLE_ADV_MODE_DIRECTED_HIGH_DUTY))        ||((p_advertising-&amp;gt;adv_modes_config.ble_adv_directed_enabled)           &amp;amp;&amp;amp; (p_advertising-&amp;gt;adv_mode_current == BLE_ADV_MODE_DIRECTED))       )    {        if (p_advertising-&amp;gt;evt_handler != NULL)        {            p_advertising-&amp;gt;peer_addr_reply_expected = true;            p_advertising-&amp;gt;evt_handler(BLE_ADV_EVT_PEER_ADDR_REQUEST);        }        else        {            p_advertising-&amp;gt;peer_addr_reply_expected = false;        }    }    p_advertising-&amp;gt;adv_mode_current = adv_mode_next_avail_get(p_advertising, advertising_mode);    // Fetch the whitelist.    if ((p_advertising-&amp;gt;evt_handler != NULL) &amp;amp;&amp;amp;        (p_advertising-&amp;gt;adv_mode_current == BLE_ADV_MODE_FAST || p_advertising-&amp;gt;adv_mode_current == BLE_ADV_MODE_SLOW) &amp;amp;&amp;amp;        (p_advertising-&amp;gt;adv_modes_config.ble_adv_whitelist_enabled) &amp;amp;&amp;amp;        (!p_advertising-&amp;gt;whitelist_temporarily_disabled))    {        p_advertising-&amp;gt;whitelist_in_use         = false;        p_advertising-&amp;gt;whitelist_reply_expected = true;        p_advertising-&amp;gt;evt_handler(BLE_ADV_EVT_WHITELIST_REQUEST);    }    else    {        p_advertising-&amp;gt;whitelist_reply_expected = false;    }    // Initialize advertising parameters with default values.    memset(&amp;amp;p_advertising-&amp;gt;adv_params, 0, sizeof(p_advertising-&amp;gt;adv_params));    p_advertising-&amp;gt;adv_params.properties.type = properties_type;    // Use 1MBIT as primary phy if no phy was selected.    if (phy_is_valid(&amp;amp;p_advertising-&amp;gt;adv_modes_config.ble_adv_primary_phy))    {        p_advertising-&amp;gt;adv_params.primary_phy = p_advertising-&amp;gt;adv_modes_config.ble_adv_primary_phy;    }    else    {        p_advertising-&amp;gt;adv_params.primary_phy = BLE_GAP_PHY_1MBPS;    }    if (p_advertising-&amp;gt;adv_modes_config.ble_adv_extended_enabled)    {        // Use 1MBIT as secondary phy if no phy was selected.        if (phy_is_valid(&amp;amp;p_advertising-&amp;gt;adv_modes_config.ble_adv_secondary_phy))        {            p_advertising-&amp;gt;adv_params.secondary_phy = p_advertising-&amp;gt;adv_modes_config.ble_adv_secondary_phy;        }        else        {            p_advertising-&amp;gt;adv_params.secondary_phy = BLE_GAP_PHY_1MBPS;        }    }    p_advertising-&amp;gt;adv_params.filter_policy = BLE_GAP_ADV_FP_ANY;    // Set advertising parameters and events according to selected advertising mode.    switch (p_advertising-&amp;gt;adv_mode_current)    {        case BLE_ADV_MODE_DIRECTED_HIGH_DUTY:            ret = set_adv_mode_directed_high_duty(p_advertising, &amp;amp;p_advertising-&amp;gt;adv_params);            break;        case BLE_ADV_MODE_DIRECTED:            ret = set_adv_mode_directed(p_advertising, &amp;amp;p_advertising-&amp;gt;adv_params);            break;        case BLE_ADV_MODE_FAST:            ret = set_adv_mode_fast(p_advertising, &amp;amp;p_advertising-&amp;gt;adv_params);            break;        case BLE_ADV_MODE_SLOW:            ret = set_adv_mode_slow(p_advertising, &amp;amp;p_advertising-&amp;gt;adv_params);            break;        case BLE_ADV_MODE_IDLE:            p_advertising-&amp;gt;adv_evt = BLE_ADV_EVT_IDLE;            break;        default:            break;    }    if (p_advertising-&amp;gt;adv_mode_current != BLE_ADV_MODE_IDLE)    {        ret = sd_ble_gap_adv_set_configure(&amp;amp;p_advertising-&amp;gt;adv_handle, p_advertising-&amp;gt;p_adv_data, &amp;amp;p_advertising-&amp;gt;adv_params);        if (ret != NRF_SUCCESS)        {            return ret;        }        ret = sd_ble_gap_adv_start(p_advertising-&amp;gt;adv_handle, p_advertising-&amp;gt;conn_cfg_tag);        if (ret != NRF_SUCCESS)        {            return ret;        }    }    if (p_advertising-&amp;gt;evt_handler != NULL)    {        p_advertising-&amp;gt;evt_handler(p_advertising-&amp;gt;adv_evt);    }    return NRF_SUCCESS;}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Got an error (err_code is 18) when I started the non-connectable advertising at the event 'BLE_GAP_EVT_CONNECTED'</title><link>https://devzone.nordicsemi.com/thread/458471?ContentTypeID=1</link><pubDate>Fri, 01 Dec 2023 09:51:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:843b0cb8-1398-4cfd-ab27-38e56626ae4c</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Do you mind sharing what you did to fix this?&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Terje&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Got an error (err_code is 18) when I started the non-connectable advertising at the event 'BLE_GAP_EVT_CONNECTED'</title><link>https://devzone.nordicsemi.com/thread/458426?ContentTypeID=1</link><pubDate>Fri, 01 Dec 2023 03:22:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:253a7c76-af82-4057-b0f2-d687ea427443</guid><dc:creator>Terry</dc:creator><description>&lt;p&gt;Hi All,&lt;/p&gt;
&lt;p&gt;Finally, I updated&amp;nbsp;ble_advertising.c and fixed this issue. Also, I reverted&amp;nbsp;&lt;span&gt;NRF_SDH_BLE_PERIPHERAL_LINK_COUNT&amp;nbsp;to 1 and&amp;nbsp;NRF_SDH_BLE_TOTAL_LINK_COUNT to 1.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Got an error (err_code is 18) when I started the non-connectable advertising at the event 'BLE_GAP_EVT_CONNECTED'</title><link>https://devzone.nordicsemi.com/thread/458199?ContentTypeID=1</link><pubDate>Thu, 30 Nov 2023 02:09:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:45f40aef-6a95-466c-a8d2-533f06bc67cd</guid><dc:creator>Terry</dc:creator><description>&lt;p&gt;Hi Turbo J,&lt;/p&gt;
&lt;p&gt;Thanks for your information.&lt;/p&gt;
&lt;p&gt;I updated&amp;nbsp;&lt;span&gt;NRF_SDH_BLE_PERIPHERAL_LINK_COUNT&amp;nbsp;to 2 and&amp;nbsp;NRF_SDH_BLE_TOTAL_LINK_COUNT to 2 and rebuilt the FW.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;It seems OK. However, if the second advertisement (non-connectable) is tried to connect by another central device, there is a fatal error raised.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;For my application, I only need one connection.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Please advise. Thanks!&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Got an error (err_code is 18) when I started the non-connectable advertising at the event 'BLE_GAP_EVT_CONNECTED'</title><link>https://devzone.nordicsemi.com/thread/458086?ContentTypeID=1</link><pubDate>Wed, 29 Nov 2023 12:25:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1838e50c-fe22-4616-8982-2d12e7e0f4fe</guid><dc:creator>Turbo J</dc:creator><description>&lt;p&gt;You would need to configure the softdevice for 2 peripherial connections, that is why you got the NRF_ERROR_CONN_COUNT error.&lt;/p&gt;
&lt;p&gt;Try increasing NRF_SDH_BLE_PERIPHERAL_LINK_COUNT and NRF_SDH_BLE_TOTAL_LINK_COUNT. This will consume more RAM for the sd.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>