Pioneer kit - BLE - change R/W in custom characteristics

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

cross mob
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Hello, 

   

in BLE component is Custom characteristics "MESSAGE" and in Properties are two parameters: Read and Write

   

These parameters I can change by "tick" button in configure window. It's clear. 

   

But how I can enable/disable for example Write parameter directly in C file? 

   

I would like to have something as: 

   

if ( i == 1) "Write is enable"

   

else "Write is disable"

   

 

   

Thanks in advance, Libor

0 Likes
1 Solution
Anonymous
Not applicable

Nope. That's the constant declared for Cypress' API usage. What you are looking for is more like this:

   

extern CYBLE_GATTC_WRITE_REQ_T serviceChangedCccdPacket;

   

serviceChangedCccdPacket.value = cccdIndFlagSetStruct;
serviceChangedCccdPacket.attrHandle = cyBle_gattc.cccdHandle;
CyBle_GattcWriteCharacteristicDescriptors(cyBle_connHandle, &serviceChangedCccdPacket);
 

   

Note: The example updates the descriptor value within the BLE callback stack, and thus it might have some call requirements to work properly.

   

I got this from the ANCS Example project on github: https://github.com/cypresssemiconductorco/PSoC-4-BLE/tree/master/100_Projects_in_100_Days/Day022_App...

View solution in original post

0 Likes
5 Replies
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

Please post your code so we can check it.

0 Likes
Anonymous
Not applicable
0 Likes
Anonymous
Not applicable

You need to change the associated CCCD value of the custom characteristic that you want to disable and enable.

   

(I believe it is set to 1 to enable and 0 to disable on a bitwise level, but you should look it up in the documentation on the BLE component to be sure).

   

Some of the example projects contain examples of what you want to do as well in the 100 projects in 100 days.

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

I found in file BLE_gatt.c const CYBLE_GATTS_DB_T cyBle_gattDB[0x12u] and inside is characteristic for "MESSAGE". 

   

When I change value from 0x000A0001u to 0x00020001u, parametr Write is disable. It's what I need

   

But it's a const and isn't possible to change it in program. Or I'm wrong? 

0 Likes
Anonymous
Not applicable

Nope. That's the constant declared for Cypress' API usage. What you are looking for is more like this:

   

extern CYBLE_GATTC_WRITE_REQ_T serviceChangedCccdPacket;

   

serviceChangedCccdPacket.value = cccdIndFlagSetStruct;
serviceChangedCccdPacket.attrHandle = cyBle_gattc.cccdHandle;
CyBle_GattcWriteCharacteristicDescriptors(cyBle_connHandle, &serviceChangedCccdPacket);
 

   

Note: The example updates the descriptor value within the BLE callback stack, and thus it might have some call requirements to work properly.

   

I got this from the ANCS Example project on github: https://github.com/cypresssemiconductorco/PSoC-4-BLE/tree/master/100_Projects_in_100_Days/Day022_App...

0 Likes