I use a phonegap plugin to communicate a bluetooth le device with my app. The app sends a message to the bluetooth device every 5 seconds and the bluetooth device replies.
If i ‘close’ the app (go somewhere else on the phone - not on the app), the communication continues in the background. When i re-open the app, i need to connect again. However after connecting, random messages are sent to the bluetooth device that appear to belong to the previous running session . This causes random messages and the app loses complete track of the messages.
If i stop the messages then ‘close’ the app, then reopen it, after i re-connect, everything works perfect.
Is there a way to completely close or clear any previous sessions of the app when i restart it?