<?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 collect value from multiple characteristics in the client?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/58519/how-to-collect-value-from-multiple-characteristics-in-the-client</link><description>Hi, 
 I am working on the client program to retrieve the value from 4 characteristics at the same time using notifications. I have already done with the server program. Using nrf connect to connect with my program, it looks like this: 
 
 I would like</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 10 Mar 2020 14:28:31 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/58519/how-to-collect-value-from-multiple-characteristics-in-the-client" /><item><title>RE: How to collect value from multiple characteristics in the client?</title><link>https://devzone.nordicsemi.com/thread/239165?ContentTypeID=1</link><pubDate>Tue, 10 Mar 2020 14:28:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6d7a9736-3185-4ae4-b836-a6cb53ba8eea</guid><dc:creator>Taoyi</dc:creator><description>&lt;p&gt;I have already solved this. Thank you!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to collect value from multiple characteristics in the client?</title><link>https://devzone.nordicsemi.com/thread/239159?ContentTypeID=1</link><pubDate>Tue, 10 Mar 2020 14:22:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a3f5bfe3-bef8-4a0c-90ba-8f19838636f7</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;What error code do you get, and from what function call? (It sounds like it is from ble_eeg_ch4_c_tx_notif_enable(), can you confirm or correct that assumption?) This will usually point towards what kind of error you are seeing.&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Terje&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to collect value from multiple characteristics in the client?</title><link>https://devzone.nordicsemi.com/thread/239157?ContentTypeID=1</link><pubDate>Tue, 10 Mar 2020 14:19:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b3ced72e-3f11-4f16-8181-0db7fc1edb00</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I am afraid we only have a peripheral example for the Glucose Service, and we also only provide a library for the server (ble_gls) and not for the client.&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Terje&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to collect value from multiple characteristics in the client?</title><link>https://devzone.nordicsemi.com/thread/238965?ContentTypeID=1</link><pubDate>Tue, 10 Mar 2020 01:57:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fc21c4ae-2ea8-4542-b537-6c113fc7b807</guid><dc:creator>Taoyi</dc:creator><description>&lt;p&gt;Also, I &amp;#39;m trying to enable 4 notifications after discovering the characteristics. The functions are:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static uint32_t cccd_configure(uint16_t conn_handle, uint16_t cccd_handle, bool enable)
{
    uint8_t buf[BLE_CCCD_VALUE_LEN];
    buf[0] = enable ? BLE_GATT_HVX_NOTIFICATION : 0;
    buf[1] = 0;
    ble_gattc_write_params_t const write_params =
    {
        .write_op = BLE_GATT_OP_WRITE_REQ,
        .flags    = BLE_GATT_EXEC_WRITE_FLAG_PREPARED_WRITE,
        .handle   = cccd_handle,
        .offset   = 0,
        .len      = sizeof(buf),
        .p_value  = buf
    };
    return sd_ble_gattc_write(conn_handle, &amp;amp;write_params);
}
//functions of ch1, ch2, ch3, ch4 are same
uint32_t ble_eeg_ch1_c_tx_notif_enable(ble_eeg_uarts_c_t * p_ble_uarts_c)
{
    VERIFY_PARAM_NOT_NULL(p_ble_uarts_c);
    if ( (p_ble_uarts_c-&amp;gt;conn_handle == BLE_CONN_HANDLE_INVALID)
       ||(p_ble_uarts_c-&amp;gt;handles.eeg_ch1_tx_cccd_handle == BLE_GATT_HANDLE_INVALID)
       )
    {
        return NRF_ERROR_INVALID_STATE;
    }
		
    return cccd_configure(p_ble_uarts_c-&amp;gt;conn_handle,p_ble_uarts_c-&amp;gt;handles.eeg_ch1_tx_cccd_handle, true);
}
// in the main.c:

static void ble_uarts_c_evt_handler(ble_eeg_uarts_c_t * p_ble_uarts_c, ble_eeg_uarts_c_evt_t const * p_ble_uarts_evt)
{
    ret_code_t err_code;

    switch (p_ble_uarts_evt-&amp;gt;evt_type)
    {
        case BLE_UARTS_C_EVT_DISCOVERY_COMPLETE:
            NRF_LOG_INFO(&amp;quot;Discovery complete.&amp;quot;);
            err_code = ble_uarts_c_handles_assign(p_ble_uarts_c, p_ble_uarts_evt-&amp;gt;conn_handle, &amp;amp;p_ble_uarts_evt-&amp;gt;handles);
            APP_ERROR_CHECK(err_code);
            //Enable Notify
            err_code = ble_eeg_ch1_c_tx_notif_enable(p_ble_uarts_c);
            APP_ERROR_CHECK(err_code);
			NRF_LOG_INFO(&amp;quot;Enabel notification of the Channel 1 Char&amp;quot;);
			
			err_code = ble_eeg_ch2_c_tx_notif_enable(p_ble_uarts_c);
            APP_ERROR_CHECK(err_code);
			NRF_LOG_INFO(&amp;quot;Enabel notification of the Channel 2 Char&amp;quot;);
				
		    err_code = ble_eeg_ch3_c_tx_notif_enable(p_ble_uarts_c);
            APP_ERROR_CHECK(err_code);
			NRF_LOG_INFO(&amp;quot;Enabel notification of the Channel 3 Char&amp;quot;);
						
			err_code = ble_eeg_ch4_c_tx_notif_enable(p_ble_uarts_c);
            APP_ERROR_CHECK(err_code);
			NRF_LOG_INFO(&amp;quot;Enabel notification of the Channel 4 Char&amp;quot;);
            NRF_LOG_INFO(&amp;quot;Connected to device with EEG Service.&amp;quot;);
            break;

        case BLE_UARTS_C_EVT_NUS_TX_EVT:
            uart_chars_print(p_ble_uarts_evt-&amp;gt;p_data, p_ble_uarts_evt-&amp;gt;data_len);
            break;

        case BLE_UARTS_C_EVT_DISCONNECTED:
            NRF_LOG_INFO(&amp;quot;Disconnected.&amp;quot;);
            scan_start();
            break;
    }
}

&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;However,&amp;nbsp;when it tries to enable the notifications of ch1~4, it is said there&amp;#39;s a fatal error. How to enable these four characteristics correctly?&lt;/p&gt;
&lt;p&gt;Thank you!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to collect value from multiple characteristics in the client?</title><link>https://devzone.nordicsemi.com/thread/238656?ContentTypeID=1</link><pubDate>Sun, 08 Mar 2020 10:29:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dd82df37-129e-4fb6-bef8-fb3f657d503a</guid><dc:creator>Taoyi</dc:creator><description>&lt;p&gt;Thank you for your help!&lt;/p&gt;
&lt;p&gt;&amp;nbsp;I noticed that the glucose sensor peripheral example ble_app_gls have&amp;nbsp;two characteristics that need notification/indication in one service. However, I can&amp;#39;t find the central example of it. Do you have the central example of it?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;div style="left:341px;position:absolute;top:22.3333px;" id="gtx-trans"&gt;
&lt;div class="gtx-trans-icon"&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to collect value from multiple characteristics in the client?</title><link>https://devzone.nordicsemi.com/thread/237981?ContentTypeID=1</link><pubDate>Wed, 04 Mar 2020 10:04:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1c63a651-ddaf-4b00-b7ee-8766c311b5bf</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;In the ble event, the handle in the &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.s132.api.v7.0.1%2Fstructble__gattc__evt__hvx__t.html"&gt;ble_gattc_evt_hvx_t&lt;/a&gt; data structure is the attribute handle which identifies the characteristic. (Not to be confused with the connection handle, which is found in the &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.s132.api.v7.0.1%2Fstructble__gattc__evt__t.html"&gt;ble_gattc_evt_t&lt;/a&gt; structure that holds the ble_gattc_evt_hvx_t structure in its params.hvx field.)&lt;/p&gt;
&lt;p&gt;For examples on how to handle this, please have a look at the client service implementations in &amp;lt;sdk folder&amp;gt;/components/ble/ble_services (the folders ending in &amp;quot;_c&amp;quot;). Typically there is an on_hvx() function that checks the handle, e.g. for the battery service client in ble_bas_c.c:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/**@brief     Function for handling Handle Value Notification received from the SoftDevice.
 *
 * @details   This function handles the Handle Value Notification received from the SoftDevice
 *            and checks whether it is a notification of the Battery Level measurement from the peer. If
 *            it is, this function decodes the battery level measurement and sends it to the
 *            application.
 *
 * @param[in] p_ble_bas_c Pointer to the Battery Service Client structure.
 * @param[in] p_ble_evt   Pointer to the BLE event received.
 */
static void on_hvx(ble_bas_c_t * p_ble_bas_c, ble_evt_t const * p_ble_evt)
{
    // Check if the event is on the link for this instance.
    if (p_ble_bas_c-&amp;gt;conn_handle != p_ble_evt-&amp;gt;evt.gattc_evt.conn_handle)
    {
        return;
    }
    // Check if this notification is a battery level notification.
    if (p_ble_evt-&amp;gt;evt.gattc_evt.params.hvx.handle == p_ble_bas_c-&amp;gt;peer_bas_db.bl_handle)
    {
        if (p_ble_evt-&amp;gt;evt.gattc_evt.params.hvx.len == 1)
        {
            ble_bas_c_evt_t ble_bas_c_evt;
            ble_bas_c_evt.conn_handle = p_ble_evt-&amp;gt;evt.gattc_evt.conn_handle;
            ble_bas_c_evt.evt_type    = BLE_BAS_C_EVT_BATT_NOTIFICATION;

            ble_bas_c_evt.params.battery_level = p_ble_evt-&amp;gt;evt.gattc_evt.params.hvx.data[0];

            p_ble_bas_c-&amp;gt;evt_handler(p_ble_bas_c, &amp;amp;ble_bas_c_evt);
        }
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Terje&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>