This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Reading the central device name (smart phone) in nRF52DK(Peripheral) and printing on the terminal

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't store the central device name.
Please let me know how to read the central device name during the connection.

Parents
  • What "name" are you thinking of?

  • nRF52 is programmed as peripheral. I have not set any name so by default it get recognized as "nrf " in my smart phone. My smart phone Bluetooth device name is "skulkarni" . 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.

  • But isn't that name just for when other things are trying to connect to your phone - ie, when the phone is a "peripheral" ?

  • Yes. Just came to know that device name is part of the GATT primary service. I am looking for reading this attribute on connection.

  • Tried to get the device name using  sd_ble_gatts_attr_get but it doent work.

  • Hi, 

    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 GATTC Characteristic or Descriptor Value Read. 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. You can use the database discovery module for this.

    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.   

  • Thank you Vidar for the detailed explanation. Now I am am able to read the device name. 

Reply Children
No Data