BluetoothLE1 Disconnect issue Background Tasks: Itoo

In this block initially it scans Bluetooth device and stores MAC address in itoo. Now, when I start background process. It connects to the stored MAC address and send RELAY_ON to esp32. My aim is to Disconnect after 3 second. Issue lies here. In Android 12 devices it disconnects after certain time interval. where as in android 14 device it does not disconnect. Please help me out.
Thanks,
Prashanth.

BLE_Basic.aia (333.3 KB)

Global variables do not exist in the background

Add debug statements, for example Notifier1.LogInfo blocks and use logcat to find out what's going on

Taifun

Here is the log file.
Thanks
Prashanth
Log.txt (1.1 MB)

Should I replace Global variables to 6E400001-B5A3-F393-E0A9-E50E24DCCA9E

Did you add debug statements?
Which part of the blocks works for Android 12 and does not work for 14?
Provide a screenshot of those blocks including your debug statements

You can do that or use Store/Fetch Property blocks

Taifun

In Android 12 device. Once the data RELAY_ON or RELAY_OFF sent, after 3 second procProcessStopClock runs i.e bluetooth disconnects. where as in Android 14 device sends data but it does not disconnects from esp32 device.

Yes I did added add debug statements.

This seems to be redundant

Just remove the if statement

Is there any error between procProcessStopStart and End in the log? I'm currently on mobile...

Taifun

Here is the relevant part from the log

It looks fine for me. .

Are you saying, the other clock did not stop?
Taifun

I checked by removing if statement. but issue remains the same.

Clock runs and stops. BluetoothLE1.Disconnect do not disconnects in Android 14 device. where as it disconnect in Android 12 device.

can you elaborate what exactly happens?

Taifun

I have attached two file One is Android 12 device, other once is of android 14.

  • Initially Scan Pick and Connect button selects required MAC address.
  • Save Button stores the MAC address in itoo store.
  • Connect and disconnect button does connection and disconnection operation.
    Now, If I press Start button(GREEN). Check two Serial monitor outputs of both Android 12 and 14 device.
    In Android 12, when start button pressed, it connects (Connected) after 3 seconds app sends data RELAY_ON, i.e procSendOnClock clock runs. once the data is sent after 3 seconds procProcessStopClock clock executes and disconnects from ESP32.

In android 14, when start button pressed, it connects (Connected) after 3 seconds app sends data RELAY_ON, i.e procSendOnClock clock runs. once the data is sent after 3 seconds procProcessStopClock clock executes (Till here everything works fine) but BluetoothLE1.disconnect does not disconnect from the connected ESP32 module.


Could you please post the only blocks of background service that are relevant and has a role in the issue you are describing?

It'd also be helpful if you could describe the flow, to have a better understanding.

The question was to elaborate on this
For example how do you know that it did not disconnect or what happens differently after disconnecting

Is it the missing Disconnected on the monitor?

Taifun

Yes. I wrote the ESP32 code such a way that if the device (App) is disconnected from ESP32 it displays Disconnected. and ESP32 is ready to connect other device (App).
At first I connect ESP32 from Android 12 device. once the data sent, device disconnects. If I connect from Android 14. App sends data but it does not disconnects. Now, If I start process again from Android 12, device does not connect because it is still connected to Android 14 which I can see in Setting - Bluetooth tab. App disconnects only when I completely close from recent app.

What happens if you disconnect in the foreground on the Android 14 device?
Do you get Disconnected on the monitor?

Taifun

Yes. It disconnects.