altosdroid: remove complexity around message passing
[fw/altos] / altosdroid / src / org / altusmetrum / AltosDroid / AltosBluetooth.java
index cc039206924fe682b5e994826dd4681c9ecc6556..bb188d80ca2a1d95186e9150a3ba3cabdbdf163f 100644 (file)
@@ -26,7 +26,9 @@ import java.util.UUID;
 import android.bluetooth.BluetoothAdapter;
 import android.bluetooth.BluetoothDevice;
 import android.bluetooth.BluetoothSocket;
+//import android.os.Bundle;
 import android.os.Handler;
+//import android.os.Message;
 import android.util.Log;
 
 import org.altusmetrum.AltosLib.*;
@@ -112,6 +114,10 @@ public class AltosBluetooth extends AltosLink {
                                // Reset the ConnectThread because we're done
                                connect_thread = null;
 
+                               // Send the device name back to the Telemetry Service
+                               name = device.getName();
+                               handler.obtainMessage(TelemetryService.MSG_CONNECTED).sendToTarget();
+
                                // Notify other waiting threads, now that we're connected
                                AltosBluetooth.this.notifyAll();
 
@@ -142,7 +148,7 @@ public class AltosBluetooth extends AltosLink {
        private void connection_failed() {
                if (D) Log.e(TAG, "Bluetooth Socket IO failed!");
        }
-       
+
        public void print(String data) {
                byte[] bytes = data.getBytes();
                if (D) Log.i(TAG, "print(): begin");
@@ -170,7 +176,7 @@ public class AltosBluetooth extends AltosLink {
                }
                return AltosLink.ERROR;
        }
-                       
+
        public void close() {
                if (D) Log.i(TAG, "close(): begin");
                synchronized(this) {