Bluetooth BLE Read/Write Architecture


I am currently developing a Bluetooth BLE application for Espressif’s ESP32-S3 and looking for some help in regards to setting up the read/write architecture with FreeRTOS. I am encountering issues when trying to subscribing to read and write notifications. My applications runs sequentially and fails when trying to run a read and write (e.g., GATT procedure read and subscribe initiated → GATT procedure write initiated → read complete → write complete → subscription failed, connection terminates). I believe I will need to implement a way of blocking the execution of my program until a read or write operation is completed. What would be the best approach for this using FreeRTOS? I was looking into possibly using Task Notifications or Event Groups but if anyone has worked with Bluetooth BLE before any help would be appreciated.


Hi Kevin,

Welcome to the FreeRTOS community.
A good example will be to look at the FreeRTOS-plus-TCP library (GitHub - FreeRTOS/FreeRTOS-Plus-TCP: FreeRTOS-Plus-TCP library repository. +TCP files only. Submoduled into and various other repos.), especially the receive part of it.
In receive there is an ip-task(prvIPTask) which is always waiting to be signaled by the portable layer(ethernet interface) to receive the data.

Infact, you can use the FreeRTOS-plus-TCP library and just replace the portable layer (FreeRTOS-Plus-TCP/source/portable at main · FreeRTOS/FreeRTOS-Plus-TCP · GitHub) to have “Bluetooth Network Interface read/write” instead of the existing ethernet interface while keeping the “NetworkInterface” APIs unchanged.

Hello Shub,

Thank you for your response, I will take a look into this.