telegps: Auto-connect to any base stations plugged in at startup
authorKeith Packard <keithp@keithp.com>
Thu, 29 May 2014 05:45:23 +0000 (22:45 -0700)
committerKeith Packard <keithp@keithp.com>
Thu, 29 May 2014 05:45:23 +0000 (22:45 -0700)
Signed-off-by: Keith Packard <keithp@keithp.com>
telegps/TeleGPS.java

index 1bb505e03c068e102e1a1551bce205c3750d0681..de2b4aa33f84d05c9ed1a8d658a39d5143613df8 100644 (file)
@@ -433,6 +433,11 @@ public class TeleGPS extends AltosUIFrame implements AltosFlightDisplay, AltosFo
                set_reader(reader);
        }
 
+       public TeleGPS(AltosDevice device) {
+               this();
+               connect(device);
+       }
+
        static AltosStateIterable record_iterable(File file) {
                FileInputStream in;
                try {
@@ -562,7 +567,15 @@ public class TeleGPS extends AltosUIFrame implements AltosFlightDisplay, AltosFo
                }
                if (errors != 0)
                        System.exit(errors);
-               if (!any_created)
-                       new TeleGPS();
+               if (!any_created) {
+                       java.util.List<AltosDevice> devices = AltosUSBDevice.list(AltosLib.product_basestation);
+                       if (devices != null)
+                               for (AltosDevice device : devices) {
+                                       new TeleGPS(device);
+                                       any_created = true;
+                               }
+                       if (!any_created)
+                               new TeleGPS();
+               }
        }
 }