<?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>Get connected device name in Generic Access Service from ble central</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/46407/get-connected-device-name-in-generic-access-service-from-ble-central</link><description>Hi all, 
 I would like to get the complete name from the connected peripheral by reading the device name characteristic (0x2A00) in the Generic Access Service (0x1800). I am using SDK 15.2.0 with soft device s132 v6.1.1. 
 I have tried to call sd_ble_gattc_char_value_by_uuid_read</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 10 May 2019 14:28:37 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/46407/get-connected-device-name-in-generic-access-service-from-ble-central" /><item><title>RE: Get connected device name in Generic Access Service from ble central</title><link>https://devzone.nordicsemi.com/thread/186460?ContentTypeID=1</link><pubDate>Fri, 10 May 2019 14:28:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a20913f9-582a-457d-8cb1-835d4dd1569d</guid><dc:creator>HDuc</dc:creator><description>&lt;p&gt;Hi Simon,&lt;br /&gt;&lt;br /&gt;Thank you for your reply. I will try later and give feedback.&lt;br /&gt;I think I must discover all services, then discover&amp;nbsp;&lt;span&gt;service characteristics inside 1800 uuid, and&amp;nbsp;finally read the characteristic value of&amp;nbsp;2A00 uuid.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Get connected device name in Generic Access Service from ble central</title><link>https://devzone.nordicsemi.com/thread/184600?ContentTypeID=1</link><pubDate>Tue, 30 Apr 2019 13:24:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fe2492d4-54db-43dd-8876-25d126a30d97</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;The reason this won&amp;#39;t work is because you are looking for the device name characteristic inside the NUS service. The device name characteristics lies inside the generic access service. I tried to check for&amp;nbsp;p_evt-&amp;gt;params.discovered_db.srv_uuid.uuid == 0x1800 but never got any hit, and I am not sure why.&lt;/p&gt;
&lt;p&gt;I tried to get &lt;em&gt;sd_ble_gattc_char_value_by_uuid_read()&amp;nbsp;&lt;/em&gt;to work, and have partly succeeded. I called it inside&amp;nbsp;case BLE_GATTC_EVT_WRITE_RSP (Then the call to &lt;em&gt;ble_nus_c_tx_notif_enable--&amp;gt; cccd_configure()--&amp;gt;sd_ble_gattc_write()&amp;nbsp;&lt;/em&gt;has completed and I won&amp;#39;t receive NRF_ERROR_BUSY)&amp;nbsp;and I successfully received the event&amp;nbsp;BLE_GATTC_EVT_CHAR_VAL_BY_UUID_READ_RSP. However, I haven&amp;#39;t been able to get the data yet. But I think you have to use the function&amp;nbsp;&lt;em&gt;sd_ble_gattc_evt_char_val_by_uuid_read_rsp_iter().&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;If you don&amp;#39;t figure it out, please ask, and I will look into it.&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: Get connected device name in Generic Access Service from ble central</title><link>https://devzone.nordicsemi.com/thread/183846?ContentTypeID=1</link><pubDate>Thu, 25 Apr 2019 13:44:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7c4a05e1-1441-4173-9664-fc67762f2b19</guid><dc:creator>HDuc</dc:creator><description>&lt;p&gt;Hi Andy,&lt;br /&gt;I have put the code in &amp;quot;db_disc_handler&amp;quot; and&amp;nbsp;BLE_GATTC_EVT_READ_RSP event;&amp;nbsp;&lt;span&gt;sd_ble_gattc_read() is also called inside&amp;nbsp;&amp;quot;db_disc_handler&amp;quot;. But I see only the log line&amp;nbsp;&amp;quot;Found GAP profile service&amp;quot;.&amp;nbsp;&amp;quot;Found device name characteristic&amp;quot; and&amp;nbsp;&amp;quot;Read length:&amp;nbsp;Read offset: &amp;quot;&amp;nbsp;do not appear.&lt;pre class="ui-code" data-mode="text"&gt;static void db_disc_handler(ble_db_discovery_evt_t * p_evt)
{
    ble_nus_c_on_db_disc_evt(&amp;amp;m_ble_nus_c, p_evt);

    if ((p_evt-&amp;gt;evt_type == BLE_DB_DISCOVERY_COMPLETE) &amp;amp;&amp;amp;
            (p_evt-&amp;gt;params.discovered_db.srv_uuid.uuid == BLE_UUID_NUS_SERVICE) &amp;amp;&amp;amp;
            (p_evt-&amp;gt;params.discovered_db.srv_uuid.type == NUS_SERVICE_UUID_TYPE))
            {
                NRF_LOG_INFO(&amp;quot;Found GAP profile service&amp;quot;);
                // Find the CCCD Handles of the device name characteristic
                for (uint8_t i = 0; i &amp;lt; p_evt-&amp;gt;params.discovered_db.char_count; i++)
                {
                    if ((p_evt-&amp;gt;params.discovered_db.charateristics[i].characteristic.uuid.uuid == BLE_UUID_GAP_CHARACTERISTIC_DEVICE_NAME) &amp;amp;&amp;amp;
			(p_evt-&amp;gt;params.discovered_db.charateristics[i].characteristic.uuid.type == BLE_UUID_TYPE_BLE))
                    {
			NRF_LOG_INFO(&amp;quot;Found device name characteristic&amp;quot;);
			device_name_handle = p_evt-&amp;gt;params.discovered_db.charateristics[i].characteristic.handle_value;
			// Break out of for loop
			break;
                    }
                }
            }

     ret_code_t err_code;
     err_code = sd_ble_gattc_read(p_evt-&amp;gt;conn_handle, device_name_handle, 0);
     if (err_code != NRF_ERROR_BUSY)
     {
        APP_ERROR_CHECK(err_code);
     }
}&lt;/pre&gt;&lt;pre class="ui-code" data-mode="text"&gt;case BLE_GATTC_EVT_READ_RSP:
        {
            uint8_t device_name[50];
            uint8_t device_name_length;
            ble_gattc_evt_read_rsp_t const * p_read_rsp = &amp;amp;p_ble_evt-&amp;gt;evt.gattc_evt.params.read_rsp;
            NRF_LOG_INFO(&amp;quot;Read length: %d, Read offset: %d&amp;quot;, p_read_rsp-&amp;gt;len, p_read_rsp-&amp;gt;offset);
            // We are reading the device name
            if (p_read_rsp-&amp;gt;handle == device_name_handle)
            {
		for (uint8_t i = 0; i &amp;lt; p_read_rsp-&amp;gt;len; i++)
                {
			device_name[i + p_read_rsp-&amp;gt;offset] = p_read_rsp-&amp;gt;data[i];
		}
		device_name_length = p_read_rsp-&amp;gt;len + p_read_rsp-&amp;gt;offset;
            }
	} break;&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Get connected device name in Generic Access Service from ble central</title><link>https://devzone.nordicsemi.com/thread/183737?ContentTypeID=1</link><pubDate>Thu, 25 Apr 2019 10:28:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d9cb4d35-0536-4920-a3c0-6856f367fab1</guid><dc:creator>Andy</dc:creator><description>&lt;p&gt;On your discovery event handler you do this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;if ((p_evt-&amp;gt;evt_type == BLE_DB_DISCOVERY_COMPLETE) &amp;amp;&amp;amp;
	(p_evt-&amp;gt;params.discovered_db.srv_uuid.uuid == gap_profile_s_uuid.uuid) &amp;amp;&amp;amp;
	(p_evt-&amp;gt;params.discovered_db.srv_uuid.type == gap_profile_s_uuid.type)) {

	NRF_LOG_INFO(&amp;quot;Found GAP profile service&amp;quot;);

	// Find the CCCD Handles of the device name characteristic
	for (uint8_t i = 0; i &amp;lt; p_evt-&amp;gt;params.discovered_db.char_count; i++) {
		if ((p_evt-&amp;gt;params.discovered_db.charateristics[i].characteristic.uuid.uuid == device_name_c_uuid.uuid) &amp;amp;&amp;amp;
			(p_evt-&amp;gt;params.discovered_db.charateristics[i].characteristic.uuid.type == device_name_c_uuid.type)) {

			NRF_LOG_INFO(&amp;quot;Found device name characteristic&amp;quot;);
			device_name_handle = p_evt-&amp;gt;params.discovered_db.charateristics[i].characteristic.handle_value;

			// Break out of for loop
			break;
		}
	}
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Then you can use the device_name_handle in sd_ble_gattc_read(). In the offset just write 0.&amp;nbsp;Where you call&amp;nbsp;&lt;span&gt;sd_ble_gattc_read() is up to you, and it doesn&amp;#39;t really matter.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;To get the device name data, you need to do this in you BLE event handler:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;case BLE_GATTC_EVT_READ_RSP:;
	ble_gattc_evt_read_rsp_t const * p_read_rsp = &amp;amp;p_ble_evt-&amp;gt;evt.gattc_evt.params.read_rsp;

	NRF_LOG_INFO(&amp;quot;Read length: %d, Read offset: %d&amp;quot;, p_read_rsp-&amp;gt;len, p_read_rsp-&amp;gt;offset);

	// We are reading the device name
	if (p_read_rsp-&amp;gt;handle == device_name_handle) {
		for (uint8_t i = 0; i &amp;lt; p_read_rsp-&amp;gt;len; i++) {
			device_name[i + p_read_rsp-&amp;gt;offset] = p_read_rsp-&amp;gt;data[i];
		}
		device_name_length = p_read_rsp-&amp;gt;len + p_read_rsp-&amp;gt;offset;
	}
	break;&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Get connected device name in Generic Access Service from ble central</title><link>https://devzone.nordicsemi.com/thread/183734?ContentTypeID=1</link><pubDate>Thu, 25 Apr 2019 10:14:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c98ac703-dd61-42bb-a237-b8417523ae3e</guid><dc:creator>HDuc</dc:creator><description>&lt;p&gt;Hi Andy,&lt;br /&gt;&lt;span&gt;Thank for your reply. Could you explain more detail about how you do.&lt;br /&gt;&lt;/span&gt;What are the references I must put in &amp;quot;handle&amp;quot; and &amp;quot;offset&amp;quot;.&lt;br /&gt;Where I have to call&amp;nbsp;&lt;span&gt;sd_ble_gattc_read(), in&amp;nbsp;BLE_GAP_EVT_CONNECTED event or in&amp;nbsp;EVT_DISCOVERY_COMPLETE event.&lt;br /&gt;And how to get the value.&lt;br /&gt;Many thanks in advance.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Get connected device name in Generic Access Service from ble central</title><link>https://devzone.nordicsemi.com/thread/183731?ContentTypeID=1</link><pubDate>Thu, 25 Apr 2019 10:04:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cfb4442e-5b46-4450-9965-64145d3329af</guid><dc:creator>HDuc</dc:creator><description>&lt;p&gt;Hi Simon,&lt;br /&gt;Thank for your reply. I haven&amp;#39;t used sniffer, so I will try later.&amp;nbsp;Is there any other way to check it&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Get connected device name in Generic Access Service from ble central</title><link>https://devzone.nordicsemi.com/thread/183478?ContentTypeID=1</link><pubDate>Wed, 24 Apr 2019 12:59:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5fc8a98d-e7e2-4c22-b893-1106dee9e07b</guid><dc:creator>Andy</dc:creator><description>&lt;p&gt;I did this once by discovering the characteristic using the discovery module, storing the value handle and then calling&amp;nbsp;sd_ble_gattc_read() using that value handle. It worked like a charm.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Get connected device name in Generic Access Service from ble central</title><link>https://devzone.nordicsemi.com/thread/183469?ContentTypeID=1</link><pubDate>Wed, 24 Apr 2019 12:49:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9282975f-7886-4e7d-8a21-72c1f28d2dba</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;Does&amp;nbsp;&lt;em&gt;sd_ble_gattc_char_value_by_uuid_read(..)&amp;nbsp;&lt;/em&gt;return NRF_SUCCESS? If it does, could you provide a sniffer trace? If not, what does it return?&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>