<?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>Can not change a custom variable in ble_our_service_on_ble_evt()</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/48907/can-not-change-a-custom-variable-in-ble_our_service_on_ble_evt</link><description>Hi everyone, 
 I completed tutorials and i tried to get a value from characteristic and i tried to do something extra. But i am encountering a problem which i could&amp;#39;t understand. I will share my code with a screenshot. 
 1) I wrote &amp;quot;0x12&amp;quot; to characteristic</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 24 Jun 2019 12:37:03 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/48907/can-not-change-a-custom-variable-in-ble_our_service_on_ble_evt" /><item><title>RE: Can not change a custom variable in ble_our_service_on_ble_evt()</title><link>https://devzone.nordicsemi.com/thread/194362?ContentTypeID=1</link><pubDate>Mon, 24 Jun 2019 12:37:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:12168bcf-34ac-443b-be86-f9f54ba564e9</guid><dc:creator>Caner Celiktas</dc:creator><description>&lt;p&gt;Okey, now it&amp;#39;s worked. I declared &amp;quot;button_value&amp;quot; as an integer in main.c and i declared as extern in our_service.c. Now it&amp;#39;s&amp;nbsp; working fine. Thank you !&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can not change a custom variable in ble_our_service_on_ble_evt()</title><link>https://devzone.nordicsemi.com/thread/194333?ContentTypeID=1</link><pubDate>Mon, 24 Jun 2019 11:51:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fde534cd-3b44-439a-9ae5-ee1a1886332e</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Like&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/members/awneil"&gt;awneil&lt;/a&gt;&amp;nbsp;said, you cannot have the&amp;nbsp;button_value as static. That will clearly not work since it will be two completely independent variables in both files, which just happens to have the same name. If you want the same variable in both files, then you need to declare it normally (without static!) in one .c file, and as extern in the other c file or header file.&lt;/p&gt;
&lt;p&gt;If you get a build error when you fix this, then you need to resolve it. We cannot help without knowing more about the error, though. What is the full error message?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can not change a custom variable in ble_our_service_on_ble_evt()</title><link>https://devzone.nordicsemi.com/thread/194326?ContentTypeID=1</link><pubDate>Mon, 24 Jun 2019 11:40:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8855a8f6-e12d-423e-9ed7-61d159403cbe</guid><dc:creator>Caner Celiktas</dc:creator><description>&lt;p&gt;well, i remove &amp;quot;static&amp;quot; and tried &amp;quot;extern&amp;quot;. Nothing change.. If i only use &amp;quot;int button_value;&amp;quot; then i&amp;#39;m getting &amp;quot;Build Failed&amp;quot; error.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can not change a custom variable in ble_our_service_on_ble_evt()</title><link>https://devzone.nordicsemi.com/thread/194304?ContentTypeID=1</link><pubDate>Mon, 24 Jun 2019 11:14:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3946664f-af3e-4bd6-9d1e-508cc531585d</guid><dc:creator>awneil</dc:creator><description>[quote userid="79370" url="~/f/nordic-q-a/48907/can-not-change-a-custom-variable-in-ble_our_service_on_ble_evt"]i declared the variable &amp;quot;static int button_value;&amp;quot; in our_service.h[/quote]
&lt;p&gt;Declaring variables as &amp;#39;static&amp;#39; in a header is not generally a good idea!&lt;/p&gt;
&lt;p&gt;It means that each source file which #includes that header gets its own private copy!&lt;/p&gt;
&lt;p&gt;This is standard &amp;#39;C&amp;#39; - nothing to do with Nordic or BLE.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can not change a custom variable in ble_our_service_on_ble_evt()</title><link>https://devzone.nordicsemi.com/thread/194293?ContentTypeID=1</link><pubDate>Mon, 24 Jun 2019 10:28:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:deba627f-d9b8-413a-82ff-71380bf64692</guid><dc:creator>Caner Celiktas</dc:creator><description>&lt;p&gt;Fixed.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can not change a custom variable in ble_our_service_on_ble_evt()</title><link>https://devzone.nordicsemi.com/thread/194277?ContentTypeID=1</link><pubDate>Mon, 24 Jun 2019 09:34:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:db05c678-00c1-4269-8de9-6436cb05ddd1</guid><dc:creator>awneil</dc:creator><description>&lt;p&gt;How to properly post source code (not as an image):&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/5468._5F00_Insert-Code-_2D00_-Nordic.png" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>