I am working on an application which has Bluetooth connection as core part. Currently the app is connecting to and communicating with the Bluetooth device successfully. The main problem now is that the device we are using to collect data goes into sleep mode after some idle condition.
My question is, how can I detect that the device is in sleep mode so that my application can ask the user to wake up the device?
I am connecting through SSP. Connection code is exact copy of Bluetooth Chat application from API demo.
Sleep Mode — The device (Not Mobile) to which my application is connected runs on a battery, so optimize use of battery if Android application don’t any request to the device in 1 min Device goes in sleep mode.(May be off without dropping connection). So my application need to catch this condition and let the user know that device is in sleep mode and wake it up so it can respond to applications request.
This is the best way I can explain sleep mode. Keep in mind sleep mode of Bluetooth device and not the android mobile.
Solution —
I know it’s not perfect but still I m working on it…
Whenever connection drops I get socket error which I use as the remote device is in sleep mode or out of reach or dead. Also I changed my code so that I doesn’t require UUID(Now it’s low level connection) Code as below.