<?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>how to get value from custom char?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/14636/how-to-get-value-from-custom-char</link><description>hi
i get vlaue with this line of code
 
 but i did not specify what char should get it value
how can i get value from specific char?
i have nrf51422 v2 sdk v6</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 21 Jun 2016 13:34:48 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/14636/how-to-get-value-from-custom-char" /><item><title>RE: how to get value from custom char?</title><link>https://devzone.nordicsemi.com/thread/55860?ContentTypeID=1</link><pubDate>Tue, 21 Jun 2016 13:34:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:04e49f79-eefe-4d68-af92-2b8e3cecdcc1</guid><dc:creator>Petter Myhre</dc:creator><description>&lt;p&gt;If you want the characteristic value you should look for the attribute handle of it. For bas you can find it in p_bas-&amp;gt;battery_level_handles.value_handle&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: how to get value from custom char?</title><link>https://devzone.nordicsemi.com/thread/55859?ContentTypeID=1</link><pubDate>Tue, 21 Jun 2016 12:56:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:13b08b51-912f-4297-bc72-929f9e475178</guid><dc:creator>FormerMember</dc:creator><description>&lt;p&gt;The event BLE_GATTS_EVT_WRITE (SDK 6) contains the following information:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;/**@brief Event structure for BLE_GATTS_EVT_WRITE. */
typedef struct
{
  uint16_t                    handle;             /**&amp;lt; Attribute Handle. */
  uint8_t                     op;                 /**&amp;lt; Type of write operation, see @ref BLE_GATTS_OPS. */
  ble_gatts_attr_context_t    context;            /**&amp;lt; Attribute Context. */
  uint16_t                    offset;             /**&amp;lt; Offset for the write operation. */
  uint16_t                    len;                /**&amp;lt; Length of the incoming data. */
  uint8_t                     data[1];            /**&amp;lt; Incoming data, variable length. */
} ble_gatts_evt_write_t;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;All BLE event handlers in your application can receive and retrieve data from all BLE write events. The &amp;quot;handle&amp;quot; parameter in the write event tells the intended destination of the write event. However, it is up to the application to pass it there.&lt;/p&gt;
&lt;p&gt;In ble_app_hrs, the device (peripheral) can notify the central with heart rate values. In order for peripheral to start notifying, &amp;quot;notification&amp;quot; has to be enabled. Notifications are being enabled by the central, when writing to the heart rate CCCD, in the example it is handled like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;void ble_hrs_on_ble_evt(ble_hrs_t * p_hrs, ble_evt_t * p_ble_evt)
{
...
 case BLE_GATTS_EVT_WRITE:
            on_write(p_hrs, p_ble_evt);
            break;
...
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The on_write(..) function checks if write event contains the correct handle/if the write event is addressed to the heart rate CCCD :&lt;/p&gt;
&lt;p&gt;void ble_hrs_on_ble_evt(ble_hrs_t * p_hrs, ble_evt_t * p_ble_evt)
{&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    if (p_bas-&amp;gt;is_notification_supported)
    {
        ble_gatts_evt_write_t * p_evt_write = &amp;amp;p_ble_evt-&amp;gt;evt.gatts_evt.params.write;

        if (
            (p_evt_write-&amp;gt;handle == p_bas-&amp;gt;battery_level_handles.cccd_handle)
            &amp;amp;&amp;amp;
            (p_evt_write-&amp;gt;len == 2)
           )
        {
            // CCCD written, call application event handler
           ....

     }
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>