<?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>Incorrect custom service being updated by ble_cus_custom_value_update()</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/52344/incorrect-custom-service-being-updated-by-ble_cus_custom_value_update</link><description>Hi in the code below I successfully register multiple custom services (m_cus and m_cus2) using NRF_SDH_BLE_OBSERVERS(). In my original code when notifications is turned on for custom characteristic of m_cus the characteristic value would increment every</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 26 Sep 2019 14:27:01 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/52344/incorrect-custom-service-being-updated-by-ble_cus_custom_value_update" /><item><title>RE: Incorrect custom service being updated by ble_cus_custom_value_update()</title><link>https://devzone.nordicsemi.com/thread/212101?ContentTypeID=1</link><pubDate>Thu, 26 Sep 2019 14:27:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:19c5c490-f056-4d0a-b743-2d2d3b72c3a7</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;No, just call&amp;nbsp;&lt;span&gt;BLE_CUS_DEF once&amp;nbsp; with _name set to mcus and the _cnt to 2.&amp;nbsp;&lt;br /&gt;Then refer to&amp;nbsp;mcus[0] and mcus[1] as the two instances&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Incorrect custom service being updated by ble_cus_custom_value_update()</title><link>https://devzone.nordicsemi.com/thread/212061?ContentTypeID=1</link><pubDate>Thu, 26 Sep 2019 12:45:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2494a923-584b-4da4-9b90-8631192a4a7a</guid><dc:creator>thoric_fish</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;span&gt;Bj&amp;oslash;rn,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;So when&amp;nbsp;I call BLE_CUS_DEF in main.c, I should now pass mcus into the first parameter of the BLE_CUS_DEF(mcus, 2) call? Then I can use mcus[0] and mcus[1] as the two instances&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Incorrect custom service being updated by ble_cus_custom_value_update()</title><link>https://devzone.nordicsemi.com/thread/211846?ContentTypeID=1</link><pubDate>Wed, 25 Sep 2019 13:16:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ad0e072c-f8ef-42d0-90a2-2ea7a6ede218</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;Call&amp;nbsp;&lt;span&gt;BLE_CUS_DEF once with cnt set to 2 ( which ever number of custom services youre populating&amp;nbsp;the gatt table with) so that it defines an array of&amp;nbsp;ble_cus_s structures. Then refer to the first instance as &amp;amp;mcus[0] and the second as &amp;amp;mcus[2] etc.&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Incorrect custom service being updated by ble_cus_custom_value_update()</title><link>https://devzone.nordicsemi.com/thread/211291?ContentTypeID=1</link><pubDate>Mon, 23 Sep 2019 13:28:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c176c65b-6410-41ca-bd99-8fa392f418be</guid><dc:creator>thoric_fish</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;span&gt;Bj&amp;oslash;rn,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I am&amp;nbsp;using&amp;nbsp;SDK v15. I will try to find the handle for&amp;nbsp;ble_cus_custom_value_update().&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
[quote userid="7571" url="~/f/nordic-q-a/52344/incorrect-custom-service-being-updated-by-ble_cus_custom_value_update/211283"]&lt;p&gt;I would argue that there is no need to&amp;nbsp;add&amp;nbsp;BLE_CUS_DEF twice in main.c when you&amp;#39;re using&amp;nbsp;&lt;span&gt;&lt;span&gt;NRF_SDH_BLE_OBSERVERS and not&amp;nbsp;&lt;/span&gt;&lt;/span&gt;NRF_SDH_BLE_OBSERVER. Now, you&amp;#39;re infact declaring 4 ble_cus structs as well as registering 4 observers instead of two.&amp;nbsp;&lt;/p&gt;&lt;div class="quote-header"&gt;&lt;br /&gt;&lt;/div&gt;&lt;blockquote class="quote"&gt;&lt;div class="quote-content"&gt;&lt;br /&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;[/quote]
&lt;p&gt;So&amp;nbsp;what is the proper way to declare and register&amp;nbsp;&lt;span&gt;&amp;#39;mcus2&amp;#39;&lt;/span&gt;&amp;nbsp;(the second instance of the custom service&amp;nbsp;&lt;span&gt;ble_cus_s&amp;nbsp;&lt;/span&gt;struct), if there is no need to call BLE_CUS_DEF twice in main.c?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Incorrect custom service being updated by ble_cus_custom_value_update()</title><link>https://devzone.nordicsemi.com/thread/211283?ContentTypeID=1</link><pubDate>Mon, 23 Sep 2019 13:18:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fc94454c-8b67-4a17-94ab-29ef5d3e688c</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;Hi Thoric_fish,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Firstly which SDK version are you using?&lt;/p&gt;
&lt;p&gt;I see that you have defined BLE_CUS_DEF the following way&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#define BLE_CUS_DEF(_name, _cnt)                                                                      \
static ble_cus_t _name[_cnt];                          \
NRF_SDH_BLE_OBSERVERS(_name ## _obs,                                                                 \
                     BLE_HRS_BLE_OBSERVER_PRIO,                                                     \
                     ble_cus_on_ble_evt, &amp;amp;_name, _cnt)
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I would argue that there is no need to&amp;nbsp;add&amp;nbsp;BLE_CUS_DEF twice in main.c when you&amp;#39;re using&amp;nbsp;&lt;span&gt;&lt;span&gt;NRF_SDH_BLE_OBSERVERS and not&amp;nbsp;&lt;/span&gt;&lt;/span&gt;NRF_SDH_BLE_OBSERVER. Now, you&amp;#39;re infact declaring 4 ble_cus structs as well as registering 4 observers instead of two.&amp;nbsp;&lt;/p&gt;
[quote user=""]However, right now the most confusing issue is why m_cus2 is getting&amp;nbsp;its custom characteristic value incremented after notifications are turned on, when this behavior was supposed to be for m_cus only.&amp;nbsp; Any suggestions? [/quote]
&lt;p&gt;I agree that&amp;nbsp; since&amp;nbsp;&lt;span&gt;ble_cus_custom_value_update&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;ble_cus_t&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;*&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;p_cus&lt;/span&gt;&lt;span&gt;,&amp;nbsp;&lt;/span&gt;&lt;span&gt;uint8_t&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;custom_value&lt;/span&gt;&lt;span&gt;&lt;span&gt;) takes a pointer to a&amp;nbsp;ble_cus_t structure, then the&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span&gt;sd_ble_gatts_value_set() and&amp;nbsp;&lt;/span&gt;&lt;/span&gt;sd_ble_gatts_hvx() calls should refer to the handle passed with the&amp;nbsp;&lt;span&gt;p_cus pointer.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Which handle is used when you&amp;#39;re calling&amp;nbsp;ble_cus_custom_value_update()? Just add a NRF_LOG_INFO() line that prints the&amp;nbsp;&lt;span&gt;p_cus&lt;/span&gt;&lt;span&gt;-&amp;gt;&lt;/span&gt;&lt;span&gt;custom_value_handles&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;value_handle.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Bjørn&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>