Reverted package name to 'altosui' from 'AltosUI'
[fw/altos] / altosui / AltosUSBDevice.java
index deed00568b1d023fe3ad50e332c6a83d45598e1b..ed5f8307d178bba720de462c47b358e3f4f4ddf4 100644 (file)
@@ -39,6 +39,13 @@ public class AltosUSBDevice  extends altos_device implements AltosDevice {
 
        }
 
+       public String getErrorString() {
+               altos_error     error = new altos_error();
+
+               libaltos.altos_get_last_error(error);
+               return String.format("%s (%d)", error.getString(), error.getCode());
+       }
+
        public SWIGTYPE_p_altos_file open() {
                return libaltos.altos_open(this);
        }
@@ -64,7 +71,12 @@ public class AltosUSBDevice  extends altos_device implements AltosDevice {
                if (want_product == Altos.product_basestation)
                        return matchProduct(Altos.product_teledongle) ||
                                matchProduct(Altos.product_teleterra) ||
-                               matchProduct(Altos.product_telebt);
+                               matchProduct(Altos.product_telebt) ||
+                               matchProduct(Altos.product_megadongle);
+
+               if (want_product == Altos.product_altimeter)
+                       return matchProduct(Altos.product_telemetrum) ||
+                               matchProduct(Altos.product_megametrum);
 
                int have_product = getProduct();
 
@@ -77,13 +89,13 @@ public class AltosUSBDevice  extends altos_device implements AltosDevice {
                return false;
        }
 
-       static AltosUSBDevice[] list(int product) {
+       static java.util.List<AltosDevice> list(int product) {
                if (!Altos.load_library())
                        return null;
 
                SWIGTYPE_p_altos_list list = libaltos.altos_list_start();
 
-               ArrayList<AltosUSBDevice> device_list = new ArrayList<AltosUSBDevice>();
+               ArrayList<AltosDevice> device_list = new ArrayList<AltosDevice>();
                if (list != null) {
                        for (;;) {
                                AltosUSBDevice device = new AltosUSBDevice();
@@ -95,9 +107,6 @@ public class AltosUSBDevice  extends altos_device implements AltosDevice {
                        libaltos.altos_list_finish(list);
                }
 
-               AltosUSBDevice[] devices = new AltosUSBDevice[device_list.size()];
-               for (int i = 0; i < device_list.size(); i++)
-                       devices[i] = device_list.get(i);
-               return devices;
+               return device_list;
        }
 }
\ No newline at end of file