feat: add Json config (unfinished)
This commit is contained in:
37
FW/leo_muziekdoos_esp32/src/config.cpp
Normal file
37
FW/leo_muziekdoos_esp32/src/config.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
#include "config.h"
|
||||
#include <vector>
|
||||
#include "FS.h"
|
||||
#include "LITTLEFS.h"
|
||||
#include "ArduinoJson.h"
|
||||
|
||||
const char *tagConfigfile = "/tagconfig.json";
|
||||
|
||||
struct tagConfig {
|
||||
char filename[64];
|
||||
char tagID[64];
|
||||
};
|
||||
|
||||
std::vector<tagConfig> tags;
|
||||
|
||||
void loadConfig(const char *fname)
|
||||
{
|
||||
File file = LITTLEFS.open(fname);
|
||||
StaticJsonDocument<512> doc;
|
||||
DeserializationError error = deserializeJson(doc, file);
|
||||
if (error)
|
||||
Serial.println(F("Failed to read file, using default configuration"));
|
||||
JsonArray array = doc.as<JsonArray>();
|
||||
for(JsonVariant v : array) {
|
||||
Serial.println(v.as<String>());
|
||||
}
|
||||
}
|
||||
|
||||
void initConfig(void)
|
||||
{
|
||||
loadConfig(tagConfigfile);
|
||||
}
|
||||
|
||||
void handleConfig(void)
|
||||
{
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user