I am having some issue with disconnecting from an ESP-32, I click on the disconnect button, which uses the disconnect function from the BLE module, but for some reason my ESP does not detect the disconnection. Also, this issue only happen on my phone(Samsung S24+), when I tried the app on my tablet(Samsung Tab S8+) it worked and the ESP-32 was able to detect the disconnection.
Logic for the button
Another issue related to this is with the function Listen for Disconnection, it also does not seems to work, I tried going too far from the ESP 32 and the program just crashed probably because it tried received data when the devices disconnected.
Logic for the Listen to disconnection
Project Link
Hello @diogo_goto welcome to the community
Why do you need the connect block when you click disconnect button?
Have you tried to use only the disconnect blocks?
![image](https://global.discourse-cdn.com/business4/uploads/thunkable/original/3X/8/4/844346782f60ad79264a9f9c4d89d973c84f7bfc.png)
Yeah, I tried only the disconnect block, but I had the same issue. I read on another post that also worked to disconnect, so that is why it’s there, but it does not work.
That post is over 4 years old and so the platform has likely changed enough since then that the OPs suggestion is no longer relevant.
What is happening in the End_connection_Procedure
function? Did you try just the disconnect block (you can test if it is running by adding in a label to show once the device has disconnected? The disconnect block itself is working just fine as I just tested it on my own BLE device.
![Screenshot 2024-07-16 at 11.41.40 AM](https://global.discourse-cdn.com/business4/uploads/thunkable/original/3X/e/f/efc6285efd200b66a0b736d3218c4b9d68b55eb3.png)
Hello, I made a few changes to the blocks. I tried only the disconnect block but it still had the same issue of not working only when using my phone, when running on my tablet it worked.
This is the end of connection procedure is logging some data and re-assigning variables
this is the complete code, the changes are that moved the listen for disconnection to the beginning of the loop and started saving the received data on the a spreadsheet.
Can you try adding in a small wait block after the disconnect block? This may give the small delay needed for the connection to terminate before moving on to the other screen.
The other option would be to remove the function after the disconnect block and see if it disconnects properly. But I think a wait block should allow this to work as you are intending.It can be less than 1 second.
![image](https://global.discourse-cdn.com/business4/uploads/thunkable/original/3X/c/1/c19d85e1b659db501946c212f69f5e5990ecc66c.png)