+ device = null;
+ }
+
+ private void startAltosBluetooth() {
+ if (mAltosBluetooth == null) {
+ if (D) Log.i(TAG, "Connecting to " + device.getName());
+ mAltosBluetooth = new AltosBluetooth(device, mHandler);
+ setState(STATE_CONNECTING);
+ } else {
+ stopAltosBluetooth();
+ mHandler.sendMessageDelayed(Message.obtain(null, MSG_CONNECT, device), 1000);
+ }
+ }
+
+ private synchronized void setState(int s) {
+ if (D) Log.d(TAG, "setState() " + state + " -> " + s);
+ state = s;
+
+ sendMessageToClients(Message.obtain(null, AltosDroid.MSG_STATE_CHANGE, state, -1));