<?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>Private GATT NOTIFY</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/105550/private-gatt-notify</link><description>I have defined a private GATT Service with several cahractersitics. I have defined a 128bit UUID:: 
 
 Then I define the charactersitic: 
 
 In my NOTIFY callback: 
 
 Then I&amp;#39;ve defined a notify function where i invoke: 
 
 But my NOTIFY characteristic</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 14 Nov 2023 21:44:49 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/105550/private-gatt-notify" /><item><title>RE: Private GATT NOTIFY</title><link>https://devzone.nordicsemi.com/thread/455639?ContentTypeID=1</link><pubDate>Tue, 14 Nov 2023 21:44:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:38c61770-bb19-4d3b-8070-031c16fa96b6</guid><dc:creator>MtnDrew</dc:creator><description>&lt;p&gt;Yes!! This allows me to define an attrs struct:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static struct bt_gatt_attr svc_attrs[] = {{&amp;amp;data_uuid.uuid}};
static struct bt_gatt_service logAttrs;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Then in main:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;logAttrs = (struct bt_gatt_service)BT_GATT_SERVICE(svc_attrs);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;In my notify function:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;err = bt_gatt_notify_uuid(NULL, &amp;amp;data_uuid.uuid, logAttrs.attrs, &amp;amp;logData, sizeof(logData));&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;And I&amp;#39;m able to eliminate the write property from my characteristic:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;	BT_GATT_CHARACTERISTIC(&amp;amp;data_uuid.uuid,
		BT_GATT_CHRC_NOTIFY, 
		BT_GATT_PERM_READ, NULL, NULL, NULL),
	BT_GATT_CCC(data_ccc_cfg_changed, BT_GATT_PERM_READ | BT_GATT_PERM_WRITE),
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Thank you, Amanda for your guidance. If you see any glaring errors in my implementation above, I welcome your suggestions. Otherwise you may consider this matter solved.&lt;/p&gt;
&lt;p&gt;Drew&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Private GATT NOTIFY</title><link>https://devzone.nordicsemi.com/thread/455413?ContentTypeID=1</link><pubDate>Mon, 13 Nov 2023 20:37:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:34df4eb3-aac4-415b-af6f-0faf8ed35c78</guid><dc:creator>Amanda Hsieh</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v3.4.99-ncs1/subsys/bluetooth/host/gatt.c#L2794-L2796"&gt;&lt;span&gt;-128 is&amp;nbsp;&lt;/span&gt;ENOTCONN&lt;/a&gt; which means the socket is not connected and is returned by&amp;nbsp;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v3.4.99-ncs1/include/zephyr/bluetooth/gatt.h#L1190"&gt;bt_gatt_notify_cb&lt;/a&gt; in the&amp;nbsp;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v3.4.99-ncs1/include/zephyr/bluetooth/gatt.h#L1173"&gt;bt_gatt_notify_uuid()&lt;/a&gt;. It needs to check the connection status.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you create a&amp;nbsp;GATT Service with&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/connectivity/bluetooth/api/gatt.html#c.bt_gatt_service"&gt;bt_gatt_service&lt;/a&gt;, you could use &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/connectivity/bluetooth/api/gatt.html#c.bt_gatt_service.attrs"&gt;.attrs&lt;/a&gt;. &lt;br /&gt;See the example:&lt;br /&gt;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v3.4.99-ncs1/subsys/bluetooth/audio/mcs.c#L914"&gt;https://github.com/nrfconnect/sdk-zephyr/blob/v3.4.99-ncs1/subsys/bluetooth/audio/mcs.c#L914&lt;/a&gt;&amp;nbsp;&lt;br /&gt;&lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/v3.4.99-ncs1/subsys/bluetooth/audio/mcs.c#L932"&gt;https://github.com/nrfconnect/sdk-zephyr/blob/v3.4.99-ncs1/subsys/bluetooth/audio/mcs.c#L932&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Amanda H.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Private GATT NOTIFY</title><link>https://devzone.nordicsemi.com/thread/455164?ContentTypeID=1</link><pubDate>Fri, 10 Nov 2023 16:30:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6e75017c-8645-47d7-ad7d-7f6dd618a545</guid><dc:creator>MtnDrew</dc:creator><description>&lt;p&gt;As coded above the&amp;nbsp;&lt;span&gt;bt_gatt_notify_uuid() function returns &amp;quot;-128&amp;quot;.&amp;nbsp; I also receive a LOG_WRN message &amp;quot;Link is not encrypted&amp;quot;.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;As A workaround, this is how I&amp;#39;ve had to define the characteristic:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;    BT_GATT_CHARACTERISTIC(&amp;amp;data_uuid.uuid,
        BT_GATT_CHRC_NOTIFY | BT_GATT_CHRC_READ,
        BT_GATT_PERM_READ, read_data, NULL, NULL),
	BT_GATT_CCC(data_ccc_cfg_changed, BT_GATT_PERM_READ | BT_GATT_PERM_WRITE),
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Then I declare a bt_gatt_attr in global scope:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;struct bt_gatt_attr *privateAttr;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;And assign it to the attr passed into the read callback:&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;static ssize_t read_data(

    struct bt_conn *conn,
    const struct bt_gatt_attr *attr,
    void *buf, uint16_t len, uint16_t offset)
{

	privateAttr = attr; // TODO: Acquire attribute
		
	uint8_t logData[10];

	getLogData((uint8_t*)&amp;amp;logData);

    return bt_gatt_attr_read(conn, attr, buf, len, offset, &amp;amp;logData, sizeof(logData));
}&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;And that is used in my bt_gatt_notify_uuid() call:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;uint8_t data_notify(void) 
{
	//LOG_INF(&amp;quot;Data Notification&amp;quot;);

	int err;

	uint8_t logData[10];

	getLogData((uint8_t*)&amp;amp;logData);

	err = bt_gatt_notify_uuid(NULL, &amp;amp;data_uuid.uuid, privateAttr, &amp;amp;logData, sizeof(logData));
	if(err) {

		LOG_DBG(&amp;quot;Data Notify Error = %d&amp;quot;, err);
		return err;
	}

	return 1;
}&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;This works but it is a bit of a hack as our customer only required a NOTIFY property on this characteristic.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Again, I believe the issue might be in how I am acquiring the &amp;quot;attr&amp;quot; parameter from the bt_gatt_notify_uuid() call.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Any suggestions would be appreciated.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;-Drew&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Private GATT NOTIFY</title><link>https://devzone.nordicsemi.com/thread/455018?ContentTypeID=1</link><pubDate>Thu, 09 Nov 2023 20:19:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:46807e67-b9a7-45c7-9bf7-ac46f40d82e7</guid><dc:creator>khelmutlord</dc:creator><description>&lt;p&gt;Hello Drew,&lt;/p&gt;
&lt;p&gt;Could you share what return value you receive from your call to bt_gatt_notify_uuid?&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Helmut Lord&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>