summaryrefslogtreecommitdiff
path: root/altoslib/AltosLib.java
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2013-12-08 19:48:27 -0800
committerKeith Packard <keithp@keithp.com>2013-12-08 19:48:27 -0800
commite0af4569446b12c026aa0ffd52c55839d69af0e1 (patch)
treeabcf62aacd3064c20285f352d746aef05998dafb /altoslib/AltosLib.java
parent88fa5fa6acbdd66d1338ca73cbbac219d62b5136 (diff)
altoslib: Publish mapping from product name back to USB id
This lets us choose which device to flash based on the filename Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altoslib/AltosLib.java')
-rw-r--r--altoslib/AltosLib.java36
1 files changed, 36 insertions, 0 deletions
diff --git a/altoslib/AltosLib.java b/altoslib/AltosLib.java
index 46031912..36a2ab32 100644
--- a/altoslib/AltosLib.java
+++ b/altoslib/AltosLib.java
@@ -104,6 +104,42 @@ public class AltosLib {
public final static int product_basestation = 0x10000 + 1;
public final static int product_altimeter = 0x10000 + 2;
+ private static class Product {
+ final String name;
+ final int product;
+
+ Product (String name, int product) {
+ this.name = name;
+ this.product = product;
+ }
+ }
+
+ private static Product[] products = {
+ new Product("telemetrum", product_telemetrum),
+ new Product("teleballoon", product_telemetrum),
+ new Product("teledongle", product_teledongle),
+ new Product("teleterra", product_teledongle),
+ new Product("telebt", product_telebt),
+ new Product("telelaunch", product_telelaunch),
+ new Product("telelco", product_telelco),
+ new Product("telescience", product_telescience),
+ new Product("telepyro", product_telepyro),
+ new Product("telemega", product_telemega),
+ new Product("megadongle", product_megadongle),
+ new Product("telegps", product_telegps),
+ new Product("easymini", product_easymini),
+ new Product("telemini", product_telemini)
+ };
+
+ public static int name_to_product(String name) {
+ String low = name.toLowerCase();
+
+ for (int i = 0; i < products.length; i++)
+ if (low.startsWith(products[i].name))
+ return products[i].product;
+ return product_any;
+ }
+
/* Bluetooth "identifier" (bluetooth sucks) */
public final static String bt_product_telebt = "TeleBT";