#ifndef CONFIG_H
#define CONFIG_H

#include <Arduino.h>
#include <FS.h>
#include <ArduinoJson.h>

class MqttConfig {
    public:
        String  server;
        int     port;
        String  username;
        String  password;
        String  id;
        String  topic;
        void setId(const String& id);
        void setMqtt(const String& server, const int& port, const String& username, const String& password, const String& topic);
};

class LoraConfig {
public:
    long  frequency;
    int   spreadingFactor;
    long  signalBandwidth;
    int   codingRate4;
    int   power;
};

class Config {
    public:
        bool isConfigLoaded = false;
        MqttConfig mqttConfig;
        LoraConfig loraConfig;
        Config();
        void writeData();
        void setMqttConfig(const String& server, const int& port, const String& username, const String& password, const String& topic) {
            mqttConfig.setMqtt(server, port, username, password, topic);
        }
        void setMqttId(const String& id){
            mqttConfig.setId(id);
        }
        
        void logConfigInfo(JsonDocument& configJson);
    private:
        void readFile(fs::FS &fs, const char *fileName);
        String _filePath;
};

#endif /* CONFIG_H */