I am having a problem when my app should close the bluetooth connection. I have done some research and I understand that there can be problems with 'BluetoothClient IsConnected' block. I have also found info on making sure the connection is valid before trying to disconnect, but none of these cases apply to my problem.
I'm using a global variable 'use_BT' as a flag to determine if Bluetooth is connected. As such, this block should only disconnect the Bleutooth connection once, and only once. Yet the code produces an 'Error 515: Not connected to a Bluetooth device.' error message. It appears the app, after closing the connection, it is still trying to close the connection again.
Get all those blocks off the button, and so are the flags. Just leave disconect bluetooth and insert a block that will turn off the button when disconnected. This will prevent the button from being pressed again. However, in the blocks where you connect to bluetooth, add a block that will turn on the disconnect button.
It still produces the same results. The app does close the connection, but then keeps trying to close it again and again, even with the button disabled.
Hello Randy,
(maybe is trivial but) are you sure you don't still have a clock running , trying to communicate on the BT, after having hit the button ?
Cheers.
As @uskiara wrote. You have a clock somewhere that sends data via bluetooth. When disconnecting the connection, turn off this timer as well. Best of all, show all the blocks or put your AIA here.
That's it! As soon as I read 'clock running' part, I figured it out.
Yes, I should have posted all the blocks or AIA. It's kinda big and sloppy ATM, and I dislike posting sloppy code up.
To anyone who finds this thread looking for a solution to this error message, here's where the problem was - I had a clock running to trigger an event to check for new Bluetooth data received. When my app disconnected from the Bluetooth device, I didn't disable the timer, and the app kept looking for data. That is what triggered the error message I received.