<?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>When I add 2 &amp;quot;service data&amp;quot; in the gap, only the second is showed</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/55106/when-i-add-2-service-data-in-the-gap-only-the-second-is-showed</link><description>Hi all, ( nRF52 DK, SDK 15.3, S132 ) 
 Many asking about how to add 2 &amp;quot;service data&amp;quot; in the GAP advertising, but no real answer on the solution ! 
 The first service data is a Battery level and is working well, but when I add a second service data this</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 04 Dec 2019 09:10:35 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/55106/when-i-add-2-service-data-in-the-gap-only-the-second-is-showed" /><item><title>RE: When I add 2 "service data" in the gap, only the second is showed</title><link>https://devzone.nordicsemi.com/thread/223503?ContentTypeID=1</link><pubDate>Wed, 04 Dec 2019 09:10:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f0e1a22d-da67-4bfa-a3bd-235c6a6c4c47</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Please look for &amp;quot;Configuring advertising parameters for an advertising set&amp;quot; inside the migration document pdf file for s132_nrf52_6.0.0. It&amp;#39;s located in&amp;nbsp;\components\softdevice\s132\doc&amp;nbsp;&lt;/p&gt;
&lt;p&gt;We have example code for&amp;nbsp;&lt;span&gt;sd_ble_gap_adv_set_configure() function.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I have a blog &lt;a href="https://devzone.nordicsemi.com/nordic/nordic-blog/b/blog/posts/bluetooth-smart-and-the-nordics-softdevices-part-1"&gt;here &lt;/a&gt;that I created long time ago, the APIs have changed, but you can&amp;nbsp;get some information&amp;nbsp;about advertising data packet.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When I add 2 "service data" in the gap, only the second is showed</title><link>https://devzone.nordicsemi.com/thread/223412?ContentTypeID=1</link><pubDate>Tue, 03 Dec 2019 17:01:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6ed70832-e981-4155-ae5d-3c4eed0795ca</guid><dc:creator>Jean-marie</dc:creator><description>&lt;p&gt;Hi Hung,&lt;/p&gt;
&lt;p&gt;Thanks for your reply.&lt;/p&gt;
&lt;p&gt;The first solution is not possible for me, as I&amp;#39;m very, very new in C langage and&amp;nbsp;I do not know the command set needed to carry out this work.&lt;/p&gt;
&lt;p&gt;About the second solution could you provide a working example ? or a snippet with the whole process ?&lt;/p&gt;
&lt;p&gt;Thank you very much for your help, I really need help for that development, Thanks!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&amp;nbsp; &amp;nbsp;Jiemde&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When I add 2 "service data" in the gap, only the second is showed</title><link>https://devzone.nordicsemi.com/thread/223407?ContentTypeID=1</link><pubDate>Tue, 03 Dec 2019 16:16:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a1b80fb2-1af8-4951-8369-a8ea079208a7</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Jiemde,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You would need to encode the service data 128 bit on your own. Please have a look at&amp;nbsp;service_data_encode() function in ble_advdata.c to see how we encode the 16 bit UUID. You need to write a similar function for the 128 bit service data.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you simply want to copy exactly what you have achieved with&amp;nbsp;&lt;span&gt;&amp;nbsp;Zerynth. You can get the raw data packet from that application and then call&amp;nbsp;sd_ble_gap_adv_set_configure() to set the raw advertising data directly, and call&amp;nbsp;sd_ble_gap_adv_start() to start advertising.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;There is no easy way to get around this, you want to achieve something a bit advanced and not supported out of the box in our library. Some understanding on&amp;nbsp; advertising package data encoding is needed.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When I add 2 "service data" in the gap, only the second is showed</title><link>https://devzone.nordicsemi.com/thread/223202?ContentTypeID=1</link><pubDate>Tue, 03 Dec 2019 06:57:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:95cd9713-f7f4-4caa-baf7-4b9120bccb81</guid><dc:creator>Jean-marie</dc:creator><description>&lt;p&gt;Hi Hung,&lt;/p&gt;
&lt;p&gt;Many thanks for your fast reply and your code is working ! :))&lt;/p&gt;
&lt;p&gt;It&amp;#39;s not a problem to send you my code but be indulgent I&amp;#39;m very new in C language and Ble is not easy !&lt;/p&gt;
&lt;p&gt;I send you screen capture of the result I must have in final.&lt;/p&gt;
&lt;p&gt;So a service data ( 0x16 ) with the value of the Battery level and an other one&lt;/p&gt;
&lt;p&gt;&lt;img class="align-left" style="float:left;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/5315.Screenshot_5F00_20191011_5F00_165451_5F00_no.nordicsemi.android.mcp.jpg" /&gt;&lt;img class="align-left" style="float:left;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/3056.Screenshot_5F00_20191011_5F00_165503_5F00_no.nordicsemi.android.mcp.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;service data ( 0x21 )&amp;nbsp;with 128Bit UUID with 4 bytes of data ( in fac the 4 last bytes of the Mac address ! )&lt;/p&gt;
&lt;p&gt;In total I use 30 bytes! so can be advertise in a simple GAP.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;As you say in your reply &amp;quot;&lt;span&gt;&lt;strong&gt;The library only support service data 16 bit (ADType 0x16&lt;/strong&gt;).&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;So what do you propose for solve my need ?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;How can I send you my code file ?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Hope you can help me.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Jiemde&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: When I add 2 "service data" in the gap, only the second is showed</title><link>https://devzone.nordicsemi.com/thread/223145?ContentTypeID=1</link><pubDate>Mon, 02 Dec 2019 16:54:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:71db7d2e-1271-4656-b7a9-a67951c2273c</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Jean-Marie,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Could you send the code you used ?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Note that if you use&amp;nbsp;&amp;nbsp;ble_advertising library with&amp;nbsp;&amp;nbsp;ble_advertising_init() function, we don&amp;#39;t support the 128 bit service data (AD Type 0x21) yet.&amp;nbsp;The library only support service data 16 bit (ADType 0x16).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you want to advertise with 128 bit UUID service data, you would need to either modify the library, or prepare the raw advertising packet from scratch.&lt;/p&gt;
&lt;p&gt;There is a big chance that the advertising packet is not enough (31 bytes max) and you would need to use the scan response to advertise the 2nd service data (use&amp;nbsp;srdata in addition to advdata)&amp;nbsp;&amp;nbsp;&lt;br /&gt;This code worked for me with 2 16 bit service data:&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt; ret_code_t             err_code;
    ble_advertising_init_t init;
    static ble_advdata_service_data_t service_data_array[2];
    static uint8_array_t data_array1,data_array2;
    static uint8_t data1[3]={1,2,3};
    static uint8_t data2[3]={3,4,5};
    data_array1.size=3;
    data_array1.p_data=data1;
    
    data_array2.size=3;
    data_array2.p_data=data2;
    service_data_array[0].service_uuid= 0x1234;
    service_data_array[1].service_uuid= 0x5678;
    service_data_array[0].data=data_array1;
    service_data_array[1].data=data_array2;
    memset(&amp;amp;init, 0, sizeof(init));

    init.advdata.name_type               = BLE_ADVDATA_FULL_NAME;
    init.advdata.include_appearance      = true;
    init.advdata.flags                   = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
    init.advdata.p_service_data_array=service_data_array;
    init.advdata.service_data_count=2;
        init.config.ble_adv_fast_enabled  = true;
    init.config.ble_adv_fast_interval = APP_ADV_INTERVAL;
    init.config.ble_adv_fast_timeout  = APP_ADV_DURATION;

    init.evt_handler = on_adv_evt;

    err_code = ble_advertising_init(&amp;amp;m_advertising, &amp;amp;init);
    APP_ERROR_CHECK(err_code);

    ble_advertising_conn_cfg_tag_set(&amp;amp;m_advertising, APP_BLE_CONN_CFG_TAG);&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>