BLE Read Characteristic - Select between Notify and Read on Demand

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

cross mob
TW_Chia
Level 3
Level 3
First like received 25 replies posted 10 sign-ins

I am using CYBLE416045-02 as a BLE logger device.

I have a read characteristic defined as shown. It has both Read and Notify selected.

TW_Chia_0-1648781907037.png

This read mode should have the ability to send out data periodically as notifications.

In addition, it can also allow read on demand.

The following is my function to do the above said.

For notification, I am able to send out uint8_t data array of any size.

However, for the on demand read, the size is somehow limited to the 16 bytes that was set during configuration.

I would like to inquire if there is any possibility of making this on demand read to be of any size depending on the amount of data that is written into it.

Thank you

void SetCustomAttributeValue ( uint16 *pnData, uint16 nDataSize, bool bNotify)
{
if(bNotify)
{
cy_stc_ble_gatts_handle_value_ntf_t notificationPacket;
notificationPacket.connHandle = cy_ble_connHandle[0];
notificationPacket.handleValPair.value.val = (uint8 *)pnData;
notificationPacket.handleValPair.value.len = nDataSize;
notificationPacket.handleValPair.attrHandle = CY_BLE_LOGGER_CONTROL_DATA_CHAR_HANDLE;
/* To register the service change in the Database of the GATT Server */
// apiGattErrCode =
Cy_BLE_GATTS_WriteAttributeValueLocal(&notificationPacket.handleValPair);
Cy_BLE_GATTS_Notification(&notificationPacket);
}
else
{
cy_stc_ble_gatt_handle_value_pair_t cyDataChar;
cyDataChar.attrHandle = CY_BLE_LOGGER_CONTROL_DATA_CHAR_HANDLE;
cyDataChar.value.val = (uint8 *)pnData;
cyDataChar.value.len = nDataSize;
Cy_BLE_GATTS_WriteAttributeValueLocal(&cyDataChar);
}
}

 

0 Likes
1 Solution
PratikshaV
Moderator
Moderator
Moderator
100 solutions authored 5 likes given 250 sign-ins

Hi @TW_Chia 

The length of the read characteristic cannot be changed programmatically because once the service is discovered by client .Client will be able to read data of the defined length set in ble component at the peripheral side.

For notifications whatever length set in the ble component at peripheral side is the maximum length to send the data to client.

 

Thanks 

Pratiksha V 

View solution in original post

0 Likes
4 Replies
PratikshaV
Moderator
Moderator
Moderator
100 solutions authored 5 likes given 250 sign-ins

Hello,

You can also change the value of "length" in the BLE component and also Please have look at the "CE222046_Throughput_Measurement " GATT_OUT example project in the PSoC Creator to understand how to send data from PSoC6 peripheral to central device over BLE custom service.

 

Please let me know if this helps.

Thanks,

Pratiksha V

0 Likes

Good day PratikshaV,

Thank you for your reply. I need to have the length for this read characteristic changed programmatically. 

This is because the length of data to be read will be different for different mode set.

 

Please advice.

 

Thank you.

 

0 Likes
PratikshaV
Moderator
Moderator
Moderator
100 solutions authored 5 likes given 250 sign-ins

Hi @TW_Chia 

The length of the read characteristic cannot be changed programmatically because once the service is discovered by client .Client will be able to read data of the defined length set in ble component at the peripheral side.

For notifications whatever length set in the ble component at peripheral side is the maximum length to send the data to client.

 

Thanks 

Pratiksha V 

0 Likes

Dear Pratiksha,

 

Thank you for the information.

 

Best regards,

0 Likes