Reputation: 81
Finally got my device (based on TI's CC2541) to work with my phone (a prototype/non-commercial-yet phone running Android 4.3). I can scan, discover, connect and get notifications successfully. However, when I disconnect (calling BluetoothGatt.disconnect()), the onConnectionStateChange callback is called with newState=STATE_DISCONNECTED (as expected) but then immediately called again with newState=STATE_CONNECTED.
The connection is definitely terminated so I'm not sure why I'm getting the 2nd onConnectionStateChange call. Has anyone experienced anything similar?
Upvotes: 4
Views: 2603
Reputation: 2542
Check the status given to you in onConnectionStateChange; if the status isn't 0 (OK) then you didn't actually get a connection. I've found a number of occasions where I get the CONNECTED message but the status was indicating something else was happening.
Upvotes: 1