Read device name characteristic of GAP using some event handler

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

At present I know that we can use CyBle_GapGetLocalName to read BLE device's changed name and then using CyBle_GapSetLocalName and saving that local name in FLASH memory can change my device namme. Even after reset device name retains if we call CyBle_GapSetLocalName with saved device name from FLASH. Its clear that I am reading device name by polling, If device name is changed I will get in CyBle_GapGetLocalName otw not.

   

 

   

Is there any kind of event that is generated on PSoC BLE device , if I change my BLE device name from my android side using GAP's device name characteristic.

0 Likes
1 Solution
Anonymous
Not applicable

I assume you can handle the CYBLE_EVT_GATTS_WRITE_REQ event in your custom event handler and see if the ATT handle to be written is the one of Device Name Characteristic. Take a look at the variable CYBLE_GATTS_DB_T cyBle_gattDB[] defined in the generated file BLE_gatt.c and you will see generated ATT handles.

   

 

   

In my BLE_gatt.c, the ATT handle for Device Name is 0x0003 (the first Characteristic). I am not sure if this value is persistent during code generation (but maybe it is required by Bluetooth specification?), so you should instead search through cyBle_gattDB (for example at the beginning of your program) to find an (the!) attribute with an UUID of CYBLE_UUID_CHAR_DEVICE_NAME. Then you will have your ATT handle.

View solution in original post

0 Likes
8 Replies
Anonymous
Not applicable

Edit - To be more specific, all I want is whenever android person send's a GAP device name characteristic for updating PSoC BLE's name I should know immediately rather than polling using CyBle_GapGetLocalName (which I am doing at this moment).

0 Likes
Anonymous
Not applicable

Anyone from Cypress ?

   

 

   

All I want is a an event that is generated on writing GAP's device name characteristic from iOS or anroid.

0 Likes
Anonymous
Not applicable

I assume you can handle the CYBLE_EVT_GATTS_WRITE_REQ event in your custom event handler and see if the ATT handle to be written is the one of Device Name Characteristic. Take a look at the variable CYBLE_GATTS_DB_T cyBle_gattDB[] defined in the generated file BLE_gatt.c and you will see generated ATT handles.

   

 

   

In my BLE_gatt.c, the ATT handle for Device Name is 0x0003 (the first Characteristic). I am not sure if this value is persistent during code generation (but maybe it is required by Bluetooth specification?), so you should instead search through cyBle_gattDB (for example at the beginning of your program) to find an (the!) attribute with an UUID of CYBLE_UUID_CHAR_DEVICE_NAME. Then you will have your ATT handle.

0 Likes
Anonymous
Not applicable

I was unable to find device name handle earlier. But now I can see it in BLE_gatt.c. This is what I was missing. Thanks a lot.

   

I will implement this tomorrow and post the results here.

   

Thanks.

0 Likes
Anonymous
Not applicable

I did not find that particular ATT handle defined in a generated .h file (like it is done in BLE_custom.h), so I think the best solution will be to search through cyBle_gattDB to find it, since one should not rely on hardcoded details inside the generated source files!

0 Likes
Anonymous
Not applicable

Yeah, I was also unable to find the handle. But now I can change device name. Thanks for your help.

0 Likes
Anonymous
Not applicable

Hi again! It look like the device name handle is CYBLE_GAP_DEVICE_NAME_INDEX + 1; take a look in the implementations of CyBle_GapSetLocalName()/CyBle_GapGetLocalName() 🙂

0 Likes

I also trying to save but no success

please let know how your able to set the device name by giving piece of code for the same.

0 Likes