Page 1 of 1

ESP32Easy BLE

Posted: 23 Nov 2019, 22:23
by enesbcs
I am struggling to make BLE based plugins for reading Mijia temperature and Flora plant monitor devices to ESPEasy, using the integrated Bluetooth in ESP32. Test version works but occasionally Wifi is unavailable, it seems that BLE blocks the system when tries to communicate... also sometimes reboot occurs which may be because i am not a good friend of pointers/ArduinoC. (or simply the ESP32 BLE library is unstable)
Whatever, i am publishing the code for testing/fixing:

https://github.com/enesbcs/ESPEasyRetro ... EMijia.ino
https://github.com/enesbcs/ESPEasyRetro ... EFlora.ino

(ESPEasyRetro is my own playground, plugins tested with it, but may work with other versions - BLE scan implemented in its Webserver.ino!)

Re: ESP32Easy BLE

Posted: 23 Nov 2019, 23:55
by TD-er
Why not let the BLE be handled by the 2nd core?

Re: ESP32Easy BLE

Posted: 24 Nov 2019, 01:32
by ThomasB
The Arduino BLE library's scan and connect functions are code blockers. If that is a problem for ESPEasy then maybe TD-ers idea might help out.

Fortunately, once connected the BLE callbacks are not code blocked. But reconnects will experience the code blocking issue. So your plugin should schedule reconnect attempts so that they do not spend too much time trying to find a missing BLE server.

However, the Arduino BLE client library is a buggy. A recent release removed some useful NULL pointer checking which has invited crashes, at least for me. And there are some semaphore issues that can invite random endless hangs.

I recently completed a ESP32 BLE project (not ESP Easy) that experienced these bug issues. I used the BLE library's debug log function and with it's help I was able to apply some library tweaks to eliminate the problems. You may have to do that too.

- Thomas

Re: ESP32Easy BLE

Posted: 24 Nov 2019, 07:12
by kniazio
I would like to open my lock using a telephone without using a Chinese application.
Is it possible to make an esp32 plugin?
https://pl.aliexpress.com/item/32839514 ... 39.99734.0

Re: ESP32Easy BLE

Posted: 24 Nov 2019, 08:55
by enesbcs
Mijia data request works with BLE notification callback, and when i tried to run it another core it did not ends well. :) Flora may work on second core as it works as simple ble connect-than-read.