<?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>SoftDevice s110 AND s130 have issues with scanResponse in advertisement?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/70019/softdevice-s110-and-s130-have-issues-with-scanresponse-in-advertisement</link><description>I know that SoftDevice 110 is old but I am stuck with it as it is on a production device with nRF51822. For some reason when I call sd_ble_gap_adv_data_set() with a non NULL value of the parameter uint8_t const * const p_sr_data which is the scan response</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 11 Jan 2021 00:23:54 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/70019/softdevice-s110-and-s130-have-issues-with-scanresponse-in-advertisement" /><item><title>RE: SoftDevice s110 AND s130 have issues with scanResponse in advertisement?</title><link>https://devzone.nordicsemi.com/thread/288287?ContentTypeID=1</link><pubDate>Mon, 11 Jan 2021 00:23:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:73d29e94-4f65-4d28-b632-6485557bd120</guid><dc:creator>brianreinhold</dc:creator><description>&lt;p&gt;The same text appears in all the &amp;#39;h&amp;#39; files and SoftDevice API docs that I have read. The funny thing when I use the pc-ble-driver for the nRF52840 dongle I duplicated the flags and local name in the scan response &lt;strong&gt;and it worked&lt;/strong&gt;. Since that was my first experience with Nordic chips I assumed my interpretation of the documentation was correct and I carried that code to this.&lt;/p&gt;
&lt;p&gt;In desperation I started looking at the SDK to try and find out what was wrong and stumbled on that comment. Solved the problem but it seems the &amp;#39;limitation&amp;#39; no longer applies in s140 v 6. Or at least if one uses the pc-ble-driver.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SoftDevice s110 AND s130 have issues with scanResponse in advertisement?</title><link>https://devzone.nordicsemi.com/thread/288283?ContentTypeID=1</link><pubDate>Sun, 10 Jan 2021 23:45:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:85e636a6-2070-419b-8fd6-30c3b4dd0bf7</guid><dc:creator>Joakim Jakobsen</dc:creator><description>&lt;p&gt;Thanks for sharing the solution.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m glad you figured it out.&lt;/p&gt;
&lt;p&gt;Br, &lt;br /&gt;Joakim&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SoftDevice s110 AND s130 have issues with scanResponse in advertisement?</title><link>https://devzone.nordicsemi.com/thread/288260?ContentTypeID=1</link><pubDate>Sat, 09 Jan 2021 13:49:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d15f07f9-007d-40b0-b4a5-451f883c6052</guid><dc:creator>brianreinhold</dc:creator><description>&lt;p&gt;Turns out I read the documentation backwards. The docs say&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Limitations imposed by this API call to the data provided include having a flags data type in the scan response data and&lt;br /&gt; * duplicating the local name in the advertising data and scan response data.&lt;/p&gt;
&lt;p&gt;I read that as the limitation was that you had to do that (&lt;em&gt;something I would not normally do&lt;/em&gt;). But when I looked in the SDK code I saw text which was much clearer. It said simply that you &amp;quot;do not allow flags in scan response&amp;#39; next to an &amp;#39;if&amp;#39; statement. Removing the flags and the name from the scan response solved the problem --- at least for s130.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SoftDevice s110 have issues with scanResponse in advertisement?</title><link>https://devzone.nordicsemi.com/thread/287480?ContentTypeID=1</link><pubDate>Tue, 05 Jan 2021 11:26:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:da053353-a097-436d-8f53-e4a0bba63779</guid><dc:creator>brianreinhold</dc:creator><description>&lt;p&gt;I could upload the entire code but it wont do much good - you can&amp;#39;t run it without the actual physical device. The Bluetooth does not start until the Pulse Ox sensor has given the nRF51822 module a finished sensor value via the serial port.&lt;/p&gt;
&lt;p&gt;In any case, once that is received, these two methods are called, one to create the advertisement data itself and the other to start the advertising:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static ble_gap_adv_params_t     g_adv_params;
static uint8_t                  data_buffer[BUFFER_SIZE];
static uint8_t                  scan_rsp_buffer[BUFFER_SIZE];

uint32_t advertisement_data_set(short int* serviceUuids,
    int length, uint8_t* service128Uuids, const char* friendlyName)
{
    uint32_t error_code;
    uint8_t  index = 0;
    uint8_t  scan_index = 0;
    uint8_t  i = 0;
    memset(data_buffer, 0, sizeof(data_buffer));
    memset(scan_rsp_buffer, 0, sizeof(scan_rsp_buffer));

    const uint8_t name_length = (uint8_t)strlen(friendlyName);

    // Set the flags - important to indicate no EDR/BR support for some Androids
    // Actually by spec one is SUPPOSED to set one of the discoverable flags to be discoverable.
    data_buffer[index++] = 2;        // length of flags data type
    data_buffer[index++] = BLE_GAP_AD_TYPE_FLAGS;
    data_buffer[index++] = BLE_GAP_ADV_FLAG_LE_GENERAL_DISC_MODE | BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED;    // No EDR/BR support and general discoverable

    // Set the device name.
    if (friendlyName != NULL)
    {
        data_buffer[index++] = name_length + 1; // Device name + data type
        data_buffer[index++] = BLE_GAP_AD_TYPE_COMPLETE_LOCAL_NAME;
        memcpy((char*)&amp;amp;data_buffer[index], friendlyName, name_length);
        index += name_length;
    }

    // Set the device full name as a copy in the scan response.
    if (friendlyName != NULL)
    {
        scan_rsp_buffer[scan_index++] = name_length + 1; // Device name + data type
        scan_rsp_buffer[scan_index++] = BLE_GAP_AD_TYPE_COMPLETE_LOCAL_NAME;
        memcpy((char*)&amp;amp;scan_rsp_buffer[scan_index], friendlyName, name_length);
        scan_index += name_length;
    }

    if (serviceUuids != NULL)
    {
        // Set the device&amp;#39;s available services.
        data_buffer[index++] = 1 + 2 * length;
        data_buffer[index++] = BLE_GAP_AD_TYPE_16BIT_SERVICE_UUID_COMPLETE;
        for (i = 0; i &amp;lt; length; i++)
        {
            // Store in little-endian format.
            data_buffer[index++] = serviceUuids[i] &amp;amp; 0xFF;
            data_buffer[index++] = (serviceUuids[i] &amp;amp; 0xFF00) &amp;gt;&amp;gt; 8;
        }
    }

    // Scan response:
    if (service128Uuids != NULL)
    {
        scan_rsp_buffer[scan_index++] = 1 + 16; //(only room for one)
        scan_rsp_buffer[scan_index++] = BLE_GAP_AD_TYPE_128BIT_SERVICE_UUID_MORE_AVAILABLE;
        // Store in little-endian format.
        memcpy(&amp;amp;scan_rsp_buffer[scan_index], service128Uuids, 16);
        scan_index = scan_index + 16;
    }


    error_code = sd_ble_gap_adv_data_set(data_buffer, index, NULL, 0);
   // error_code = sd_ble_gap_adv_data_set(data_buffer, index, scan_rsp_buffer, scan_index); // For some reason scan responses dont work
    APP_ERROR_CHECK(error_code);
    return NRF_SUCCESS;
}

static uint32_t new_advertising_start()
{
    // Used in start advertising:
    memset(&amp;amp;g_adv_params, 0, sizeof(ble_gap_adv_params_t));
    g_adv_params.type = BLE_GAP_ADV_TYPE_ADV_IND; // BLE_GAP_ADV_TYPE_ADV_SCAN_IND;              // general connectable scannable
    g_adv_params.fp = BLE_GAP_ADV_FP_ANY;                           // Any one can scan and connect
    g_adv_params.interval = ADVERTISING_INTERVAL_40_MS;
    g_adv_params.timeout = BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED;   // Advertises until connected
    simple_uart_put(BLE_STATUS_ADVER_START);
    return sd_ble_gap_adv_start(&amp;amp;g_adv_params);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;When I call the method option with a non-null value of the scan array, no advertisement is sent when calling the start method. If I do as coded (not the commented-out variant) then an advertisement is generated.&lt;/p&gt;
&lt;p&gt;The UART calls are just for the sensor module which has control of the display. It is not relevant for the Bluetooth behavior.&lt;/p&gt;
&lt;p&gt;I should also add that this is down ported from an nRF52840 pc-ble-driver module that I wrote (which does work with scan responses). Don&amp;#39;t know if I missed something in my down-port to this old s110 based module.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SoftDevice s110 have issues with scanResponse in advertisement?</title><link>https://devzone.nordicsemi.com/thread/287474?ContentTypeID=1</link><pubDate>Tue, 05 Jan 2021 11:19:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:02c4b8cc-7249-4dc0-aa3f-9f7d332b5227</guid><dc:creator>Joakim Jakobsen</dc:creator><description>&lt;p&gt;Hi.&lt;/p&gt;
&lt;p&gt;Is it possible for you to upload your code? We can turn the ticket private first, if you don&amp;#39;t want to upload your code on the public forum.&lt;/p&gt;
&lt;p&gt;Atleast the code related to advertising and your main() could be useful.&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t know of any known issues regarding scan response on s110.&lt;/p&gt;
&lt;p&gt;Br, &lt;br /&gt;Joakim&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>