<?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>Advertise two services at the same time?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/39744/advertise-two-services-at-the-same-time</link><description>EDIT: I have added the battery data in percentage to scan response manufacturer specific data. Is that the only possible way? 
 Hello, 
 I am working on a beacon application that updates the advertisement every second. 
 I have a &amp;quot;time counter&amp;quot;, so to</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 26 Oct 2018 05:02:40 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/39744/advertise-two-services-at-the-same-time" /><item><title>RE: Advertise two services at the same time?</title><link>https://devzone.nordicsemi.com/thread/154597?ContentTypeID=1</link><pubDate>Fri, 26 Oct 2018 05:02:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:982f68fb-d610-45ba-a6e0-d18285fef4a1</guid><dc:creator>devops</dc:creator><description>&lt;p&gt;Thank you for such a thorough response. I will try to implement the changes you described over the weekend and will update the post.&lt;/p&gt;
&lt;p&gt;EDIT:&lt;/p&gt;
&lt;p&gt;Your solution works very well and I have implemented it to my&amp;nbsp;code. I removed the scan response packet and am now advertising two services instead. The current consumption should go down as well, right?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Advertise two services at the same time?</title><link>https://devzone.nordicsemi.com/thread/154527?ContentTypeID=1</link><pubDate>Thu, 25 Oct 2018 13:47:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fc9a001d-a927-4dac-8a42-513bf01fad29</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;What you are doing now is to just overwrite the old data (as you mentioned). What you need to do is the following:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#define SIG_TEMP_SERVICE_UUID 0x1815 //Official SIG temperature service
#define SIG_BAT_SERVICE_UUID 0x180F  //official SIG battery service

ble_advdata_service_data_t service_data[2] = {};

//Creating data structure for temperature
uint8_t rotation_data[] = {1, 2, 3, 4, 5};
uint8_array_t rotation;
rotation.size = sizeof(rotation_data);
rotation.p_data = rotation_data;

// Adding temperature &amp;quot;service&amp;quot; to service_data array
service_data[0].service_uuid = SIG_TEMP_SERVICE_UUID; 
service_data[0].data = rotation;


//Creating data structure for battery
uint8_t battery_data[] = {6, 7, 8, 9, 10};
uint8_array_t battery;
battery.size = sizeof(battery_data);
battery.p_data = battery_data;

// Adding temperature &amp;quot;service&amp;quot; to service_data array
service_data[1].service_uuid = SIG_BAT_SERVICE_UUID; 
service_data[1].data = battery;

init.advdata.service_data_count = 2;
init.advdata.p_service_data_array = service_data;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The changes I made from your code was roughly:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Created an array of&amp;nbsp;type&amp;nbsp;&lt;em&gt;ble_advdata_service_data_t&lt;/em&gt;&amp;nbsp;and assigned the temperature info to field 0 and the battery info to field 1&lt;/li&gt;
&lt;li&gt;&amp;nbsp;Set the field init.advdata.service_count to 2&lt;/li&gt;
&lt;li&gt;Excluded the &amp;amp; sign when assigning service_data to the init structure, since the variable is turned in to pointer when declared as array&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The reason for these changes can be found in the function&amp;nbsp;advertising_init()-&amp;gt;ble_advdata_encode(..)-&amp;gt;service_data_encode(..)&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;service_data_encode(..){
.
.
for (i = 0; i &amp;lt; p_advdata-&amp;gt;service_data_count; i++)
{
    ble_advdata_service_data_t * p_service_data;
    uint32_t                     data_size;

    p_service_data = &amp;amp;p_advdata-&amp;gt;p_service_data_array[i];
.
.&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;As you can see, it will only encode as may GAP data types of &amp;quot;Service Data&amp;quot; as specified by service_data_count.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards, Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Advertise two services at the same time?</title><link>https://devzone.nordicsemi.com/thread/154332?ContentTypeID=1</link><pubDate>Wed, 24 Oct 2018 16:09:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1ee84f45-f7de-4da6-afe8-866e5c93e2fc</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;I will try to provide you with an answer by tomorrow.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>