<?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>Characteristic Value Read</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/29036/characteristic-value-read</link><description>Hello together, 
 i know, there are similar questions about &amp;quot;Reading Characteristic Value&amp;quot;, but i don&amp;#39;t get a solution for me. My Problem:
I use nRF51DK with SD130 and the Example Project from the Characteristics Tutorial .
I added 1 service and 2</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 06 Feb 2018 14:06:01 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/29036/characteristic-value-read" /><item><title>RE: Characteristic Value Read</title><link>https://devzone.nordicsemi.com/thread/119962?ContentTypeID=1</link><pubDate>Tue, 06 Feb 2018 14:06:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6d2b4bb6-6523-4c8e-bc34-b08230302b11</guid><dc:creator>run_ar</dc:creator><description>&lt;p&gt;This should probably have been a separate question...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Characteristic Value Read</title><link>https://devzone.nordicsemi.com/thread/114968?ContentTypeID=1</link><pubDate>Mon, 22 Jan 2018 01:25:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bc98ac97-9cfe-4dda-8f54-a4e9a7573a6e</guid><dc:creator>puff</dc:creator><description>&lt;p&gt;what if location_for_my_value is an array of 16 values of uint8_t?&lt;/p&gt;
&lt;p&gt;i set the temp.len to 16, but whenever I printf the resulted array, I get the same values all the time, which seem to be addresses, not the actual data.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Characteristic Value Read</title><link>https://devzone.nordicsemi.com/thread/114967?ContentTypeID=1</link><pubDate>Fri, 17 Jun 2016 11:32:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f08bff9d-a620-47d1-ba63-1a7ce3f5d77b</guid><dc:creator>FormerMember</dc:creator><description>&lt;p&gt;In order to make sure that you get/read the correct value,  temp.len should be set to the number of bytes that you want to read.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Characteristic Value Read</title><link>https://devzone.nordicsemi.com/thread/114966?ContentTypeID=1</link><pubDate>Thu, 16 Jun 2016 12:17:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:34cea47d-8b51-4ced-94ed-6f9ec801eab0</guid><dc:creator>Sascha</dc:creator><description>&lt;p&gt;Ok, i dont know why, but after i erased Region 0(SD) and Region 1(APP) and flashed it again it&amp;#39;s running correctly. :) thx!!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Characteristic Value Read</title><link>https://devzone.nordicsemi.com/thread/114965?ContentTypeID=1</link><pubDate>Thu, 16 Jun 2016 10:12:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d2a4571e-69c2-45e0-894b-df4f2f8145fd</guid><dc:creator>Sascha</dc:creator><description>&lt;p&gt;Hi Kristin, thank you. I think, i now understand this function with the ble_gatts_value_t struct. So i have changed my code to yours. When i run this code, after the sd_ble_gatts_value_get() the &amp;quot;location_for_my_value&amp;quot; value should contain the value from the characteristic!? But even when i change the characteristic value to AA-AA-AA-AA-AA, the &amp;quot;location_for_my_value&amp;quot; contains 0x00 from memset() :-/&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Characteristic Value Read</title><link>https://devzone.nordicsemi.com/thread/114964?ContentTypeID=1</link><pubDate>Thu, 16 Jun 2016 08:39:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:81406b66-6f7b-4ac4-8e49-c75849e2021d</guid><dc:creator>FormerMember</dc:creator><description>&lt;p&gt;ble_gatts_value_t is defined the following way:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;typedef struct
{
  uint16_t  len;       
  uint16_t  offset;    
  uint8_t   *p_value;   
} ble_gatts_value_t;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In your example,  in order to make temp contain the value of the attribute  after calling sd_ble_gatts_value_get(), p_value in ble_gatts_value_t has to be set to point to a location:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;uint8_t location_for_my_value;


temp.p_value   = &amp;amp;location_for_my_value;
temp.len      = number_of_bytes_you_want_to_read;
temp.offset   = 0;
err_code = sd_ble_gatts_value_set(BLE_CONN_HANDLE_INVALID, 0x000E, temp);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To make the code more robust, I would recommend you to refer to the reference for the attribute handle value, rather than hard code the handle value. For retrieving the battery level value in the ble_app_hrs example in the SDK, it would be the following:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;err_code = sd_ble_gatts_value_set(m_conn_handle,m_bas.battery_level_handles.value_handle, temp);
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Characteristic Value Read</title><link>https://devzone.nordicsemi.com/thread/114963?ContentTypeID=1</link><pubDate>Wed, 15 Jun 2016 13:24:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2e66251c-be7f-4e81-9bca-f39d1a263d5d</guid><dc:creator>Sascha</dc:creator><description>&lt;p&gt;Hi Wojtek, ok that was really embarrassing, i changed it. Now no error occurs. But when i view at temp, i only get an empty p_value 0x00000000 with the correct len of 0x0005 (5Bytes)!?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Characteristic Value Read</title><link>https://devzone.nordicsemi.com/thread/114962?ContentTypeID=1</link><pubDate>Wed, 15 Jun 2016 12:49:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:68028043-e056-43b8-ad42-6d143272947c</guid><dc:creator>Wojtek</dc:creator><description>&lt;p&gt;0x00000010 = NRF_ERROR_INVALID_ADDR, which for function sd_ble_gatts_value_get means that Invalid pointer supplied. Temp is only the pointer to the ble_gatts_value_t, but where physically is that value stored?  Please try changing temp type to ble_gatts_value_t (instead of ble_gatts_value_t*)...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>