altosdroid: start restoring from log data on startup
[fw/altos] / altoslib / AltosStateIterable.java
index f7cd424d554a82422b8f403775f178ad717e3b84..4154b71ceec90a8d77473e0432977b0c47ae6f32 100644 (file)
@@ -26,4 +26,18 @@ public abstract class AltosStateIterable implements Iterable<AltosState> {
        }
 
        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);
+       }
 }