// Name of the connected device
private String mConnectedDeviceName = null;
private AltosBluetooth mAltosBluetooth = null;
-
+ private int state = STATE_NONE;
LinkedBlockingQueue<AltosLine> telem;
// Handler of incoming messages from clients.
break;
case MSG_CONNECTED:
if (D) Log.d(TAG, "Connected to device");
+ s.setState(STATE_CONNECTED);
break;
default:
super.handleMessage(msg);
}
private void stopAltosBluetooth() {
+ setState(STATE_READY);
if (mAltosBluetooth != null) {
mAltosBluetooth.close();
mAltosBluetooth = null;
private void startAltosBluetooth(BluetoothDevice d) {
mAltosBluetooth = new AltosBluetooth(d);
mAltosBluetooth.add_monitor(telem);
+ setState(STATE_CONNECTING);
+ }
+
+ 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));
}
@Override
//mNM = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
telem = new LinkedBlockingQueue<AltosLine>();
+ setState(STATE_READY);
}
@Override