esp-idf: File Transfer over BTClassic (SPP profile) crash (IDFGH-935)
Environment
- Development Kit: none
- Core: ESP-WROOM32
- IDF version: 1e8ab3d1
- Development Env: Make
- Operating System: Windows 10
- Power Supply: external 5V
Problem Description
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 and sends the proper bin file.
Expected Behavior
Once connected to the main device, the test device sends file information in a json format and then begins sending the file as a stream of data packets.
Actual Behavior
There seems to be no problem on the main device with starting the OTA update, however after a variable number of packets have been sent, the test device crashes.
Code to reproduce this issue
Task that reads and sends the file in packets via esp_spp_write()
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);
}
}
}
Debug Logs
I (21038) BtSppConnInitiator: ESP_SPP_WRITE_EVT - status:0 len=145 cong=0
1024 - 18
I (22038) BtSppConnInitiator: ESP_SPP_WRITE_EVT - status:0 len=17 cong=0
1024 - 19
assertion "data != NULL" failed: file "C:/msys32/home/Louis/esp32/esp-idf/components/bt/bluedroid/osi/list.c", line 14
2, function: list_append
abort() was called at PC 0x400d4657 on core 0
0x400d4657: __assert_func at /Users/ivan/e/newlib_xtensa-2.2.0-bin/newlib_xtensa-2.2.0/xtensa-esp32-elf/newlib/libc/st
dlib/../../../.././newlib/libc/stdlib/assert.c:63 (discriminator 8)
Backtrace: 0x4008c9f7:0x3ffd8fc0 0x4008ca23:0x3ffd8fe0 0x400d4657:0x3ffd9000 0x400f69db:0x3ffd9030 0x400fafde:0x3ffd90
50 0x400f7492:0x3ffd90b0
0x4008c9f7: invoke_abort at C:/msys32/home/Louis/esp32/esp-idf/components/esp32/panic.c:648
0x4008ca23: abort at C:/msys32/home/Louis/esp32/esp-idf/components/esp32/panic.c:648
0x400d4657: __assert_func at /Users/ivan/e/newlib_xtensa-2.2.0-bin/newlib_xtensa-2.2.0/xtensa-esp32-elf/newlib/libc/st
dlib/../../../.././newlib/libc/stdlib/assert.c:63 (discriminator 8)
0x400f69db: list_append at C:/msys32/home/Louis/esp32/esp-idf/components/bt/bluedroid/osi/list.c:214
0x400fafde: btc_spp_write at C:/msys32/home/Louis/esp32/esp-idf/components/bt/bluedroid/btc/profile/std/spp/btc_spp.c:
441
(inlined by) btc_spp_call_handler at C:/msys32/home/Louis/esp32/esp-idf/components/bt/bluedroid/btc/profile/std/spp/b
tc_spp.c:517
0x400f7492: btc_task at C:/msys32/home/Louis/esp32/esp-idf/components/bt/bluedroid/btc/core/btc_task.c:104
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 19 (1 by maintainers)
Commits related to this issue
- Fixed previous error (#1908) — committed to 0xFEEDC0DE64/esp-idf by yelvlab 6 years ago
Hi all, Let me start from begining - 1- First after BT connection send some command to initiate the above task. 2- Then start sending the data in the chunks of 988 bytes. 3- Now, the data will come in this “ESP_SPP_DATA_IND_EVT” event where you can store in a variable here (firmware_data[]).
my code is below:-