//Load config from Json file in SPIFFS boolean loadJsonParam(const char *service) { File configFile = SPIFFS.open("/config/config.json", "r"); if (!configFile) { Serial.println("ERROR: Failed to open config file (loadJsonParam)"); return (boolean) false; } size_t size = configFile.size(); if (size > 1024) { Serial.println("ERROR: Config file size is too large (loadJsonParam)"); return (boolean) false; } std::unique_ptr<char[]> buf(new char[size]); configFile.readBytes(buf.get(), size); DynamicJsonBuffer jsonBuffer; JsonObject &json = jsonBuffer.parseObject(buf.get()); if (!json.success()) { Serial.println("ERROR: Failed to parse config file (loadJsonParam)"); return (boolean) false; } boolean config = json[service]["enabled"]; if (config) { return (boolean) true; } return (boolean) false; }
/******************************************************************** parse the websocket json and look for a message type ********************************************************************/ void ArduinoSlackBot::parseResponse(char *payload) { DynamicJsonBuffer jsonBuffer; JsonObject& root = jsonBuffer.parseObject(payload); if (root.success()) { if (root.containsKey("type")) { slackMsg.type = root["type"]; PRINTLN(slackMsg.type); PRINT("free heap size:"); PRINTLN(ESP.getFreeHeap()); if (strcasecmp(slackMsg.type, "message") == 0) { slackMsg.channel = root["channel"]; slackMsg.user = root["user"]; slackMsg.text = root["text"]; slackMsg.timestamp = root["ts"]; slackMsg.team = root["team"]; PRINTLN("parseCommands"); parseCmds(); } } } else { PRINTLN("parse fail"); } }
boolean saveJsonConfig(const char *service, const char *param, boolean status) { File configFile = SPIFFS.open("/config/config.json", "r"); if (!configFile) { Serial.println("ERROR: Failed to open config file (saveJsonConfig)"); return (boolean) false; } size_t size = configFile.size(); if (size > 1024) { Serial.println("ERROR: Config file size is too large (saveJsonConfig)"); return (boolean) false; } std::unique_ptr<char[]> buf(new char[size]); configFile.readBytes(buf.get(), size); DynamicJsonBuffer jsonBuffer; JsonObject &json = jsonBuffer.parseObject(buf.get()); if (!json.success()) { Serial.println("ERROR: Failed to parse config file (saveJsonConfig)"); return (boolean) false; } configFile.close(); JsonObject &nested = json[service]; nested.set(param, status); configFile = SPIFFS.open("/config/config.json", "w+"); json.prettyPrintTo(configFile); return (boolean) true; }
void ThingSpeakClass::begin() //loads settings from json file.... { String values = ""; File f = SPIFFS.open("/cloudgen.json", "r"); if (!f) { DebugPrintln("thingspeak config not found"); } else { //file exists; values = f.readStringUntil('\n'); //read json f.close(); DynamicJsonBuffer jsonBuffer; JsonObject& root = jsonBuffer.parseObject(values); //parse weburl if (!root.success()) { DebugPrintln("parseObject() thingspeak failed"); return; } if (root["spkurl"].asString() != "") { //verify good json info thingSpeakURL = root["spkurl"].asString(); thingWriteKey = root["spkwkey"].asString(); thingInterval = String(root["spkint"].asString()).toInt(); TalkBackID = root["tkbid"].asString(); TalkBackKey = root["tkbkey"].asString(); talkBackInterval = String(root["tkbint"].asString()).toInt(); if (String(root["status"].asString()).toInt() == 1) ThingEnabled = true; else ThingEnabled = false; if (String(root["tbstatus"].asString()).toInt() == 1) TalkBackEnabled = true; else TalkBackEnabled = false; DebugPrintln("ThingSpeak Starting...."); } } //file exists; }
MeteoConfig loadConfig() { DynamicJsonBuffer jsonBuffer; MeteoConfig cfg; if (fileExist(METEO_CONFIG_FILE)) { int size = fileGetSize(METEO_CONFIG_FILE); char* jsonString = new char[size + 1]; fileGetContent(METEO_CONFIG_FILE, jsonString, size + 1); JsonObject& root = jsonBuffer.parseObject(jsonString); JsonObject& network = root["network"]; cfg.NetworkSSID = String((const char*)network["ssid"]); cfg.NetworkPassword = String((const char*)network["password"]); JsonObject& correction = root["correction"]; cfg.AddT1 = correction["T1"]; cfg.AddT2 = correction["T2"]; cfg.AddTZ = correction["TZ"]; JsonObject& trigger = root["trigger"]; cfg.Trigger = (TriggerType)(int)trigger["type"]; cfg.RangeMin = trigger["min"]; cfg.RangeMax = trigger["max"]; delete[] jsonString; } else { cfg.NetworkSSID = WIFI_SSID; cfg.NetworkPassword = WIFI_PWD; } return cfg; }
void GlobalsClass::SendProbesToHM(String fname) { //sends Probes info to HM String values = ""; String hmsg; File f = SPIFFS.open(fname, "r"); if (f) { // we could open the file values = f.readStringUntil('\n'); //read json f.close(); //WRITE CONFIG TO HeaterMeter DynamicJsonBuffer jsonBuffer; JsonObject& root = jsonBuffer.parseObject(values); //parse json data if (!root.success()) { DebugPrintln("parseObject() failed"); return; } //const char* sensor = root["sensor"]; //long time = root["time"]; //double latitude = root["data"][0]; //double longitude = root["data"][1]; } qCon.println(String("/set?pn0=") + root["p0name"].asString()); delay(comdelay); qCon.println(String("/set?pn1=") + root["p1name"].asString()); delay(comdelay); qCon.println(String("/set?pn2=") + root["p2name"].asString()); delay(comdelay); qCon.println(String("/set?pn3=") + root["p3name"].asString()); delay(comdelay); //Set offsets hmsg = String("/set?po=") + root["p0off"].asString() + "," + root["p1off"].asString() + "," + root["p2off"].asString() + "," + root["p3off"].asString(); qCon.println(hmsg); delay(comdelay); DebugPrintln(hmsg); //Set Probe coeff. hmsg = String("/set?pc0=") + root["p0a"].asString() + "," + root["p0b"].asString() + "," + root["p0c"].asString() + "," + root["p0r"].asString() + "," + root["p0trm"].asString(); qCon.println(hmsg); delay(comdelay); DebugPrintln(hmsg); hmsg = String("/set?pc1=") + root["p1a"].asString() + "," + root["p1b"].asString() + "," + root["p1c"].asString() + "," + root["p1r"].asString() + "," + root["p1trm"].asString(); qCon.println(hmsg); delay(comdelay); DebugPrintln(hmsg); hmsg = String("/set?pc2=") + root["p2a"].asString() + "," + root["p2b"].asString() + "," + root["p2c"].asString() + "," + root["p2r"].asString() + "," + root["p2trm"].asString(); qCon.println(hmsg); delay(comdelay); DebugPrintln(hmsg); hmsg = String("/set?pc3=") + root["p3a"].asString() + "," + root["p3b"].asString() + "," + root["p3c"].asString() + "," + root["p3r"].asString() + "," + root["p3trm"].asString(); qCon.println(hmsg); delay(comdelay); DebugPrintln(hmsg); //Set Alarm offsets hmsg = String("/set?al=") + root["p0all"].asString() + "," + root["p0alh"].asString() + "," + root["p1all"].asString() + "," + root["p1alh"].asString() + "," + root["p2all"].asString() + "," + root["p2alh"].asString() + "," + root["p3all"].asString() + "," + root["p3alh"].asString(); qCon.println(hmsg); delay(comdelay); DebugPrintln(hmsg); qCon.println("/set?tt=Web Settings,Updated!!"); delay(comdelay); qCon.println("/save?"); delay(comdelay); } //open file success }
void Esp8266Configuration::writeConfiguration(const char* configuration){ DynamicJsonBuffer jsonBuffer; JsonObject& json = jsonBuffer.parseObject(configuration); json.printTo(Serial); File configFile = SPIFFS.open("/configuration.json", "w"); if (!configFile) { Serial.println("failed to open config file for writing"); } // json.printTo(configFile); configFile.close(); }
void commandReceived(char* topic, byte* payload, unsigned int length) { StructureCommand command; DynamicJsonBuffer jsonBuffer; JsonObject& root = jsonBuffer.parseObject((char*)payload); if(root.success()) { command.name = root["name"]; command.time = root["$time"]; command.payload = &(root["payload"].asObject()); StructureDevice::commandCallback(&command); } }
void GlobalsClass::SendHeatGeneralToHM(String fname) { //sends general info to HM String values = ""; String hmsg; File f = SPIFFS.open(fname, "r"); if (f) { // we could open the file values = f.readStringUntil('\n'); //read json f.close(); //WRITE CONFIG TO HeaterMeter //fBuf(sbuf,"/set?sp=%iF",299); //format command; DynamicJsonBuffer jsonBuffer; JsonObject& root = jsonBuffer.parseObject(values); //parse weburl if (!root.success()) { DebugPrintln("parseObject() failed"); return; } //const char* sensor = root["sensor"]; //long time = root["time"]; //double latitude = root["data"][0]; //double longitude = root["data"][1]; } //set PID qCon.println(String("/set?pidb=") + root["pidb"].asString()); delay(comdelay); qCon.println(String("/set?pidp=") + root["pidp"].asString()); delay(comdelay); qCon.println(String("/set?pidi=") + root["pidi"].asString()); delay(comdelay); qCon.println(String("/set?pidd=") + root["pidd"].asString()); delay(comdelay); //Set Fan info /set?fn=FL,FH,SL,SH,Flags,MSS,FAF,SAC hmsg = String("/set?fn=") + root["minfan"].asString() + "," + root["maxfan"].asString() + "," + root["srvlow"].asString() + "," + root["srvhi"].asString() + "," + root["fanflg"].asString() + root["maxstr"].asString() + "," + root["fanflr"].asString() + "," + root["srvcl"].asString(); qCon.println(hmsg); delay(comdelay); DebugPrintln(hmsg); //Set Display props hmsg = String("/set?lb=") + root["blrange"].asString() + "," + root["hsmode"].asString() + "," + root["ledcfg"].asString(); qCon.println(hmsg); delay(comdelay); DebugPrintln(hmsg); //Set Lid props hmsg = String("/set?ld=") + root["lidoff"].asString() + "," + root["liddur"].asString(); qCon.println(hmsg); delay(comdelay); DebugPrintln(hmsg); qCon.println("/set?tt=Web Settings,Updated!!"); delay(comdelay); qCon.println("/save?"); delay(comdelay); } //open file success }
bool EE_LoadData(void) { bool ret = false; char data[EE_SIZE]; uint16_t i; DEBUG_PRINT("EEPROM loading...\n"); for (i = 0; i < EE_SIZE; i++) { yield(); data[i] = EEPROM.read(i); // DEBUG_PRINT("%c", data[i]); } DEBUG_PRINT("\n"); DynamicJsonBuffer jsonBuffer; JsonObject &root = jsonBuffer.parseObject(data); // Test if parsing succeeds. if (root.success() == 1) { const char *ssid = root[FPSTR("ssid")]; DEBUG_PRINT("ssid: %s\n", ssid); const char *password = root[FPSTR("password")]; DEBUG_PRINT("password: %s\n", password); const char *uid = root[FPSTR("uid")]; DEBUG_PRINT("uid: %s\n", uid); const char *domain = root[FPSTR("domain")]; DEBUG_PRINT("domain: %s\n", domain); const char *nodename = root[FPSTR("nodename")]; DEBUG_PRINT("nodename: %s\n", nodename); if ((ssid != NULL) && (password != NULL) && (uid != NULL) && (domain != NULL) && (nodename != NULL)) { ee_ssid = String(ssid); ee_password = String(password); ee_uid = String(uid); ee_domain = String(domain); ee_nodename = String(nodename); DEBUG_PRINT("EEPROM ok\n"); ret = true; } else { DEBUG_PRINT("EEPROM content not ok\n"); } } else { DEBUG_PRINT("parseObject() failed\n"); } return ret; }
//---------------------------------------------------------------------------- // //---------------------------------------------------------------------------- void CApplication::confLoad() { DynamicJsonBuffer jsonBuffer; if (!confExists()) confSave(); if (confExists()) { int size = fileGetSize(CAPP_CONF_FILE); char* strJson = new char[size + 1]; fileGetContent(CAPP_CONF_FILE, strJson, size + 1); JsonObject& root = jsonBuffer.parseObject(strJson); m_cpuBoost = root["cpuBoost"]; m_otaBaseUrl = (const char *)root["otaBaseUrl"]; m_gpiodEmul = root["emul"]; m_gpiodMode = root["mode"]; m_gpiodLock = root["lock"]; m_gpiodDisable = root["disable"]; m_gpiodInDebounce[0] = root["in0Debounce"]; m_gpiodInDebounce[1] = root["in1Debounce"]; m_gpiodInDebounce[2] = root["in2Debounce"]; m_gpiodInDebounce[3] = root["in3Debounce"]; m_gpiodOutDefRun[0] = root["out0DefRun"]; m_gpiodOutDefRun[1] = root["out1DefRun"]; m_gpiodOutDefRun[2] = root["out2DefRun"]; m_gpiodOutDefRun[3] = root["out3DefRun"]; m_gpiodUdmDefRun[0] = root["udm0DefRun"]; m_gpiodUdmDefRun[1] = root["udm1DefRun"]; delete[] strJson; } } // confLoad
void onAjaxConnect(HttpRequest &request, HttpResponse &response) { response.setHeader("Access-Control-Allow-Origin", "*"); response.setHeader("Access-Control-Allow-Methods", "POST"); response.setHeader("Access-Control-Allow-Headers", "Content-Type, X-Requested-With"); // parse the json-string from request body DynamicJsonBuffer jsonBuffer; String bodyString = request.getBody(); int stringLength = request.getContentLength(); char* requestJson = new char[stringLength + 1]; strcpy(requestJson, bodyString.c_str()); JsonObject& body = jsonBuffer.parseObject(requestJson); // get parameter form json String newNetwork = body["network"].asString(); String newPassword = body["password"].asString(); AppSettings.channelKey = body["channelKey"].asString(); AppSettings.save(); // json for response JsonObjectStream* stream = new JsonObjectStream(); JsonObject& responseJson = stream->getRoot(); // try connecting network = newNetwork; password = newPassword; debugf("CONNECT TO: %s %s", network.c_str(), password.c_str()); connectionTimer.initializeMs(1200, makeConnection).startOnce(); // response always connected because we don't know yet if connecting was successful responseJson["status"] = (bool) true; responseJson["connected"] = true; response.sendJsonObject(stream); }
void parseTextMessage(AsyncWebSocketClient * client, uint8_t * data, size_t len) { DynamicJsonBuffer jsonBuffer; // parse possible json files if( data[0] =='{' && data[len - 1] == '}' ) { // let's parse the json file Serial.println("JSON STR RECEIVED!"); char tmp[len + 1]; memcpy(tmp, (char *)data, len); tmp[len] = '\0'; JsonObject& root = jsonBuffer.parseObject(tmp); // ######################## // Wifi configuration file // ######################## if ( root.containsKey("mode") ) { if ( strcmp((const char*)root["mode"], "ap") == 0 ) { Serial.println("AP"); storage.wifisett.setSSID((const char*)root["ssid"]); storage.wifisett.setPwd((const char*)root["pwd"]); storage.wifisett.enableSoftAP(); } else if ( strcmp((const char*)root["mode"], "sta") == 0 ) { Serial.println("STA"); storage.wifisett.setClientSSID((const char*)root["ssid"]); storage.wifisett.setClientPwd((const char*)root["pwd"]); // set mode to STA storage.wifisett.enableClient(); } } // ######################### // Set Clock // ######################### if (root.containsKey("setclock") ) { JsonObject& rootsetclock = root.get("setclock"); if ( rootsetclock.containsKey("type") && ( strcmp((const char*)rootsetclock["type"], "ntp") == 0 ) ) { // get ntp time opaq_controller.syncClock(); } else { // get values from json RtcDateTime tmp = RtcDateTime( rootsetclock["year"], rootsetclock["month"], rootsetclock["day"], rootsetclock["hour"], rootsetclock["minute"], rootsetclock["second"]); opaq_controller.getCom().setClock(tmp); } } // ######################### // Get Clock // ######################### if (root.containsKey("getclock") ) { // let's send the clock values JsonObject& tmp_root = jsonBuffer.createObject(); JsonObject& conf = tmp_root.createNestedObject("realtimeclock"); RtcDateTime date; opaq_controller.getCom().getClock(date); // [TODO] this can fail conf["second"] = date.Second(); conf["minute"] = date.Minute(); conf["hour"] = date.Hour(); conf["day"] = date.Day(); conf["month"] = date.Month(); conf["year"] = date.Year(); String tmp = ""; tmp_root.printTo(tmp); client->text(tmp); } // ################ // Filename getter // ################ if (root.containsKey("filename") ) { String content = ""; sendFile(SPIFFS, root["filename"], content); client->text(content); } // ################################ // Light device full dimmer setter // ############################### if (root.containsKey("adimid") ) { // let's write the file configuration storage.faqdim.save(root["adimid"], data, len); client->text("{\"success\":\"\"}"); } // ################################ // Light device full dimmer getter // ################################ if (root.containsKey("adim") ) { String content = "", dirname = ""; // list devices and send it // {"adim":["filea.json","fileb.json"]} content += F("{\"adim\":[\"\""); storage.faqdim.getDir(dirname); // for each file in /sett/adim directory do Dir directory = SPIFFS.openDir(dirname.c_str()); while ( directory.next() ) { content += F(", \""); content += directory.fileName(); content += F("\" "); } content += F(" ]}"); client->text(content); } // ################################## // Light device full dimmer remover // ################################# if (root.containsKey("adimremove") ) { storage.faqdim.remove(root["adimremove"]); client->text("{\"success\":\"\"}"); } // ################################ // Light device full dimmer setter // ################################ if (root.containsKey("adimadd") ) { storage.faqdim.add(); client->text("{\"success\":\"\"}"); } // #################################### // Light device full dimmer bind state // #################################### if (root.containsKey("adimbind") ) { //root["adimbind"] } // ################################ // Power device getter // ################################ if (root.containsKey("pdev") ) { String content = "", dirname = ""; // list devices and send it // {"pdev":["filea.json","fileb.json"]} content += F("{\"pdev\":[\"\""); storage.pwdevice.getDir(dirname); // for each file in /sett/pdev directory do Dir directory = SPIFFS.openDir(dirname.c_str()); while ( directory.next() ) { content += F(", \""); content += directory.fileName(); content += F("\" "); } content += F(" ]}"); client->text(content); } // ################################ // Power device setter // ################################ if (root.containsKey("pdevid") ) { // let's write the file configuration storage.pwdevice.save(root["pdevid"], data, len); client->text("{\"success\":\"\"}"); } // ################################ // Power device add setter // ################################ if (root.containsKey("pdevadd") ) { storage.pwdevice.add(); client->text("{\"success\":\"\"}"); } // ################################## // Power device remover // ################################# if (root.containsKey("pdevremove") ) { storage.pwdevice.remove(root["pdevremove"]); client->text("{\"success\":\"\"}"); } // ################################ // Update filesystem // ############################### if (root.containsKey("updatefilesystem") ) { // let's write the file configuration storage.setUpdate(true); client->text("{\"success\":\"\"}"); } } else if( strcmp((char*)data, "GET_OPAQ_WIFISETTINGS") == 0 ) { // let's send the wifisettings JsonObject& root = jsonBuffer.createObject(); JsonObject& conf = root.createNestedObject("wifisettings"); String wssid, wpwd, wclientssid, wclientpwd, wmode; storage.wifisett.getSSID(wssid); storage.wifisett.getPwd(wpwd); storage.wifisett.getClientSSID(wclientssid); storage.wifisett.getClientPwd(wclientpwd); storage.wifisett.getMode(wmode); conf["wssid"] = wssid.c_str(); conf["wpwd"] = wpwd.c_str(); conf["wchan"] = 6; // [TODO] conf["wssidsta"] = wclientssid.c_str(); conf["wpwdsta"] = wclientpwd.c_str(); conf["wmode"] = wmode.c_str(); String tmp = ""; root.printTo(tmp); client->text(tmp); } else if( strcmp((char*)data, "GET_OPAQ_SUMMARY") == 0 ) { String wssid; storage.wifisett.getSSID(wssid); JsonObject& root = jsonBuffer.createObject(); root["version"] = OPAQ_VERSION; root["id"] = ESP.getFlashChipId(); root["status"] = "Running without errors"; // [TODO] root["wstatus"] = "Radio is On"; // [TODO] root["wmode"] = (storage.wifisett.getModeOperation())? "softAP" : "client"; root["wssid"] = wssid.c_str(); root["wchan"] = WiFi.channel(); root["wdhcp"] = "Enabled"; // [TODO] root["wmac"] = WiFi.softAPmacAddress(); root["wip"] = (storage.wifisett.getModeOperation())? WiFi.softAPIP().toString() : WiFi.localIP().toString(); String tmp = ""; root.printTo(tmp); client->text(tmp); } else { client->text("{\"msg\":\"I got your text message\"}"); } }
void CommandExecutor::processCommand(Command cmdCommand) { debugf("Received Command, size = %d,cmd = %s",cmdCommand.cmdString.length(),cmdCommand.cmdString.c_str()); if (cmdCommand.cmdName == "") { // Need to extract command from inputline // Check if we have a json input DynamicJsonBuffer jsonBuffer; JsonObject& cmdRoot = jsonBuffer.parseObject(cmdCommand.cmdString); if (cmdRoot.success()) { debugf("ParseObject() -> cmdString is Json object"); if (cmdRoot.containsKey("cmd")) { cmdCommand.cmdName = cmdRoot["cmd"].asString(); } else { if (cmdRoot.begin() != cmdRoot.end()) // There is at least one key { cmdCommand.cmdName = cmdRoot.begin()->key; } } } else // First word of cmdString is cmdCommand { int cmdLen = cmdCommand.cmdString.indexOf(' '); if (cmdLen == -1) { cmdCommand.cmdName = cmdCommand.cmdString; } else { cmdCommand.cmdName = cmdCommand.cmdString.substring(0,cmdLen); } } } debugf("CommandExecutor : executing command %s",cmdCommand.cmdName.c_str()); CommandDelegate cmdDelegate = commandHandler.getCommandDelegate(cmdCommand.cmdName); if ((!cmdDelegate.commandProcessDelegate) && (!cmdDelegate.commandFunction)) { commandOutput->printf("Command not found, cmd = '"); commandOutput->printf(cmdCommand.cmdString.c_str()); commandOutput->printf("'\r\n"); } else { if (cmdDelegate.commandProcessDelegate) { cmdDelegate.commandProcessDelegate(cmdCommand,commandOutput); } else { cmdDelegate.commandFunction(cmdCommand.cmdString,commandOutput); } } commandOutput->flush(); if (commandHandler.getVerboseMode() == VERBOSE) { commandOutput->printf(commandHandler.getCommandPrompt().c_str()); commandOutput->flush(); } }
bool tryParseObject(const char *json) { DynamicJsonBuffer buffer; char s[256]; strcpy(s, json); return buffer.parseObject(s, _nestingLimit).success(); }
void Esp8266Configuration::read(){ if (SPIFFS.begin()) { Serial.println("mounted file system"); if (SPIFFS.exists("/configuration.json")) { // //file exists, reading and loading Serial.println("reading config file"); File configFile = SPIFFS.open("/configuration.json", "r"); if (configFile) { Serial.println("opened config file"); size_t size = configFile.size(); // Allocate a buffer to store contents of the file. std::unique_ptr<char[]> buf(new char[size]); configFile.readBytes(buf.get(), size); DynamicJsonBuffer jsonBuffer; JsonObject& json = jsonBuffer.parseObject(buf.get()); json.printTo(Serial); if (json.success()) { Serial.println("\nparsed json"); Serial.println("trying wifi_ap_ssid"); if (json.containsKey("wifi_ap_ssid")) { const char* value = json["wifi_ap_ssid"]; Serial.println(value); if (value != NULL) { Serial.println(value); strcpy(wifi_ap_ssid, value); } } Serial.println("trying wifi_ap_password"); if (json.containsKey("wifi_ap_password")) { const char* value = json["wifi_ap_password"]; if (value != NULL) { Serial.println(value); strcpy(wifi_ap_password, value); } } Serial.println("trying wifi_station_ssid"); if (json.containsKey("wifi_station_ssid")) { const char* value = json["wifi_station_ssid"]; if (value != NULL) { Serial.println(value); strcpy(wifi_station_ssid, value); } } Serial.println("trying wifi_station_password"); if (json.containsKey("wifi_station_password")) { const char* value = json["wifi_station_password"]; if (value != NULL) { Serial.println(value); strcpy(wifi_station_password, value); } } Serial.println("trying mqtt_host"); if (json.containsKey("mqtt_host")) { const char* value = json["mqtt_host"]; if (value != NULL) { Serial.println(value); strcpy(mqtt_host, value); } } Serial.println("trying mqtt_port"); if (json.containsKey("mqtt_port")) { const char* value = json["mqtt_port"]; if (value != NULL) { Serial.println(value); mqtt_port = atoi(value); } } Serial.println("trying mqtt_user"); if (json.containsKey("mqtt_user")) { const char* value = json["mqtt_user"]; if (value != NULL) { Serial.println(value); strcpy(mqtt_user, value); } } Serial.println("trying mqtt_password"); if (json.containsKey("mqtt_password")) { const char* value = json["mqtt_password"]; if (value != NULL) { Serial.println(value); strcpy(mqtt_password, value); } } } else { Serial.println("failed to load json config"); } } } } else { Serial.println("failed to mount FS"); } //end read }