swimtracker-firmware/SessionChunkIO.h

29 lines
598 B
C++

#include <FS.h>
#include <ESP8266WebServer.h>
class ESP8266HttpMsgPackWriter {
public:
HttpWriterAdaptor(ESP8266WebServer
* o)
:
obj_(o) {}
void write(const char *data, uint32_t size) {
obj_->sendContent_P(data, size);
}
private:
ESP8266WebServer *obj_;
};
template<typename SessionChunk_T>
void saveSessionChunkToFile(const SessionChunk_T &chunk, const String &fileName) {
String startTimeStr(chunk.getStartTime());
File f = SPIFFS.open(fileName, "w");
StreamingMsgPackEncoder<File> encoder(&f);
chunk.serialize(encoder);
f.close();
}