X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=altosui%2FAltosBTDevice.java;h=a6eee0859213c275f4f94fe07ed76634ca7cf6ab;hb=1fc97dd9875a7639533a34438c4c7c999412eb3a;hp=5e946415235d7f24220ee637c24ed5762e3acb6d;hpb=84163eee7847a09fe78f8762b28f857d76bf5755;p=fw%2Faltos diff --git a/altosui/AltosBTDevice.java b/altosui/AltosBTDevice.java index 5e946415..a6eee085 100644 --- a/altosui/AltosBTDevice.java +++ b/altosui/AltosBTDevice.java @@ -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", - getProduct(), getSerial(), getAddr()); + 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,8 +87,8 @@ public class AltosBTDevice extends altos_bt_device implements AltosDevice { public boolean matchProduct(int want_product) { - if (!isAltusMetrum()) - return false; +// if (!isAltusMetrum()) +// return false; if (want_product == Altos.product_any) return true; @@ -100,4 +101,23 @@ public class AltosBTDevice extends altos_bt_device implements AltosDevice { return false; } + + public boolean equals(Object o) { + if (!(o instanceof AltosBTDevice)) + return false; + AltosBTDevice other = (AltosBTDevice) o; + return getName().equals(other.getName()) && getAddr().equals(other.getAddr()); + } + + public int hashCode() { + return getName().hashCode() ^ getAddr().hashCode(); + } + + public AltosBTDevice(String name, String addr) { + Altos.load_library(); + libaltos.altos_bt_fill_in(name, addr,this); + } + + public AltosBTDevice() { + } } \ No newline at end of file