summaryrefslogtreecommitdiff
path: root/altosdroid
diff options
context:
space:
mode:
authorBdale Garbee <bdale@gag.com>2013-12-19 01:38:40 -0700
committerBdale Garbee <bdale@gag.com>2013-12-19 01:38:40 -0700
commit575bbaf976c5840fd0e308549c45a466fdec1352 (patch)
tree11bfb498348bf7687bffc24699c4b1a998988ee4 /altosdroid
parentb825116df173b77e2cab217a7b76112c742f9279 (diff)
parentbc3610d8cecbfed40c62d4dcb93fc9a4d2a7c9e3 (diff)
Merge branch 'branch-1.3' into debian
Conflicts: ChangeLog altoslib/AltosRecordMM.java altosui/Makefile.am altosui/altos-windows.nsi.in configure.ac debian/changelog debian/control doc/Makefile doc/altusmetrum.xsl doc/release-notes-1.2.1.xsl doc/release-notes-1.2.xsl
Diffstat (limited to 'altosdroid')
-rw-r--r--altosdroid/AndroidManifest.xml4
-rw-r--r--altosdroid/Notebook2
-rw-r--r--altosdroid/src/org/altusmetrum/AltosDroid/AltosBluetooth.java16
-rw-r--r--altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java20
-rw-r--r--altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidPreferences.java2
-rw-r--r--altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidTab.java2
-rw-r--r--altosdroid/src/org/altusmetrum/AltosDroid/AltosVoice.java404
-rw-r--r--altosdroid/src/org/altusmetrum/AltosDroid/Dumper.java366
-rw-r--r--altosdroid/src/org/altusmetrum/AltosDroid/TabAscent.java18
-rw-r--r--altosdroid/src/org/altusmetrum/AltosDroid/TabDescent.java12
-rw-r--r--altosdroid/src/org/altusmetrum/AltosDroid/TabLanded.java6
-rw-r--r--altosdroid/src/org/altusmetrum/AltosDroid/TabMap.java2
-rw-r--r--altosdroid/src/org/altusmetrum/AltosDroid/TabPad.java22
-rw-r--r--altosdroid/src/org/altusmetrum/AltosDroid/TelemetryLogger.java2
-rw-r--r--altosdroid/src/org/altusmetrum/AltosDroid/TelemetryReader.java189
-rw-r--r--altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java8
16 files changed, 547 insertions, 528 deletions
diff --git a/altosdroid/AndroidManifest.xml b/altosdroid/AndroidManifest.xml
index 04a679e1..06644fbb 100644
--- a/altosdroid/AndroidManifest.xml
+++ b/altosdroid/AndroidManifest.xml
@@ -17,8 +17,8 @@
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.altusmetrum.AltosDroid"
- android:versionCode="3"
- android:versionName="1.2">
+ android:versionCode="4"
+ android:versionName="1.3">
<uses-sdk android:targetSdkVersion="10" android:minSdkVersion="10"/>
<!-- Google Maps -->
<uses-feature android:glEsVersion="0x00020000" android:required="true"/>
diff --git a/altosdroid/Notebook b/altosdroid/Notebook
index b4ae2b7f..ebb3578d 100644
--- a/altosdroid/Notebook
+++ b/altosdroid/Notebook
@@ -28,3 +28,5 @@ Desired AltosDroid feature list
'find my rocket' mode after shutting down the application.
*) Imperial Units mode
+
+ *) TeleBT battery voltage
diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosBluetooth.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosBluetooth.java
index 0aea06f1..643e94f5 100644
--- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosBluetooth.java
+++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosBluetooth.java
@@ -31,7 +31,7 @@ import android.os.Handler;
//import android.os.Message;
import android.util.Log;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
public class AltosBluetooth extends AltosLink {
@@ -162,6 +162,20 @@ public class AltosBluetooth extends AltosLink {
}
}
+ public void putchar(byte c) {
+ byte[] bytes = { c };
+ if (D) Log.d(TAG, "print(): begin");
+ try {
+ wait_connected();
+ output.write(bytes);
+ if (D) Log.d(TAG, "print(): Wrote byte: '" + c + "'");
+ } catch (IOException e) {
+ connection_lost();
+ } catch (InterruptedException e) {
+ connection_lost();
+ }
+ }
+
public int getchar() {
try {
wait_connected();
diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java
index e10982f7..92287476 100644
--- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java
+++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroid.java
@@ -49,7 +49,7 @@ import android.widget.Toast;
import android.app.AlertDialog;
import android.location.Location;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
public class AltosDroid extends FragmentActivity {
// Debugging
@@ -147,7 +147,7 @@ public class AltosDroid extends FragmentActivity {
case MSG_CRC_ERROR:
case MSG_UPDATE_AGE:
if (ad.saved_state != null) {
- ad.mAgeView.setText(String.format("%d", (System.currentTimeMillis() - ad.saved_state.report_time + 500) / 1000));
+ ad.mAgeView.setText(String.format("%d", (System.currentTimeMillis() - ad.saved_state.received_time + 500) / 1000));
}
break;
}
@@ -243,11 +243,11 @@ public class AltosDroid extends FragmentActivity {
}
if (state != null) {
- mCallsignView.setText(state.data.callsign);
- mSerialView.setText(String.format("%d", state.data.serial));
- mFlightView.setText(String.format("%d", state.data.flight));
- mStateView.setText(state.data.state());
- mRSSIView.setText(String.format("%d", state.data.rssi));
+ mCallsignView.setText(state.callsign);
+ mSerialView.setText(String.format("%d", state.serial));
+ mFlightView.setText(String.format("%d", state.flight));
+ mStateView.setText(state.state_name());
+ mRSSIView.setText(String.format("%d", state.rssi));
}
for (AltosDroidTab mTab : mTabs)
@@ -266,7 +266,7 @@ public class AltosDroid extends FragmentActivity {
static String pos(double p, String pos, String neg) {
String h = pos;
- if (p == AltosRecord.MISSING)
+ if (p == AltosLib.MISSING)
return "";
if (p < 0) {
h = neg;
@@ -278,13 +278,13 @@ public class AltosDroid extends FragmentActivity {
}
static String number(String format, double value) {
- if (value == AltosRecord.MISSING)
+ if (value == AltosLib.MISSING)
return "";
return String.format(format, value);
}
static String integer(String format, int value) {
- if (value == AltosRecord.MISSING)
+ if (value == AltosLib.MISSING)
return "";
return String.format(format, value);
}
diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidPreferences.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidPreferences.java
index fd4b0768..59fef842 100644
--- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidPreferences.java
+++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidPreferences.java
@@ -23,7 +23,7 @@ import android.content.Context;
import android.content.SharedPreferences;
import android.os.Environment;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
public class AltosDroidPreferences implements AltosPreferencesBackend {
public final static String NAME = "org.altusmetrum.AltosDroid";
diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidTab.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidTab.java
index 6ebb47f7..c652a169 100644
--- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidTab.java
+++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosDroidTab.java
@@ -17,7 +17,7 @@
package org.altusmetrum.AltosDroid;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
import android.location.Location;
public interface AltosDroidTab {
diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosVoice.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosVoice.java
index b3dba626..f17cb821 100644
--- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosVoice.java
+++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosVoice.java
@@ -1,202 +1,202 @@
-/*
- * Copyright © 2011 Keith Packard <keithp@keithp.com>
- * Copyright © 2012 Mike Beattie <mike@ethernal.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- */
-
-package org.altusmetrum.AltosDroid;
-
-import android.speech.tts.TextToSpeech;
-import android.speech.tts.TextToSpeech.OnInitListener;
-
-import org.altusmetrum.altoslib_1.*;
-
-public class AltosVoice {
-
- private TextToSpeech tts = null;
- private boolean tts_enabled = false;
-
- private IdleThread idle_thread = null;
-
- private AltosState old_state = null;
-
- public AltosVoice(AltosDroid a) {
-
- tts = new TextToSpeech(a, new OnInitListener() {
- public void onInit(int status) {
- if (status == TextToSpeech.SUCCESS) tts_enabled = true;
- if (tts_enabled) {
- idle_thread = new IdleThread();
- }
- }
- });
-
- }
-
- public void speak(String s) {
- if (!tts_enabled) return;
- tts.speak(s, TextToSpeech.QUEUE_ADD, null);
- }
-
- public void stop() {
- if (tts != null) tts.shutdown();
- if (idle_thread != null) {
- idle_thread.interrupt();
- idle_thread = null;
- }
- }
-
- public void tell(AltosState state) {
- if (!tts_enabled) return;
-
- boolean spoke = false;
- if (old_state == null || old_state.state != state.state) {
- speak(state.data.state());
- if ((old_state == null || old_state.state <= AltosLib.ao_flight_boost) &&
- state.state > AltosLib.ao_flight_boost) {
- speak(String.format("max speed: %d meters per second.", (int) (state.max_speed() + 0.5)));
- spoke = true;
- } else if ((old_state == null || old_state.state < AltosLib.ao_flight_drogue) &&
- state.state >= AltosLib.ao_flight_drogue) {
- speak(String.format("max height: %d meters.", (int) (state.max_height + 0.5)));
- spoke = true;
- }
- }
- if (old_state == null || old_state.gps_ready != state.gps_ready) {
- if (state.gps_ready) {
- speak("GPS ready");
- spoke = true;
- } else if (old_state != null) {
- speak("GPS lost");
- spoke = true;
- }
- }
- old_state = state;
- idle_thread.notice(state, spoke);
- }
-
-
- class IdleThread extends Thread {
- boolean started;
- private AltosState state;
- int reported_landing;
- int report_interval;
- long report_time;
-
- public synchronized void report(boolean last) {
- if (state == null)
- return;
-
- /* reset the landing count once we hear about a new flight */
- if (state.state < AltosLib.ao_flight_drogue)
- reported_landing = 0;
-
- /* Shut up once the rocket is on the ground */
- if (reported_landing > 2) {
- return;
- }
-
- /* If the rocket isn't on the pad, then report height */
- if (AltosLib.ao_flight_drogue <= state.state &&
- state.state < AltosLib.ao_flight_landed &&
- state.range >= 0)
- {
- speak(String.format("Height %d, bearing %s %d, elevation %d, range %d.\n",
- (int) (state.height + 0.5),
- state.from_pad.bearing_words(
- AltosGreatCircle.BEARING_VOICE),
- (int) (state.from_pad.bearing + 0.5),
- (int) (state.elevation + 0.5),
- (int) (state.range + 0.5)));
- } else if (state.state > AltosLib.ao_flight_pad) {
- speak(String.format("%d meters", (int) (state.height + 0.5)));
- } else {
- reported_landing = 0;
- }
-
- /* If the rocket is coming down, check to see if it has landed;
- * either we've got a landed report or we haven't heard from it in
- * a long time
- */
- if (state.state >= AltosLib.ao_flight_drogue &&
- (last ||
- System.currentTimeMillis() - state.report_time >= 15000 ||
- state.state == AltosLib.ao_flight_landed))
- {
- if (Math.abs(state.baro_speed) < 20 && state.height < 100)
- speak("rocket landed safely");
- else
- speak("rocket may have crashed");
- if (state.from_pad != null)
- speak(String.format("Bearing %d degrees, range %d meters.",
- (int) (state.from_pad.bearing + 0.5),
- (int) (state.from_pad.distance + 0.5)));
- ++reported_landing;
- }
- }
-
- long now () {
- return System.currentTimeMillis();
- }
-
- void set_report_time() {
- report_time = now() + report_interval;
- }
-
- public void run () {
- try {
- for (;;) {
- set_report_time();
- for (;;) {
- synchronized (this) {
- long sleep_time = report_time - now();
- if (sleep_time <= 0)
- break;
- wait(sleep_time);
- }
- }
- report(false);
- }
- } catch (InterruptedException ie) {
- }
- }
-
- public synchronized void notice(AltosState new_state, boolean spoken) {
- AltosState old_state = state;
- state = new_state;
- if (!started && state.state > AltosLib.ao_flight_pad) {
- started = true;
- start();
- }
-
- if (state.state < AltosLib.ao_flight_drogue)
- report_interval = 10000;
- else
- report_interval = 20000;
- if (old_state != null && old_state.state != state.state) {
- report_time = now();
- this.notify();
- } else if (spoken)
- set_report_time();
- }
-
- public IdleThread() {
- state = null;
- reported_landing = 0;
- report_interval = 10000;
- }
- }
-
-}
+/*
+ * Copyright © 2011 Keith Packard <keithp@keithp.com>
+ * Copyright © 2012 Mike Beattie <mike@ethernal.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+package org.altusmetrum.AltosDroid;
+
+import android.speech.tts.TextToSpeech;
+import android.speech.tts.TextToSpeech.OnInitListener;
+
+import org.altusmetrum.altoslib_2.*;
+
+public class AltosVoice {
+
+ private TextToSpeech tts = null;
+ private boolean tts_enabled = false;
+
+ private IdleThread idle_thread = null;
+
+ private AltosState old_state = null;
+
+ public AltosVoice(AltosDroid a) {
+
+ tts = new TextToSpeech(a, new OnInitListener() {
+ public void onInit(int status) {
+ if (status == TextToSpeech.SUCCESS) tts_enabled = true;
+ if (tts_enabled) {
+ idle_thread = new IdleThread();
+ }
+ }
+ });
+
+ }
+
+ public void speak(String s) {
+ if (!tts_enabled) return;
+ tts.speak(s, TextToSpeech.QUEUE_ADD, null);
+ }
+
+ public void stop() {
+ if (tts != null) tts.shutdown();
+ if (idle_thread != null) {
+ idle_thread.interrupt();
+ idle_thread = null;
+ }
+ }
+
+ public void tell(AltosState state) {
+ if (!tts_enabled) return;
+
+ boolean spoke = false;
+ if (old_state == null || old_state.state != state.state) {
+ speak(state.state_name());
+ if ((old_state == null || old_state.state <= AltosLib.ao_flight_boost) &&
+ state.state > AltosLib.ao_flight_boost) {
+ speak(String.format("max speed: %d meters per second.", (int) (state.max_speed() + 0.5)));
+ spoke = true;
+ } else if ((old_state == null || old_state.state < AltosLib.ao_flight_drogue) &&
+ state.state >= AltosLib.ao_flight_drogue) {
+ speak(String.format("max height: %d meters.", (int) (state.max_height() + 0.5)));
+ spoke = true;
+ }
+ }
+ if (old_state == null || old_state.gps_ready != state.gps_ready) {
+ if (state.gps_ready) {
+ speak("GPS ready");
+ spoke = true;
+ } else if (old_state != null) {
+ speak("GPS lost");
+ spoke = true;
+ }
+ }
+ old_state = state;
+ idle_thread.notice(state, spoke);
+ }
+
+
+ class IdleThread extends Thread {
+ boolean started;
+ private AltosState state;
+ int reported_landing;
+ int report_interval;
+ long report_time;
+
+ public synchronized void report(boolean last) {
+ if (state == null)
+ return;
+
+ /* reset the landing count once we hear about a new flight */
+ if (state.state < AltosLib.ao_flight_drogue)
+ reported_landing = 0;
+
+ /* Shut up once the rocket is on the ground */
+ if (reported_landing > 2) {
+ return;
+ }
+
+ /* If the rocket isn't on the pad, then report height */
+ if (AltosLib.ao_flight_drogue <= state.state &&
+ state.state < AltosLib.ao_flight_landed &&
+ state.range >= 0)
+ {
+ speak(String.format("Height %d, bearing %s %d, elevation %d, range %d.\n",
+ (int) (state.height() + 0.5),
+ state.from_pad.bearing_words(
+ AltosGreatCircle.BEARING_VOICE),
+ (int) (state.from_pad.bearing + 0.5),
+ (int) (state.elevation + 0.5),
+ (int) (state.range + 0.5)));
+ } else if (state.state > AltosLib.ao_flight_pad) {
+ speak(String.format("%d meters", (int) (state.height() + 0.5)));
+ } else {
+ reported_landing = 0;
+ }
+
+ /* If the rocket is coming down, check to see if it has landed;
+ * either we've got a landed report or we haven't heard from it in
+ * a long time
+ */
+ if (state.state >= AltosLib.ao_flight_drogue &&
+ (last ||
+ System.currentTimeMillis() - state.received_time >= 15000 ||
+ state.state == AltosLib.ao_flight_landed))
+ {
+ if (Math.abs(state.speed()) < 20 && state.height() < 100)
+ speak("rocket landed safely");
+ else
+ speak("rocket may have crashed");
+ if (state.from_pad != null)
+ speak(String.format("Bearing %d degrees, range %d meters.",
+ (int) (state.from_pad.bearing + 0.5),
+ (int) (state.from_pad.distance + 0.5)));
+ ++reported_landing;
+ }
+ }
+
+ long now () {
+ return System.currentTimeMillis();
+ }
+
+ void set_report_time() {
+ report_time = now() + report_interval;
+ }
+
+ public void run () {
+ try {
+ for (;;) {
+ set_report_time();
+ for (;;) {
+ synchronized (this) {
+ long sleep_time = report_time - now();
+ if (sleep_time <= 0)
+ break;
+ wait(sleep_time);
+ }
+ }
+ report(false);
+ }
+ } catch (InterruptedException ie) {
+ }
+ }
+
+ public synchronized void notice(AltosState new_state, boolean spoken) {
+ AltosState old_state = state;
+ state = new_state;
+ if (!started && state.state > AltosLib.ao_flight_pad) {
+ started = true;
+ start();
+ }
+
+ if (state.state < AltosLib.ao_flight_drogue)
+ report_interval = 10000;
+ else
+ report_interval = 20000;
+ if (old_state != null && old_state.state != state.state) {
+ report_time = now();
+ this.notify();
+ } else if (spoken)
+ set_report_time();
+ }
+
+ public IdleThread() {
+ state = null;
+ reported_landing = 0;
+ report_interval = 10000;
+ }
+ }
+
+}
diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/Dumper.java b/altosdroid/src/org/altusmetrum/AltosDroid/Dumper.java
index 17e4cf5b..2797fc5e 100644
--- a/altosdroid/src/org/altusmetrum/AltosDroid/Dumper.java
+++ b/altosdroid/src/org/altusmetrum/AltosDroid/Dumper.java
@@ -1,183 +1,183 @@
-package org.altusmetrum.AltosDroid;
-
- import java.lang.reflect.Array;
- import java.lang.reflect.Field;
- import java.util.HashMap;
-
- public class Dumper {
- private static Dumper instance = new Dumper();
-
- protected static Dumper getInstance() {
- return instance;
- }
-
- class DumpContext {
- int maxDepth = 0;
- int maxArrayElements = 0;
- int callCount = 0;
- HashMap<String, String> ignoreList = new HashMap<String, String>();
- HashMap<Object, Integer> visited = new HashMap<Object, Integer>();
- }
-
- public static String dump(Object o) {
- return dump(o, 0, 0, null);
- }
-
- public static String dump(Object o, int maxDepth, int maxArrayElements, String[] ignoreList) {
- DumpContext ctx = Dumper.getInstance().new DumpContext();
- ctx.maxDepth = maxDepth;
- ctx.maxArrayElements = maxArrayElements;
-
- if (ignoreList != null) {
- for (int i = 0; i < Array.getLength(ignoreList); i++) {
- int colonIdx = ignoreList[i].indexOf(':');
- if (colonIdx == -1)
- ignoreList[i] = ignoreList[i] + ":";
- ctx.ignoreList.put(ignoreList[i], ignoreList[i]);
- }
- }
-
- return dump(o, ctx);
- }
-
- protected static String dump(Object o, DumpContext ctx) {
- if (o == null) {
- return "<null>";
- }
-
- ctx.callCount++;
- StringBuffer tabs = new StringBuffer();
- for (int k = 0; k < ctx.callCount; k++) {
- tabs.append("\t");
- }
- StringBuffer buffer = new StringBuffer();
- @SuppressWarnings("rawtypes")
- Class oClass = o.getClass();
-
- String oSimpleName = getSimpleNameWithoutArrayQualifier(oClass);
-
- if (ctx.ignoreList.get(oSimpleName + ":") != null)
- return "<Ignored>";
-
- if (oClass.isArray()) {
- buffer.append("\n");
- buffer.append(tabs.toString().substring(1));
- buffer.append("[\n");
- int rowCount = ctx.maxArrayElements == 0 ? Array.getLength(o) : Math.min(ctx.maxArrayElements, Array.getLength(o));
- for (int i = 0; i < rowCount; i++) {
- buffer.append(tabs.toString());
- try {
- Object value = Array.get(o, i);
- buffer.append(dumpValue(value, ctx));
- } catch (Exception e) {
- buffer.append(e.getMessage());
- }
- if (i < Array.getLength(o) - 1)
- buffer.append(",");
- buffer.append("\n");
- }
- if (rowCount < Array.getLength(o)) {
- buffer.append(tabs.toString());
- buffer.append(Array.getLength(o) - rowCount + " more array elements...");
- buffer.append("\n");
- }
- buffer.append(tabs.toString().substring(1));
- buffer.append("]");
- } else {
- buffer.append("\n");
- buffer.append(tabs.toString().substring(1));
- buffer.append("{\n");
- buffer.append(tabs.toString());
- buffer.append("hashCode: " + o.hashCode());
- buffer.append("\n");
- while (oClass != null && oClass != Object.class) {
- Field[] fields = oClass.getDeclaredFields();
-
- if (ctx.ignoreList.get(oClass.getSimpleName()) == null) {
- if (oClass != o.getClass()) {
- buffer.append(tabs.toString().substring(1));
- buffer.append(" Inherited from superclass " + oSimpleName + ":\n");
- }
-
- for (int i = 0; i < fields.length; i++) {
-
- String fSimpleName = getSimpleNameWithoutArrayQualifier(fields[i].getType());
- String fName = fields[i].getName();
-
- fields[i].setAccessible(true);
- buffer.append(tabs.toString());
- buffer.append(fName + "(" + fSimpleName + ")");
- buffer.append("=");
-
- if (ctx.ignoreList.get(":" + fName) == null &&
- ctx.ignoreList.get(fSimpleName + ":" + fName) == null &&
- ctx.ignoreList.get(fSimpleName + ":") == null) {
-
- try {
- Object value = fields[i].get(o);
- buffer.append(dumpValue(value, ctx));
- } catch (Exception e) {
- buffer.append(e.getMessage());
- }
- buffer.append("\n");
- } else {
- buffer.append("<Ignored>");
- buffer.append("\n");
- }
- }
- oClass = oClass.getSuperclass();
- oSimpleName = oClass.getSimpleName();
- } else {
- oClass = null;
- oSimpleName = "";
- }
- }
- buffer.append(tabs.toString().substring(1));
- buffer.append("}");
- }
- ctx.callCount--;
- return buffer.toString();
- }
-
- protected static String dumpValue(Object value, DumpContext ctx) {
- if (value == null) {
- return "<null>";
- }
- if (value.getClass().isPrimitive() ||
- value.getClass() == java.lang.Short.class ||
- value.getClass() == java.lang.Long.class ||
- value.getClass() == java.lang.String.class ||
- value.getClass() == java.lang.Integer.class ||
- value.getClass() == java.lang.Float.class ||
- value.getClass() == java.lang.Byte.class ||
- value.getClass() == java.lang.Character.class ||
- value.getClass() == java.lang.Double.class ||
- value.getClass() == java.lang.Boolean.class) {
-
- return value.toString();
-
- } else {
-
- Integer visitedIndex = ctx.visited.get(value);
- if (visitedIndex == null) {
- ctx.visited.put(value, ctx.callCount);
- if (ctx.maxDepth == 0 || ctx.callCount < ctx.maxDepth) {
- return dump(value, ctx);
- } else {
- return "<Reached max recursion depth>";
- }
- } else {
- return "<Previously visited - see hashCode " + value.hashCode() + ">";
- }
- }
- }
-
-
- private static String getSimpleNameWithoutArrayQualifier(@SuppressWarnings("rawtypes") Class clazz) {
- String simpleName = clazz.getSimpleName();
- int indexOfBracket = simpleName.indexOf('[');
- if (indexOfBracket != -1)
- return simpleName.substring(0, indexOfBracket);
- return simpleName;
- }
-}
+package org.altusmetrum.AltosDroid;
+
+ import java.lang.reflect.Array;
+ import java.lang.reflect.Field;
+ import java.util.HashMap;
+
+ public class Dumper {
+ private static Dumper instance = new Dumper();
+
+ protected static Dumper getInstance() {
+ return instance;
+ }
+
+ class DumpContext {
+ int maxDepth = 0;
+ int maxArrayElements = 0;
+ int callCount = 0;
+ HashMap<String, String> ignoreList = new HashMap<String, String>();
+ HashMap<Object, Integer> visited = new HashMap<Object, Integer>();
+ }
+
+ public static String dump(Object o) {
+ return dump(o, 0, 0, null);
+ }
+
+ public static String dump(Object o, int maxDepth, int maxArrayElements, String[] ignoreList) {
+ DumpContext ctx = Dumper.getInstance().new DumpContext();
+ ctx.maxDepth = maxDepth;
+ ctx.maxArrayElements = maxArrayElements;
+
+ if (ignoreList != null) {
+ for (int i = 0; i < Array.getLength(ignoreList); i++) {
+ int colonIdx = ignoreList[i].indexOf(':');
+ if (colonIdx == -1)
+ ignoreList[i] = ignoreList[i] + ":";
+ ctx.ignoreList.put(ignoreList[i], ignoreList[i]);
+ }
+ }
+
+ return dump(o, ctx);
+ }
+
+ protected static String dump(Object o, DumpContext ctx) {
+ if (o == null) {
+ return "<null>";
+ }
+
+ ctx.callCount++;
+ StringBuffer tabs = new StringBuffer();
+ for (int k = 0; k < ctx.callCount; k++) {
+ tabs.append("\t");
+ }
+ StringBuffer buffer = new StringBuffer();
+ @SuppressWarnings("rawtypes")
+ Class oClass = o.getClass();
+
+ String oSimpleName = getSimpleNameWithoutArrayQualifier(oClass);
+
+ if (ctx.ignoreList.get(oSimpleName + ":") != null)
+ return "<Ignored>";
+
+ if (oClass.isArray()) {
+ buffer.append("\n");
+ buffer.append(tabs.toString().substring(1));
+ buffer.append("[\n");
+ int rowCount = ctx.maxArrayElements == 0 ? Array.getLength(o) : Math.min(ctx.maxArrayElements, Array.getLength(o));
+ for (int i = 0; i < rowCount; i++) {
+ buffer.append(tabs.toString());
+ try {
+ Object value = Array.get(o, i);
+ buffer.append(dumpValue(value, ctx));
+ } catch (Exception e) {
+ buffer.append(e.getMessage());
+ }
+ if (i < Array.getLength(o) - 1)
+ buffer.append(",");
+ buffer.append("\n");
+ }
+ if (rowCount < Array.getLength(o)) {
+ buffer.append(tabs.toString());
+ buffer.append(Array.getLength(o) - rowCount + " more array elements...");
+ buffer.append("\n");
+ }
+ buffer.append(tabs.toString().substring(1));
+ buffer.append("]");
+ } else {
+ buffer.append("\n");
+ buffer.append(tabs.toString().substring(1));
+ buffer.append("{\n");
+ buffer.append(tabs.toString());
+ buffer.append("hashCode: " + o.hashCode());
+ buffer.append("\n");
+ while (oClass != null && oClass != Object.class) {
+ Field[] fields = oClass.getDeclaredFields();
+
+ if (ctx.ignoreList.get(oClass.getSimpleName()) == null) {
+ if (oClass != o.getClass()) {
+ buffer.append(tabs.toString().substring(1));
+ buffer.append(" Inherited from superclass " + oSimpleName + ":\n");
+ }
+
+ for (int i = 0; i < fields.length; i++) {
+
+ String fSimpleName = getSimpleNameWithoutArrayQualifier(fields[i].getType());
+ String fName = fields[i].getName();
+
+ fields[i].setAccessible(true);
+ buffer.append(tabs.toString());
+ buffer.append(fName + "(" + fSimpleName + ")");
+ buffer.append("=");
+
+ if (ctx.ignoreList.get(":" + fName) == null &&
+ ctx.ignoreList.get(fSimpleName + ":" + fName) == null &&
+ ctx.ignoreList.get(fSimpleName + ":") == null) {
+
+ try {
+ Object value = fields[i].get(o);
+ buffer.append(dumpValue(value, ctx));
+ } catch (Exception e) {
+ buffer.append(e.getMessage());
+ }
+ buffer.append("\n");
+ } else {
+ buffer.append("<Ignored>");
+ buffer.append("\n");
+ }
+ }
+ oClass = oClass.getSuperclass();
+ oSimpleName = oClass.getSimpleName();
+ } else {
+ oClass = null;
+ oSimpleName = "";
+ }
+ }
+ buffer.append(tabs.toString().substring(1));
+ buffer.append("}");
+ }
+ ctx.callCount--;
+ return buffer.toString();
+ }
+
+ protected static String dumpValue(Object value, DumpContext ctx) {
+ if (value == null) {
+ return "<null>";
+ }
+ if (value.getClass().isPrimitive() ||
+ value.getClass() == java.lang.Short.class ||
+ value.getClass() == java.lang.Long.class ||
+ value.getClass() == java.lang.String.class ||
+ value.getClass() == java.lang.Integer.class ||
+ value.getClass() == java.lang.Float.class ||
+ value.getClass() == java.lang.Byte.class ||
+ value.getClass() == java.lang.Character.class ||
+ value.getClass() == java.lang.Double.class ||
+ value.getClass() == java.lang.Boolean.class) {
+
+ return value.toString();
+
+ } else {
+
+ Integer visitedIndex = ctx.visited.get(value);
+ if (visitedIndex == null) {
+ ctx.visited.put(value, ctx.callCount);
+ if (ctx.maxDepth == 0 || ctx.callCount < ctx.maxDepth) {
+ return dump(value, ctx);
+ } else {
+ return "<Reached max recursion depth>";
+ }
+ } else {
+ return "<Previously visited - see hashCode " + value.hashCode() + ">";
+ }
+ }
+ }
+
+
+ private static String getSimpleNameWithoutArrayQualifier(@SuppressWarnings("rawtypes") Class clazz) {
+ String simpleName = clazz.getSimpleName();
+ int indexOfBracket = simpleName.indexOf('[');
+ if (indexOfBracket != -1)
+ return simpleName.substring(0, indexOfBracket);
+ return simpleName;
+ }
+}
diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TabAscent.java b/altosdroid/src/org/altusmetrum/AltosDroid/TabAscent.java
index 0e141ae4..3eaf12db 100644
--- a/altosdroid/src/org/altusmetrum/AltosDroid/TabAscent.java
+++ b/altosdroid/src/org/altusmetrum/AltosDroid/TabAscent.java
@@ -17,7 +17,7 @@
package org.altusmetrum.AltosDroid;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
import android.app.Activity;
import android.os.Bundle;
@@ -87,12 +87,12 @@ public class TabAscent extends Fragment implements AltosDroidTab {
public void update_ui(AltosState state, AltosGreatCircle from_receiver, Location receiver) {
if (state != null) {
- mHeightView.setText(AltosDroid.number("%6.0f m", state.height));
- mMaxHeightView.setText(AltosDroid.number("%6.0f m", state.max_height));
+ mHeightView.setText(AltosDroid.number("%6.0f m", state.height()));
+ mMaxHeightView.setText(AltosDroid.number("%6.0f m", state.max_height()));
mSpeedView.setText(AltosDroid.number("%6.0f m/s", state.speed()));
mMaxSpeedView.setText(AltosDroid.number("%6.0f m/s", state.max_speed()));
- mAccelView.setText(AltosDroid.number("%6.0f m/s²", state.acceleration));
- mMaxAccelView.setText(AltosDroid.number("%6.0f m/s²", state.max_acceleration));
+ mAccelView.setText(AltosDroid.number("%6.0f m/s²", state.acceleration()));
+ mMaxAccelView.setText(AltosDroid.number("%6.0f m/s²", state.max_acceleration()));
if (state.gps != null) {
mLatitudeView.setText(AltosDroid.pos(state.gps.lat, "N", "S"));
@@ -102,11 +102,11 @@ public class TabAscent extends Fragment implements AltosDroidTab {
mLongitudeView.setText("");
}
- mApogeeVoltageView.setText(AltosDroid.number("%4.2f V", state.drogue_sense));
- mApogeeLights.set(state.drogue_sense > 3.2, state.drogue_sense == AltosRecord.MISSING);
+ mApogeeVoltageView.setText(AltosDroid.number("%4.2f V", state.apogee_voltage));
+ mApogeeLights.set(state.apogee_voltage > 3.2, state.apogee_voltage == AltosLib.MISSING);
- mMainVoltageView.setText(AltosDroid.number("%4.2f V", state.main_sense));
- mMainLights.set(state.main_sense > 3.2, state.main_sense == AltosRecord.MISSING);
+ mMainVoltageView.setText(AltosDroid.number("%4.2f V", state.main_voltage));
+ mMainLights.set(state.main_voltage > 3.2, state.main_voltage == AltosLib.MISSING);
}
}
}
diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TabDescent.java b/altosdroid/src/org/altusmetrum/AltosDroid/TabDescent.java
index 09e7169b..e4a954ca 100644
--- a/altosdroid/src/org/altusmetrum/AltosDroid/TabDescent.java
+++ b/altosdroid/src/org/altusmetrum/AltosDroid/TabDescent.java
@@ -17,7 +17,7 @@
package org.altusmetrum.AltosDroid;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
import android.app.Activity;
import android.os.Bundle;
@@ -92,7 +92,7 @@ public class TabDescent extends Fragment implements AltosDroidTab {
public void update_ui(AltosState state, AltosGreatCircle from_receiver, Location receiver) {
if (state != null) {
mSpeedView.setText(AltosDroid.number("%6.0f m/s", state.speed()));
- mHeightView.setText(AltosDroid.number("%6.0f m", state.height));
+ mHeightView.setText(AltosDroid.number("%6.0f m", state.height()));
if (from_receiver != null) {
mElevationView.setText(AltosDroid.number("%3.0f°", from_receiver.elevation));
mRangeView.setText(AltosDroid.number("%6.0f m", from_receiver.range));
@@ -111,11 +111,11 @@ public class TabDescent extends Fragment implements AltosDroidTab {
mLongitudeView.setText(AltosDroid.pos(state.gps.lon, "W", "E"));
}
- mApogeeVoltageView.setText(AltosDroid.number("%4.2f V", state.drogue_sense));
- mApogeeLights.set(state.drogue_sense > 3.2, state.drogue_sense == AltosRecord.MISSING);
+ mApogeeVoltageView.setText(AltosDroid.number("%4.2f V", state.apogee_voltage));
+ mApogeeLights.set(state.apogee_voltage > 3.2, state.apogee_voltage == AltosLib.MISSING);
- mMainVoltageView.setText(AltosDroid.number("%4.2f V", state.main_sense));
- mMainLights.set(state.main_sense > 3.2, state.main_sense == AltosRecord.MISSING);
+ mMainVoltageView.setText(AltosDroid.number("%4.2f V", state.main_voltage));
+ mMainLights.set(state.main_voltage > 3.2, state.main_voltage == AltosLib.MISSING);
}
}
diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TabLanded.java b/altosdroid/src/org/altusmetrum/AltosDroid/TabLanded.java
index f42b46b5..40399f2a 100644
--- a/altosdroid/src/org/altusmetrum/AltosDroid/TabLanded.java
+++ b/altosdroid/src/org/altusmetrum/AltosDroid/TabLanded.java
@@ -17,7 +17,7 @@
package org.altusmetrum.AltosDroid;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
import android.app.Activity;
import android.os.Bundle;
@@ -89,8 +89,8 @@ public class TabLanded extends Fragment implements AltosDroidTab {
}
if (state != null) {
- mMaxHeightView.setText(String.format("%6.0f m", state.max_height));
- mMaxAccelView.setText(String.format("%6.0f m/s²", state.max_acceleration));
+ mMaxHeightView.setText(String.format("%6.0f m", state.max_height()));
+ mMaxAccelView.setText(String.format("%6.0f m/s²", state.max_acceleration()));
mMaxSpeedView.setText(String.format("%6.0f m/s", state.max_speed()));
}
}
diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TabMap.java b/altosdroid/src/org/altusmetrum/AltosDroid/TabMap.java
index d831f117..a4e224aa 100644
--- a/altosdroid/src/org/altusmetrum/AltosDroid/TabMap.java
+++ b/altosdroid/src/org/altusmetrum/AltosDroid/TabMap.java
@@ -19,7 +19,7 @@ package org.altusmetrum.AltosDroid;
import java.util.Arrays;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TabPad.java b/altosdroid/src/org/altusmetrum/AltosDroid/TabPad.java
index 066c1353..b9e878f1 100644
--- a/altosdroid/src/org/altusmetrum/AltosDroid/TabPad.java
+++ b/altosdroid/src/org/altusmetrum/AltosDroid/TabPad.java
@@ -17,7 +17,7 @@
package org.altusmetrum.AltosDroid;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
import android.app.Activity;
import android.os.Bundle;
@@ -103,26 +103,26 @@ public class TabPad extends Fragment implements AltosDroidTab {
public void update_ui(AltosState state, AltosGreatCircle from_receiver, Location receiver) {
if (state != null) {
- mBatteryVoltageView.setText(AltosDroid.number("%4.2f V", state.battery));
- mBatteryLights.set(state.battery > 3.7, state.battery == AltosRecord.MISSING);
+ mBatteryVoltageView.setText(AltosDroid.number("%4.2f V", state.battery_voltage));
+ mBatteryLights.set(state.battery_voltage >= AltosLib.ao_battery_good, state.battery_voltage == AltosLib.MISSING);
- mApogeeVoltageView.setText(AltosDroid.number("%4.2f V", state.drogue_sense));
- mApogeeLights.set(state.drogue_sense > 3.2, state.drogue_sense == AltosRecord.MISSING);
+ mApogeeVoltageView.setText(AltosDroid.number("%4.2f V", state.apogee_voltage));
+ mApogeeLights.set(state.apogee_voltage >= AltosLib.ao_igniter_good, state.apogee_voltage == AltosLib.MISSING);
- mMainVoltageView.setText(AltosDroid.number("%4.2f V", state.main_sense));
- mMainLights.set(state.main_sense > 3.2, state.main_sense == AltosRecord.MISSING);
+ mMainVoltageView.setText(AltosDroid.number("%4.2f V", state.main_voltage));
+ mMainLights.set(state.main_voltage >= AltosLib.ao_igniter_good, state.main_voltage == AltosLib.MISSING);
- if (state.data.flight != 0) {
- if (state.data.state <= AltosLib.ao_flight_pad)
+ if (state.flight != 0) {
+ if (state.state <= AltosLib.ao_flight_pad)
mDataLoggingView.setText("Ready to record");
- else if (state.data.state < AltosLib.ao_flight_landed)
+ else if (state.state < AltosLib.ao_flight_landed)
mDataLoggingView.setText("Recording data");
else
mDataLoggingView.setText("Recorded data");
} else {
mDataLoggingView.setText("Storage full");
}
- mDataLoggingLights.set(state.data.flight != 0, state.data.flight == AltosRecord.MISSING);
+ mDataLoggingLights.set(state.flight != 0, state.flight == AltosLib.MISSING);
if (state.gps != null) {
mGPSLockedView.setText(AltosDroid.integer("%4d sats", state.gps.nsat));
diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryLogger.java b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryLogger.java
index 3ece04ac..4d793413 100644
--- a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryLogger.java
+++ b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryLogger.java
@@ -1,6 +1,6 @@
package org.altusmetrum.AltosDroid;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
import android.content.BroadcastReceiver;
import android.content.Context;
diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryReader.java b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryReader.java
index 716ec589..45604284 100644
--- a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryReader.java
+++ b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryReader.java
@@ -1,94 +1,95 @@
-/*
- * Copyright © 2011 Keith Packard <keithp@keithp.com>
- * Copyright © 2012 Mike Beattie <mike@ethernal.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- */
-
-
-package org.altusmetrum.AltosDroid;
-
-import java.text.*;
-import java.io.*;
-import java.util.concurrent.*;
-import android.util.Log;
-import android.os.Handler;
-
-import org.altusmetrum.altoslib_1.*;
-
-
-public class TelemetryReader extends Thread {
-
- private static final String TAG = "TelemetryReader";
-
- int crc_errors;
-
- Handler handler;
-
- AltosLink link;
- AltosRecord previous;
-
- LinkedBlockingQueue<AltosLine> telem;
-
- public AltosRecord read() throws ParseException, AltosCRCException, InterruptedException, IOException {
- AltosLine l = telem.take();
- if (l.line == null)
- throw new IOException("IO error");
- AltosRecord next = AltosTelemetry.parse(l.line, previous);
- previous = next;
- return next;
- }
-
- public void close() {
- previous = null;
- link.remove_monitor(telem);
- link = null;
- telem.clear();
- telem = null;
- }
-
- public void run() {
- AltosState state = null;
-
- try {
- for (;;) {
- try {
- AltosRecord record = read();
- if (record == null)
- break;
- state = new AltosState(record, state);
- handler.obtainMessage(TelemetryService.MSG_TELEMETRY, state).sendToTarget();
- } catch (ParseException pp) {
- Log.e(TAG, String.format("Parse error: %d \"%s\"", pp.getErrorOffset(), pp.getMessage()));
- } catch (AltosCRCException ce) {
- ++crc_errors;
- handler.obtainMessage(TelemetryService.MSG_CRC_ERROR, new Integer(crc_errors)).sendToTarget();
- }
- }
- } catch (InterruptedException ee) {
- } catch (IOException ie) {
- } finally {
- close();
- }
- }
-
- public TelemetryReader (AltosLink in_link, Handler in_handler) {
- link = in_link;
- handler = in_handler;
-
- previous = null;
- telem = new LinkedBlockingQueue<AltosLine>();
- link.add_monitor(telem);
- }
-}
+/*
+ * Copyright © 2011 Keith Packard <keithp@keithp.com>
+ * Copyright © 2012 Mike Beattie <mike@ethernal.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+
+package org.altusmetrum.AltosDroid;
+
+import java.text.*;
+import java.io.*;
+import java.util.concurrent.*;
+import android.util.Log;
+import android.os.Handler;
+
+import org.altusmetrum.altoslib_2.*;
+
+
+public class TelemetryReader extends Thread {
+
+ private static final String TAG = "TelemetryReader";
+
+ int crc_errors;
+
+ Handler handler;
+
+ AltosLink link;
+ AltosState state = null;
+
+ LinkedBlockingQueue<AltosLine> telemQueue;
+
+ public AltosState read() throws ParseException, AltosCRCException, InterruptedException, IOException {
+ AltosLine l = telemQueue.take();
+ if (l.line == null)
+ throw new IOException("IO error");
+ AltosTelemetry telem = AltosTelemetryLegacy.parse(l.line);
+ if (state == null)
+ state = new AltosState();
+ else
+ state = state.clone();
+ telem.update_state(state);
+ return state;
+ }
+
+ public void close() {
+ state = null;
+ link.remove_monitor(telemQueue);
+ link = null;
+ telemQueue.clear();
+ telemQueue = null;
+ }
+
+ public void run() {
+ AltosState state = null;
+
+ try {
+ for (;;) {
+ try {
+ state = read();
+ handler.obtainMessage(TelemetryService.MSG_TELEMETRY, state).sendToTarget();
+ } catch (ParseException pp) {
+ Log.e(TAG, String.format("Parse error: %d \"%s\"", pp.getErrorOffset(), pp.getMessage()));
+ } catch (AltosCRCException ce) {
+ ++crc_errors;
+ handler.obtainMessage(TelemetryService.MSG_CRC_ERROR, new Integer(crc_errors)).sendToTarget();
+ }
+ }
+ } catch (InterruptedException ee) {
+ } catch (IOException ie) {
+ } finally {
+ close();
+ }
+ }
+
+ public TelemetryReader (AltosLink in_link, Handler in_handler) {
+ link = in_link;
+ handler = in_handler;
+
+ state = null;
+ telemQueue = new LinkedBlockingQueue<AltosLine>();
+ link.add_monitor(telemQueue);
+ }
+}
diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java
index 0236b537..76efa749 100644
--- a/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java
+++ b/altosdroid/src/org/altusmetrum/AltosDroid/TelemetryService.java
@@ -36,13 +36,15 @@ import android.os.Handler;
import android.os.Message;
import android.os.Messenger;
import android.os.RemoteException;
+import android.os.Looper;
import android.util.Log;
import android.widget.Toast;
import android.location.Location;
import android.location.LocationManager;
import android.location.LocationListener;
+import android.location.Criteria;
-import org.altusmetrum.altoslib_1.*;
+import org.altusmetrum.altoslib_2.*;
public class TelemetryService extends Service implements LocationListener {
@@ -280,8 +282,8 @@ public class TelemetryService extends Service implements LocationListener {
// Listen for GPS and Network position updates
LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);
- locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this);
- locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this);
+ locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 1, this);
+// locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this);
}
@Override