BLE client disconnect causes reboot
Posted: Mon Jun 03, 2019 9:12 pm
Hi i have the following code
But when i call client->disconnect(); i get the following error:
What am i doing wrong?
Code: Select all
#include <BLEDevice.h>
#include <BLEAddress.h>
void setup() {
Serial.begin(115200);
// put your setup code here, to run once:
BLEDevice::init("");
}
static BLEUUID serviceUUID("00001204-0000-1000-8000-00805F9B34FB");
static BLEUUID modeChangeUUID("00001a00-0000-1000-8000-00805f9b34fb");
void loop() {
for(int i = 0; i < 5; i++) {
delay(1000);
Serial.print('.');
}
writeToDevice();
Serial.print("Sleeping");
for(int i = 0; i < 5; i++) {
delay(1000);
Serial.print('.');
}
Serial.println("");
}
void writeToDevice()
{
Serial.println("");
Serial.println("Connecting");
// put your main code here, to run repeatedly:
BLEClient* client = BLEDevice::createClient();
BLEAddress bleAddress = BLEAddress("C4:7C:8D:63:7C:15");
bool connected = client->connect(bleAddress);
if (connected)
{
Serial.println("Connected");
Serial.println("Getting service");
auto service = client->getService(serviceUUID);
Serial.println("Writing change mode bits");
service->setValue(modeChangeUUID, "\xA0\x1F");
Serial.println("Disconnecting");
client->disconnect();
}
else
{
Serial.println("Failed to connect");
}
}
I'm using a Adafruit ESP32 Feather.22:59:36.292 -> SleepingCORRUPT HEAP: Bad head at 0x3ffe17b4. Expected 0xabba1234 got 0x3ffe1800
22:59:36.292 -> assertion "head != NULL" failed: file "/Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/heap/multi_heap_poisoning.c", line 214, function: multi_heap_free
22:59:36.292 -> abort() was called at PC 0x40148a6b on core 0
22:59:36.292 ->
22:59:36.292 -> Backtrace: 0x40091c4c:0x3ffd3410 0x40091e7d:0x3ffd3430 0x40148a6b:0x3ffd3450 0x400918c1:0x3ffd3480 0x40084d72:0x3ffd34a0 0x4008af71:0x3ffd34c0 0x4000bec7:0x3ffd34e0 0x400dbd49:0x3ffd3500 0x400dc7de:0x3ffd3520 0x400dc8a0:0x3ffd3540 0x40118fc7:0x3ffd3560 0x40137f76:0x3ffd3580 0x40118ba2:0x3ffd3810 0x40118ce1:0x3ffd3830 0x4011bd02:0x3ffd3850 0x400f6446:0x3ffd3870 0x40090461:0x3ffd38a0
22:59:36.292 ->
22:59:36.292 -> Rebooting...
What am i doing wrong?