<?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>FULLY Custom Advertisement Data</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/8854/fully-custom-advertisement-data</link><description>hi everyone.
we are migrating to nordic nrf51 series (before we used ble modules from another vendor blugiga which depends on cc2541 chip) so I m pretty new at nordic nrf51 series. 
 we had a working solution with that modules based on fully custom</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 24 Aug 2015 12:01:02 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/8854/fully-custom-advertisement-data" /><item><title>RE: FULLY Custom Advertisement Data</title><link>https://devzone.nordicsemi.com/thread/32548?ContentTypeID=1</link><pubDate>Mon, 24 Aug 2015 12:01:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c0d98ced-519c-47eb-a0b3-da28ad53197a</guid><dc:creator>Carles</dc:creator><description>&lt;p&gt;Hi there,&lt;/p&gt;
&lt;p&gt;Just to clarify some points:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;The SoftDevice does &lt;strong&gt;not&lt;/strong&gt; verify if the advertising flags are present or not, you can have advertising data and scan response data &lt;strong&gt;without&lt;/strong&gt; any flags at all&lt;/li&gt;
&lt;li&gt;The only aspect of the advertising data that is &lt;strong&gt;strictly&lt;/strong&gt; enforced is the &amp;quot;triplet&amp;quot; format. You need to comply with the [size, type, &lt;data&gt;] format that is described in the spec&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This means that if you want to take all 31 bytes, you won&amp;#39;t be able to, but you can easily use 29 of them for whatever you want:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;  uint8_t adata[31];
  memset(adata, 0x00, sizeof(adata));
  adata[0] = 30;
  adata[1] = BLE_GAP_AD_TYPE_MANUFACTURER_SPECIFIC_DATA;
  // now fill the 29 bytes with whatever you want
  for(i = 2; i &amp;lt; sizeof(adata); i++)
    adata[i] = i;

  retv = sd_ble_gap_adv_data_set(adata, sizeof(adata), NULL, 0);
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FULLY Custom Advertisement Data</title><link>https://devzone.nordicsemi.com/thread/32552?ContentTypeID=1</link><pubDate>Fri, 21 Aug 2015 14:20:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:40e57a50-bc81-4e43-9ed2-4be53906ed20</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;Hi Martin, many thanks for the update. Sorry for being picky but I see that your example contains AD_FLAGS element at the beginning:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;// flags for discoverable/connectable
    adv_data[0] = 0x02; // ad field length = 2 bytes
    adv_data[1] = 0x01;   // ad field type = 0x01 [Flags)
    adv_data[2] = 0x06; // flags = 0x06, connectable/undirected
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is compliant to BT SIG specification but what if we want to do non-compliant advertisement (= or just avoiding GAP/GATT compliancy but rely on L2CAP and other parts of BT Smart stack)? Could you check if you can realy put any 31-byte &amp;quot;rubbish&amp;quot; string to the adv data?&lt;/p&gt;
&lt;p&gt;Thanks Jan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FULLY Custom Advertisement Data</title><link>https://devzone.nordicsemi.com/thread/32553?ContentTypeID=1</link><pubDate>Fri, 21 Aug 2015 14:19:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7e240259-5a54-49d2-818f-fd23d7748408</guid><dc:creator>Marius Heil</dc:creator><description>&lt;p&gt;The sd_ble_gap_adv_data_set() function will check if your advertising packet conforms to the Bluetooth standard and will run some checks on it. If you want to build an advertising packet that is compatible with the BLE specification, that works, but non-compatible packets will fail.&lt;/p&gt;
&lt;p&gt;I am not too sure about whether the flags need to be included. The latest BLE addendum allows to leave the flags field empty if it is a non-connectable advertising message, but I guess that they have not yet implemented this.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FULLY Custom Advertisement Data</title><link>https://devzone.nordicsemi.com/thread/32551?ContentTypeID=1</link><pubDate>Fri, 21 Aug 2015 13:54:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f8a14d43-a144-4b5e-bb92-ba1146d67520</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;Hi Martin, I&amp;#39;ve understood there is no way to avoid setting AD_FLAGS element on nRF51 when using S110/S120/S130 stacks. Is it correct? Thanks Jan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FULLY Custom Advertisement Data</title><link>https://devzone.nordicsemi.com/thread/32550?ContentTypeID=1</link><pubDate>Fri, 21 Aug 2015 13:05:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4a8df313-ce07-48dd-8621-d2c99e6d5761</guid><dc:creator>samet kocatepe</dc:creator><description>&lt;p&gt;hi martin. thank you for fast reply. fully custom advertisement means that , users can create their own advertisement data up to 31 bytes freely. in their forum there is an example named as &amp;quot;custom_advertisement&amp;quot; . &lt;a href="https://bluegiga.zendesk.com/entries/23130518--BGScript-custom-advertisement-Custom-advertisement-packet-creation"&gt;link text&lt;/a&gt;you can reach example .( in zip file open .bgs with notepad++ ).regards.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FULLY Custom Advertisement Data</title><link>https://devzone.nordicsemi.com/thread/32549?ContentTypeID=1</link><pubDate>Fri, 21 Aug 2015 12:27:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:40310a7b-a931-4b7c-831d-4155cbe1b3e2</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Hi. I&amp;#39;m not really sure what you mean by &lt;em&gt;fully custom&lt;/em&gt;, but &lt;a href="https://devzone.nordicsemi.com/tutorials/5/ble-advertising-a-beginners-tutorial/"&gt;here&lt;/a&gt; is a tutorial on how to initialize advertising and scan response with various information like UUIDs, manufacturer specific data, tx power, etc.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;EDIT:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;You can use &lt;a href="https://developer.nordicsemi.com/nRF51_SDK/nRF51_SDK_v8.x.x/doc/8.1.0/s110/html/a01288.html#gaddbb12e078d536ef2e93b41d77ff6243"&gt;sd_ble_gap_adv_data_set()&lt;/a&gt; to make your own custom advertising and scan response packet. See &lt;a href="https://devzone.nordicsemi.com/question/38057/sd_ble_gap_adv_data_set/"&gt;this&lt;/a&gt; and &lt;a href="https://devzone.nordicsemi.com/question/24611/feedback-confusing-limitation-in-sd_ble_gap_adv_data_set/"&gt;this&lt;/a&gt; semi relevant discussions or &lt;a href="https://devzone.nordicsemi.com/questions/scope%3Aall/sort%3Arelevance-desc/page%3A1/query%3Asd_ble_gap_adv_data_set/"&gt;search devzone for the function&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I tried it very quickly with the following code and it seems to work, but I don&amp;#39;t have time to test it thoroughly and there might very well be a more elegant way to do it.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static void advertising_init(void)
{
    uint32_t      err_code;
    ble_advdata_t advdata;

    // Build advertising data struct to pass into @ref ble_advertising_init.
    memset(&amp;amp;advdata, 0, sizeof(advdata));
    advdata.flags                   = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;

    ble_adv_modes_config_t options = {0};
    options.ble_adv_fast_enabled  = BLE_ADV_FAST_ENABLED;
    options.ble_adv_fast_interval = APP_ADV_INTERVAL;
    options.ble_adv_fast_timeout  = APP_ADV_TIMEOUT_IN_SECONDS;

    err_code = ble_advertising_init(&amp;amp;advdata, NULL, &amp;amp;options, on_adv_evt, NULL);
    APP_ERROR_CHECK(err_code);

    uint8_t adv_data[13] = {0};
    uint8_t sr_data[20] = {0};

    // flags for discoverable/connectable
    adv_data[0] = 0x02; // ad field length = 2 bytes
    adv_data[1] = 0x01;   // ad field type = 0x01 [Flags)
    adv_data[2] = 0x06; // flags = 0x06, connectable/undirected

    // tx power field advertisement, iOS apps may need this
    adv_data[3] = 0x02; // ad field length = 2 bytes
    adv_data[4] = 0x0a;    // ad field type = 0x0A [TX Power)
    adv_data[5] = 0x03; // TX power in dBm
    // NOTE: TX power is a signed 8-bit value, and is not changed automatically
    // when using &amp;quot;hardware_set_txpower[&amp;lt;power&amp;gt;)&amp;quot;. This may be anywhere from -23
    // to +3 based on your settings. Negative values may be converted to two&amp;#39;s
    // complement form by adding 256, so for example -23 dBm would be 233 or 0xE9.
    
    // custom manufacturer
    adv_data[6] = 0x06; // ad field length = 5 bytes [arbitrary, maybe more or less but minimum 3)
    adv_data[7] = 0xff; // ad field type = 0xFF [Manufacturer Specific Data)
    adv_data[8] = 0xff; // unknown/prototype Company Identifier Code - octet 2 
    adv_data[9] = 0xff; // unknown/prototype Company Identifier Code - octet 1 
    adv_data[10] = 0xb1; // custom data byte //1 [can be anything)
    adv_data[11] = 0xb2; // custom data byte //2 [can be anything)
    adv_data[12] = 0xb3; // custom data byte //3 (can be anything)
    // NOTE: manufacturer data fields should contain the Company Identifier Code
    // in order to stay within BT 4.0 spec. You should also ideally obtain an
    // an official Company Identifier Code, but 0xFFFF is suitable for development.
    // (this is why the minimum ad field length for this is 3, so the CIC fits)

    // More bytes are possible here, but not necessary for this demo.
    // Compare with automatically generated ad packets from other
    // demo projects to see what else you might put here, or read
    // the relevant portions of the Bluetooth 4.0 Core Spec document
    // for greater detail.
    
    // -------------------------------
    // build custom scan response data
    // -------------------------------

    // get Bluetooth MAC address of this device (NOTE: this is little-endian!)

    sr_data[0] = 0x13;  // ad field length = 19 bytes (0x13)
    sr_data[1] = 0x09;   // ad field type = 0x09 (Complete local name)
    sr_data[2] = 0x06;  // &amp;#39;M&amp;#39;
    sr_data[3] = 0x79;  // &amp;#39;y&amp;#39;
    sr_data[4] = 0x20;  // &amp;#39; &amp;#39;
    sr_data[5] = 0x57;  // &amp;#39;W&amp;#39;
    sr_data[6] = 0x69;  // &amp;#39;i&amp;#39;
    sr_data[7] = 0x64;  // &amp;#39;d&amp;#39;
    sr_data[8] = 0x67;  // &amp;#39;g&amp;#39;
    sr_data[9] = 0x65;  // &amp;#39;e&amp;#39;
    sr_data[10] = 0x74; // &amp;#39;t&amp;#39;
    sr_data[11] = 0x20; // &amp;#39; &amp;#39;
    sr_data[12] = 0x01;
    sr_data[13] = 0x02;
    sr_data[14] = 0x03;
    sr_data[15] = 0x04;
    sr_data[16] = 0x05;
    sr_data[17] = 0x06;
    sr_data[18] = 0x07;
    sr_data[19] = 0x08;
    
    uint32_t err_code;
    err_code = sd_ble_gap_adv_data_set(adv_data, 13, sr_data, 20);
    APP_ERROR_CHECK(err_code);
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>