X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altosui%2FAltosBTDevice.java;h=727a9f6625ce7953e251c94817cc9f5832c4b1ad;hp=c2721b262c0df0b83a0a23a9a20900e961d3d80a;hb=c0966cd40f05f3a65b0c977b4b92586a58192f4b;hpb=44fb71ca3e5bccd5f601fc5a2d5da7292050b1d6 diff --git a/altosui/AltosBTDevice.java b/altosui/AltosBTDevice.java index c2721b26..727a9f66 100644 --- a/altosui/AltosBTDevice.java +++ b/altosui/AltosBTDevice.java @@ -16,9 +16,8 @@ */ package altosui; -import java.lang.*; -import java.util.*; import libaltosJNI.*; +import org.altusmetrum.altosuilib_1.*; public class AltosBTDevice extends altos_bt_device implements AltosDevice { @@ -42,6 +41,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 +64,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()); } @@ -78,15 +78,16 @@ public class AltosBTDevice extends altos_bt_device implements AltosDevice { return libaltos.altos_bt_open(this); } + /* private boolean isAltusMetrum() { if (getName().startsWith(Altos.bt_product_telebt)) return true; return false; } + */ public boolean matchProduct(int want_product) { - System.out.printf("matchProduct %s %d\n", toString(), want_product); // if (!isAltusMetrum()) // return false; @@ -106,7 +107,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 +115,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); }