BLE to send a large amount of data via notify
Posted: Fri Jul 14, 2023 3:34 am
Hi
hardware: esp32 pico d4
IDE: Microsoft Visual Studio with VMicro plugin + Arduino IDE 2.1.1
esp32-arduino version 2.0.5
I am trying to send a large amount of data from SD card of 100bytes per line with more than 3000 lines to a smartphone by BLE. The MTU size set 128.
Command to use some dummy data for testing purpose is shown below:
Unfortunately, this snippet does not run as expected. It hangs up after something like 100 lines. I suspect it is the notification buffer being full or something.
Questions:
1) Is there any way that I can check if notify() is ready to accept a new data line?
2) If I want to increase the speed of transmission, how to increase the BLE connection interval and what is the command to use?
Any suggestion is welcome.
John
hardware: esp32 pico d4
IDE: Microsoft Visual Studio with VMicro plugin + Arduino IDE 2.1.1
esp32-arduino version 2.0.5
I am trying to send a large amount of data from SD card of 100bytes per line with more than 3000 lines to a smartphone by BLE. The MTU size set 128.
Command to use some dummy data for testing purpose is shown below:
Code: Select all
for (int i = 0; i < 1048; i++) {
int ts = 62300 + i ; //a simple time stamp index just to know the program is working
std::string str_ts = std::to_string(ts);
s = str_ts + ",97,0.04,0.13,0,0,0,0,0,-8.91,0.42,-50.19,-9.033,-163.818,1036.621,0,0,0"; //suppose to contain some real data here with size smaller than 128 bytes (MTU)
pLogDataCharacteristic->setValue((uint8_t*)s.c_str(), s.length());
pLogDataCharacteristic->notify();
vTaskDelay(20); //this delay is adjustable to avoid jamming the notification buffer
}
Questions:
1) Is there any way that I can check if notify() is ready to accept a new data line?
2) If I want to increase the speed of transmission, how to increase the BLE connection interval and what is the command to use?
Any suggestion is welcome.
John