My serial output:
Code: Select all
Starting Bluetooth
Trying to form connection to device at fc:58:fa:f1:99:f5
- Connected
- Found our service
Writing
Disconnecting
Done
back
CORRUPT HEAP: Bad head at 0x3ffdf07c. Expected 0xabba1234 got 0x3ffdfc8c
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
abort() was called at PC 0x40148bdb on core 0
Backtrace: 0x4008d8d0:0x3ffd3260 0x4008db01:0x3ffd3280 0x40148bdb:0x3ffd32a0 0x4009302d:0x3ffd32d0 0x40084556:0x3ffd32f0 0x4008a289:0x3ffd3310 0x4000bec7:0x3ffd3330 0x400dbc69:0x3ffd3350 0x400dc6fe:0x3ffd3370 0x400dc7c0:0x3ffd3390 0x40119197:0x3ffd33b0 0x4013810a:0x3ffd33d0 0x40118d72:0x3ffd3660 0x40118eb1:0x3ffd3680 0x4011bed2:0x3ffd36a0 0x400f658a:0x3ffd36c0 0x40092545:0x3ffd36f0
Rebooting...
My program:
Code: Select all
#include "BLEDevice.h"
// The remote service we wish to connect to.
static BLEUUID serviceUUID("0000cc02-0000-1000-8000-00805f9b34fb");
// The characteristic of the remote service we are interested in.
static BLEUUID uuid_onoff("ee03");
static BLERemoteCharacteristic* pRemoteCharacteristic;
bool getSensorData(BLEAddress pAddress) {
Serial.print("Trying to form connection to device at ");
Serial.println(pAddress.toString().c_str());
BLEClient* pClient = BLEDevice::createClient();
// Connect to the remove BLE Server.
if (!pClient->connect(pAddress)) {
Serial.println("Failed");
return false;
}
Serial.println(" - Connected");
// Obtain a reference to the service we are after in the remote BLE server.
BLERemoteService* pRemoteService = pClient->getService(serviceUUID);
if (pRemoteService == nullptr) {
Serial.print("Failed to find our service UUID: ");
Serial.println(serviceUUID.toString().c_str());
return false;
}
Serial.println(" - Found our service");
pRemoteCharacteristic = pRemoteService->getCharacteristic(uuid_onoff);
uint8_t buf[15] = {0,0,1,0,0,0,0,0,1,255};
Serial.println("Writing");
pRemoteCharacteristic->writeValue(buf, 10, true);
Serial.println("Disconnecting");
pClient->disconnect();
Serial.println("Done");
}
void setup() {
Serial.begin(9600);
Serial.println("Starting Bluetooth");
BLEDevice::init("");
} // End of setup.
// This is the Arduino main loop function.
void loop() {
char tmp[20];
strcpy(tmp,"fc:58:fa:f1:99:f5");
BLEAddress myDevice(tmp);
getSensorData(myDevice);
Serial.println("back");
delay(10000);
} // End of loop