<?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>ADC values in advertising data dynamically changing</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/11217/adc-values-in-advertising-data-dynamically-changing</link><description>Hello, 
 How to put values changing over time into advertising data?
What I want to acchieve is to send ADC values that are changing dynamically over advertising packet which I wish to change over time. 
 I would like to know how to even send random</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 14 Jan 2016 20:42:33 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/11217/adc-values-in-advertising-data-dynamically-changing" /><item><title>RE: ADC values in advertising data dynamically changing</title><link>https://devzone.nordicsemi.com/thread/42071?ContentTypeID=1</link><pubDate>Thu, 14 Jan 2016 20:42:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:67f33fb2-2d88-4f48-b27b-f56d78be1705</guid><dc:creator>tchitchi</dc:creator><description>&lt;p&gt;I got some troubles but in the end I managed to send my dynamic ADC data in manufacturer specific data ;) Thanks for your help, Anders.&lt;/p&gt;
&lt;p&gt;Cheers! :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ADC values in advertising data dynamically changing</title><link>https://devzone.nordicsemi.com/thread/42069?ContentTypeID=1</link><pubDate>Wed, 13 Jan 2016 09:53:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:47cbb3da-7ff6-42b6-bb07-41125e591760</guid><dc:creator>Anders Strand</dc:creator><description>&lt;p&gt;How many bits is the ADC data? If it is 8, you can put in into a single uint8_t like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;uint8_t value =  (uint8_t) adc_value. 
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If the adc value is more than 8 bit (for example 10), you must create two bytes to contain it.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;uint8_t value[2];
value[0] = adc &amp;gt;&amp;gt; 8;
value[1] = adc;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The first bytes will now contain the first two bits of the value, and the second one contains the last 8.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;[X,X,X,X,X,X,0,1][2,3,4,5,6,7,8,9]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If this is not familiar to you, google topics like bit shifting, uint8_t arrays, converting int to uint8_t array etc...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ADC values in advertising data dynamically changing</title><link>https://devzone.nordicsemi.com/thread/42067?ContentTypeID=1</link><pubDate>Tue, 12 Jan 2016 21:52:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f0821836-9fbc-477a-89ef-21682cbabb46</guid><dc:creator>tchitchi</dc:creator><description>&lt;p&gt;Thanks for fast reply,&lt;/p&gt;
&lt;p&gt;I am able to read ADC values, as I remember it is adc_sample, I was sending it through ble_app_hrs. But even with this my adc_sample value is integer type, it doesn&amp;#39;t match with &amp;quot;manuf_specific_data.data.p_data&amp;quot; which is uint8_t* type. Is there any way to solve this?&lt;/p&gt;
&lt;p&gt;Let&amp;#39;s pretend it&amp;#39;s working, but what with the last error I received?
&amp;quot;error: #20: identifier &amp;quot;m_advdata&amp;quot; is undefined&amp;quot;?&lt;/p&gt;
&lt;p&gt;-- edit, sorry, I didn&amp;#39;t notice you updated m_advdata-&amp;gt;&amp;gt;&amp;gt;&amp;gt; advdata :) --&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ADC values in advertising data dynamically changing</title><link>https://devzone.nordicsemi.com/thread/42068?ContentTypeID=1</link><pubDate>Tue, 12 Jan 2016 13:54:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:318997aa-d78a-415d-a0d2-f370f35943f6</guid><dc:creator>Anders Strand</dc:creator><description>&lt;p&gt;I forgot to mention that this is not code you can just paste in. You must implement get_adc_value and define ADC_VALUE_LENGTH yourself. For the last one, just change m_advdata to advdata. Have you successfully read the ADC values that should be put in here, or is this something you need help with too? This was not clear from your first question&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ADC values in advertising data dynamically changing</title><link>https://devzone.nordicsemi.com/thread/42070?ContentTypeID=1</link><pubDate>Mon, 11 Jan 2016 21:12:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4d7bc4f0-7ac7-4681-8917-59a5ba292fa8</guid><dc:creator>tchitchi</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;thanks for your response, Anders. I followed your advice and downloaded SDK10. &amp;#39;Clean&amp;#39; HRS works well, but I approached few problems when trying to compile project with the code you&amp;#39;ve given! :( I listed below lines of code and corresponding errors/warnings from Keil:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;manuf_specific_data.data.p_data = get_adc_value();
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;warning: #223-D: function &amp;quot;get_adc_value&amp;quot; declared implicitly&lt;/p&gt;
&lt;p&gt;error: #513: a value of type &amp;quot;int&amp;quot; cannot be assigned to an entity of type &amp;quot;uint8_t *&amp;quot;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;manuf_specific_data.data.size  = ADC_VALUE_LENGTH;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;error: #20: identifier &amp;quot;ADC_VALUE_LENGTH&amp;quot; is undefined&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;err_code = ble_advdata_set(&amp;amp;m_advdata, NULL);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;error: #20: identifier &amp;quot;m_advdata&amp;quot; is undefined&lt;/p&gt;
&lt;p&gt;I hope you can help me with this and I really appreciate your efforts to date.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ADC values in advertising data dynamically changing</title><link>https://devzone.nordicsemi.com/thread/42066?ContentTypeID=1</link><pubDate>Mon, 11 Jan 2016 10:38:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5c60bc3b-c7eb-4048-85c6-add3a50481b1</guid><dc:creator>Anders Strand</dc:creator><description>&lt;p&gt;First of all, i advise you to use the newest SDK (10 at this time) when creating a new project. You can download the SDK &lt;a href="http://developer.nordicsemi.com/nRF5_SDK/"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;This solution includes two tasks: 1 - Getting a value from the ADC, 2- Put the value into the advertisement packet. From you question, i assume that it is part 2 you need help with.&lt;/p&gt;
&lt;p&gt;Start by making sure that you have enough free space in the advertisement packet. You can also consider putting the adc value in the scan response packets. If you are not familiar with these concepts, please see the &lt;a href="https://devzone.nordicsemi.com/tutorials/5/ble-advertising-a-beginners-tutorial/"&gt;advertising tutorial&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The adc data should be put inside the manufacturer specific field of the advertisement.
We create a struct containing this data:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ble_advdata_manuf_data_t manuf_specific_data;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then we put our adc value into the struct&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;manuf_specific_data.data.p_data = get_adc_value();
manuf_specific_data.data.size  = ADC_VALUE_LENGTH;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then we put our data struct into the advertisement packet&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;advdata.p_manuf_specific_data = &amp;amp;manuf_specific_data;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Finally we set the advertisement data&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;err_code = ble_advdata_set(&amp;amp;advdata, NULL);
APP_ERROR_CHECK(err_code);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is in addition to all the other things we put in the advertisement packet. The total function for updating the advertisment packet might look something like this. (this is a modified advertising_init() from ble_app_hrs in SDK 10.)&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static void advertisement_update(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.name_type               = BLE_ADVDATA_FULL_NAME;
    advdata.include_appearance      = true;
    advdata.flags                   = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
    advdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
    advdata.uuids_complete.p_uuids  = m_adv_uuids;

    //New part
    ble_advdata_manuf_data_t manuf_specific_data;
    memset(&amp;amp;manuf_specific_data, 0, sizeof(manuf_specific_data));
    manuf_specific_data.data.p_data = get_adc_value();
    manuf_specific_data.data.size  = ADC_VALUE_LENGTH;
    advdata.p_manuf_specific_data = &amp;amp;manuf_specific_data;

    err_code = ble_advdata_set(&amp;amp;advdata, NULL);
    APP_ERROR_CHECK(err_code);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;PS:
The ble_app_hrs is a &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk51.v10.0.0/ble_sdk_app_hrs.html?cp=4_0_1_4_2_2_8"&gt;heart rate sensor example&lt;/a&gt; from our SDK. When you unzip the SDK, it is found here: \examples\ble_peripheral\ble_app_hrs&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ADC values in advertising data dynamically changing</title><link>https://devzone.nordicsemi.com/thread/42065?ContentTypeID=1</link><pubDate>Sun, 10 Jan 2016 19:23:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bc6f03d5-927b-48d2-a077-bd8aaf984d37</guid><dc:creator>tchitchi</dc:creator><description>&lt;p&gt;Ok, let me explain:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;I don&amp;#39;t know what is the &amp;quot;example ble_app_hrs that includes the ADC converter&amp;quot; that Xenia mentioned, but somehow I managed to send ADC values through HRS&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Martin posts some code and his main.c file, but what am I supposed to do with that? Paste this, but where? Which SDK does this use? My problem is the file isn&amp;#39;t compiling&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ADC values in advertising data dynamically changing</title><link>https://devzone.nordicsemi.com/thread/42064?ContentTypeID=1</link><pubDate>Fri, 08 Jan 2016 15:32:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b31010c0-a1ee-43eb-a6db-cb4c052df6e8</guid><dc:creator>Anders Strand</dc:creator><description>&lt;p&gt;The link you posted contains the solution. Please explain what you mean by &amp;quot;Not Working&amp;quot;. It is very hard to help you with so little information.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>