<?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 print GATT Service (Battery service) value in LOG file.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/56307/how-to-print-gatt-service-battery-service-value-in-log-file</link><description>I am using nRF52832 DK. 
 I am trying to print Battery service value in log file ( Client side ). 
 So where i get this information and how can i print this information in my log.</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 09 Jan 2020 09:07:14 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/56307/how-to-print-gatt-service-battery-service-value-in-log-file" /><item><title>RE: How to print GATT Service (Battery service) value in LOG file.</title><link>https://devzone.nordicsemi.com/thread/228291?ContentTypeID=1</link><pubDate>Thu, 09 Jan 2020 09:07:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:59bf4355-a451-4eec-88b4-898c94647a2f</guid><dc:creator>AKanade</dc:creator><description>&lt;p&gt;Thank you for your reply, it is really helpful for me&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to print GATT Service (Battery service) value in LOG file.</title><link>https://devzone.nordicsemi.com/thread/228174?ContentTypeID=1</link><pubDate>Wed, 08 Jan 2020 14:14:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:967925f7-b123-4892-b292-e49536c036e7</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;The function below is the one reading the battery level. If you flash the ble_app_hrs_c application to one board and the peripheral to another. You should then be able to follow the setup and testing instructions &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v16.0.0%2Fble_sdk_app_hrc.html&amp;amp;cp=7_1_4_2_0_1"&gt;here &lt;/a&gt;to test it and print the battery level to a UART terminal.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/**@brief Battery level Collector Handler.
 */
static void bas_c_evt_handler(ble_bas_c_t * p_bas_c, ble_bas_c_evt_t * p_bas_c_evt)
{
    ret_code_t err_code;

    switch (p_bas_c_evt-&amp;gt;evt_type)
    {
        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);

            // Battery 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);

        } break;

        case BLE_BAS_C_EVT_BATT_NOTIFICATION:
            NRF_LOG_INFO(&amp;quot;Battery Level received %d %%.&amp;quot;, p_bas_c_evt-&amp;gt;params.battery_level);
            break;

        case BLE_BAS_C_EVT_BATT_READ_RESP:
            NRF_LOG_INFO(&amp;quot;Battery Level Read as %d %%.&amp;quot;, p_bas_c_evt-&amp;gt;params.battery_level);
            break;

        default:
            break;
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to print GATT Service (Battery service) value in LOG file.</title><link>https://devzone.nordicsemi.com/thread/228131?ContentTypeID=1</link><pubDate>Wed, 08 Jan 2020 12:49:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fa682081-a60c-44a2-9c8a-fca7e6d18d6d</guid><dc:creator>AKanade</dc:creator><description>&lt;p&gt;please let me know how to add log message into a function for ble_app_hrs_c that can&amp;nbsp; be printed on debug terminal.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to print GATT Service (Battery service) value in LOG file.</title><link>https://devzone.nordicsemi.com/thread/228113?ContentTypeID=1</link><pubDate>Wed, 08 Jan 2020 11:54:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c4681a10-3556-4705-8691-d2d572530231</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;I suggest you take a look at the&amp;nbsp;&lt;strong&gt;&lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v16.0.0%2Fble_sdk_app_hrs.html&amp;amp;cp=7_1_4_2_2_13"&gt;ble_app_hrs&amp;nbsp;&lt;/a&gt;&lt;/strong&gt;example in our SDK, which implements the heart rate and battery measurement service. The central application uses the bas_c_evt_handler function to print and read the battery level.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>