<?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>How can I get my service characteristic value.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/110514/how-can-i-get-my-service-characteristic-value</link><description>How do I get the value of the characteristic of the service I created? I try to get it with the following code, but the content pointer returned is NULL.</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 30 Apr 2024 03:31:53 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/110514/how-can-i-get-my-service-characteristic-value" /><item><title>RE: How can I get my service characteristic value.</title><link>https://devzone.nordicsemi.com/thread/481189?ContentTypeID=1</link><pubDate>Tue, 30 Apr 2024 03:31:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:78e4ec87-3e58-49d0-9eef-5a30f84731ee</guid><dc:creator>MapleBay</dc:creator><description>&lt;p&gt;Hi Hieu,&lt;/p&gt;
&lt;p&gt;Thanks for your help. Now I can get service value.&lt;/p&gt;
&lt;p&gt;MapleBay&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can I get my service characteristic value.</title><link>https://devzone.nordicsemi.com/thread/480898?ContentTypeID=1</link><pubDate>Fri, 26 Apr 2024 13:12:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fdd76df2-bede-4a80-b5bc-8a2106d8d427</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;Hi MapleBay,&lt;/p&gt;
&lt;p&gt;My apology, I misunderstood the API when I wrote my previous answer. It was wrong.&lt;/p&gt;
&lt;p&gt;You need to supply a buffer to readout the value in the .p_value field when you call&amp;nbsp;sd_ble_gatts_value_get().&amp;nbsp;Something like this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;uint32_t err_code;
ble_gatts_value_t t_gatts_value;

memset(&amp;amp;t_gatts_value, 0, sizeof(t_gatts_value));

uint8_t t_buffer[__YOUR_MAXIMUM_POSSIBLE_SIZE__] = {0};

t_gatts_value.len     = __YOUR_MAXIMUM_POSSIBLE_SIZE__;
t_gatts_value.offset  = 0;
t_gatts_value.p_value = t_buffer;

err_code = sd_ble_gatts_value_get(BLE_CONN_HANDLE_INVALID,
							  __YOUR_HANDLE__,
							  &amp;amp;t_gatts_value);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Hieu&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can I get my service characteristic value.</title><link>https://devzone.nordicsemi.com/thread/480747?ContentTypeID=1</link><pubDate>Thu, 25 Apr 2024 15:05:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e1987b2c-cecf-4a6f-b51d-4ab581ab5aeb</guid><dc:creator>MapleBay</dc:creator><description>&lt;p&gt;Hi Hieu，&lt;/p&gt;
&lt;p&gt;You mean my data can always be found in my initialized pointer, right?&lt;/p&gt;
&lt;p&gt;MapleBay&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How can I get my service characteristic value.</title><link>https://devzone.nordicsemi.com/thread/480406?ContentTypeID=1</link><pubDate>Wed, 24 Apr 2024 10:23:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cd44a8e8-a764-4914-b948-d37d562f64c9</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;Update: This answer is incorrect. Please see my later answer&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration:line-through;"&gt;Hi MapleBay,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration:line-through;"&gt;Refer to the documentation for &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v0.9.0/structble__gatts__value__t.html?cp=5_7_3_11_2_0_4_3_3"&gt;ble_gatts_value_t&lt;/a&gt;:&lt;/span&gt;&lt;/p&gt;
[quote]uint8_t* ble_gatts_value_t::p_value&lt;br /&gt; Pointer to where value is stored or will be stored. &lt;br /&gt;If value is stored in user memory, only the attribute length is updated when p_value == NULL. Set to NULL when reading to obtain the complete length of the attribute value&amp;lt;[/quote]
&lt;p&gt;&lt;span style="text-decoration:line-through;"&gt;You are likely reading the value of an attribute that&amp;nbsp;was setup to be stored in user memory. Please trace back to the attribute&amp;#39;s initialization for where its value is supposed to be set, and read from there.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="text-decoration:line-through;"&gt;Hieu&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>