Try to remove this part:
Code: Select all
// Start GATT server
rc = ble_gatts_start();
if (rc != 0) {
ESP_LOGE(TAG, "GATT start failed: %d", rc);
return;
Honestly I haven't fully checked the underlying cause yet.
Apparently, `nimble_port_run` calls `ble_gatts_start` which leads to some sort of memory corruption.
I might be wrong so please verify if this solution is actually correct. I just wanted to share my findings so far since I've run into a similar or the same bug.