altosuilib: Detect pair programming by product name, not USB id
authorKeith Packard <keithp@keithp.com>
Sat, 14 Feb 2015 09:13:21 +0000 (01:13 -0800)
committerKeith Packard <keithp@keithp.com>
Sat, 14 Feb 2015 09:13:21 +0000 (01:13 -0800)
With TeleDongle, TeleBT and TeleMetrum coming in both pair- and self-
programmable versions, we can't use the USB id to tell them
apart. Instead, fetch the device name and use that instead.

Signed-off-by: Keith Packard <keithp@keithp.com>
altosuilib/AltosFlashUI.java

index 6e497c429be6bb9cbdc93674e29537e13c3b7e03..ace8fbe5b3f8dc6488a51772124f786b295ce4ef 100644 (file)
@@ -54,7 +54,7 @@ public class AltosFlashUI
        // Flash controller
        AltosProgrammer programmer;
 
-       private static String[] pair_programmed = {
+       private static final String[] pair_programmed_files = {
                "teleballoon",
                "telebt-v1",
                "teledongle-v0",
@@ -67,20 +67,34 @@ public class AltosFlashUI
                "teleterra"
        };
 
+       private static final String[] pair_programmed_devices = {
+               "TeleBalloon",
+               "TeleBT-v1",
+               "TeleDongle-v0",
+               "TeleFire",
+               "TeleMetrum-v0",
+               "TeleMetrum-v1",
+               "TeleMini",
+               "TeleNano",
+               "TeleShield",
+               "TeleTerra"
+       };
+
        private boolean is_pair_programmed() {
 
                if (file != null) {
                        String  name = file.getName();
-                       for (int i = 0; i < pair_programmed.length; i++) {
-                               if (name.startsWith(pair_programmed[i]))
+                       for (int i = 0; i < pair_programmed_files.length; i++) {
+                               if (name.startsWith(pair_programmed_files[i]))
                                        return true;
                        }
                }
                if (device != null) {
-                       if (!device.matchProduct(AltosLib.product_altusmetrum) &&
-                           (device.matchProduct(AltosLib.product_teledongle) ||
-                            device.matchProduct(AltosLib.product_telebt)))
-                               return true;
+                       String  name = device.toString();
+                       for (int i = 0; i < pair_programmed_devices.length; i++) {
+                               if (name.startsWith(pair_programmed_devices[i]))
+                                       return true;
+                       }
                }
                return false;
        }