<?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>Update characteristic when no device is connected and beeing notified on notification enabled.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/30779/update-characteristic-when-no-device-is-connected-and-beeing-notified-on-notification-enabled</link><description>I have several characteristics which are updated by a regular timer. 
 The characteristic property is notify. Due to memory issues I use as value location BLE_GATTS_VLOC_STACK. 
 In case I am connected I use the function sd_ble_gatts_hvx() to notify the</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 26 Feb 2018 07:55:29 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/30779/update-characteristic-when-no-device-is-connected-and-beeing-notified-on-notification-enabled" /><item><title>RE: Update characteristic when no device is connected and beeing notified on notification enabled.</title><link>https://devzone.nordicsemi.com/thread/121923?ContentTypeID=1</link><pubDate>Mon, 26 Feb 2018 07:55:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f86beff5-6227-48aa-8e18-cc132343439e</guid><dc:creator>Matthias Sacher</dc:creator><description>&lt;p&gt;Thank you for the answer.&lt;/p&gt;
&lt;p&gt;I think the best way is to send it directly after the BLE_BAS_EVT_NOTIFICATION_ENABLED event.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Update characteristic when no device is connected and beeing notified on notification enabled.</title><link>https://devzone.nordicsemi.com/thread/121781?ContentTypeID=1</link><pubDate>Fri, 23 Feb 2018 11:45:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ec329b2e-e33b-4cab-b51e-4faca39b4c9d</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;If the central need the value&amp;nbsp;immediately after the&amp;nbsp;service discovery, and it don&amp;#39;t want to wait for any notification, you could read the characteristic from the central directly. This is done in e.g. the central example ble_app_hrs_c in the SDK with&amp;nbsp;ble_bas_c_bl_read().&lt;/p&gt;
&lt;p&gt;Snippet:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;case BLE_BAS_C_EVT_DISCOVERY_COMPLETE:
        {
            err_code = ble_bas_c_handles_assign(p_bas_c,
                                                p_bas_c_evt-&amp;gt;conn_handle,
                                                &amp;amp;p_bas_c_evt-&amp;gt;params.bas_db);
            APP_ERROR_CHECK(err_code);

            // Initiate bonding.
            err_code = pm_conn_secure(p_bas_c_evt-&amp;gt;conn_handle, false);
            if (err_code != NRF_ERROR_INVALID_STATE)
            {
                APP_ERROR_CHECK(err_code);
            }

            // Batttery service discovered. Enable notification of Battery Level.
            NRF_LOG_DEBUG(&amp;quot;Battery Service discovered. Reading battery level.&amp;quot;);

            err_code = ble_bas_c_bl_read(p_bas_c);
            APP_ERROR_CHECK(err_code);

            NRF_LOG_DEBUG(&amp;quot;Enabling Battery Level Notification.&amp;quot;);
            err_code = ble_bas_c_bl_notif_enable(p_bas_c);
            APP_ERROR_CHECK(err_code);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Another option is to send the value with&amp;nbsp;&lt;span&gt;sd_ble_gatts_hvx()&amp;nbsp;immediately&amp;nbsp;after the central enables notification. Using the&amp;nbsp;Battery Service as an example, in addition to starting a timer that sends notifications&amp;nbsp;periodically, you could also&amp;nbsp;send the value when you get the first&amp;nbsp;BLE_BAS_EVT_NOTIFICATION_ENABLED event.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;&lt;pre class="ui-code" data-mode="text"&gt;case BLE_BAS_EVT_NOTIFICATION_ENABLED:
// Start battery timer
err_code = app_timer_start(m_battery_timer_id, BATTERY_LEVEL_MEAS_INTERVAL, NULL);
APP_ERROR_CHECK(err_code);

//Add code with sd_ble_gatts_hvx() / ble_bas_battery_level_update()

break; // BLE_BAS_EVT_NOTIFICATION_ENABLED&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>