read config from json on SPIFFS

This commit is contained in:
2018-08-26 18:58:37 +02:00
parent 5334d58433
commit b676746723
11 changed files with 129 additions and 67 deletions

View File

@@ -1,12 +1,23 @@
#include "MeshNet.h"
MeshNet::MeshNet(MeshConfig cfg) : Network() {
config = cfg;
config.stationMode = cfg.stationMode;
config.channel = cfg.channel;
config.meshPort = cfg.meshPort;
config.meshSSID = cfg.meshSSID;
config.meshPassword = cfg.meshPassword;
config.stationSSID = cfg.stationSSID;
config.stationPassword = cfg.stationPassword;
config.hostname = cfg.hostname;
config.debugTypes = cfg.debugTypes;
}
Network* MeshNet::init(){
Serial.println("init mesh");
config.fromFile("/config.json");
Serial.println(config.meshSSID);
//mesh.setDebugMsgTypes( ERROR | MESH_STATUS | CONNECTION | SYNC | COMMUNICATION | GENERAL | MSG_TYPES | REMOTE ); // all types on
mesh.setDebugMsgTypes( config.debugTypes );
mesh.init( config.meshSSID, config.meshPassword, scheduler, config.meshPort, WIFI_AP_STA, config.channel );
@@ -23,7 +34,7 @@ Network* MeshNet::connectStation(int doConnect) {
if(doConnect){
Serial.println("connect station");
mesh.stationManual(config.stationSSID, config.stationPassword);
mesh.setHostname(config.hostname);
mesh.setHostname(config.hostname.c_str());
}
return this;
}