0

My goal is to receive sensor data from the Xiaomi Plant Sensor (Flower Care) to the ESP32 Devkit C v4 via Bluetooth Low Energy (BLE). Since, I'm fairly new to ESP32 & BLE, I follow an example from github.

Unfortunately, an error occurs in line 115:

// the remote service we wish to connect to
static BLEUUID serviceUUID("00001204-0000-1000-8000-00805f9b34fb");

....    

try {
    floraService = floraClient->getService(serviceUUID); // line 115: error here
}
catch (...) {
    // something went wrong
}

That was a known issue that is fixed. Somebody pointed out that the serviceUUID didn't get handle correctly by the ESP32 BLE library.

Now I'm facing another issue and get the following output from Serial:

Initialize BLE client...
Processing Flora device at c4:7c:8d:6d:31:2a (try 1)
- Connection successful
Guru Meditation Error: Core  0 panic'ed (Double exception). 

Core  0 register dump:
PC      : 0x400925d3  PS      : 0x00040d36  A0      : 0x8012254c  A1      : 0x3ffd1100  
A2      : 0x3ffb6388  A3      : 0x3ffdc600  A4      : 0x3ffcc310  A5      : 0x400f9294
A6      : 0x007b6c7c  A7      : 0x003fffff  A8      : 0x40080080  A9      : 0x3ffd11f0
A10     : 0x00060f36  A11     : 0x00040026  A12     : 0x00001004  A13     : 0x00000000  
A14     : 0x00000000  A15     : 0x3ffb6c68  SAR     : 0x0000001c  EXCCAUSE: 0x00000002
EXCVADDR: 0xffffffe0  LBEG    : 0x4008fd94  LEND    : 0x4008fdaa  LCOUNT  : 0xffffffff

Backtrace:<a lot of encoded stuff here>

The decoded stack results look like this:

Decoding stack results
0x40120be1: fixed_queue_enqueue at /home/runner/work/esp32-arduino-lib-builder/esp32/arduino-lib-builder/esp-idf/components/bt/common/osi/fixed_queue.c line 142
0x40097d19: multi_heap_malloc at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/heap/multi_heap_poisoning.c line 229

Unfortunately, the repository I mentioned above is already archived and I can't ask the author.

Anyone has an idea why the data service can't be established between ESP32 and Xiaomi Platn Sensor? Many say it's about a memory issue or it ran out of memory but I'm pretty new to microcontroller stuff and have no clue what to do.

Thanks in advance!

Lecram
  • 60
  • 2
  • 11
  • I've noticed that I can access the service UUID 0000fe95-0000-1000-8000-00805f9b34fb but not the service that actually contains the data (UUID in my question). The app nRF Connect shows me the data service - so it exists. Any ideas why I can't access the data service? How can I handle that? – Lecram Jun 11 '22 at 17:09

2 Answers2

0

Have the identical problem, weird. Worked well end of May 2022 for me. Had to reinstall the Arduino development environment (moving from hidden Windows installation to direct download from Arduino.cc) and recompiled. Using the Xiaomi flora device. Now getting same exception, same backtrace to fixed_queue.c and multi_heap_poisioning. Have tried several versions of libraries now, unsuccessfully. Have no glue what has changed.

Erum
  • 1
  • 1
0

Finally, I solved the problem.

As the bleClient is referenced globally by a pointer (asterisk *) in almost every example and library, there must be some memory issues with that. Unfortunately, I don't really understand why this makes problems. During runtime, the pointer must be corrupted due to override its address or something like that.

Can somebody please explain why an external pointer from a library can cause problems? The instantiation is made by the new constructor. I guess, it's caused by a pointer on the method createClient()?

/**
 * @brief Create a new instance of a client.
 * @return A new instance of the client.
 */
/* STATIC */ BLEClient* BLEDevice::createClient() {
    log_v(">> createClient");
    #ifndef CONFIG_GATTC_ENABLE  // Check that BLE GATTC is enabled in make menuconfig
    log_e("BLE GATTC is not enabled - CONFIG_GATTC_ENABLE not defined");
    abort();
    #endif  // CONFIG_GATTC_ENABLE
    m_pClient = new BLEClient();
    log_v("<< createClient");
    return m_pClient;
} // createClient

A workaround is to just use the BleClient instance locally and everything works fine without any issues. Never had this error again.

Lecram
  • 60
  • 2
  • 11