<?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>Cannot able to get the multiple notification data on BLE central</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/105972/cannot-able-to-get-the-multiple-notification-data-on-ble-central</link><description>Hello, 
 Currently, I am working on an application having BLE central which connects with a custom sensor. The sensor has multiple services for parameters like Heart rate, Battery, Temperature, and ECG. And its respective characteristics notify those</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 08 Dec 2023 13:47:02 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/105972/cannot-able-to-get-the-multiple-notification-data-on-ble-central" /><item><title>RE: Cannot able to get the multiple notification data on BLE central</title><link>https://devzone.nordicsemi.com/thread/459528?ContentTypeID=1</link><pubDate>Fri, 08 Dec 2023 13:47:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cb838357-014a-47f1-bca3-fbceec48dd01</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Awesome, Thanks for caring for this community Ankit, +1 vote to you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cannot able to get the multiple notification data on BLE central</title><link>https://devzone.nordicsemi.com/thread/459512?ContentTypeID=1</link><pubDate>Fri, 08 Dec 2023 12:22:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:66224949-a7af-4560-8d4b-5b4f75f62c3f</guid><dc:creator>Ankit_chauhan</dc:creator><description>&lt;p&gt;Sure, below are the changes I have made in my code.&lt;/p&gt;
&lt;p&gt;1. The multiple instances of gatt_subscrive structure for each notification&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static struct bt_gatt_subscribe_params new_subscribe_params[6];&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;2.&amp;nbsp;&lt;strong&gt;bt_gatt_subscribe&lt;/strong&gt;&amp;nbsp;the subscribe call for the subscription of each notification.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;void subscribe_parameter(uint8_t index, subscribe_para_t parameter)
{
	printk(&amp;quot;Received Index = %d.\n&amp;quot;, index);
	switch(parameter)
	{
		case SUB_CHEST_TEMP:
			temp_subscribed = 1;
			sh_subscribe_notification(connections[index], temp_value_handle, temp_attr_handle, temp_notify_func, SUB_CHEST_TEMP);
			break;
		
		case SUB_CHEST_HR:
			hr_subscribed = 1;
			sh_subscribe_notification(connections[index], hr_value_handle, hr_attr_handle, hr_notify_func, SUB_CHEST_HR);
			break;

		case SUB_CHEST_BAT:
			bat_subscribed = 1;
			sh_subscribe_notification(connections[index], bat_value_handle, bat_attr_handle, bat_notify_func, SUB_CHEST_BAT);
			break;
	}
}



static uint8_t sh_subscribe_notification(struct bt_conn *conn,
							uint16_t handle, uint16_t attr_handle,
							bt_gatt_notify_func_t notify_fun, uint8_t index)
{
	int err;

	new_subscribe_params[index].value_handle = handle;
	new_subscribe_params[index].subscribe = subscribe_func;
	new_subscribe_params[index].notify = notify_fun;
	new_subscribe_params[index].value = BT_GATT_CCC_NOTIFY;
	new_subscribe_params[index].ccc_handle = attr_handle;

	err = bt_gatt_subscribe(conn, &amp;amp;new_subscribe_params[index]);
	if (err &amp;amp;&amp;amp; err != -EALREADY) {
		printk(&amp;quot;Subscribe failed (err %d)\n&amp;quot;, err);
	} else {
		printk(&amp;quot;[SUBSCRIBED]\n&amp;quot;);
	}
	return err;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;3. A sample notify callback function for getting temperature data&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static uint8_t temp_notify_func(struct bt_conn *conn,
			   struct bt_gatt_subscribe_params *params,
			   const void *data, uint16_t length)
{
	if (!data) {
		printk(&amp;quot;[UNSUBSCRIBED]\n&amp;quot;);
		params-&amp;gt;value_handle = 0U;
		return BT_GATT_ITER_STOP;
	}

	uint8_t* notif_data = (uint8_t*) data;

	printk(&amp;quot;[NOTIFICATION] Temp data &amp;quot;);
	for(int i = 0; i&amp;lt;length; i++)
	{
		printk(&amp;quot;%x &amp;quot;, notif_data[i]);
	}
	printk(&amp;quot;\n&amp;quot;);

	char *device_name =get_name_by_index(ble_manager, bt_conn_index(conn));
	printk(&amp;quot;[NOTIFICATION] temp data for index: %u name= %s.\n&amp;quot;, bt_conn_index(conn), device_name);

	long t_s;
	
	t_s = notif_data[3] &amp;lt;&amp;lt; 24 | notif_data[2] &amp;lt;&amp;lt; 16 | notif_data[1] &amp;lt;&amp;lt; 8 | notif_data[0];
	sh_protocol_send_streaming_packet( t_s , device_name, &amp;quot;temp_c&amp;quot;, length-5, &amp;amp;notif_data[4]);

	return BT_GATT_ITER_CONTINUE;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;4. And finally this is how I subscribe to a particular notification by giving the index of a particular&amp;nbsp;&lt;span&gt;gatt_subscrive structure.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;subscribe_parameter(0, SUB_CHEST_TEMP);
subscribe_parameter(1, SUB_CHEST_BAT);&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks...&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cannot able to get the multiple notification data on BLE central</title><link>https://devzone.nordicsemi.com/thread/459299?ContentTypeID=1</link><pubDate>Thu, 07 Dec 2023 08:45:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dbbb1b5e-773e-4fd7-98e6-9e9622c9483f</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Thanks for coming back with the changes you made Ankit. If possible, can you please post the code snippet of changes that you made? It will help this community for those who are trying to do similar things.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cannot able to get the multiple notification data on BLE central</title><link>https://devzone.nordicsemi.com/thread/459275?ContentTypeID=1</link><pubDate>Thu, 07 Dec 2023 07:08:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e6c2c92c-dac4-4490-b867-ca1435046f04</guid><dc:creator>Ankit_chauhan</dc:creator><description>&lt;p&gt;Thanks for your time and sorry for the late reply.&lt;/p&gt;
&lt;p&gt;I have been working on the same issue for the last few days and that is why I am not able to share my input into this thread.&lt;/p&gt;
&lt;p&gt;So here is an update to this issue, I figure out the actual use case of how we can utilize the&amp;nbsp;&lt;span&gt;bt_gatt_subscribe for multiple notifications. Below is the update in my code.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;In&amp;nbsp;discover_func I have used the&amp;nbsp;&lt;strong&gt;discover_params&lt;/strong&gt; structure for the discovery of services and characteristics and the &lt;strong&gt;subscribe_params&lt;/strong&gt; structure for subscribing to particular notifications.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Instead of using the subscribe_params structure, I changed it to&amp;nbsp;&lt;strong&gt;subscribe_params[6]&lt;/strong&gt; for each instance for each notification subscription, so now with this, I can subscribe to all my notifications and can able to get each notification data simultaneously.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks for your support.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cannot able to get the multiple notification data on BLE central</title><link>https://devzone.nordicsemi.com/thread/457808?ContentTypeID=1</link><pubDate>Tue, 28 Nov 2023 11:22:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8383e9e5-0276-4670-82c0-426ccc496f16</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;I see that we have not tested the client using multiple bt_gatt_subscribe method for more than one notification. So you might be on to something here.&lt;/p&gt;
&lt;p&gt;Can you please share your project for client and server here which has merged hrs, temp and battery so that I can test it here? It looks like you are doing everything right but only the last subscription is the only thing that is effective. Could be a bug at our end.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cannot able to get the multiple notification data on BLE central</title><link>https://devzone.nordicsemi.com/thread/457123?ContentTypeID=1</link><pubDate>Thu, 23 Nov 2023 10:29:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8d80f31b-88ed-435b-b80f-a6c8cddcbd20</guid><dc:creator>Ankit_chauhan</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Thanks for the reply,&lt;/p&gt;
&lt;p&gt;Currently, I am printing the raw data received from the sensor.&lt;/p&gt;
&lt;p&gt;NOTIFICATION] HR data e2 26 10 52 65 fa 1 f9 0 4b 0 0 f7 0 0 48 1 0&lt;/p&gt;
&lt;p&gt;[NOTIFICATION] battery data 43 96 2d 9e 58 b6 6a fc cf a7 ab 8e 12 20 66 5 b2 2d 90 1b&lt;/p&gt;
&lt;p&gt;This is my notify callback for HR. I am using similar functions for the others as well.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static uint8_t hr_notify_func(struct bt_conn *conn,
			   struct bt_gatt_subscribe_params *params,
			   const void *data, uint16_t length)
{
	if (!data) {
		printk(&amp;quot;[UNSUBSCRIBED]\n&amp;quot;);
		params-&amp;gt;value_handle = 0U;
		return BT_GATT_ITER_STOP;
	}

	uint8_t* notif_data = (uint8_t*) data;

	printk(&amp;quot;[NOTIFICATION] HR data &amp;quot;);
	for(int i = 0; i&amp;lt;length; i++)
	{
		printk(&amp;quot;%x &amp;quot;, notif_data[i]);
	}
	printk(&amp;quot;\n&amp;quot;);

	return BT_GATT_ITER_CONTINUE;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Yes, I am able to receive all the notification data over the nRF Connect Mobile App once I subscribe. Also as I said earlier, if I use a single service at a time i.e. If I discover HR characteristics and subscribe to HR notification it works. Similar for the Battery and Temperature as well.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regards.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Cannot able to get the multiple notification data on BLE central</title><link>https://devzone.nordicsemi.com/thread/457120?ContentTypeID=1</link><pubDate>Thu, 23 Nov 2023 10:20:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:385cfbe2-d835-44b2-8e97-d7e92d036036</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;Can you show me how you print the received subscription data onto your central device? And are you able to receive all the notification data on I.E. the nRF Connect app for Mobile or do you see the same issue there as well? I just want to confirm on what end the issue is exactly.&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>