Webdav test - SPIFFS setup
This commit is contained in:
@@ -18,6 +18,7 @@ public:
|
||||
bool addPoint(Measurement_T measurement) {
|
||||
const bool successful = currentChunk->addPoint(measurement);
|
||||
if (!successful) {
|
||||
Serial.println("Starting session rotate");
|
||||
rotate();
|
||||
const bool secondInsertSuccess = currentChunk->addPoint(measurement);
|
||||
assert(secondInsertSuccess, "Session: insertion after rotation failed");
|
||||
@@ -77,6 +78,8 @@ private:
|
||||
void saveChunkToFile(Chunk_T *chunk) const {
|
||||
const uint32_t chunkNr = chunk->getStartIndex() / CHUNK_SIZE;
|
||||
const auto fileName = chunkFileName(chunkNr, chunk->getStartTime());
|
||||
Serial.print("Writing session to file ");
|
||||
Serial.println(fileName);
|
||||
Writer writer( fileName );
|
||||
chunk->serialize(writer.encoder());
|
||||
};
|
||||
|
||||
@@ -7,13 +7,26 @@ class SpiffsStorageWriter {
|
||||
public:
|
||||
SpiffsStorageWriter(const String &fileName) :
|
||||
f_(SPIFFS.open(fileName, "w")),
|
||||
encoder_(&f_) {}
|
||||
|
||||
encoder_(&f_),
|
||||
fileName_(fileName)
|
||||
{
|
||||
Serial.println("Opened file for writing successful?");
|
||||
bool success = f_;
|
||||
Serial.println(success);
|
||||
}
|
||||
~SpiffsStorageWriter() {
|
||||
f_.close();
|
||||
Serial.print("Closing file: ");
|
||||
Serial.println(fileName_);
|
||||
Serial.print("File exists: ");
|
||||
Serial.println(SPIFFS.exists(fileName_));
|
||||
}
|
||||
StreamingMsgPackEncoder<File> &encoder() { return encoder_; }
|
||||
|
||||
private:
|
||||
File f_;
|
||||
StreamingMsgPackEncoder<File> encoder_;
|
||||
String fileName_;
|
||||
};
|
||||
|
||||
|
||||
@@ -23,6 +36,9 @@ public:
|
||||
SpiffsStorageReader(const String &fileName) :
|
||||
f_(SPIFFS.open(fileName, "w"))
|
||||
{}
|
||||
~SpiffsStorageReader() {
|
||||
f_.close();
|
||||
}
|
||||
|
||||
uint32_t readBytes(char *buffer, size_t length) {
|
||||
return f_.readBytes(buffer, length);
|
||||
|
||||
Reference in New Issue
Block a user