input = null;
output = null;
AltosBluetooth.this.notifyAll();
+ handler.obtainMessage(TelemetryService.MSG_CONNECT_FAILED).sendToTarget();
if (D) Log.e(TAG, "ConnectThread: Failed to establish connection");
return;
}
private void connection_failed() {
if (D) Log.e(TAG, "Bluetooth Socket IO failed!");
+ handler.obtainMessage(TelemetryService.MSG_DISCONNECTED).sendToTarget();
}
public void print(String data) {
static final int MSG_UNREGISTER_CLIENT = 2;
static final int MSG_CONNECT = 3;
static final int MSG_CONNECTED = 4;
+ static final int MSG_CONNECT_FAILED = 5;
+ static final int MSG_DISCONNECTED = 6;
public static final int STATE_NONE = 0;
public static final int STATE_READY = 1;
s.setState(STATE_CONNECTED);
s.mAltosBluetooth.add_monitor(s.telem);
break;
+ case MSG_CONNECT_FAILED:
+ if (D) Log.d(TAG, "Connection failed... retrying");
+ s.startAltosBluetooth();
+ break;
+ case MSG_DISCONNECTED:
+ if (D) Log.d(TAG, "Disconnected from " + s.device.getName());
+ s.stopAltosBluetooth();
+ break;
default:
super.handleMessage(msg);
}