<?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>Service Event Double Trigger</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/50374/service-event-double-trigger</link><description>Hello, I have 2 custom service running each with one characteristic. When data is written to the characteristic one (io_controle.c) the write event is triggered twice. The other characteristic (device_info.c) works as expected with only one trigger. The</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 30 Jul 2019 20:14:02 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/50374/service-event-double-trigger" /><item><title>RE: Service Event Double Trigger</title><link>https://devzone.nordicsemi.com/thread/201361?ContentTypeID=1</link><pubDate>Tue, 30 Jul 2019 20:14:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9e823911-29f4-48e2-8b6c-7c0281a5044f</guid><dc:creator>BinderT</dc:creator><description>&lt;p&gt;Hi &lt;span&gt;Bj&amp;oslash;rn&lt;/span&gt;,&lt;br /&gt;&lt;br /&gt;I have move all the code that interface with services and&amp;nbsp;characteristics handles to the&amp;nbsp;&lt;span&gt;service_hal.c files (this is in the main app). The macro is still in the .h file. The only global&amp;nbsp;data is the information that will get sent to the service.&lt;br /&gt;&lt;br /&gt;Making the veritable&amp;nbsp;static broke the definitions&amp;nbsp;in main.c. The&amp;nbsp;characteristics had garbage in as there init values.&lt;br /&gt;&lt;br /&gt;PS: Can I ask you to use my screen name please as this is a public&amp;nbsp;ticket.&lt;br /&gt;&lt;br /&gt;Regards&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Service Event Double Trigger</title><link>https://devzone.nordicsemi.com/thread/201273?ContentTypeID=1</link><pubDate>Tue, 30 Jul 2019 13:36:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4a5e075c-3a86-4865-8c79-84ccff94b3bc</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;Hi Luloff,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I think it is because you&amp;nbsp;have added the&amp;nbsp;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;BLE_IO_CONTROLE_SERVICE_DEF&lt;/span&gt;&lt;span&gt;(io_controle);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;span&gt;macro to service_hal.h. Which is included in both the service_hal.c and main.c. This means that the&amp;nbsp;&lt;/span&gt;&lt;/span&gt;
&lt;div&gt;&lt;span&gt;&lt;span&gt;NRF_SDH_BLE_OBSERVER macro will register the&amp;nbsp;&lt;/span&gt;&lt;/span&gt;ble_io_controle_service_on_ble_evt callback twice.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;You should&amp;nbsp;add it the same way as&amp;nbsp;&lt;span&gt;BLE_DEVICE_INFO_SERVICE_DEF,&amp;nbsp;&lt;/span&gt;i.e. in service_hal.c.&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;Best regards&lt;/div&gt;
&lt;div&gt;Bjørn&lt;/div&gt;
&lt;/div&gt;
&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Service Event Double Trigger</title><link>https://devzone.nordicsemi.com/thread/201261?ContentTypeID=1</link><pubDate>Tue, 30 Jul 2019 13:13:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:974ef029-e67b-4479-a2f2-35240bcc06d8</guid><dc:creator>BinderT</dc:creator><description>&lt;p&gt;Hi,&lt;br /&gt;&lt;br /&gt;I have just resolved this issue. I did not declare the variable as static in the macro to add the service to NRF_SDH_BLE_OBSERVER().&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;//Fault version

#define BLE_IO_CONTROLE_SERVICE_DEF(_name) 		\
ble_io_controle_service_t _name;			\
NRF_SDH_BLE_OBSERVER(_name ## _obs,					\
                     BLE_HRS_BLE_OBSERVER_PRIO,     \
					 ble_io_controle_service_on_ble_evt, &amp;amp;_name)
					 
// Fix version					 
#define BLE_IO_CONTROLE_SERVICE_DEF(_name) 		\
static ble_io_controle_service_t _name;			\
NRF_SDH_BLE_OBSERVER(_name ## _obs,					\
                     BLE_HRS_BLE_OBSERVER_PRIO,     \
					 ble_io_controle_service_on_ble_evt, &amp;amp;_name)&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Regards&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>