<?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>Advertising data via BLE GATT SERVICE with bl_notify_gatt() function</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/110039/advertising-data-via-ble-gatt-service-with-bl_notify_gatt-function</link><description>Hi! I am working on an application using the XIAO BLE SENSE soc equipped with the nRF52840 chip. The application should be capable of advertising two streams of data via a BLE GATT SERVICE connection by sending notifications to the client whenever a value</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 09 Apr 2024 13:20:07 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/110039/advertising-data-via-ble-gatt-service-with-bl_notify_gatt-function" /><item><title>RE: Advertising data via BLE GATT SERVICE with bl_notify_gatt() function</title><link>https://devzone.nordicsemi.com/thread/477827?ContentTypeID=1</link><pubDate>Tue, 09 Apr 2024 13:20:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0b910bf1-5605-4670-86c7-509b3bca80ce</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;span&gt;Ossian,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I see now that you are also missing the CCCD descriptor needed by the client to enable notifications. Please try changing your service declaration like this:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void tx_ccc_cfg_changed(const struct bt_gatt_attr *attr,
				  uint16_t value)
{
	if (value == BT_GATT_CCC_NOTIFY) {
		printk(&amp;quot;Notifications enabled\n&amp;quot;);
	}
	else {
		printk(&amp;quot;Notifications disabled\n&amp;quot;);
	} 
}

BT_GATT_SERVICE_DEFINE(custom_srv,
        BT_GATT_PRIMARY_SERVICE(BT_UUID_MY_CUSTOM_SERVICE),
        BT_GATT_CHARACTERISTIC(BT_UUID_MY_CAPACITANCE_CHRC, BT_GATT_CHRC_READ | BT_GATT_CHRC_NOTIFY, BT_GATT_PERM_READ, my_read_capacitance_function, NULL, NULL),
	BT_GATT_CCC(tx_ccc_cfg_changed,
			       BT_GATT_PERM_READ | BT_GATT_PERM_WRITE),
        BT_GATT_CHARACTERISTIC(BT_UUID_MY_BATV_CHRC, BT_GATT_CHRC_READ, BT_GATT_PERM_READ, my_read_battery_status_function, NULL, NULL)
);&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Vidar&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Advertising data via BLE GATT SERVICE with bl_notify_gatt() function</title><link>https://devzone.nordicsemi.com/thread/477824?ContentTypeID=1</link><pubDate>Tue, 09 Apr 2024 13:13:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cc62b8d8-9b2e-4ad7-92ba-d0f32aac111a</guid><dc:creator>ossian33</dc:creator><description>&lt;p&gt;Hi Vidar,&lt;/p&gt;
&lt;p&gt;I tried to swap to &amp;#39;&amp;amp;custom_srv.attrs[2]&amp;#39;, but i still get the error code &amp;#39;-22&amp;#39; after calling &amp;#39;int ret = bt_gatt_notify(conn, &amp;amp;custom_srv.attrs[2],&amp;nbsp; &amp;amp;picoFarads_32, sizeof(picoFarads_32));&amp;#39;. Could it be that i have missed something when defining the notify functionality?&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Ossian&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Advertising data via BLE GATT SERVICE with bl_notify_gatt() function</title><link>https://devzone.nordicsemi.com/thread/477798?ContentTypeID=1</link><pubDate>Tue, 09 Apr 2024 12:21:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4a588b54-b851-4201-a8f0-8e8c2ee28a67</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;Please try to change the &amp;#39;&amp;amp;custom_srv.attrs[1]&amp;#39; parameter to &amp;#39;&amp;amp;custom_srv.attrs[2]&amp;#39; so it points to your characteristic in the service structure and not the service itself.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Vidar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>