<?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>Reading the central device name (smart phone) in nRF52DK(Peripheral) and printing on the terminal</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/49837/reading-the-central-device-name-smart-phone-in-nrf52dk-peripheral-and-printing-on-the-terminal</link><description>I am working on nRF52DK. This will act as peripheral device and smart phone device will act as central. From my observations i could see 48-bit mac address and GATT local db components are getting stored in the flash during pairing sequence. It doesn</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 18 Jul 2019 10:16:31 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/49837/reading-the-central-device-name-smart-phone-in-nrf52dk-peripheral-and-printing-on-the-terminal" /><item><title>RE: Reading the central device name (smart phone) in nRF52DK(Peripheral) and printing on the terminal</title><link>https://devzone.nordicsemi.com/thread/199215?ContentTypeID=1</link><pubDate>Thu, 18 Jul 2019 10:16:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d2ee7cda-0fd5-43aa-bd76-565ae5a5cdf6</guid><dc:creator>skulkarni</dc:creator><description>&lt;p&gt;Thank you Vidar for the detailed explanation. Now I am am able to read the device name.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reading the central device name (smart phone) in nRF52DK(Peripheral) and printing on the terminal</title><link>https://devzone.nordicsemi.com/thread/199126?ContentTypeID=1</link><pubDate>Thu, 18 Jul 2019 07:38:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:84c01734-a8d8-4c96-9aed-a3899544f54a</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;sd_ble_gatts_attr_get will only return information about local attributes. You have to use GATT client read procedure to get the device name from your connected phone, see &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v6.1.1/group___b_l_e___g_a_t_t_c___v_a_l_u_e___r_e_a_d___m_s_c.html?cp=3_4_2_1_2_2_3_4"&gt;GATTC Characteristic or Descriptor Value Read&lt;/a&gt;.&amp;nbsp;But before you attempt to a GATT read you need to do a service discovery to find the attribute handles of the characteristics you want to access.&amp;nbsp;You can use the&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.3.0/lib_ble_db_discovery.html?cp=5_1_3_2_3"&gt;database discovery module&lt;/a&gt;&amp;nbsp;for this.&lt;/p&gt;
&lt;p&gt;Below is a code snippet showing how you can configure the discovery module to search for the device name characteristic. Please refer to the GAP central examples in the SDK if you run into problems with adding the module to your project.&amp;nbsp; &amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/**@brief Function for handling database discovery events.
 *
 * @details This function is a callback function to handle events from the database discovery module.
 *          Depending on the UUIDs that are discovered, this function forwards the events
 *          to their respective services.
 *
 * @param[in] p_event  Pointer to the database discovery event.
 */
static void db_disc_handler(ble_db_discovery_evt_t * p_evt)
{
    
    uint32_t err_code; 
    uint16_t att_handle;

    ble_gatt_db_char_t * p_chars = p_evt-&amp;gt;params.discovered_db.charateristics;
    
    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_GAP)
        &amp;amp;&amp;amp;  (p_evt-&amp;gt;params.discovered_db.srv_uuid.type == BLE_UUID_TYPE_BLE))
    {
        for (uint32_t i = 0; i &amp;lt; p_evt-&amp;gt;params.discovered_db.char_count; i++)
        {
              if (p_chars[i].characteristic.uuid.uuid == BLE_UUID_GAP_CHARACTERISTIC_DEVICE_NAME)
              {
                  att_handle = p_chars[i].characteristic.handle_value;
                  /*Found Device name characteristic - Start read procedure*/
                  err_code = sd_ble_gattc_read(p_evt-&amp;gt;conn_handle, att_handle, 0);
                  APP_ERROR_CHECK(err_code);
              }
        }
    }
    
}


/** @brief Function for initializing the database discovery module. */
static void db_discovery_init(void)
{
    static ble_uuid_t ble_uuid;

    ble_uuid.type = BLE_UUID_TYPE_BLE;
    ble_uuid.uuid = BLE_UUID_GAP;
    
    ret_code_t err_code = ble_db_discovery_init(db_disc_handler);
    APP_ERROR_CHECK(err_code);

    err_code = ble_db_discovery_evt_register(&amp;amp;ble_uuid);
    APP_ERROR_CHECK(err_code);
}&lt;/pre&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reading the central device name (smart phone) in nRF52DK(Peripheral) and printing on the terminal</title><link>https://devzone.nordicsemi.com/thread/199103?ContentTypeID=1</link><pubDate>Thu, 18 Jul 2019 04:01:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:32cd7746-570a-4b89-92c7-381487783a5b</guid><dc:creator>skulkarni</dc:creator><description>&lt;p&gt;Tried to get the device name using&amp;nbsp; sd_ble_gatts_attr_get but it doent work.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void on_ble_evt(ble_evt_t * p_ble_evt)
{
  case BLE_GAP_EVT_CONNECTED:
  m_conn_handle = p_ble_evt-&amp;gt;evt.gap_evt.conn_handle;
  ble_uuid_t temp;
  temp.type = BLE_UUID_TYPE_BLE;
  temp.uuid = BLE_UUID_GAP_CHARACTERISTIC_DEVICE_NAME;
  err_code = sd_ble_gatts_attr_get(m_conn_handle, &amp;amp;temp, NULL);
  APP_ERROR_CHECK(err_code); // Fails here&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reading the central device name (smart phone) in nRF52DK(Peripheral) and printing on the terminal</title><link>https://devzone.nordicsemi.com/thread/198651?ContentTypeID=1</link><pubDate>Tue, 16 Jul 2019 09:32:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b1195261-fa2d-4175-aeb1-eb3a0362616c</guid><dc:creator>skulkarni</dc:creator><description>&lt;p&gt;Yes. Just came to know that device name is part of the GATT primary service. I am looking for reading this attribute on connection.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reading the central device name (smart phone) in nRF52DK(Peripheral) and printing on the terminal</title><link>https://devzone.nordicsemi.com/thread/198621?ContentTypeID=1</link><pubDate>Tue, 16 Jul 2019 07:53:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f6739785-fda9-41a7-bf0f-4d1b18f8b824</guid><dc:creator>awneil</dc:creator><description>&lt;p&gt;But isn&amp;#39;t that name just for when other things are trying &lt;span style="text-decoration:underline;"&gt;&lt;em&gt;&lt;strong&gt;to&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt; connect to your phone - ie, when the phone is a &amp;quot;peripheral&amp;quot; ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reading the central device name (smart phone) in nRF52DK(Peripheral) and printing on the terminal</title><link>https://devzone.nordicsemi.com/thread/198617?ContentTypeID=1</link><pubDate>Tue, 16 Jul 2019 07:44:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7cf3ab17-940b-4030-804d-4b224ab45e80</guid><dc:creator>skulkarni</dc:creator><description>&lt;p&gt;nRF52 is programmed as peripheral. I have not set any name so by default it get recognized as &amp;quot;nrf &amp;quot; in my smart phone. My smart phone Bluetooth device name is &amp;quot;skulkarni&amp;quot; . When I try to pair (from Smart phone), I want to read central device name(skulkarni) in the peripheral. For some reasons i need to know the central device name.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reading the central device name (smart phone) in nRF52DK(Peripheral) and printing on the terminal</title><link>https://devzone.nordicsemi.com/thread/198609?ContentTypeID=1</link><pubDate>Tue, 16 Jul 2019 07:32:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5e89708a-8305-461f-a6a0-d1d679ff89c5</guid><dc:creator>awneil</dc:creator><description>&lt;p&gt;What &amp;quot;name&amp;quot; are you thinking of?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>