altosdroid: Send device name and connected state back to TelemetryService
authorMike Beattie <mike@ethernal.org>
Sun, 26 Aug 2012 11:37:58 +0000 (23:37 +1200)
committerMike Beattie <mike@ethernal.org>
Sun, 26 Aug 2012 11:37:58 +0000 (23:37 +1200)
Signed-off-by: Mike Beattie <mike@ethernal.org>
altosdroid/src/org/altusmetrum/AltosDroid/AltosBluetooth.java

index cc039206924fe682b5e994826dd4681c9ecc6556..278c6a5336b1298f807a536587382bb923a5380d 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,14 @@ 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();
+                               Message msg = handler.obtainMessage(TelemetryService.MSG_CONNECTED);
+                               Bundle b  = new Bundle();
+                               b.putString(TelemetryService.KEY_DEVNAME, name);
+                               msg.setData(b);
+                               handler.sendMessage(msg);
+
                                // Notify other waiting threads, now that we're connected
                                AltosBluetooth.this.notifyAll();