Skip to content

Bluetooth looses data at high speed #8808

Closed
@EricHarbers

Description

@EricHarbers

Related area

BluetoothSerial.cpp driver (V2.0.14)

Hardware specification

ESP32 dev module

Is your feature request related to a problem?

On Arduino BSP I have created a program that reads data from the serial port and sends it to the Bluetooth SPP serial port. At high speeds (260 KBit/s) the bluetooth module looses data. If you connect to the Bluetooth SPP port using eg a PC with a client app, it will not receive all sent bytes.

Describe the solution you'd like

After searching around in my software, I concluded that the Bluetooth module would loose the data bytes.
Then I started looking around in the BluetoothSerial.cpp driver and found the initialisation of the Bluetooth Serial process. When I change the task priority of the Bluetooth Process, the problem is solved.

The change I have made is in the function "_init_bt()".
I changed this code:

if(!_spp_task_handle){
    xTaskCreatePinnedToCore(_spp_tx_task, "spp_tx", 4096, NULL, 10, &_spp_task_handle, 0);
    if(!_spp_task_handle){
        log_e("Network Event Task Start Failed!");
        return false;
    }
}

The changed code:

if(!_spp_task_handle){
    xTaskCreatePinnedToCore(_spp_tx_task, "spp_tx", 4096, NULL, configMAX_PRIORITIES-1, &_spp_task_handle, 0);
    if(!_spp_task_handle){
        log_e("Network Event Task Start Failed!");
        return false;
    }
}

I found this because other processes in the ESP32 module will have the (configMAX_PRIORITIES-1) priority.
After changing the priority, I have had no data loose at all.

Describe alternatives you've considered

In my code, I have made the transfer from serial port to SPP as fast as possible.
At first I transferred the data byte by byte. Now I transfer the data in blocks, using the read and write functions.
I 've looked around on the internet, but I couldn't find any good solution to my problem.
BluetoothSerial_changed.zip
ESP32_Myomed.zip

Additional context

No response

I have checked existing list of Feature requests and the Contribution Guide

  • I confirm I have checked existing list of Feature requests and Contribution Guide.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions