# Bluetooth BLE Read/Write Architecture

**URL:** <https://forums.freertos.org/t/bluetooth-ble-read-write-architecture/17328>\
**Category:** Kernel\
**Created:** [May 1, 2023, 1:55pm UTC](https://forums.freertos.org/t/bluetooth-ble-read-write-architecture/17328 "2023-05-01T13:55:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![khuang](https://avatars.discourse-cdn.com/v4/letter/k/fbc32d/32.png) [@khuang](https://forums.freertos.org/u/khuang)\
**Post date:** [May 1, 2023, 1:55pm UTC](https://forums.freertos.org/t/bluetooth-ble-read-write-architecture/17328/1 "2023-05-01T13:55:32Z")

</div>

Hello,

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.

Thanks!

---

<div class="post-metadata">

**Author:** ![Shub](https://avatars.discourse-cdn.com/v4/letter/s/6f9a4e/32.png) [@Shub](https://forums.freertos.org/u/Shub)\
**Post date:** [May 2, 2023, 7:21pm UTC](https://forums.freertos.org/t/bluetooth-ble-read-write-architecture/17328/2 "2023-05-02T19:21:45Z")

</div>

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 https://github.com/FreeRTOS/FreeRTOS and various other repos.](https://github.com/FreeRTOS/FreeRTOS-Plus-TCP)), 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](https://github.com/FreeRTOS/FreeRTOS-Plus-TCP/tree/main/source/portable)) to have “Bluetooth Network Interface read/write” instead of the existing ethernet interface while keeping the “NetworkInterface” APIs unchanged.

---

<div class="post-metadata">

**Author:** ![khuang](https://avatars.discourse-cdn.com/v4/letter/k/fbc32d/32.png) [@khuang](https://forums.freertos.org/u/khuang)\
**Post date:** [May 3, 2023, 2:58pm UTC](https://forums.freertos.org/t/bluetooth-ble-read-write-architecture/17328/3 "2023-05-03T14:58:06Z")

</div>

Hello Shub,

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