diff --git a/filer.h b/filer.h index 53de1e8..7b99e3b 100644 --- a/filer.h +++ b/filer.h @@ -13,27 +13,4 @@ public: virtual void stop() =0; }; -// split into sd_filer and fs_filer -// implement write to new file (like checkpoint) -class flash_filer: public filer { -public: - flash_filer(const char *programs): _programs(programs) {} - - const char *advance(); - const char *rewind(); - - const char *checkpoint(); - void restore(const char *); - - bool start(); - void stop(); - - uint8_t read() { return _buf[_pos++]; } - bool more(); - -private: - const char *_programs; - unsigned _pos, _len; - uint8_t _buf[128]; -}; #endif diff --git a/filer.cpp b/flash_filer.cpp similarity index 99% rename from filer.cpp rename to flash_filer.cpp index 4891ec8..c7275dd 100644 --- a/filer.cpp +++ b/flash_filer.cpp @@ -14,6 +14,7 @@ #include "serialio.h" #include "filer.h" +#include "flash_filer.h" #if defined(DISK) static File file, dir; diff --git a/flash_filer.h b/flash_filer.h new file mode 100644 index 0000000..58ebcfd --- /dev/null +++ b/flash_filer.h @@ -0,0 +1,27 @@ +#ifndef __FLASH_FILER_H__ +#define __FLASH_FILER_H__ + +// split into sd_filer and fs_filer +// implement write to new file (like checkpoint) +class flash_filer: public filer { +public: + flash_filer(const char *programs): _programs(programs) {} + + const char *advance(); + const char *rewind(); + + const char *checkpoint(); + void restore(const char *); + + bool start(); + void stop(); + + uint8_t read() { return _buf[_pos++]; } + bool more(); + +private: + const char *_programs; + unsigned _pos, _len; + uint8_t _buf[128]; +}; +#endif diff --git a/r65emu.h b/r65emu.h index 0398db3..5114cf9 100644 --- a/r65emu.h +++ b/r65emu.h @@ -11,6 +11,7 @@ #include "keyboard.h" #include "serialio.h" #include "filer.h" +#include "flash_filer.h" #include "serial_filer.h" #include "socket_filer.h" #include "timed.h" diff --git a/socket_filer.cpp b/socket_filer.cpp index d23a62b..09f7a5c 100644 --- a/socket_filer.cpp +++ b/socket_filer.cpp @@ -20,6 +20,12 @@ static bool connected() { return client.connected(); } +const char *socket_filer::advance() { + if (connected()) + return "connected"; + return 0; +} + bool socket_filer::start() { #if defined(WIFI_SSID) @@ -53,12 +59,20 @@ bool socket_filer::more() { #if !defined(NO_CHECKPOINT) const char *socket_filer::checkpoint() { - // FIXME - return 0; + if (connected()) { + hardware_checkpoint(client); + client.flush(); + client.stop(); + return "checkpointed"; + } + return "not connected"; } void socket_filer::restore(const char *) { - // FIXME + if (connected()) { + hardware_restore(client); + client.stop(); + } } #endif diff --git a/socket_filer.h b/socket_filer.h index 1a3048c..fb2e944 100644 --- a/socket_filer.h +++ b/socket_filer.h @@ -5,7 +5,7 @@ class socket_filer: public filer { public: socket_filer(const char *hostname): _hostname(hostname) {} - const char *advance() { return 0; } + const char *advance(); const char *rewind() { return advance(); } const char *checkpoint();