How do I use the Service Changed characteristic effectively?

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

cross mob
Anonymous
Not applicable

I am using two projects to reference from when writing my BLE application on the PRoC CYBLE 02201-00. The first is the BLE Heart Rate Sensor example project, and the second is the creating a custom ble profile project.

   

​I am now able to check an individual CCCD to see if notify has been set and can use the notify or non-notify versions of the write value function. However, on both example projects when I use Enable All Notifications from the CySmart windows app it will flip the bit on the Service Changed CCCD and then update all the other CCCDs. However, I can not find the function that handles this in either project. I am not even sure of the Service Changed CCCD Handle.

   

Can anyone show me how these projects accomplish that so I can use it in my application?

0 Likes
1 Solution
Anonymous
Not applicable

Are you asking how to Enable All Notifications using a function in the CyBle_ library? I don't think there is a specific one that does that. If you look at the CySmart log output (bottom of screen, or saved in file) I bet it is sending multiple packets to change each CCCD individually, and then changing the Service Changed CCCD as well.

   

CCCD's have a specific UUID value that you can look for/compare with to find all CCCD values in a BLE profile, and thus enable/disable all CCCD values.

View solution in original post

0 Likes
4 Replies
Anonymous
Not applicable

Are you asking how to Enable All Notifications using a function in the CyBle_ library? I don't think there is a specific one that does that. If you look at the CySmart log output (bottom of screen, or saved in file) I bet it is sending multiple packets to change each CCCD individually, and then changing the Service Changed CCCD as well.

   

CCCD's have a specific UUID value that you can look for/compare with to find all CCCD values in a BLE profile, and thus enable/disable all CCCD values.

0 Likes
Anonymous
Not applicable

I see. The log indicates it is writing a '2' to service changed CCCD and then reading back to ensure that it was received correctly. It then writes to the notification flag for each CCCD.

   

 

   

I was unsure if Service Changed was intended to act as some mega switch that turned everything on, but it seems that no such mega switch was intended and everything is self contained.

   

 

   

If I wanted to check Service Changed would I use 0x000Au or 0x000Bu while operating in a server role based on this section of code in CYBLE_gatt.c? Or am I looking in the wrong place?

   

 

   

#if(CYBLE_GATT_ROLE_SERVER)
    
    const CYBLE_GATTS_T cyBle_gatts =
{
    0x0008u,    /* Handle of the GATT service */
    0x000Au,    /* Handle of the Service Changed characteristic */
    0x000Bu,    /* Handle of the Client Characteristic Configuration descriptor */
};

0 Likes
Anonymous
Not applicable

Hi Nate,

   

The 'Service Changed' characteristic is used by the GATT server to indicate to the GATT client if there was any change in the GATT DB when the two are connected. 

   

On CySmart, when you click ' Enable All Notifications', as e.pratt_1639216 rightly said, CySmart sends a write request to every CCCD one after the other.

   

The 'Service Changed' characteristic has a CCCD which is used to enable/disable Indications. When you 'Enable All Notifications', CySmart sends a 0x02, which is the value to enable indications.

   

The Service Changed characteristic, whose handle is 0x000Au in your case will have the starting handle and ending handle of the affected attribute range.

MikeAustin
Level 4
Level 4
25 replies posted 25 sign-ins 10 replies posted

Apologies for dredging up an old topic, but I need a bit of assistance with forcing a Client to rediscover all available services and I'm having trouble working out how to do this.  I understand conceptually what I need to do (that is, write to the Service Changed Characteristic with the start and end handles of the affected attribute range), but from a code perspective, I'm struggling to work out how to do this.

The situation is where I have a Client (iOS device) paired with a Server (my PSOC device), and I force the Server into an OTA upgrade.  When the Server is in Bootloader mode,  I want to hide the normal services available when in Bootloadable mode, and show only the ones applicable to Bootloader mode.  Then, when the firmware has been updated, I want to be able to have the Server go back into Bootloadable mode and start showing all the normal Services again.

From the looks of the examples, I need to do something like:

value = "complete range of Services"; (not sure how to set this)

handleValuePair.value.val = (uint8 *)&value;
handleValuePair.value.len = sizeof(value);

handleValuePair.attrHandle = cyBle_gatts.serviceChangedHandle;
CyBle_GattsWriteAttributeValue(&handleValuePair, 0u, NULL,CYBLE_GATT_DB_LOCALLY_INITIATED);

Is it possible to do say "look for all Services" or do you have to specify individual Services on-by-one.  In either case, what do I need to do to correctly set "value" so it is specifying the appropriate services or range of services?

Cheers,

Mike

0 Likes