mirror of
https://gitlab.com/wirelos/sprocket-lib.git
synced 2025-12-16 13:25:03 +01:00
read config from json on SPIFFS
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user