Esp32 ble onwrite function behaves strangely

Phevaoubas
Posts: 1
Joined: Fri Aug 25, 2023 5:57 pm

Esp32 ble onwrite function behaves strangely

Postby Phevaoubas » Fri Aug 25, 2023 6:38 pm

As I can't provide code atm, I'll explain the problem as best as I can.

Setup:
I have two esp32 dev boards as ble clients.
I have 1 esp32 dev boards acting as a ble server.

Working principle:
The two clients should write on the servers's two different characteristics. I use free rtos for all my tasks and use a notification for each characteristic(in the onwrite() function) which inturn calls a function which places the messages in a queue for the UART to later handle.

Issue at hand:
The problem is that if I choose to transmit large amount of data over the characteristics(400 packets of 238( by a set MTU) bytes by each esp32 client), the onwrite gets called with half the data in the buffer.
If only one device is using the server, everything is fine and the onwrite behaves as promised,if both devices write, the onwrite gets called even when there is not the whole message in the readdata() or getvalue() buffer.

Summary:
Both clients say thay transmit the correct message length over ble.
The server receives the wrong length only when simultaneous writes happen by two ble clients.

Is there a problem if both esp32 clients write at the same time?
Is there a way to overcome this?

Thanks in advance!!!!

Who is online

Users browsing this forum: No registered users and 44 guests