<?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>Updating variable in custom service characteristic</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/23055/updating-variable-in-custom-service-characteristic</link><description>(/attachment/fad3a1e781331c528a9db48ec177b9b7)Hi there! i need help. I am using NRF52Dk with Bluetooth developmebt studio.
I set up my custom service in BDS an then imported in Keil project.
Now i have service with my characteristic. I can see it in</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 29 Jun 2017 17:53:47 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/23055/updating-variable-in-custom-service-characteristic" /><item><title>RE: Updating variable in custom service characteristic</title><link>https://devzone.nordicsemi.com/thread/90739?ContentTypeID=1</link><pubDate>Thu, 29 Jun 2017 17:53:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b5fec92a-07fc-4abe-aae0-7589cad42677</guid><dc:creator>Amigo</dc:creator><description>&lt;p&gt;Yes it works!!! I forgot that i redifined struct in main.c. Thanks a lot!!!!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Updating variable in custom service characteristic</title><link>https://devzone.nordicsemi.com/thread/90738?ContentTypeID=1</link><pubDate>Thu, 29 Jun 2017 14:11:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f57e89f2-e2df-4ff1-91f5-70b0ef338f66</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;It seems that the issue is that you initialize the profile using the struct &lt;code&gt;ble_myprofile_t m_myprofile;&lt;/code&gt;, defined in &lt;em&gt;service_if.c&lt;/em&gt;. This is where the correct characteristics handles are stored. When you try to update the value, you define a new struct in &lt;em&gt;main.c&lt;/em&gt;, &lt;code&gt;ble_myprofile_t m_ble_myprofile;&lt;/code&gt;. This struct will not contain correct handles.&lt;/p&gt;
&lt;p&gt;To solve the issue, remove the definition of the struct from &lt;em&gt;service_if.c&lt;/em&gt;, and add it in &lt;em&gt;ble_myprofile.h&lt;/em&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;extern ble_myprofile_t    m_myprofile; 
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and in &lt;em&gt;main.c&lt;/em&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ble_myprofile_t    m_myprofile;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now you should be able to update the value in &lt;code&gt;get_data_handler()&lt;/code&gt; using:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ble_myprofile_mycharacteristic_set(&amp;amp;m_myprofile, &amp;amp;m_mycharacteristic);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Updating variable in custom service characteristic</title><link>https://devzone.nordicsemi.com/thread/90737?ContentTypeID=1</link><pubDate>Wed, 28 Jun 2017 15:57:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:770ac7c2-9a77-457e-a992-a19addedf508</guid><dc:creator>Amigo</dc:creator><description>&lt;p&gt;Now i tried to set value in timer handler:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static void get_data_handler(void * p_context)
{
	UNUSED_PARAMETER(p_context);
	uint32_t err_code;
	val++;		

	nrf_gpio_pin_toggle(LED4);
	
	ble_myprofile_mycharacteristic_t m_mycharacteristic;
	m_mycharacteristic.value = val;
	
	ble_myprofile_mycharacteristic_set(&amp;amp;m_ble_myprofile, &amp;amp;m_mycharacteristic);
	ble_myprofile_mycharacteristic_indicate(&amp;amp;m_ble_myprofile, &amp;amp;m_mycharacteristic);
	//err_code = ble_my_service_value_update(&amp;amp;m_ble_myprofile, val);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It has no effect.&lt;/p&gt;
&lt;p&gt;there is a function prototype ble_myprofile_mycharacteristic_send but there is no code for it....
is it correct?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Updating variable in custom service characteristic</title><link>https://devzone.nordicsemi.com/thread/90734?ContentTypeID=1</link><pubDate>Wed, 28 Jun 2017 15:02:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:520c8fe7-8df1-4fba-98ca-564205f53e47</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Are you not able to set the characteristics value using &lt;code&gt;ble_myprofile_mycharacteristic_set()&lt;/code&gt;?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Updating variable in custom service characteristic</title><link>https://devzone.nordicsemi.com/thread/90735?ContentTypeID=1</link><pubDate>Tue, 27 Jun 2017 13:15:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:77832900-c2e8-4798-9242-e77572d07f9f</guid><dc:creator>Amigo</dc:creator><description>&lt;p&gt;I have edited my post by uploading BDS output files... hoping for help)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Updating variable in custom service characteristic</title><link>https://devzone.nordicsemi.com/thread/90736?ContentTypeID=1</link><pubDate>Tue, 27 Jun 2017 12:44:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f1404a68-a2ce-449b-95eb-96fea5d432f9</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Can you upload &lt;em&gt;ble_myprofile.c&lt;/em&gt; / &lt;em&gt;ble_myprofile.h&lt;/em&gt;? These files are not included in the project you uploaded.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>