Bluetooth connection problems

I have posted this under General Discussion because I don't believe that it is an AI issue. However, there may, or may not, be an AI solution, so here goes:

I have an AI app that communicates with an ESP32 via Bluetooth.
So far, so good. Everything works fine.

A few weeks ago I had to update the OS on my phone (that is a completely different story, that I won't get into here), suffice to say that I changed the OS from stock Android 5.1.1 to Lineage 14.1 (Android 7.1.2). The update went okay and everything works as expected, that is except for a small "glitch" in my AI app.

The problem is:
The app connects to the ESP32 without problems.
The app is fully functional with no problems.
However, if the app is closed down, or the Bluetooth on the phone is disrupted then the app cannot reconnect to the ESP32 unless the ESP32 is reset.
Before changing the phone's OS, the app could reconnect with the ESP32 without having to reset it. It is as if some part of the "old" Bluetooth connection is remaining active and stopping a new connection from being made.
I was wondering if there is anything I can do in AI to "flush" the "old" connection?
..Or any other suggestions would be welcomed.

Thanks

Custom ROMs often have a lot of bugs. If everything was fine on the official android version, there may be a bug in Lineage.
I think without access to hardware with a specification like yours, it will be hard to find out what's wrong.

You write that the problem only occurs when the connection is accidentally dropped.
I understand that when you disconnect BT manually, then everything is ok?

Sorry for the confusion.
No - if the Bluetooth is disconnected manually, it still will NOT reconnect unless the ESP32 is rebooted.

Can you send an instruction to your ESP32 to reboot before you disconnect ?

@TIMAI2 - Theoretically, YES. Practically, NO.

Or less practical, set a script running on your ESP32 to routinely reboot....

Try changing the UUID.
https://www.uuidgenerator.net/

@Juan_Antonio, sounds interesting, but after looking at your link I am a little confused as to how I would implement this in AI?

Generate a UUID and set that number in the ESP32 and AI2 code.