예제 #1
0
//----------------------------------------------------------------------------
//
//----------------------------------------------------------------------------
void CApplication::confSave()
{
  DynamicJsonBuffer jsonBuffer;
  JsonObject& root = jsonBuffer.createObject();

  root["cpuBoost"]    = m_cpuBoost;
  root["otaBaseUrl"]  = m_otaBaseUrl.c_str();

  root["emul"]        = m_gpiodEmul;
  root["mode"]        = m_gpiodMode;
  root["lock"]        = m_gpiodLock;
  root["disable"]     = m_gpiodDisable;

  root["in0Debounce"] = m_gpiodInDebounce[0];
  root["in1Debounce"] = m_gpiodInDebounce[1];
  root["in2Debounce"] = m_gpiodInDebounce[2];
  root["in3Debounce"] = m_gpiodInDebounce[3];

  root["out0DefRun"]  = m_gpiodOutDefRun[0];
  root["out1DefRun"]  = m_gpiodOutDefRun[1];
  root["out2DefRun"]  = m_gpiodOutDefRun[2];
  root["out3DefRun"]  = m_gpiodOutDefRun[3];

  root["udm0DefRun"]  = m_gpiodUdmDefRun[0];
  root["udm1DefRun"]  = m_gpiodUdmDefRun[1];

  // write to file
  String strRoot;
  root.printTo(strRoot);
  fileSetContent(CAPP_CONF_FILE, strRoot);
  } // confSave
예제 #2
0
void saveConfig(MeteoConfig& cfg)
{
	ActiveConfig = cfg;

	DynamicJsonBuffer jsonBuffer;
	JsonObject& root = jsonBuffer.createObject();

	JsonObject& network = jsonBuffer.createObject();
	root["network"] = network;
	network["ssid"] = cfg.NetworkSSID.c_str();
	network["password"] = cfg.NetworkPassword.c_str();

	JsonObject& correction = jsonBuffer.createObject();
	root["correction"] = correction;
	correction["T1"] = cfg.AddT1;
	correction["T2"] = cfg.AddT2;
	correction["TZ"] = cfg.AddTZ;

	JsonObject& trigger = jsonBuffer.createObject();
	root["trigger"] = trigger;
	trigger["type"] = (int)cfg.Trigger;
	trigger["min"] = cfg.RangeMin;
	trigger["max"] = cfg.RangeMax;

	char buf[3048];
	root.prettyPrintTo(buf, sizeof(buf));
	fileSetContent(METEO_CONFIG_FILE, buf);
}
예제 #3
0
void startFTP()
{
	if (!fileExist("index.html"))
		fileSetContent("index.html", "<h3>Please connect to FTP and upload files from folder 'web/build' (details in code)</h3>");

	// Start FTP server
	ftp.listen(21);
	ftp.addUser("me", "123"); // FTP account
}
예제 #4
0
void fileSetContent(const String fileName, const String& content)
{
	fileSetContent(fileName, content.c_str());
}