File Transfer over BTClassic (SPP profile) issue
Posted: Mon Apr 23, 2018 7:14 pm
I have recently been working on a project where I have switched over from WiFi to Bluetooth and I am trying to implement and test OTA over BTClassic (SPP profile). To do this, I have made a "tester" device using the bt_spp_initiator example that my main device (based off of bt_spp_acceptor and ota example) connects to and then initiates an ota update.
Below is the task that gets called by the test device to send the bin file to the main device over Bluetooth once it has made a connection:
There seems to be no problem on the main device with starting the OTA update, however after a few packets of data have been sent, I get the following error from my tester device:
Has anyone else been working with sending large files over a BTClassic (SPP profile) connection? Any help would be greatly appreciated.
Below is the task that gets called by the test device to send the bin file to the main device over Bluetooth once it has made a connection:
Code: Select all
void BtTransmit_Init_SendFileTask(char* fileName) {
xTaskCreate(BtTransmit_Run_SendFileTask, "BtTransmit_SendFile", 4096,
(void *) fileName, 1, &hSendFileTask);
}
void BtTransmit_Run_SendFileTask(char* fileName) {
_Bool doneFile = false;
char buf[256];
char bufFile[1024];
int n;
long sz = 0;
FILE *fp;
fp = fopen(fileName, "rb");
printf("\n%s buffers:\n", fileName);
if (fp == NULL) {
printf("Error, file %s not found.", fileName);
}
fseek(fp, 0L, SEEK_END);
sz = ftell(fp);
fseek(fp, 0L, SEEK_SET);
ESP_LOGI(TAG, ">> Start sending file:%s", fileName);
int i = 0;
for (;;) {
if (!doneFile) {
//vTaskDelay(1000 / portTICK_PERIOD_MS);
if ((n = fread(bufFile, 1, 1024, fp)) > 0) {
i++;
printf(" %d - %d\n", n, i);
ESP_ERROR_CHECK(esp_spp_write(bt_handle, strlen(bufFile), (uint8_t *) bufFile));
} else {
doneFile = true;
}
} else {
ESP_LOGI(TAG, "<< Done sending file:%s", fileName);
vTaskDelay(100 / portTICK_PERIOD_MS);
vTaskDelete(hSendFileTask);
}
}
}
I suspect it might be due to the size of the bin file I am sending over (~945KB), because smaller files seem to work just fine.assertion "data != NULL" failed: file "C:/msys32/home/Louis/esp32/esp-idf/components/bt/bluedroid/osi/list.c", line 142, function: list_append
abort() was called at PC 0x400d4493 on core 0
0x400d4493: __assert_func at /Users/ivan/e/newlib_xtensa-2.2.0-bin/newlib_xtensa-2.2.0/xtensa-esp32-elf/newlib/libc/stdlib/../../../.././newlib/libc/stdlib/assert.c:63 (discriminator 8)
Backtrace: 0x4008c2df:0x3ffdc440 0x4008c30b:0x3ffdc460 0x400d4493:0x3ffdc480 0x400f6723:0x3ffdc4b0 0x400fabde:0x3ffdc4d0 0x400f71da:0x3ffdc530
0x4008c2df: invoke_abort at C:/msys32/home/Louis/esp32/esp-idf/components/esp32/panic.c:648
0x4008c30b: abort at C:/msys32/home/Louis/esp32/esp-idf/components/esp32/panic.c:648
0x400d4493: __assert_func at /Users/ivan/e/newlib_xtensa-2.2.0-bin/newlib_xtensa-2.2.0/xtensa-esp32-elf/newlib/libc/stdlib/../../../.././newlib/libc/stdlib/assert.c:63 (discriminator 8)
0x400f6723: list_append at C:/msys32/home/Louis/esp32/esp-idf/components/bt/bluedroid/osi/list.c:214
0x400fabde: btc_spp_write at C:/msys32/home/Louis/esp32/esp-idf/components/bt/bluedroid/btc/profile/std/spp/btc_spp.c:364
(inlined by) btc_spp_call_handler at C:/msys32/home/Louis/esp32/esp-idf/components/bt/bluedroid/btc/profile/std/spp/btc_spp.c:439
0x400f71da: btc_task at C:/msys32/home/Louis/esp32/esp-idf/components/bt/bluedroid/btc/core/btc_task.c:104
Has anyone else been working with sending large files over a BTClassic (SPP profile) connection? Any help would be greatly appreciated.