BLE disconnect is not working properly

TextBox1 and TextBox3 should Labels - Similarly, Buttons 'minutes' and 'sec' should be Labels. Discard the display of milliseconds and update the timer in seconds.

I completely removed clock2 and timer display but still same with disconnect.

Hmm, that should not be the case - perhaps the full address is formatted in an unexpected way (from the perspective of the extension).

There are a lot of little things wrong in your code - the ListView for example. It's not being used by the User? You make it invisible several times. If the User does not need it, delete it.

Disconnection is not necessarily instant, you could try waiting before testing:
DisconnectWait

Wait 200 milliseconds or more.

A tidy code version of your Project with niggles fixed (but may fail on device address as you described):
Testing_edit.aia (197.9 KB)
...untested!

on pressing scan it gives error. The operation select list item cannot accept the arguments: And then it shows all the devices addresses and names in the argument.

I used this method


Still not disconnecting. But bluetooth_status changes to none immediately after pressing disconnect and then after 300ms it changes to disconnect. It jumps into when.BLE1.disconnected instantly within nano or micro seconds I guess.

Timer always fires should never be true for this type of App (it is mostly intended for games).

Well that has always worked before :thinking:

...it did not take you to Bluetooth Settings when disconnect failed?

My Bad! Should be:

Same problem that I encountered and used only a chunk of the address. It says address is not valid because It includes MAC, device name and power.

Now It takes me to the Bluetooth setting when I click disconnect as I changed this block

I assume the problem is with device address, at the time of connecting we can get a chunk but I don't know if this is enough for disconnection or not?

I just check when it takes me to BT settings and if I move back to the app without tuning off the BT the status shows Disconnect failed means it is not disconnected after calling BLE.disconnecWithAdress.

I really don't know - I expected to be able to use the full string delivered by the Scan. Evan Patton (Top MIT Guru) will know, he has been enhancing the extension for some time now. However, he is no doubt very busy with the new AI2 release at the moment.

Ok I think the problem is with BLE.Disconnect. I changed BLE.disconnecWithAdress block with BLE.Disconnect and it now immediately display status disconnected. Where as if block BLE.disconnecWithAdress is sued the status stays on Disconnect Failed unless I disable BT from settings.

main.txt - is that the complete script? I can't see how often the values are sent to the App.

In your Main Project or in a simple (small) test?

This code is totally dependent on the app. The app calls for read every 200ms and then the dev board will read sensor and send the data to the app.

In the Testing_edit that you sent.

I recall at some point there was an issue where registering for notifications caused issue on disconnect. At least skimming this thread it sounds like you're using Read instead of Register. Is this correct? I can take a look at the sources but it's not clear exactly what would be causing the remote device to not recognize the disconnect.

The Disconnect method isn't particular complex:

and basically just calls through to the underlying Android API to perform the disconnect. We also have a force-disconnect method we could try calling instead. I may try to build you a version you can use to try that.

Yes :grin:

Ok. So I've built a version that tries to use the forceDisconnect internal method to disassociate the device object in the app from the physical device. I have not had a chance to test this version yet on real hardware. You can try it at your own risk.

Hi,

Now I have completely changed my app. This time DK is sending data means I am not using clock.ticks to read data instead DK is sending data periodically. Still having the same issue with disconnect. Whereas if I test it with nrf connect for android app it works fine.