Skip to content

Instantly share code, notes, and snippets.

@s-bauer
Created February 19, 2018 17:44
Show Gist options
  • Save s-bauer/2cedbf8223cd3f826ca6573599bfed08 to your computer and use it in GitHub Desktop.
Save s-bauer/2cedbf8223cd3f826ca6573599bfed08 to your computer and use it in GitHub Desktop.
#ifndef ConfigManager_H
#define ConfigManager_H
#include <Arduino.h>
#include <ArduinoJson.h>
#include <FS.h>
#include "Logger.h"
class WiFiNetwork {
public:
char *ssid; //max 32
char *pass; //max 32
};
class Settings {
public:
const static char current_version[4];
char version[4];
WiFiNetwork *networks;
int led_count;
};
class ConfigManager {
public:
ConfigManager();
void read_from_eeprom();
private:
Settings *settings;
File configFile;
JsonObject *json;
StaticJsonBuffer<200> jsonBuffer;
void open_file(const char *permission);
void read_json();
void recreate_file();
void create_json();
void check_success();
void populate_settings();
void clean_up();
};
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment