From 810f9a4f79b0480973d84595140d3f8948ce26d9 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 29 Aug 2014 15:22:43 -0500 Subject: altosdroid: start restoring from log data on startup Remember which flight was last being received and reload that file Signed-off-by: Keith Packard --- altoslib/AltosStateIterable.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'altoslib/AltosStateIterable.java') diff --git a/altoslib/AltosStateIterable.java b/altoslib/AltosStateIterable.java index f7cd424d..4154b71c 100644 --- a/altoslib/AltosStateIterable.java +++ b/altoslib/AltosStateIterable.java @@ -26,4 +26,18 @@ public abstract class AltosStateIterable implements Iterable { } public abstract void write(PrintStream out); + + public static AltosStateIterable iterable(File file) { + FileInputStream in; + try { + in = new FileInputStream(file); + } catch (Exception e) { + System.out.printf("Failed to open file '%s'\n", file); + return null; + } + if (file.getName().endsWith("telem")) + return new AltosTelemetryFile(in); + else + return new AltosEepromFile(in); + } } -- cgit v1.2.3