CyBle_GattsNotification() error

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

cross mob
Anonymous
Not applicable

 I have been working on a early development system to read sensor data and transmit using BLE.  My system seems to be working well except for sending the notification data.  The error returned is CYBLE_ERROR_INVALID_PARAMETER.  The manual states the "'connHandle' value does not represent any existing entry in the Stack", but I'm using the global connHandle:

   

    /* Initialize Notification handle */

   

    SensorDataNTF.attrHandle = CYBLE_SENSOR_SERVICE_SENSOR_DATA_CHAR_HANDLE;

   

    SensorDataNTF.value.val = (uint8 *)&gi_ADC_Count;

   

    SensorDataNTF.value.len = sizeof(gi_ADC_Count);

   

   

    /* Send notification */

   

    apiResult = CyBle_GattsNotification(cyBle_connHandle, &SensorDataNTF);

   

    if (CYBLE_ERROR_OK != apiResult) {

   

        apiResult = CYBLE_ERROR_OK;

   

    }

   

I've verified that cyBle_connHandle.bdHandle is not 0.

   

I'm hoping I'm missing something obvious and that one of you will be able to point me in the right direction to correct the problem.

0 Likes
8 Replies
Anonymous
Not applicable

 Hi,

   

 

   

Pls check whether the handle is correct or not.

   

 

   

Can you share the project?

   

 

   

Regards,

   

Vikas

0 Likes
Anonymous
Not applicable

I had understood that the BLE code handles the setting of the cyBle_connHandle variable and would always reflect the current connection.  Am I incorrect in that assumption?  What would I be comparing it to to verify that it is correct?

0 Likes
Anonymous
Not applicable

 I meant to say CYBLE_SENSOR_SERVICE_SENSOR_DATA_CHAR_HANDLE not Cyble_ConnHandle.

   

 

   

Please share the project

   

 

   

Regards,

   

Vikas

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

 Project attached.

   

The Define of CYBLE_SENSOR_SERVICE_SENSOR_DATA_CHAR_HANDLE seems correct to me.  Same as the Data characteristic.

0 Likes
Anonymous
Not applicable

 Hi,

   

 

   

MTU size is set to 23(BLE component->GAP settings->General

   

 

   

But you are trying to send 64 bytes of notification. You cannot send a notification of size greater than MTU-3 in a single trasnfer.Change the MTU to 67 and then try.

   

 

   

Also I found that you are trying to enablethe notifications locally by writing to the CCCD. It doesn't make any sense by enabling the notifications locally.It is supposed to be enabled by client

   

 

   

Regards,

   

Vikas

0 Likes
Anonymous
Not applicable

It works with the change you suggested.  Thank you.

   

Would you be able to explain further?  I'd like a better understanding.  What was I able to get a read of the attribute to work, but not the notification when the MTU size was still at 23?  I thought the system would be able to split data between multiple packets.  Is this true for reads, but not for notifications?

0 Likes
Anonymous
Not applicable

 Hi,

   

 

   

Attribute length which is more than MTU-1 are called long attributes.

   

When you try to read an attribute with size MTU-1 you can read by sending readrequest.

   

 

   

In case if the size is more than MTU-1 you cann't read by sending readrequest.You have to send readblob reqeust.

   

 

   

Probably your app might be sending the readblob(readlongcharacteristic) request instead of read request.

   

 

   

In more detail:

   

 

   

When sending a notifciation you have to include attribute opcode(1byte), attribute handle(2bytes) and 20bytes of data(max when MTU is 23

   

 

   

If you trying to read,client send a request by sending the request with the particualr attribute handle

   

.Server respond with attribute opcode(1byte) and attribute data of MTU-1

   

 

   

Regards,

   

Vikas

0 Likes
Anonymous
Not applicable

 That is very helpful.  Thank you, Vikas.

   

Best regards,

   

Matt

0 Likes