ESP32 - NimBLE and EQIVA EQ3 thermostatic valve

Hi everyone,
This my first topic I am posting since I am new in this community.
I am developing an heating system controller with an ESP32 wroom 32 devkit v2.
This system, beside been connected to the house wifi, need to comunicate via BLE with EQIVA EQ3 thermostatic valve.
I am using pieter/ESP-EQ3@^0.1.0 library to control the valve.
I establish communication with the valve and I am able to send command and received status correctly except for this problem.
If no data are exchange with the valve within 30 seconds the connection timeout.
If I try to reconnect to the valve the system immediately crash.
Since I do not need to exchange data with the valve more then few times a day I cannot overcome this problem:
I include the reported decoded backtrace I am getting upon crashing.

23:02:18.918 > Connecting to 00:1a:22:16:ea:8a THIS THE FIRST CONNECTION TO THE VALVE
23:02:18.918 > Connected to 00:1a:22:16:ea:8a
23:02:18.918 > Updated Time with string: 3, 16, 0, A, 17, 2, E,
23:02:18.918 > Updated mode
23:02:18.918 > Updated temperature to 17.0
23:03:47.795 > Disconnected from 00:1a:22:16:ea:8a THIS IS WHEN THE BLE TIMEOUT OCCOUR
23:04:22.348 > Connecting to 00:1a:22:16:ea:8a THIS IS WHEN I TRY TO EXCHANGE DATA AGAIN
23:04:23.195 > Connected to 00:1a:22:16:ea:8a
23:04:23.395 > Guru Meditation Error: Core 1 panic’ed (LoadProhibited). Exception was unhandled.
23:04:23.403 > Core 1 register dump:
23:04:23.405 > PC : 0x400ef6cb PS : 0x00060630 A0 : 0x800f0293 A1 : 0x3ffcd190
23:04:23.413 > A2 : 0x800e3a1a A3 : 0x00000001 A4 : 0x80091398 A5 : 0x3ffcd0d0
23:04:23.421 > A6 : 0x00000000 A7 : 0x3ffcb480 A8 : 0x00000020 A9 : 0x80000020
23:04:23.429 > A10 : 0x00000008 A11 : 0x00000001 A12 : 0x00000005 A13 : 0x00000020
23:04:23.437 > A14 : 0x00000020 A15 : 0x3ffc3a28 SAR : 0x00000010 EXCCAUSE: 0x0000001c
23:04:23.444 > EXCVADDR: 0x800e3a22 LBEG : 0x4000c2e0 LEND : 0x4000c2f6 LCOUNT : 0x00000000
23:04:23.452 >
23:04:23.452 > ELF file SHA256: 0000000000000000
23:04:23.455 >
23:04:23.456 > Backtrace: 0x400ef6cb:0x3ffcd190 0x400f0290:0x3ffcd1b0 0x400eff1b:0x3ffcd1f0 0x400effc1:0x3ffcd250 0x400f0047:0x3ffcd290 0x400f22ff:0x3ffcd2d0 0x400f26bb:0x3ffcd310 0x400f26c5:0x3ffcd330 0x400d75c2:0x3ffcd350 0x400f84b4:0x3ffcd3c0 0x40091186:0x3ffcd3e0
23:04:24.497 > #0 0x400ef6cb:0x3ffcd190 in NimBLEClient::isConnected() at .pio\libdeps\esp32dev\NimBLE-Arduino\src/NimBLEClient.cpp:462
23:04:24.497 > #1 0x400f0290:0x3ffcd1b0 in NimBLERemoteDescriptor::writeValue(unsigned char const*, unsigned int, bool) at .pio\libdeps\esp32dev\NimBLE-Arduino\src/NimBLERemoteDescriptor.cpp:276
23:04:24.497 > #2 0x400eff1b:0x3ffcd1f0 in NimBLERemoteCharacteristic::setNotify(unsigned short, std::function<void (NimBLERemoteCharacteristic*, unsigned char*, unsigned int, bool)>, bool) at .pio\libdeps\esp32dev\NimBLE-Arduino\src/NimBLERemoteCharacteristic.cpp:384
23:04:24.497 > #3 0x400effc1:0x3ffcd250 in NimBLERemoteCharacteristic::subscribe(bool, std::function<void (NimBLERemoteCharacteristic*, unsigned char*, unsigned int, bool)>, bool) at .pio\libdeps\esp32dev\NimBLE-Arduino\src/NimBLERemoteCharacteristic.cpp:384
23:04:24.497 > #4 0x400f0047:0x3ffcd290 in NimBLERemoteCharacteristic::registerForNotify(std::function<void (NimBLERemoteCharacteristic*, unsigned char*, unsigned int, bool)>, bool, bool) at .pio\libdeps\esp32dev\NimBLE-Arduino\src/NimBLERemoteCharacteristic.cpp:384
23:04:24.497 > #5 0x400f22ff:0x3ffcd2d0 in EQ3Thermostat::setupNotifications() at .pio\libdeps\esp32dev\ESP-EQ3\src/eq3thermostat.cpp:145
23:04:24.497 > #6 0x400f26bb:0x3ffcd310 in EQ3Thermostat::connect() at .pio\libdeps\esp32dev\ESP-EQ3\src/eq3thermostat.cpp:145
23:04:24.497 > #7 0x400f26c5:0x3ffcd330 in EQ3Thermostat::JustConnect() at .pio\libdeps\esp32dev\ESP-EQ3\src/eq3thermostat.cpp:145
23:04:24.497 > #8 0x400d75c2:0x3ffcd350 in loop() at src/main.cpp:914
23:04:24.497 > #9 0x400f84b4:0x3ffcd3c0 in loopTask(void*) at C:\Users\Carlo.platformio\packages\framework-arduinoespressif32\cores\esp32/main.cpp:23
23:04:24.497 > #10 0x40091186:0x3ffcd3e0 in vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c:355 (discriminator 1)
23:04:24.500 >
23:04:24.500 > Rebooting…
23:04:24.500 > ets Jun 8 2016 00:22:57

The MAC address belong to EQ3 valve.
I am fairly new to this platform and programming enviroment and I am not sure how to interpreted all this info.
for example backtrace #0 refer to a funtion in NimbleClient class which set a timeout but I was not able to understand where this function is call.
At the moment the only way to keep the system alive is to send a command to the valve repeatedly before the 30 seconds expire,
Any help it’s greatly appreciated.

Thanks

The libary shouldn’t just crash like this. Please report this bug to the library author.

However, if you’re using

this library dictates the usage of the outdated library

and yet you’re using NimbleBLE-Arduino (NimBLE-Arduino/src at master · h2zero/NimBLE-Arduino · GitHub) somehow. What did you modify to achieve this?

Thanks for the replay.
Actually I have not changed anything.
The choice of NimBLE was reach while trying to solving the problem of program size.
As I stated before this is my first experience with this platform.
Once I added BLE features to the app the program became too big and I was not aware of the various memory configuration to allow the program to fit. With a search online some result suggested the use of NimBLE library because is using less flash and ram then the regular built-in BLE library.
Of course it did not solve the problem of the program not fitting.
On subsequent searches I learn about memory configuration which solve my problem of fitting the program on the board.
I try to run the program and it seems to work until I stumbled in the problem reported in my post.
I’ll try to revert to the built-in BLE library to see what happens

Hi everyone!
An update on the topic.
I did try to revert to the built-in BLE library but with this the memory allocated for the it’s HUGE!
With NimBLE I was running with Heap memory of 145K while the built-in BLE I was left with only 40K.
All kind of error message and crash so I went on NimBLE library.
I notice the connect function has an additional parameter which is set to true by default.

/**

  • brief Connect to the BLE Server.
  • param [in] address The address of the server.
  • param [in] deleteAttibutes If true this will delete any attribute objects this client may already\n
  • have created and clears the vectors after successful connection.
  • return True on success.
    */.
    I modify the EQ3 library in the connect call by setting deleteAttributes to false and the crashing on valve reconnect has been solve.
    Thanks @maxgerhardt for you time