- private class ConnectThread extends Thread {
- private final UUID SPP_UUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
+ // Constructor
+ public AltosBluetooth(BluetoothDevice device, Handler handler, boolean pause) {
+ super(handler);
+ this.device = device;
+ this.handler = handler;
+ this.pause = pause;
+
+ connect_thread = new ConnectThread();
+ connect_thread.start();
+ }
+
+ void connected() {
+ if (closed()) {
+ AltosDebug.debug("connected after closed");
+ return;
+ }
+
+ AltosDebug.check_ui("connected\n");
+ try {
+ synchronized(this) {
+ if (socket != null) {
+ input = socket.getInputStream();
+ output = socket.getOutputStream();
+ super.connected();
+ }
+ }
+ } catch (InterruptedException ie) {
+ connect_failed();
+ } catch (IOException io) {
+ connect_failed();
+ }
+ }
+
+ private void connect_failed() {
+ if (closed()) {
+ AltosDebug.debug("connect_failed after closed");
+ return;
+ }