altosdroid: add handling when restarting BT. delay start after stop.
authorMike Beattie <mike@ethernal.org>
Sun, 26 Aug 2012 11:34:45 +0000 (23:34 +1200)
committerMike Beattie <mike@ethernal.org>
Sun, 26 Aug 2012 11:34:45 +0000 (23:34 +1200)
Signed-off-by: Mike Beattie <mike@ethernal.org>
altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java

index 218c6d3378103c9f03dcbf74466af4ad626872ea..3181d1614764edce1ce7fc6b8712bcd4599ba86f 100644 (file)
@@ -141,9 +141,14 @@ public class TelemetryService extends Service {
        }
 
        private void startAltosBluetooth(BluetoothDevice d) {
+               if (mAltosBluetooth == null) {
                        if (D) Log.i(TAG, "Connecting to " + d.getName());
                        mAltosBluetooth = new AltosBluetooth(d, mHandler);
                        setState(STATE_CONNECTING);
+               } else {
+                       stopAltosBluetooth();
+                       mHandler.sendMessageDelayed(Message.obtain(null, MSG_CONNECT, d), 1000);
+               }
        }
 
        private synchronized void setState(int s) {