BLE with ESP32. The app crashes when ESP32 is turned off

Hi.
My app is reading some data from an ESP32, using BLE.

The extension i use is version 20181124, which is, as far i as know, the latest one.

I tried the app in 2 different phones:

  • LG G6 (Bluetooth v4.2 A2DP, LE, aptX) + Android 9
  • Samsung A8 (Bluetooth v5.0, A2DP, EDR, LE) + Android 8.0.0

The app connects perfectly with ESP32 and receive data. But, if i turned off the ESP32, the app crashes and stops.
I spend 2 days fighting with this issue. It cannot be so difficult!

I thought that the failure was because i begin a scanning when the disconnect event was raised, and i also had activated the BluetoothLE1 “AutoReconnect” option, but it is not that.
In the proyect attached i do nothing when the connection is lost… and it crash!

I have disabled most part off blocks, just in case, but it continue to crash.

I also did a small proyect, with only the BLE, and it work perfectly. Not a single crash!.
Can be a proyect be corrupted?
Or maybe the BLE cannot work if the screen has timers, firebasedb, TinyDB, or any other component?

BLE3: is the proyect that works fine
paramotor_BLE_v11: is the one that fails

BLE3.aia (161.6 KB) paramotor_BLE_v11.aia (237.4 KB)

Any help will be really appreciated!

Regards,

Patricio

I did not have time to look at your working project, only theClock_bluetooth broken one.
when clock_bluetooth timer
In BLE, people usually register for floats once per stream, and sit there and accept what arrives, without repeatedly reading from BLE.


The default from TinyDB for a list should be an empty list (I corrected it here in this procedure.) to prevent errors trying to treat a text as a list.

All the BLE when …s received blocks receive multi item LISTS, which need to be addressed item by item, not just peeling off ( ) on the outside. For floats, this is important because you might be trying to feed two or more blank separated floats into a format as decimal block, which does not recognize internal blanks. For Each fixes that.

Hi ABG.
Thanks foutr your help.
I have already corrected your suggestions about TinyDB and about how you did thee BLE loop.
Now i will try to modify the ESP32 software in order to use the “registerfloats” instead “readfloats”.
Regards,
Patricio

Solved.
Using “registertfloats” instead “readfloats” the app do not crash when the connection with device is lost.
I had to modify a bit the ESP32 software, but now it works perfectly.
Thanks!!!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.