Merge branch 'master' of ssh://git.gag.com/scm/git/fw/altos
[fw/altos] / altosui / AltosBTDevice.java
index c2721b262c0df0b83a0a23a9a20900e961d3d80a..a6eee0859213c275f4f94fe07ed76634ca7cf6ab 100644 (file)
@@ -15,7 +15,7 @@
  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
  */
 
-package altosui;
+package AltosUI;
 import java.lang.*;
 import java.util.*;
 import libaltosJNI.*;
@@ -42,6 +42,13 @@ public class AltosBTDevice extends altos_bt_device implements AltosDevice {
                return getAddr();
        }
 
+       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 int getSerial() {
                String name = getName();
                if (name == null)
@@ -58,19 +65,13 @@ public class AltosBTDevice extends altos_bt_device implements AltosDevice {
        }
 
        public String toString() {
-               String  name = getName();
-               if (name == null)
-                       name = "Altus Metrum";
                return String.format("%-20.20s %4d %s",
                                     getProductName(), getSerial(), getAddr());
        }
 
        public String toShortString() {
-               String  name = getName();
-               if (name == null)
-                       name = "Altus Metrum";
                return String.format("%s %d %s",
-                                    getProduct(), getSerial(), getAddr());
+                                    getProductName(), getSerial(), getAddr());
 
        }
 
@@ -86,7 +87,6 @@ public class AltosBTDevice extends altos_bt_device implements AltosDevice {
 
        public boolean matchProduct(int want_product) {
 
-               System.out.printf("matchProduct %s %d\n", toString(), want_product);
 //             if (!isAltusMetrum())
 //                     return false;
 
@@ -106,7 +106,6 @@ public class AltosBTDevice extends altos_bt_device implements AltosDevice {
                if (!(o instanceof AltosBTDevice))
                        return false;
                AltosBTDevice other = (AltosBTDevice) o;
-               System.out.printf("AltosBTDevice equals %s == %s\n", toString(), other.toString());
                return getName().equals(other.getName()) && getAddr().equals(other.getAddr());
        }
 
@@ -115,6 +114,7 @@ public class AltosBTDevice extends altos_bt_device implements AltosDevice {
        }
 
        public AltosBTDevice(String name, String addr) {
+               Altos.load_library();
                libaltos.altos_bt_fill_in(name, addr,this);
        }