Trying to use Cy_BLE_WriteCharacteristicValue() in an interrupt

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

cross mob
JoYa_4140271
Level 1
Level 1

I am trying to call Cy_BLE_WriteCharacteristicValue() in an timer interrupt that periodically sends data to a Peripheral device. However, on the Peripheral end, I receive way much less bytes than I expected. Is it thread safe to call such non-blocking function in my interrupt?

0 Likes
4 Replies
Yugandhar
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 5 likes given

Hello,

Please let me know how many bytes you are sending from central device and also how many bytes your getting at the peripheral side.

Thanks,

P Yugandhar.

0 Likes
Yugandhar
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 5 likes given

Hello,

Could you please share your project ?

Please check the MTU size of both central and peripheral. The amount of data that has to be transmitted is depends on the MTU size of client and peripheral. Client will send the MTU request to the peripheral. CYBLE_EVT_GATTS_XCNHG_MTU_REQ event will be generated at the Peripheral device. The client and server exchange the maximum size of a packet that can be received using the Exchange MTU Request and Response PDUs. Both devices then use the minimum of these exchanged values for all further communication.

Thanks,

P Yugandhar.

0 Likes

Hi,

I am not able to share my project at the moment.

I am trying to send 64-byte GATT value in both direction (peripheral to central and central to peripheral; concurrently) with the timer triggering interrupts every 10ms. I let it run for a couple of minutes and while one side receives over 100,000 bytes in total, the other side receives much less.

I have done the exchange MTU requests for both sides. Does the function of blocking or non-blocking affect the results in such a timing that is very close to BLE connection interval?

Thanks!

0 Likes

Hello,

Sending data from peripheral to central requires notify or indicate property. For notification it does not need any acknowledgement from the client device after sending data.

For sending data from central to peripheral it requires write property. For every write request to peripheral a write response shall be sent by the server if the write of Characteristic Value succeeded or not. So write data is only sent when the server gets a write response from the client device that it has received the previous packet.

Please increase your timer value to more than BLE connection interval because this will results in missing of some data calls which results in missing of packets.

Thanks,

P Yugandhar.

0 Likes