Write Characteristic Values

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

cross mob
Anonymous
Not applicable

Hi Cypress Community,

   

I am working with a Client/Central-Server/Peripheral set up using 2 pioneer kits where I have the server sending notifications to the Client. 

   

Using the CySmart Tool and dongle and I can easily enable notifications on all the characteristics that I have set using the BLE circuit block.

   

When I try using the Client/Central pioneer kit to writeCharacterisitc values to ([01:00]) the various characteristics on the Server/Pheripheral pioneer kit, only the first one is enabled and the second returns an CYBLE_ERROR_INVALID_OPERATION. Even if I call the same function twice the first one is enabled and the second returns that error. It also doesn't even matter what handle I set.

   

I know it is not the Server/Peripheral side because the Dongle can enable notifications perfectly fine.

   

Any thoughts?

   

Thank you.

0 Likes
10 Replies
Anonymous
Not applicable

I believe you are writing 01:00 to CCCD's of the characteristic.

   

Can you try calling CyBle_ProcessEvents() after every characteristic write of individual CCCDs? Try enabling them from the main loop, not from the Event handler of the BLE component.

0 Likes
Anonymous
Not applicable
        Hello roit, Yes you're correct I'm writing 0100 to the CCCDs value. I do have them being enabled in the main loop and have tried cyble_processevents after each one as well. It's a very strange problem. The cysmart dongle setup has no problem which is frustrating .   
0 Likes
Anonymous
Not applicable

Can you attach your project ZIP here so that forum members can give it a look?

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

Sure I can,

   

Thank you

0 Likes
Anonymous
Not applicable

John,

   

Can you replace the 'CyBle_GattcWriteCharacteristicDescriptors' API with following in your 'EnableFootPedalNotification' function?

   

apiResult = CyBle_GattcWriteCharacteristicDescriptors(cyBle_connHandle, &writeReqParam_FootPedal);

   

Similarly in 'EnableFootPedal2Notification'.

   

Also, I believe that 0x0025 and 0x0029 are the attribute handles of the CCCD of the Characteristics that you want the notification to be enable on.

0 Likes
Anonymous
Not applicable

In the BLEclient.c , the connection event stores the param as connHandle. Should I change it there too?

   

And yes you are correct, the 0x0025, 0x0029 are the attribute handles for the CCCD of those characteristics.

0 Likes
Anonymous
Not applicable

No need to change the connHandle value.

   

It is preferable to use cyBle_connHandle wherever it is required, as it is updated by the component directly.

0 Likes
Anonymous
Not applicable

So I tried changing the connHandle with cyBle_connHandle and I still receive the INVALID OPERATION error. 

0 Likes
Anonymous
Not applicable

John,

   

Do you have a BLE sniffer with your? I am trying to see what kind of BLE activity happens on the second notification.

   

I don't have the server side of your project so I cannot test the changes. Can you try the following:

   

As you already know the attribute handles, you don't need to do Service discovery after connection.

   

Remove the 'apiResult = CyBle_GattcStartDiscovery(connHandle);' from the 'CYBLE_EVT_GAP_DEVICE_CONNECTED' event and move 'deviceConnected = TRUE;'  from 'CYBLE_EVT_GATTC_DISCOVERY_COMPLETE' to 'CYBLE_EVT_GAP_DEVICE_CONNECTED'.

   

The reason I am asking is because Creator 3.1 had some issue with Custom service discovery, just want to make sure that does not create a problem.

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

I tried using a co-workers BLE sniffer but had trouble getting it to sniff my projects packets. I might have to retry.

   

I posted the Server's project.

   

 

   

Thank you so much for your help by the way. 

0 Likes