mirror of https://github.com/arendst/Tasmota.git
6.2.1.14 Webserver rewrite
6.2.1.14 20181010 * Rewrite Webserver page handler for easier extension (thx to Adrian Scillato)
This commit is contained in:
parent
be5f86f911
commit
077b8a79e1
|
@ -1,4 +1,7 @@
|
|||
/* 6.2.1.13 20181008
|
||||
/* 6.2.1.14 20181010
|
||||
* Rewrite Webserver page handler for easier extension (thx to Adrian Scillato)
|
||||
*
|
||||
* 6.2.1.13 20181008
|
||||
* Change default Mqtt client library from PubSubClient to non-blocking ArduinoMqtt by Joel Gaehwiler
|
||||
* Add command WebRefresh 1000..10000 to control web page refresh in milliseconds. Default is 2345
|
||||
*
|
||||
|
|
|
@ -539,7 +539,6 @@ const char S_CONFIGURATION[] PROGMEM = D_CONFIGURATION;
|
|||
const char S_CONFIGURE_MODULE[] PROGMEM = D_CONFIGURE_MODULE;
|
||||
const char S_CONFIGURE_WIFI[] PROGMEM = D_CONFIGURE_WIFI;
|
||||
const char S_NO_NETWORKS_FOUND[] PROGMEM = D_NO_NETWORKS_FOUND;
|
||||
const char S_CONFIGURE_MQTT[] PROGMEM = D_CONFIGURE_MQTT;
|
||||
const char S_CONFIGURE_LOGGING[] PROGMEM = D_CONFIGURE_LOGGING;
|
||||
const char S_CONFIGURE_OTHER[] PROGMEM = D_CONFIGURE_OTHER;
|
||||
const char S_SAVE_CONFIGURATION[] PROGMEM = D_SAVE_CONFIGURATION;
|
||||
|
|
|
@ -214,7 +214,7 @@ enum LichtSchemes {LS_POWER, LS_WAKEUP, LS_CYCLEUP, LS_CYCLEDN, LS_RANDOM, LS_MA
|
|||
|
||||
enum XsnsFunctions {FUNC_PRE_INIT, FUNC_INIT, FUNC_LOOP, FUNC_EVERY_50_MSECOND, FUNC_EVERY_100_MSECOND, FUNC_EVERY_200_MSECOND, FUNC_EVERY_250_MSECOND, FUNC_EVERY_SECOND, FUNC_PREP_BEFORE_TELEPERIOD,
|
||||
FUNC_JSON_APPEND, FUNC_WEB_APPEND, FUNC_SAVE_BEFORE_RESTART, FUNC_COMMAND, FUNC_MQTT_SUBSCRIBE, FUNC_MQTT_INIT, FUNC_MQTT_DATA, FUNC_SET_POWER, FUNC_SHOW_SENSOR,
|
||||
FUNC_RULES_PROCESS, FUNC_SERIAL, FUNC_FREE_MEM};
|
||||
FUNC_RULES_PROCESS, FUNC_SERIAL, FUNC_FREE_MEM, FUNC_WEB_ADD_BUTTON, FUNC_WEB_ADD_HANDLER};
|
||||
|
||||
const uint8_t kDefaultRfCode[9] PROGMEM = { 0x21, 0x16, 0x01, 0x0E, 0x03, 0x48, 0x2E, 0x1A, 0x00 };
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#ifndef _SONOFF_VERSION_H_
|
||||
#define _SONOFF_VERSION_H_
|
||||
|
||||
#define VERSION 0x0602010D
|
||||
#define VERSION 0x0602010E
|
||||
|
||||
#define D_PROGRAMNAME "Sonoff-Tasmota"
|
||||
#define D_AUTHOR "Theo Arends"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
xdrv_02_webserver.ino - webserver for Sonoff-Tasmota
|
||||
xdrv_01_webserver.ino - webserver for Sonoff-Tasmota
|
||||
|
||||
Copyright (C) 2018 Theo Arends
|
||||
|
||||
|
@ -193,25 +193,9 @@ const char HTTP_BTN_MENU1[] PROGMEM =
|
|||
const char HTTP_BTN_RSTRT[] PROGMEM =
|
||||
"<br/><form action='rb' method='get' onsubmit='return confirm(\"" D_CONFIRM_RESTART "\");'><button class='button bred'>" D_RESTART "</button></form>";
|
||||
const char HTTP_BTN_MENU_MODULE[] PROGMEM =
|
||||
"<br/><form action='md' method='get'><button>" D_CONFIGURE_MODULE "</button></form>";
|
||||
#if defined(USE_TIMERS) && defined(USE_TIMERS_WEB)
|
||||
const char HTTP_BTN_MENU_TIMER[] PROGMEM =
|
||||
"<br/><form action='tm' method='get'><button>" D_CONFIGURE_TIMER "</button></form>";
|
||||
#endif // USE_TIMERS and USE_TIMERS_WEB
|
||||
const char HTTP_BTN_MENU_WIFI[] PROGMEM =
|
||||
"<br/><form action='w0' method='get'><button>" D_CONFIGURE_WIFI "</button></form>";
|
||||
const char HTTP_BTN_MENU_MQTT[] PROGMEM =
|
||||
"<br/><form action='mq' method='get'><button>" D_CONFIGURE_MQTT "</button></form>"
|
||||
#ifdef USE_DOMOTICZ
|
||||
"<br/><form action='dm' method='get'><button>" D_CONFIGURE_DOMOTICZ "</button></form>"
|
||||
#endif // USE_DOMOTICZ
|
||||
"";
|
||||
"<br/><form action='md' method='get'><button>" D_CONFIGURE_MODULE "</button></form>"
|
||||
"<br/><form action='wi' method='get'><button>" D_CONFIGURE_WIFI "</button></form>";
|
||||
const char HTTP_BTN_MENU4[] PROGMEM =
|
||||
#ifdef USE_KNX
|
||||
#ifdef USE_KNX_WEB_MENU
|
||||
"<br/><form action='kn' method='get'><button>" D_CONFIGURE_KNX "</button></form>"
|
||||
#endif // USE_KNX_WEB_MENU
|
||||
#endif // USE_KNX
|
||||
"<br/><form action='lg' method='get'><button>" D_CONFIGURE_LOGGING "</button></form>"
|
||||
"<br/><form action='co' method='get'><button>" D_CONFIGURE_OTHER "</button></form>"
|
||||
"<br/>"
|
||||
|
@ -229,34 +213,21 @@ const char HTTP_FORM_LOGIN[] PROGMEM =
|
|||
const char HTTP_BTN_CONF[] PROGMEM =
|
||||
"<br/><br/><form action='cn' method='get'><button>" D_CONFIGURATION "</button></form>";
|
||||
const char HTTP_FORM_MODULE[] PROGMEM =
|
||||
"<fieldset><legend><b> " D_MODULE_PARAMETERS " </b></legend><form method='get' action='sv'>"
|
||||
"<input id='w' name='w' value='6,1' hidden>"
|
||||
"<fieldset><legend><b> " D_MODULE_PARAMETERS " </b></legend><form method='get' action='md'>"
|
||||
"<br/><b>" D_MODULE_TYPE "</b> ({mt)<br/><select id='g99' name='g99'></select><br/>";
|
||||
const char HTTP_LNK_ITEM[] PROGMEM =
|
||||
"<div><a href='#p' onclick='c(this)'>{v}</a> ({w}) <span class='q'>{i} {r}%</span></div>";
|
||||
const char HTTP_LNK_SCAN[] PROGMEM =
|
||||
"<div><a href='/w1'>" D_SCAN_FOR_WIFI_NETWORKS "</a></div><br/>";
|
||||
"<div><a href='/wi?scan='>" D_SCAN_FOR_WIFI_NETWORKS "</a></div><br/>";
|
||||
const char HTTP_FORM_WIFI[] PROGMEM =
|
||||
"<fieldset><legend><b> " D_WIFI_PARAMETERS " </b></legend><form method='get' action='sv'>"
|
||||
"<input id='w' name='w' value='1,1' hidden>"
|
||||
"<fieldset><legend><b> " D_WIFI_PARAMETERS " </b></legend><form method='get' action='wi'>"
|
||||
"<br/><b>" D_AP1_SSID "</b> (" STA_SSID1 ")<br/><input id='s1' name='s1' placeholder='" STA_SSID1 "' value='{s1'><br/>"
|
||||
"<br/><b>" D_AP1_PASSWORD "</b><br/><input id='p1' name='p1' type='password' placeholder='" D_AP1_PASSWORD "' value='" D_ASTERIX "'><br/>"
|
||||
"<br/><b>" D_AP2_SSID "</b> (" STA_SSID2 ")<br/><input id='s2' name='s2' placeholder='" STA_SSID2 "' value='{s2'><br/>"
|
||||
"<br/><b>" D_AP2_PASSWORD "</b><br/><input id='p2' name='p2' type='password' placeholder='" D_AP2_PASSWORD "' value='" D_ASTERIX "'><br/>"
|
||||
"<br/><b>" D_HOSTNAME "</b> (" WIFI_HOSTNAME ")<br/><input id='h' name='h' placeholder='" WIFI_HOSTNAME" ' value='{h1'><br/>";
|
||||
const char HTTP_FORM_MQTT[] PROGMEM =
|
||||
"<fieldset><legend><b> " D_MQTT_PARAMETERS " </b></legend><form method='get' action='sv'>"
|
||||
"<input id='w' name='w' value='2,1' hidden>"
|
||||
"<br/><b>" D_HOST "</b> (" MQTT_HOST ")<br/><input id='mh' name='mh' placeholder='" MQTT_HOST" ' value='{m1'><br/>"
|
||||
"<br/><b>" D_PORT "</b> (" STR(MQTT_PORT) ")<br/><input id='ml' name='ml' placeholder='" STR(MQTT_PORT) "' value='{m2'><br/>"
|
||||
"<br/><b>" D_CLIENT "</b> ({m0)<br/><input id='mc' name='mc' placeholder='" MQTT_CLIENT_ID "' value='{m3'><br/>"
|
||||
"<br/><b>" D_USER "</b> (" MQTT_USER ")<br/><input id='mu' name='mu' placeholder='" MQTT_USER "' value='{m4'><br/>"
|
||||
"<br/><b>" D_PASSWORD "</b><br/><input id='mp' name='mp' type='password' placeholder='" MQTT_PASS "' value='{m5'><br/>"
|
||||
"<br/><b>" D_TOPIC "</b> = %topic% (" MQTT_TOPIC ")<br/><input id='mt' name='mt' placeholder='" MQTT_TOPIC" ' value='{m6'><br/>"
|
||||
"<br/><b>" D_FULL_TOPIC "</b> (" MQTT_FULLTOPIC ")<br/><input id='mf' name='mf' placeholder='" MQTT_FULLTOPIC" ' value='{m7'><br/>";
|
||||
const char HTTP_FORM_LOG1[] PROGMEM =
|
||||
"<fieldset><legend><b> " D_LOGGING_PARAMETERS " </b></legend><form method='get' action='sv'>"
|
||||
"<input id='w' name='w' value='3,0' hidden>";
|
||||
"<fieldset><legend><b> " D_LOGGING_PARAMETERS " </b></legend><form method='get' action='lg'>";
|
||||
const char HTTP_FORM_LOG2[] PROGMEM =
|
||||
"<br/><b>{b0</b> ({b1)<br/><select id='{b2' name='{b2'>"
|
||||
"<option{a0value='0'>0 " D_NONE "</option>"
|
||||
|
@ -270,8 +241,8 @@ const char HTTP_FORM_LOG3[] PROGMEM =
|
|||
"<br/><b>" D_SYSLOG_PORT "</b> (" STR(SYS_LOG_PORT) ")<br/><input id='lp' name='lp' placeholder='" STR(SYS_LOG_PORT) "' value='{l3'><br/>"
|
||||
"<br/><b>" D_TELEMETRY_PERIOD "</b> (" STR(TELE_PERIOD) ")<br/><input id='lt' name='lt' placeholder='" STR(TELE_PERIOD) "' value='{l4'><br/>";
|
||||
const char HTTP_FORM_OTHER[] PROGMEM =
|
||||
"<fieldset><legend><b> " D_OTHER_PARAMETERS " </b></legend><form method='get' action='sv'>"
|
||||
"<input id='w' name='w' value='5,1' hidden>"
|
||||
"<fieldset><legend><b> " D_OTHER_PARAMETERS " </b></legend><form method='get' action='co'>"
|
||||
// "<input id='w' name='w' value='5,1' hidden>"
|
||||
"<br/><b>" D_WEB_ADMIN_PASSWORD "</b><br/><input id='p1' name='p1' type='password' placeholder='" D_WEB_ADMIN_PASSWORD "' value='" D_ASTERIX "'><br/>"
|
||||
"<br/><input style='width:10%;' id='b1' name='b1' type='checkbox'{r1><b>" D_MQTT_ENABLE "</b><br/>";
|
||||
const char HTTP_FORM_OTHER2[] PROGMEM =
|
||||
|
@ -283,7 +254,7 @@ const char HTTP_FORM_OTHER3b[] PROGMEM =
|
|||
"<br/><input style='width:10%;' id='r{1' name='b2' type='radio' value='{1'{2><b>{3</b>{4"; // Different id only used for labels
|
||||
#endif // USE_EMULATION
|
||||
const char HTTP_FORM_END[] PROGMEM =
|
||||
"<br/><button type='submit' class='button bgrn'>" D_SAVE "</button></form></fieldset>";
|
||||
"<br/><button name='save' type='submit' class='button bgrn'>" D_SAVE "</button></form></fieldset>";
|
||||
const char HTTP_FORM_RST[] PROGMEM =
|
||||
"<div id='f1' name='f1' style='display:block;'>"
|
||||
"<fieldset><legend><b> " D_RESTORE_CONFIGURATION " </b></legend>";
|
||||
|
@ -383,46 +354,23 @@ void StartWebserver(int type, IPAddress ipweb)
|
|||
WebServer->on("/ay", HandleAjaxStatusRefresh);
|
||||
WebServer->on("/cm", HandleHttpCommand);
|
||||
WebServer->on("/rb", HandleRestart);
|
||||
// WebServer->on("/fwlink", HandleRoot); // Microsoft captive portal. Maybe not needed. Might be handled by notFound handler.
|
||||
WebServer->onNotFound(HandleNotFound);
|
||||
#ifndef BE_MINIMAL
|
||||
WebServer->on("/cn", HandleConfiguration);
|
||||
WebServer->on("/md", HandleModuleConfiguration);
|
||||
#if defined(USE_TIMERS) && defined(USE_TIMERS_WEB)
|
||||
WebServer->on("/tm", HandleTimerConfiguration);
|
||||
#endif // USE_TIMERS and USE_TIMERS_WEB
|
||||
WebServer->on("/w1", HandleWifiConfigurationWithScan);
|
||||
WebServer->on("/w0", HandleWifiConfiguration);
|
||||
if (Settings.flag.mqtt_enabled) {
|
||||
WebServer->on("/mq", HandleMqttConfiguration);
|
||||
#ifdef USE_DOMOTICZ
|
||||
WebServer->on("/dm", HandleDomoticzConfiguration);
|
||||
#endif // USE_DOMOTICZ
|
||||
}
|
||||
#ifdef USE_KNX
|
||||
#ifdef USE_KNX_WEB_MENU
|
||||
WebServer->on("/kn", HandleKNXConfiguration);
|
||||
#endif // USE_KNX_WEB_MENU
|
||||
#endif // USE_KNX
|
||||
WebServer->on("/wi", HandleWifiConfiguration);
|
||||
WebServer->on("/lg", HandleLoggingConfiguration);
|
||||
WebServer->on("/co", HandleOtherConfiguration);
|
||||
WebServer->on("/dl", HandleBackupConfiguration);
|
||||
WebServer->on("/sv", HandleSaveSettings);
|
||||
WebServer->on("/rs", HandleRestoreConfiguration);
|
||||
WebServer->on("/rt", HandleResetConfiguration);
|
||||
WebServer->on("/in", HandleInformation);
|
||||
#ifdef USE_EMULATION
|
||||
if (EMUL_WEMO == Settings.flag2.emulation) {
|
||||
WebServer->on("/upnp/control/basicevent1", HTTP_POST, HandleUpnpEvent);
|
||||
WebServer->on("/eventservice.xml", HandleUpnpService);
|
||||
WebServer->on("/metainfoservice.xml", HandleUpnpMetaService);
|
||||
WebServer->on("/setup.xml", HandleUpnpSetupWemo);
|
||||
}
|
||||
if (EMUL_HUE == Settings.flag2.emulation) {
|
||||
WebServer->on("/description.xml", HandleUpnpSetupHue);
|
||||
}
|
||||
HueWemoAddHandlers();
|
||||
#endif // USE_EMULATION
|
||||
XdrvCall(FUNC_WEB_ADD_HANDLER);
|
||||
#endif // Not BE_MINIMAL
|
||||
WebServer->on("/fwlink", HandleRoot); // Microsoft captive portal. Maybe not needed. Might be handled by notFound handler.
|
||||
WebServer->onNotFound(HandleNotFound);
|
||||
}
|
||||
reset_web_log_flag = 0;
|
||||
WebServer->begin(); // Web server start
|
||||
|
@ -697,7 +645,30 @@ boolean HttpUser()
|
|||
return status;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef BE_MINIMAL
|
||||
|
||||
void WaitForRestart(String result)
|
||||
{
|
||||
String page = FPSTR(HTTP_HEAD);
|
||||
page.replace(F("{v}"), FPSTR(S_SAVE_CONFIGURATION));
|
||||
page += FPSTR(HTTP_HEAD_STYLE);
|
||||
page += F("<div style='text-align:center;'><b>" D_CONFIGURATION_SAVED "</b><br/>");
|
||||
page += result;
|
||||
page += F("</div>");
|
||||
page += FPSTR(HTTP_MSG_RSTRT);
|
||||
if (HTTP_MANAGER == webserver_state) {
|
||||
webserver_state = HTTP_ADMIN;
|
||||
} else {
|
||||
page += FPSTR(HTTP_BTN_MAIN);
|
||||
}
|
||||
ShowPage(page);
|
||||
|
||||
ShowWebSource(SRC_WEBGUI);
|
||||
restart_flag = 2;
|
||||
}
|
||||
|
||||
void HandleConfiguration()
|
||||
{
|
||||
if (HttpUser()) { return; }
|
||||
|
@ -708,29 +679,34 @@ void HandleConfiguration()
|
|||
page.replace(F("{v}"), FPSTR(S_CONFIGURATION));
|
||||
page += FPSTR(HTTP_HEAD_STYLE);
|
||||
page += FPSTR(HTTP_BTN_MENU_MODULE);
|
||||
#if defined(USE_TIMERS) && defined(USE_TIMERS_WEB)
|
||||
#ifdef USE_RULES
|
||||
page += FPSTR(HTTP_BTN_MENU_TIMER);
|
||||
#else
|
||||
if (devices_present) { page += FPSTR(HTTP_BTN_MENU_TIMER); }
|
||||
#endif // USE_RULES
|
||||
#endif // USE_TIMERS and USE_TIMERS_WEB
|
||||
page += FPSTR(HTTP_BTN_MENU_WIFI);
|
||||
if (Settings.flag.mqtt_enabled) { page += FPSTR(HTTP_BTN_MENU_MQTT); }
|
||||
|
||||
mqtt_data[0] = '\0';
|
||||
XdrvCall(FUNC_WEB_ADD_BUTTON);
|
||||
page += String(mqtt_data);
|
||||
|
||||
page += FPSTR(HTTP_BTN_MENU4);
|
||||
page += FPSTR(HTTP_BTN_MAIN);
|
||||
ShowPage(page);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------------------------*/
|
||||
|
||||
void HandleModuleConfiguration()
|
||||
{
|
||||
if (HttpUser()) { return; }
|
||||
if (!WebAuthenticate()) { return WebServer->requestAuthentication(); }
|
||||
char stemp[20];
|
||||
uint8_t midx;
|
||||
|
||||
AddLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, S_CONFIGURE_MODULE);
|
||||
|
||||
if (WebServer->hasArg("save")) {
|
||||
ModuleSaveSettings();
|
||||
WaitForRestart("");
|
||||
return;
|
||||
}
|
||||
|
||||
char stemp[20];
|
||||
uint8_t midx;
|
||||
|
||||
String page = FPSTR(HTTP_HEAD);
|
||||
page.replace(F("{v}"), FPSTR(S_CONFIGURE_MODULE));
|
||||
page += FPSTR(HTTP_SCRIPT_MODULE1);
|
||||
|
@ -783,15 +759,36 @@ void HandleModuleConfiguration()
|
|||
ShowPage(page);
|
||||
}
|
||||
|
||||
void HandleWifiConfigurationWithScan()
|
||||
void ModuleSaveSettings()
|
||||
{
|
||||
HandleWifi(true);
|
||||
char tmp[100];
|
||||
char stemp[TOPSZ];
|
||||
|
||||
WebGetArg("g99", tmp, sizeof(tmp));
|
||||
byte new_module = (!strlen(tmp)) ? MODULE : atoi(tmp);
|
||||
Settings.last_module = Settings.module;
|
||||
Settings.module = new_module;
|
||||
mytmplt cmodule;
|
||||
memcpy_P(&cmodule, &kModules[Settings.module], sizeof(cmodule));
|
||||
String gpios = "";
|
||||
for (byte i = 0; i < MAX_GPIO_PIN; i++) {
|
||||
if (Settings.last_module != new_module) {
|
||||
Settings.my_gp.io[i] = 0;
|
||||
} else {
|
||||
if (GPIO_USER == ValidGPIO(i, cmodule.gp.io[i])) {
|
||||
snprintf_P(stemp, sizeof(stemp), PSTR("g%d"), i);
|
||||
WebGetArg(stemp, tmp, sizeof(tmp));
|
||||
Settings.my_gp.io[i] = (!strlen(tmp)) ? 0 : atoi(tmp);
|
||||
gpios += F(", " D_GPIO ); gpios += String(i); gpios += F(" "); gpios += String(Settings.my_gp.io[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
snprintf_P(stemp, sizeof(stemp), kModules[Settings.module].name);
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_MODULE "%s " D_CMND_MODULE "%s"), stemp, gpios.c_str());
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
}
|
||||
|
||||
void HandleWifiConfiguration()
|
||||
{
|
||||
HandleWifi(false);
|
||||
}
|
||||
/*-------------------------------------------------------------------------------------------*/
|
||||
|
||||
String htmlEscape(String s)
|
||||
{
|
||||
|
@ -804,18 +801,25 @@ String htmlEscape(String s)
|
|||
return s;
|
||||
}
|
||||
|
||||
void HandleWifi(boolean scan)
|
||||
void HandleWifiConfiguration()
|
||||
{
|
||||
if (HttpUser()) { return; }
|
||||
if (!WebAuthenticate()) { return WebServer->requestAuthentication(); }
|
||||
|
||||
AddLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, S_CONFIGURE_WIFI);
|
||||
|
||||
if (WebServer->hasArg("save")) {
|
||||
WifiSaveSettings();
|
||||
String result = F("<br/>" D_TRYING_TO_CONNECT "<br/>");
|
||||
WaitForRestart(result);
|
||||
return;
|
||||
}
|
||||
|
||||
String page = FPSTR(HTTP_HEAD);
|
||||
page.replace(F("{v}"), FPSTR(S_CONFIGURE_WIFI));
|
||||
page += FPSTR(HTTP_HEAD_STYLE);
|
||||
|
||||
if (scan) {
|
||||
if (WebServer->hasArg("scan")) {
|
||||
#ifdef USE_EMULATION
|
||||
UdpDisconnect();
|
||||
#endif // USE_EMULATION
|
||||
|
@ -901,39 +905,46 @@ void HandleWifi(boolean scan)
|
|||
ShowPage(page, !(HTTP_MANAGER == webserver_state));
|
||||
}
|
||||
|
||||
void HandleMqttConfiguration()
|
||||
void WifiSaveSettings()
|
||||
{
|
||||
if (HttpUser()) { return; }
|
||||
if (!WebAuthenticate()) { return WebServer->requestAuthentication(); }
|
||||
AddLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, S_CONFIGURE_MQTT);
|
||||
char tmp[100];
|
||||
|
||||
String page = FPSTR(HTTP_HEAD);
|
||||
page.replace(F("{v}"), FPSTR(S_CONFIGURE_MQTT));
|
||||
page += FPSTR(HTTP_HEAD_STYLE);
|
||||
page += FPSTR(HTTP_FORM_MQTT);
|
||||
char str[sizeof(Settings.mqtt_client)];
|
||||
page.replace(F("{m0"), Format(str, MQTT_CLIENT_ID, sizeof(Settings.mqtt_client)));
|
||||
page.replace(F("{m1"), Settings.mqtt_host);
|
||||
page.replace(F("{m2"), String(Settings.mqtt_port));
|
||||
page.replace(F("{m3"), Settings.mqtt_client);
|
||||
page.replace(F("{m4"), (Settings.mqtt_user[0] == '\0')?"0":Settings.mqtt_user);
|
||||
page.replace(F("{m5"), (Settings.mqtt_pwd[0] == '\0')?"0":Settings.mqtt_pwd);
|
||||
page.replace(F("{m6"), Settings.mqtt_topic);
|
||||
page.replace(F("{m7"), Settings.mqtt_fulltopic);
|
||||
page += FPSTR(HTTP_FORM_END);
|
||||
page += FPSTR(HTTP_BTN_CONF);
|
||||
ShowPage(page);
|
||||
WebGetArg("h", tmp, sizeof(tmp));
|
||||
strlcpy(Settings.hostname, (!strlen(tmp)) ? WIFI_HOSTNAME : tmp, sizeof(Settings.hostname));
|
||||
if (strstr(Settings.hostname,"%")) {
|
||||
strlcpy(Settings.hostname, WIFI_HOSTNAME, sizeof(Settings.hostname));
|
||||
}
|
||||
WebGetArg("s1", tmp, sizeof(tmp));
|
||||
strlcpy(Settings.sta_ssid[0], (!strlen(tmp)) ? STA_SSID1 : tmp, sizeof(Settings.sta_ssid[0]));
|
||||
WebGetArg("s2", tmp, sizeof(tmp));
|
||||
strlcpy(Settings.sta_ssid[1], (!strlen(tmp)) ? STA_SSID2 : tmp, sizeof(Settings.sta_ssid[1]));
|
||||
WebGetArg("p1", tmp, sizeof(tmp));
|
||||
strlcpy(Settings.sta_pwd[0], (!strlen(tmp)) ? "" : (strchr(tmp,'*')) ? Settings.sta_pwd[0] : tmp, sizeof(Settings.sta_pwd[0]));
|
||||
WebGetArg("p2", tmp, sizeof(tmp));
|
||||
strlcpy(Settings.sta_pwd[1], (!strlen(tmp)) ? "" : (strchr(tmp,'*')) ? Settings.sta_pwd[1] : tmp, sizeof(Settings.sta_pwd[1]));
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_WIFI D_CMND_HOSTNAME " %s, " D_CMND_SSID "1 %s, " D_CMND_SSID "2 %s"),
|
||||
Settings.hostname, Settings.sta_ssid[0], Settings.sta_ssid[1]);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------------------------*/
|
||||
|
||||
void HandleLoggingConfiguration()
|
||||
{
|
||||
if (HttpUser()) { return; }
|
||||
if (!WebAuthenticate()) { return WebServer->requestAuthentication(); }
|
||||
AddLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, S_CONFIGURE_LOGGING);
|
||||
|
||||
if (WebServer->hasArg("save")) {
|
||||
LoggingSaveSettings();
|
||||
HandleConfiguration();
|
||||
return;
|
||||
}
|
||||
|
||||
String page = FPSTR(HTTP_HEAD);
|
||||
page.replace(F("{v}"), FPSTR(S_CONFIGURE_LOGGING));
|
||||
page += FPSTR(HTTP_HEAD_STYLE);
|
||||
|
||||
page += FPSTR(HTTP_FORM_LOG1);
|
||||
for (byte idx = 0; idx < 3; idx++) {
|
||||
page += FPSTR(HTTP_FORM_LOG2);
|
||||
|
@ -973,11 +984,46 @@ void HandleLoggingConfiguration()
|
|||
ShowPage(page);
|
||||
}
|
||||
|
||||
void LoggingSaveSettings()
|
||||
{
|
||||
char tmp[100];
|
||||
|
||||
WebGetArg("ls", tmp, sizeof(tmp));
|
||||
Settings.seriallog_level = (!strlen(tmp)) ? SERIAL_LOG_LEVEL : atoi(tmp);
|
||||
WebGetArg("lw", tmp, sizeof(tmp));
|
||||
Settings.weblog_level = (!strlen(tmp)) ? WEB_LOG_LEVEL : atoi(tmp);
|
||||
WebGetArg("ll", tmp, sizeof(tmp));
|
||||
Settings.syslog_level = (!strlen(tmp)) ? SYS_LOG_LEVEL : atoi(tmp);
|
||||
syslog_level = Settings.syslog_level;
|
||||
syslog_timer = 0;
|
||||
WebGetArg("lh", tmp, sizeof(tmp));
|
||||
strlcpy(Settings.syslog_host, (!strlen(tmp)) ? SYS_LOG_HOST : tmp, sizeof(Settings.syslog_host));
|
||||
WebGetArg("lp", tmp, sizeof(tmp));
|
||||
Settings.syslog_port = (!strlen(tmp)) ? SYS_LOG_PORT : atoi(tmp);
|
||||
WebGetArg("lt", tmp, sizeof(tmp));
|
||||
Settings.tele_period = (!strlen(tmp)) ? TELE_PERIOD : atoi(tmp);
|
||||
if ((Settings.tele_period > 0) && (Settings.tele_period < 10)) {
|
||||
Settings.tele_period = 10; // Do not allow periods < 10 seconds
|
||||
}
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_LOG D_CMND_SERIALLOG " %d, " D_CMND_WEBLOG " %d, " D_CMND_SYSLOG " %d, " D_CMND_LOGHOST " %s, " D_CMND_LOGPORT " %d, " D_CMND_TELEPERIOD " %d"),
|
||||
Settings.seriallog_level, Settings.weblog_level, Settings.syslog_level, Settings.syslog_host, Settings.syslog_port, Settings.tele_period);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------------------------*/
|
||||
|
||||
void HandleOtherConfiguration()
|
||||
{
|
||||
if (HttpUser()) { return; }
|
||||
if (!WebAuthenticate()) { return WebServer->requestAuthentication(); }
|
||||
AddLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, S_CONFIGURE_OTHER);
|
||||
|
||||
if (WebServer->hasArg("save")) {
|
||||
OtherSaveSettings();
|
||||
WaitForRestart("");
|
||||
return;
|
||||
}
|
||||
|
||||
char stemp[40];
|
||||
|
||||
String page = FPSTR(HTTP_HEAD);
|
||||
|
@ -1011,6 +1057,32 @@ void HandleOtherConfiguration()
|
|||
ShowPage(page);
|
||||
}
|
||||
|
||||
void OtherSaveSettings()
|
||||
{
|
||||
char tmp[100];
|
||||
char stemp[TOPSZ];
|
||||
char stemp2[TOPSZ];
|
||||
|
||||
WebGetArg("p1", tmp, sizeof(tmp));
|
||||
strlcpy(Settings.web_password, (!strlen(tmp)) ? "" : (strchr(tmp,'*')) ? Settings.web_password : tmp, sizeof(Settings.web_password));
|
||||
Settings.flag.mqtt_enabled = WebServer->hasArg("b1");
|
||||
#ifdef USE_EMULATION
|
||||
WebGetArg("b2", tmp, sizeof(tmp));
|
||||
Settings.flag2.emulation = (!strlen(tmp)) ? 0 : atoi(tmp);
|
||||
#endif // USE_EMULATION
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_OTHER D_MQTT_ENABLE " %s, " D_CMND_EMULATION " %d, " D_CMND_FRIENDLYNAME), GetStateText(Settings.flag.mqtt_enabled), Settings.flag2.emulation);
|
||||
for (byte i = 0; i < MAX_FRIENDLYNAMES; i++) {
|
||||
snprintf_P(stemp, sizeof(stemp), PSTR("a%d"), i +1);
|
||||
WebGetArg(stemp, tmp, sizeof(tmp));
|
||||
snprintf_P(stemp2, sizeof(stemp2), PSTR(FRIENDLY_NAME"%d"), i +1);
|
||||
strlcpy(Settings.friendlyname[i], (!strlen(tmp)) ? (i) ? stemp2 : FRIENDLY_NAME : tmp, sizeof(Settings.friendlyname[i]));
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("%s%s %s"), log_data, (i) ? "," : "", Settings.friendlyname[i]);
|
||||
}
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------------------------*/
|
||||
|
||||
void HandleBackupConfiguration()
|
||||
{
|
||||
if (HttpUser()) { return; }
|
||||
|
@ -1053,171 +1125,7 @@ void HandleBackupConfiguration()
|
|||
Settings.cfg_crc = cfg_crc; // Restore crc in case savedata = 0 to make sure settings will be noted as changed
|
||||
}
|
||||
|
||||
void HandleSaveSettings()
|
||||
{
|
||||
if (HttpUser()) { return; }
|
||||
if (!WebAuthenticate()) { return WebServer->requestAuthentication(); }
|
||||
|
||||
char stemp[TOPSZ];
|
||||
char stemp2[TOPSZ];
|
||||
String result = "";
|
||||
|
||||
AddLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, S_SAVE_CONFIGURATION);
|
||||
|
||||
char tmp[100];
|
||||
WebGetArg("w", tmp, sizeof(tmp)); // Returns "5,1" where 5 is config type and 1 is restart flag
|
||||
char *p = tmp;
|
||||
uint8_t what = strtol(p, &p, 10);
|
||||
p++; // Skip comma
|
||||
uint8_t restart = strtol(p, &p, 10);
|
||||
switch (what) {
|
||||
case 1:
|
||||
WebGetArg("h", tmp, sizeof(tmp));
|
||||
strlcpy(Settings.hostname, (!strlen(tmp)) ? WIFI_HOSTNAME : tmp, sizeof(Settings.hostname));
|
||||
if (strstr(Settings.hostname,"%")) {
|
||||
strlcpy(Settings.hostname, WIFI_HOSTNAME, sizeof(Settings.hostname));
|
||||
}
|
||||
WebGetArg("s1", tmp, sizeof(tmp));
|
||||
strlcpy(Settings.sta_ssid[0], (!strlen(tmp)) ? STA_SSID1 : tmp, sizeof(Settings.sta_ssid[0]));
|
||||
WebGetArg("s2", tmp, sizeof(tmp));
|
||||
strlcpy(Settings.sta_ssid[1], (!strlen(tmp)) ? STA_SSID2 : tmp, sizeof(Settings.sta_ssid[1]));
|
||||
// WebGetArg("s1", tmp, sizeof(tmp));
|
||||
// strlcpy(Settings.sta_ssid[0], (!strlen(tmp)) ? "" : tmp, sizeof(Settings.sta_ssid[0]));
|
||||
// WebGetArg("s2", tmp, sizeof(tmp));
|
||||
// strlcpy(Settings.sta_ssid[1], (!strlen(tmp)) ? "" : tmp, sizeof(Settings.sta_ssid[1]));
|
||||
WebGetArg("p1", tmp, sizeof(tmp));
|
||||
strlcpy(Settings.sta_pwd[0], (!strlen(tmp)) ? "" : (strchr(tmp,'*')) ? Settings.sta_pwd[0] : tmp, sizeof(Settings.sta_pwd[0]));
|
||||
WebGetArg("p2", tmp, sizeof(tmp));
|
||||
strlcpy(Settings.sta_pwd[1], (!strlen(tmp)) ? "" : (strchr(tmp,'*')) ? Settings.sta_pwd[1] : tmp, sizeof(Settings.sta_pwd[1]));
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_WIFI D_CMND_HOSTNAME " %s, " D_CMND_SSID "1 %s, " D_CMND_SSID "2 %s"),
|
||||
Settings.hostname, Settings.sta_ssid[0], Settings.sta_ssid[1]);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
result += F("<br/>" D_TRYING_TO_CONNECT "<br/>");
|
||||
break;
|
||||
case 2:
|
||||
WebGetArg("mt", tmp, sizeof(tmp));
|
||||
strlcpy(stemp, (!strlen(tmp)) ? MQTT_TOPIC : tmp, sizeof(stemp));
|
||||
MakeValidMqtt(0, stemp);
|
||||
WebGetArg("mf", tmp, sizeof(tmp));
|
||||
strlcpy(stemp2, (!strlen(tmp)) ? MQTT_FULLTOPIC : tmp, sizeof(stemp2));
|
||||
MakeValidMqtt(1,stemp2);
|
||||
if ((strcmp(stemp, Settings.mqtt_topic)) || (strcmp(stemp2, Settings.mqtt_fulltopic))) {
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), (Settings.flag.mqtt_offline) ? S_OFFLINE : "");
|
||||
MqttPublishPrefixTopic_P(TELE, S_LWT, true); // Offline or remove previous retained topic
|
||||
}
|
||||
strlcpy(Settings.mqtt_topic, stemp, sizeof(Settings.mqtt_topic));
|
||||
strlcpy(Settings.mqtt_fulltopic, stemp2, sizeof(Settings.mqtt_fulltopic));
|
||||
WebGetArg("mh", tmp, sizeof(tmp));
|
||||
strlcpy(Settings.mqtt_host, (!strlen(tmp)) ? MQTT_HOST : (!strcmp(tmp,"0")) ? "" : tmp, sizeof(Settings.mqtt_host));
|
||||
WebGetArg("ml", tmp, sizeof(tmp));
|
||||
Settings.mqtt_port = (!strlen(tmp)) ? MQTT_PORT : atoi(tmp);
|
||||
WebGetArg("mc", tmp, sizeof(tmp));
|
||||
strlcpy(Settings.mqtt_client, (!strlen(tmp)) ? MQTT_CLIENT_ID : tmp, sizeof(Settings.mqtt_client));
|
||||
WebGetArg("mu", tmp, sizeof(tmp));
|
||||
strlcpy(Settings.mqtt_user, (!strlen(tmp)) ? MQTT_USER : (!strcmp(tmp,"0")) ? "" : tmp, sizeof(Settings.mqtt_user));
|
||||
WebGetArg("mp", tmp, sizeof(tmp));
|
||||
strlcpy(Settings.mqtt_pwd, (!strlen(tmp)) ? MQTT_PASS : (!strcmp(tmp,"0")) ? "" : tmp, sizeof(Settings.mqtt_pwd));
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_MQTT D_CMND_MQTTHOST " %s, " D_CMND_MQTTPORT " %d, " D_CMND_MQTTCLIENT " %s, " D_CMND_MQTTUSER " %s, " D_CMND_MQTTPASSWORD " %s, " D_CMND_TOPIC " %s, " D_CMND_FULLTOPIC " %s"),
|
||||
Settings.mqtt_host, Settings.mqtt_port, Settings.mqtt_client, Settings.mqtt_user, Settings.mqtt_pwd, Settings.mqtt_topic, Settings.mqtt_fulltopic);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
break;
|
||||
case 3:
|
||||
WebGetArg("ls", tmp, sizeof(tmp));
|
||||
Settings.seriallog_level = (!strlen(tmp)) ? SERIAL_LOG_LEVEL : atoi(tmp);
|
||||
WebGetArg("lw", tmp, sizeof(tmp));
|
||||
Settings.weblog_level = (!strlen(tmp)) ? WEB_LOG_LEVEL : atoi(tmp);
|
||||
WebGetArg("ll", tmp, sizeof(tmp));
|
||||
Settings.syslog_level = (!strlen(tmp)) ? SYS_LOG_LEVEL : atoi(tmp);
|
||||
syslog_level = Settings.syslog_level;
|
||||
syslog_timer = 0;
|
||||
WebGetArg("lh", tmp, sizeof(tmp));
|
||||
strlcpy(Settings.syslog_host, (!strlen(tmp)) ? SYS_LOG_HOST : tmp, sizeof(Settings.syslog_host));
|
||||
WebGetArg("lp", tmp, sizeof(tmp));
|
||||
Settings.syslog_port = (!strlen(tmp)) ? SYS_LOG_PORT : atoi(tmp);
|
||||
WebGetArg("lt", tmp, sizeof(tmp));
|
||||
Settings.tele_period = (!strlen(tmp)) ? TELE_PERIOD : atoi(tmp);
|
||||
if ((Settings.tele_period > 0) && (Settings.tele_period < 10)) {
|
||||
Settings.tele_period = 10; // Do not allow periods < 10 seconds
|
||||
}
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_LOG D_CMND_SERIALLOG " %d, " D_CMND_WEBLOG " %d, " D_CMND_SYSLOG " %d, " D_CMND_LOGHOST " %s, " D_CMND_LOGPORT " %d, " D_CMND_TELEPERIOD " %d"),
|
||||
Settings.seriallog_level, Settings.weblog_level, Settings.syslog_level, Settings.syslog_host, Settings.syslog_port, Settings.tele_period);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
break;
|
||||
#if defined(USE_TIMERS) && defined(USE_TIMERS_WEB)
|
||||
case 7:
|
||||
TimerSaveSettings();
|
||||
break;
|
||||
#endif // USE_TIMERS and USE_TIMERS_WEB
|
||||
#ifdef USE_DOMOTICZ
|
||||
case 4:
|
||||
DomoticzSaveSettings();
|
||||
break;
|
||||
#endif // USE_DOMOTICZ
|
||||
case 5:
|
||||
WebGetArg("p1", tmp, sizeof(tmp));
|
||||
strlcpy(Settings.web_password, (!strlen(tmp)) ? "" : (strchr(tmp,'*')) ? Settings.web_password : tmp, sizeof(Settings.web_password));
|
||||
Settings.flag.mqtt_enabled = WebServer->hasArg("b1");
|
||||
#ifdef USE_EMULATION
|
||||
WebGetArg("b2", tmp, sizeof(tmp));
|
||||
Settings.flag2.emulation = (!strlen(tmp)) ? 0 : atoi(tmp);
|
||||
#endif // USE_EMULATION
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_OTHER D_MQTT_ENABLE " %s, " D_CMND_EMULATION " %d, " D_CMND_FRIENDLYNAME), GetStateText(Settings.flag.mqtt_enabled), Settings.flag2.emulation);
|
||||
for (byte i = 0; i < MAX_FRIENDLYNAMES; i++) {
|
||||
snprintf_P(stemp, sizeof(stemp), PSTR("a%d"), i +1);
|
||||
WebGetArg(stemp, tmp, sizeof(tmp));
|
||||
snprintf_P(stemp2, sizeof(stemp2), PSTR(FRIENDLY_NAME"%d"), i +1);
|
||||
strlcpy(Settings.friendlyname[i], (!strlen(tmp)) ? (i) ? stemp2 : FRIENDLY_NAME : tmp, sizeof(Settings.friendlyname[i]));
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR("%s%s %s"), log_data, (i) ? "," : "", Settings.friendlyname[i]);
|
||||
}
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
break;
|
||||
case 6:
|
||||
WebGetArg("g99", tmp, sizeof(tmp));
|
||||
byte new_module = (!strlen(tmp)) ? MODULE : atoi(tmp);
|
||||
Settings.last_module = Settings.module;
|
||||
Settings.module = new_module;
|
||||
mytmplt cmodule;
|
||||
memcpy_P(&cmodule, &kModules[Settings.module], sizeof(cmodule));
|
||||
String gpios = "";
|
||||
for (byte i = 0; i < MAX_GPIO_PIN; i++) {
|
||||
if (Settings.last_module != new_module) {
|
||||
Settings.my_gp.io[i] = 0;
|
||||
} else {
|
||||
if (GPIO_USER == ValidGPIO(i, cmodule.gp.io[i])) {
|
||||
snprintf_P(stemp, sizeof(stemp), PSTR("g%d"), i);
|
||||
WebGetArg(stemp, tmp, sizeof(tmp));
|
||||
Settings.my_gp.io[i] = (!strlen(tmp)) ? 0 : atoi(tmp);
|
||||
gpios += F(", " D_GPIO ); gpios += String(i); gpios += F(" "); gpios += String(Settings.my_gp.io[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
snprintf_P(stemp, sizeof(stemp), kModules[Settings.module].name);
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_MODULE "%s " D_CMND_MODULE "%s"), stemp, gpios.c_str());
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
break;
|
||||
}
|
||||
|
||||
if (restart) {
|
||||
String page = FPSTR(HTTP_HEAD);
|
||||
page.replace(F("{v}"), FPSTR(S_SAVE_CONFIGURATION));
|
||||
page += FPSTR(HTTP_HEAD_STYLE);
|
||||
page += F("<div style='text-align:center;'><b>" D_CONFIGURATION_SAVED "</b><br/>");
|
||||
page += result;
|
||||
page += F("</div>");
|
||||
page += FPSTR(HTTP_MSG_RSTRT);
|
||||
if (HTTP_MANAGER == webserver_state) {
|
||||
webserver_state = HTTP_ADMIN;
|
||||
} else {
|
||||
page += FPSTR(HTTP_BTN_MAIN);
|
||||
}
|
||||
ShowPage(page);
|
||||
|
||||
ShowWebSource(SRC_WEBGUI);
|
||||
restart_flag = 2;
|
||||
} else {
|
||||
HandleConfiguration();
|
||||
}
|
||||
}
|
||||
/*-------------------------------------------------------------------------------------------*/
|
||||
|
||||
void HandleResetConfiguration()
|
||||
{
|
||||
|
@ -1259,6 +1167,8 @@ void HandleRestoreConfiguration()
|
|||
upload_file_type = UPL_SETTINGS;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------------------------*/
|
||||
|
||||
void HandleInformation()
|
||||
{
|
||||
if (HttpUser()) { return; }
|
||||
|
@ -1376,6 +1286,8 @@ void HandleInformation()
|
|||
}
|
||||
#endif // Not BE_MINIMAL
|
||||
|
||||
/*-------------------------------------------------------------------------------------------*/
|
||||
|
||||
void HandleUpgradeFirmware()
|
||||
{
|
||||
if (HttpUser()) { return; }
|
||||
|
@ -1669,6 +1581,8 @@ void HandleUploadLoop()
|
|||
delay(0);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------------------------*/
|
||||
|
||||
void HandlePreflightRequest()
|
||||
{
|
||||
WebServer->sendHeader(F("Access-Control-Allow-Origin"), F("*"));
|
||||
|
@ -1677,6 +1591,8 @@ void HandlePreflightRequest()
|
|||
WebServer->send(200, FPSTR(HDR_CTYPE_HTML), "");
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------------------------*/
|
||||
|
||||
void HandleHttpCommand()
|
||||
{
|
||||
if (HttpUser()) { return; }
|
||||
|
@ -1735,6 +1651,8 @@ void HandleHttpCommand()
|
|||
WebServer->send(200, FPSTR(HDR_CTYPE_JSON), message);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------------------------*/
|
||||
|
||||
void HandleConsole()
|
||||
{
|
||||
if (HttpUser()) { return; }
|
||||
|
@ -1808,6 +1726,8 @@ void HandleAjaxConsoleRefresh()
|
|||
WebServer->send(200, FPSTR(HDR_CTYPE_XML), message);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------------------------*/
|
||||
|
||||
void HandleRestart()
|
||||
{
|
||||
if (HttpUser()) { return; }
|
||||
|
@ -2061,9 +1981,9 @@ bool WebCommand()
|
|||
* Interface
|
||||
\*********************************************************************************************/
|
||||
|
||||
#define XDRV_02
|
||||
#define XDRV_01
|
||||
|
||||
boolean Xdrv02(byte function)
|
||||
boolean Xdrv01(byte function)
|
||||
{
|
||||
boolean result = false;
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
xdrv_01_mqtt.ino - mqtt support for Sonoff-Tasmota
|
||||
xdrv_02_mqtt.ino - mqtt support for Sonoff-Tasmota
|
||||
|
||||
Copyright (C) 2018 Theo Arends
|
||||
|
||||
|
@ -782,18 +782,115 @@ bool MqttCommand()
|
|||
return serviced;
|
||||
}
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Presentation
|
||||
\*********************************************************************************************/
|
||||
|
||||
#ifdef USE_WEBSERVER
|
||||
|
||||
#define WEB_HANDLE_MQTT "mq"
|
||||
|
||||
const char S_CONFIGURE_MQTT[] PROGMEM = D_CONFIGURE_MQTT;
|
||||
|
||||
const char HTTP_BTN_MENU_MQTT[] PROGMEM =
|
||||
"<br/><form action='" WEB_HANDLE_MQTT "' method='get'><button>" D_CONFIGURE_MQTT "</button></form>";
|
||||
|
||||
const char HTTP_FORM_MQTT[] PROGMEM =
|
||||
"<fieldset><legend><b> " D_MQTT_PARAMETERS " </b></legend><form method='get' action='" WEB_HANDLE_MQTT "'>"
|
||||
"<br/><b>" D_HOST "</b> (" MQTT_HOST ")<br/><input id='mh' name='mh' placeholder='" MQTT_HOST" ' value='{m1'><br/>"
|
||||
"<br/><b>" D_PORT "</b> (" STR(MQTT_PORT) ")<br/><input id='ml' name='ml' placeholder='" STR(MQTT_PORT) "' value='{m2'><br/>"
|
||||
"<br/><b>" D_CLIENT "</b> ({m0)<br/><input id='mc' name='mc' placeholder='" MQTT_CLIENT_ID "' value='{m3'><br/>"
|
||||
"<br/><b>" D_USER "</b> (" MQTT_USER ")<br/><input id='mu' name='mu' placeholder='" MQTT_USER "' value='{m4'><br/>"
|
||||
"<br/><b>" D_PASSWORD "</b><br/><input id='mp' name='mp' type='password' placeholder='" MQTT_PASS "' value='{m5'><br/>"
|
||||
"<br/><b>" D_TOPIC "</b> = %topic% (" MQTT_TOPIC ")<br/><input id='mt' name='mt' placeholder='" MQTT_TOPIC" ' value='{m6'><br/>"
|
||||
"<br/><b>" D_FULL_TOPIC "</b> (" MQTT_FULLTOPIC ")<br/><input id='mf' name='mf' placeholder='" MQTT_FULLTOPIC" ' value='{m7'><br/>";
|
||||
|
||||
void HandleMqttConfiguration()
|
||||
{
|
||||
if (HttpUser()) { return; }
|
||||
if (!WebAuthenticate()) { return WebServer->requestAuthentication(); }
|
||||
AddLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, S_CONFIGURE_MQTT);
|
||||
|
||||
if (WebServer->hasArg("save")) {
|
||||
MqttSaveSettings();
|
||||
WaitForRestart("");
|
||||
return;
|
||||
}
|
||||
|
||||
String page = FPSTR(HTTP_HEAD);
|
||||
page.replace(F("{v}"), FPSTR(S_CONFIGURE_MQTT));
|
||||
page += FPSTR(HTTP_HEAD_STYLE);
|
||||
|
||||
page += FPSTR(HTTP_FORM_MQTT);
|
||||
char str[sizeof(Settings.mqtt_client)];
|
||||
page.replace(F("{m0"), Format(str, MQTT_CLIENT_ID, sizeof(Settings.mqtt_client)));
|
||||
page.replace(F("{m1"), Settings.mqtt_host);
|
||||
page.replace(F("{m2"), String(Settings.mqtt_port));
|
||||
page.replace(F("{m3"), Settings.mqtt_client);
|
||||
page.replace(F("{m4"), (Settings.mqtt_user[0] == '\0')?"0":Settings.mqtt_user);
|
||||
page.replace(F("{m5"), (Settings.mqtt_pwd[0] == '\0')?"0":Settings.mqtt_pwd);
|
||||
page.replace(F("{m6"), Settings.mqtt_topic);
|
||||
page.replace(F("{m7"), Settings.mqtt_fulltopic);
|
||||
|
||||
page += FPSTR(HTTP_FORM_END);
|
||||
page += FPSTR(HTTP_BTN_CONF);
|
||||
ShowPage(page);
|
||||
}
|
||||
|
||||
void MqttSaveSettings()
|
||||
{
|
||||
char tmp[100];
|
||||
char stemp[TOPSZ];
|
||||
char stemp2[TOPSZ];
|
||||
|
||||
WebGetArg("mt", tmp, sizeof(tmp));
|
||||
strlcpy(stemp, (!strlen(tmp)) ? MQTT_TOPIC : tmp, sizeof(stemp));
|
||||
MakeValidMqtt(0, stemp);
|
||||
WebGetArg("mf", tmp, sizeof(tmp));
|
||||
strlcpy(stemp2, (!strlen(tmp)) ? MQTT_FULLTOPIC : tmp, sizeof(stemp2));
|
||||
MakeValidMqtt(1,stemp2);
|
||||
if ((strcmp(stemp, Settings.mqtt_topic)) || (strcmp(stemp2, Settings.mqtt_fulltopic))) {
|
||||
snprintf_P(mqtt_data, sizeof(mqtt_data), (Settings.flag.mqtt_offline) ? S_OFFLINE : "");
|
||||
MqttPublishPrefixTopic_P(TELE, S_LWT, true); // Offline or remove previous retained topic
|
||||
}
|
||||
strlcpy(Settings.mqtt_topic, stemp, sizeof(Settings.mqtt_topic));
|
||||
strlcpy(Settings.mqtt_fulltopic, stemp2, sizeof(Settings.mqtt_fulltopic));
|
||||
WebGetArg("mh", tmp, sizeof(tmp));
|
||||
strlcpy(Settings.mqtt_host, (!strlen(tmp)) ? MQTT_HOST : (!strcmp(tmp,"0")) ? "" : tmp, sizeof(Settings.mqtt_host));
|
||||
WebGetArg("ml", tmp, sizeof(tmp));
|
||||
Settings.mqtt_port = (!strlen(tmp)) ? MQTT_PORT : atoi(tmp);
|
||||
WebGetArg("mc", tmp, sizeof(tmp));
|
||||
strlcpy(Settings.mqtt_client, (!strlen(tmp)) ? MQTT_CLIENT_ID : tmp, sizeof(Settings.mqtt_client));
|
||||
WebGetArg("mu", tmp, sizeof(tmp));
|
||||
strlcpy(Settings.mqtt_user, (!strlen(tmp)) ? MQTT_USER : (!strcmp(tmp,"0")) ? "" : tmp, sizeof(Settings.mqtt_user));
|
||||
WebGetArg("mp", tmp, sizeof(tmp));
|
||||
strlcpy(Settings.mqtt_pwd, (!strlen(tmp)) ? MQTT_PASS : (!strcmp(tmp,"0")) ? "" : tmp, sizeof(Settings.mqtt_pwd));
|
||||
snprintf_P(log_data, sizeof(log_data), PSTR(D_LOG_MQTT D_CMND_MQTTHOST " %s, " D_CMND_MQTTPORT " %d, " D_CMND_MQTTCLIENT " %s, " D_CMND_MQTTUSER " %s, " D_CMND_MQTTPASSWORD " %s, " D_CMND_TOPIC " %s, " D_CMND_FULLTOPIC " %s"),
|
||||
Settings.mqtt_host, Settings.mqtt_port, Settings.mqtt_client, Settings.mqtt_user, Settings.mqtt_pwd, Settings.mqtt_topic, Settings.mqtt_fulltopic);
|
||||
AddLog(LOG_LEVEL_INFO);
|
||||
}
|
||||
#endif // USE_WEBSERVER
|
||||
|
||||
/*********************************************************************************************\
|
||||
* Interface
|
||||
\*********************************************************************************************/
|
||||
|
||||
#define XDRV_01
|
||||
#define XDRV_02
|
||||
|
||||
boolean Xdrv01(byte function)
|
||||
boolean Xdrv02(byte function)
|
||||
{
|
||||
boolean result = false;
|
||||
|
||||
if (Settings.flag.mqtt_enabled) {
|
||||
switch (function) {
|
||||
#ifdef USE_WEBSERVER
|
||||
case FUNC_WEB_ADD_BUTTON:
|
||||
strncat_P(mqtt_data, HTTP_BTN_MENU_MQTT, sizeof(mqtt_data));
|
||||
break;
|
||||
case FUNC_WEB_ADD_HANDLER:
|
||||
WebServer->on("/" WEB_HANDLE_MQTT, HandleMqttConfiguration);
|
||||
break;
|
||||
#endif // USE_WEBSERVER
|
||||
case FUNC_LOOP:
|
||||
MqttLoop();
|
||||
break;
|
|
@ -19,22 +19,6 @@
|
|||
|
||||
#ifdef USE_DOMOTICZ
|
||||
|
||||
#ifdef USE_WEBSERVER
|
||||
const char HTTP_FORM_DOMOTICZ[] PROGMEM =
|
||||
"<fieldset><legend><b> " D_DOMOTICZ_PARAMETERS " </b></legend><form method='post' action='sv'>"
|
||||
"<input id='w' name='w' value='4,1' hidden>"
|
||||
"<br/><table>";
|
||||
const char HTTP_FORM_DOMOTICZ_RELAY[] PROGMEM =
|
||||
"<tr><td style='width:260px'><b>" D_DOMOTICZ_IDX " {1</b></td><td style='width:70px'><input id='r{1' name='r{1' placeholder='0' value='{2'></td></tr>"
|
||||
"<tr><td style='width:260px'><b>" D_DOMOTICZ_KEY_IDX " {1</b></td><td style='width:70px'><input id='k{1' name='k{1' placeholder='0' value='{3'></td></tr>";
|
||||
const char HTTP_FORM_DOMOTICZ_SWITCH[] PROGMEM =
|
||||
"<tr><td style='width:260px'><b>" D_DOMOTICZ_SWITCH_IDX " {1</b></td><td style='width:70px'><input id='s{1' name='s{1' placeholder='0' value='{4'></td></tr>";
|
||||
const char HTTP_FORM_DOMOTICZ_SENSOR[] PROGMEM =
|
||||
"<tr><td style='width:260px'><b>" D_DOMOTICZ_SENSOR_IDX " {1</b> {2</td><td style='width:70px'><input id='l{1' name='l{1' placeholder='0' value='{5'></td></tr>";
|
||||
const char HTTP_FORM_DOMOTICZ_TIMER[] PROGMEM =
|
||||
"<tr><td style='width:260px'><b>" D_DOMOTICZ_UPDATE_TIMER "</b> (" STR(DOMOTICZ_UPDATE_TIMER) ")</td><td style='width:70px'><input id='ut' name='ut' placeholder='" STR(DOMOTICZ_UPDATE_TIMER) "' value='{6'</td></tr>";
|
||||
#endif // USE_WEBSERVER
|
||||
|
||||
const char DOMOTICZ_MESSAGE[] PROGMEM = "{\"idx\":%d,\"nvalue\":%d,\"svalue\":\"%s\",\"Battery\":%d,\"RSSI\":%d}";
|
||||
|
||||
enum DomoticzCommands { CMND_IDX, CMND_KEYIDX, CMND_SWITCHIDX, CMND_SENSORIDX, CMND_UPDATETIMER };
|
||||
|
@ -386,14 +370,39 @@ void DomoticzSensorPowerEnergy(int power, char *energy)
|
|||
\*********************************************************************************************/
|
||||
|
||||
#ifdef USE_WEBSERVER
|
||||
|
||||
#define WEB_HANDLE_DOMOTICZ "dm"
|
||||
|
||||
const char S_CONFIGURE_DOMOTICZ[] PROGMEM = D_CONFIGURE_DOMOTICZ;
|
||||
|
||||
const char HTTP_BTN_MENU_DOMOTICZ[] PROGMEM =
|
||||
"<br/><form action='" WEB_HANDLE_DOMOTICZ "' method='get'><button>" D_CONFIGURE_DOMOTICZ "</button></form>";
|
||||
|
||||
const char HTTP_FORM_DOMOTICZ[] PROGMEM =
|
||||
"<fieldset><legend><b> " D_DOMOTICZ_PARAMETERS " </b></legend><form method='post' action='" WEB_HANDLE_DOMOTICZ "'>"
|
||||
"<br/><table>";
|
||||
const char HTTP_FORM_DOMOTICZ_RELAY[] PROGMEM =
|
||||
"<tr><td style='width:260px'><b>" D_DOMOTICZ_IDX " {1</b></td><td style='width:70px'><input id='r{1' name='r{1' placeholder='0' value='{2'></td></tr>"
|
||||
"<tr><td style='width:260px'><b>" D_DOMOTICZ_KEY_IDX " {1</b></td><td style='width:70px'><input id='k{1' name='k{1' placeholder='0' value='{3'></td></tr>";
|
||||
const char HTTP_FORM_DOMOTICZ_SWITCH[] PROGMEM =
|
||||
"<tr><td style='width:260px'><b>" D_DOMOTICZ_SWITCH_IDX " {1</b></td><td style='width:70px'><input id='s{1' name='s{1' placeholder='0' value='{4'></td></tr>";
|
||||
const char HTTP_FORM_DOMOTICZ_SENSOR[] PROGMEM =
|
||||
"<tr><td style='width:260px'><b>" D_DOMOTICZ_SENSOR_IDX " {1</b> {2</td><td style='width:70px'><input id='l{1' name='l{1' placeholder='0' value='{5'></td></tr>";
|
||||
const char HTTP_FORM_DOMOTICZ_TIMER[] PROGMEM =
|
||||
"<tr><td style='width:260px'><b>" D_DOMOTICZ_UPDATE_TIMER "</b> (" STR(DOMOTICZ_UPDATE_TIMER) ")</td><td style='width:70px'><input id='ut' name='ut' placeholder='" STR(DOMOTICZ_UPDATE_TIMER) "' value='{6'</td></tr>";
|
||||
|
||||
void HandleDomoticzConfiguration()
|
||||
{
|
||||
if (HttpUser()) { return; }
|
||||
if (!WebAuthenticate()) { return WebServer->requestAuthentication(); }
|
||||
AddLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, S_CONFIGURE_DOMOTICZ);
|
||||
|
||||
if (WebServer->hasArg("save")) {
|
||||
DomoticzSaveSettings();
|
||||
WaitForRestart("");
|
||||
return;
|
||||
}
|
||||
|
||||
char stemp[32];
|
||||
|
||||
String page = FPSTR(HTTP_HEAD);
|
||||
|
@ -474,6 +483,14 @@ boolean Xdrv07(byte function)
|
|||
|
||||
if (Settings.flag.mqtt_enabled) {
|
||||
switch (function) {
|
||||
#ifdef USE_WEBSERVER
|
||||
case FUNC_WEB_ADD_BUTTON:
|
||||
strncat_P(mqtt_data, HTTP_BTN_MENU_DOMOTICZ, sizeof(mqtt_data));
|
||||
break;
|
||||
case FUNC_WEB_ADD_HANDLER:
|
||||
WebServer->on("/" WEB_HANDLE_DOMOTICZ, HandleDomoticzConfiguration);
|
||||
break;
|
||||
#endif // USE_WEBSERVER
|
||||
case FUNC_COMMAND:
|
||||
result = DomoticzCommand();
|
||||
break;
|
||||
|
|
|
@ -510,6 +510,14 @@ boolean TimerCommand()
|
|||
|
||||
#ifdef USE_WEBSERVER
|
||||
#ifdef USE_TIMERS_WEB
|
||||
|
||||
#define WEB_HANDLE_TIMER "tm"
|
||||
|
||||
const char S_CONFIGURE_TIMER[] PROGMEM = D_CONFIGURE_TIMER;
|
||||
|
||||
const char HTTP_BTN_MENU_TIMER[] PROGMEM =
|
||||
"<br/><form action='" WEB_HANDLE_TIMER "' method='get'><button>" D_CONFIGURE_TIMER "</button></form>";
|
||||
|
||||
const char HTTP_TIMER_SCRIPT[] PROGMEM =
|
||||
"var pt=[],ct=99;"
|
||||
"function qs(s){" // Alias to save code space
|
||||
|
@ -639,8 +647,7 @@ const char HTTP_TIMER_STYLE[] PROGMEM =
|
|||
#endif
|
||||
"</style>";
|
||||
const char HTTP_FORM_TIMER[] PROGMEM =
|
||||
"<fieldset style='min-width:470px;text-align:center;'><legend style='text-align:left;'><b> " D_TIMER_PARAMETERS " </b></legend><form method='post' action='sv'>"
|
||||
"<input id='w' name='w' value='7,0' hidden>"
|
||||
"<fieldset style='min-width:470px;text-align:center;'><legend style='text-align:left;'><b> " D_TIMER_PARAMETERS " </b></legend><form method='post' action='" WEB_HANDLE_TIMER "'>"
|
||||
"<br/><input style='width:5%;' id='e0' name='e0' type='checkbox'{e0><b>" D_TIMER_ENABLE "</b><br/><br/><hr/>"
|
||||
"<input id='t0' name='t0' value='";
|
||||
const char HTTP_FORM_TIMER1[] PROGMEM =
|
||||
|
@ -672,14 +679,18 @@ const char HTTP_FORM_TIMER1[] PROGMEM =
|
|||
const char HTTP_FORM_TIMER2[] PROGMEM =
|
||||
"type='submit' onclick='st();this.form.submit();'";
|
||||
|
||||
const char S_CONFIGURE_TIMER[] PROGMEM = D_CONFIGURE_TIMER;
|
||||
|
||||
void HandleTimerConfiguration()
|
||||
{
|
||||
if (HttpUser()) { return; }
|
||||
if (!WebAuthenticate()) { return WebServer->requestAuthentication(); }
|
||||
AddLog_P(LOG_LEVEL_DEBUG, S_LOG_HTTP, S_CONFIGURE_TIMER);
|
||||
|
||||
if (WebServer->hasArg("save")) {
|
||||
TimerSaveSettings();
|
||||
HandleConfiguration();
|
||||
return;
|
||||
}
|
||||
|
||||
String page = FPSTR(HTTP_HEAD);
|
||||
page.replace(F("{v}"), FPSTR(S_CONFIGURE_TIMER));
|
||||
page += FPSTR(HTTP_TIMER_SCRIPT);
|
||||
|
@ -743,6 +754,20 @@ boolean Xdrv09(byte function)
|
|||
case FUNC_PRE_INIT:
|
||||
TimerSetRandomWindows();
|
||||
break;
|
||||
#ifdef USE_WEBSERVER
|
||||
#ifdef USE_TIMERS_WEB
|
||||
case FUNC_WEB_ADD_BUTTON:
|
||||
#ifdef USE_RULES
|
||||
strncat_P(mqtt_data, HTTP_BTN_MENU_TIMER, sizeof(mqtt_data));
|
||||
#else
|
||||
if (devices_present) { strncat_P(mqtt_data, HTTP_BTN_MENU_TIMER, sizeof(mqtt_data)); }
|
||||
#endif // USE_RULES
|
||||
break;
|
||||
case FUNC_WEB_ADD_HANDLER:
|
||||
WebServer->on("/" WEB_HANDLE_TIMER, HandleTimerConfiguration);
|
||||
break;
|
||||
#endif // USE_TIMERS_WEB
|
||||
#endif // USE_WEBSERVER
|
||||
case FUNC_EVERY_SECOND:
|
||||
TimerEverySecond();
|
||||
break;
|
||||
|
|
|
@ -749,6 +749,9 @@ void KnxSensor(byte sensor_type, float value)
|
|||
#ifdef USE_KNX_WEB_MENU
|
||||
const char S_CONFIGURE_KNX[] PROGMEM = D_CONFIGURE_KNX;
|
||||
|
||||
const char HTTP_BTN_MENU_KNX[] PROGMEM =
|
||||
"<br/><form action='kn' method='get'><button>" D_CONFIGURE_KNX "</button></form>";
|
||||
|
||||
const char HTTP_FORM_KNX[] PROGMEM =
|
||||
"<fieldset><legend style='text-align:left;'><b> " D_KNX_PARAMETERS " </b></legend><form method='post' action='kn'>"
|
||||
"<br/><center>"
|
||||
|
@ -784,7 +787,6 @@ const char HTTP_FORM_KNX_ADD_BTN[] PROGMEM =
|
|||
|
||||
const char HTTP_FORM_KNX_ADD_TABLE_ROW[] PROGMEM =
|
||||
"<tr><td><b>{optex} -> GAfnum / GAarea / GAfdef </b></td>"
|
||||
// "<td><button type='submit' name='btn_del_ga' value='{opval}' style='background-color: #eb1e1e;'> " D_DELETE " </button></td></tr>";
|
||||
"<td><button type='submit' name='btn_del_ga' value='{opval}' class='button bred'> " D_DELETE " </button></td></tr>";
|
||||
|
||||
const char HTTP_FORM_KNX3[] PROGMEM =
|
||||
|
@ -797,10 +799,8 @@ const char HTTP_FORM_KNX4[] PROGMEM =
|
|||
|
||||
const char HTTP_FORM_KNX_ADD_TABLE_ROW2[] PROGMEM =
|
||||
"<tr><td><b>GAfnum / GAarea / GAfdef -> {optex}</b></td>"
|
||||
// "<td><button type='submit' name='btn_del_cb' value='{opval}' style='background-color: #eb1e1e;'> " D_DELETE " </button></td></tr>";
|
||||
"<td><button type='submit' name='btn_del_cb' value='{opval}' class='button bred'> " D_DELETE " </button></td></tr>";
|
||||
|
||||
|
||||
void HandleKNXConfiguration()
|
||||
{
|
||||
if (HttpUser()) { return; }
|
||||
|
@ -971,7 +971,7 @@ void HandleKNXConfiguration()
|
|||
}
|
||||
}
|
||||
page += F("</table></center></fieldset>");
|
||||
page += F("<br/><button name='save' type='submit'>" D_SAVE "</button></form></fieldset>");
|
||||
page += F("<br/><button name='save' type='submit' class='button bgrn'>" D_SAVE "</button></form></fieldset>");
|
||||
page += FPSTR(HTTP_BTN_CONF);
|
||||
|
||||
page.replace( F("</script>"),
|
||||
|
@ -1295,6 +1295,16 @@ boolean Xdrv11(byte function)
|
|||
case FUNC_PRE_INIT:
|
||||
KNX_INIT();
|
||||
break;
|
||||
#ifdef USE_WEBSERVER
|
||||
#ifdef USE_KNX_WEB_MENU
|
||||
case FUNC_WEB_ADD_BUTTON:
|
||||
strncat_P(mqtt_data, HTTP_BTN_MENU_KNX, sizeof(mqtt_data));
|
||||
break;
|
||||
case FUNC_WEB_ADD_HANDLER:
|
||||
WebServer->on("/kn", HandleKNXConfiguration);
|
||||
break;
|
||||
#endif // USE_KNX_WEB_MENU
|
||||
#endif // USE_WEBSERVER
|
||||
case FUNC_LOOP:
|
||||
knx.loop(); // Process knx events
|
||||
break;
|
||||
|
|
|
@ -835,4 +835,18 @@ void HandleHueApi(String *path)
|
|||
else if (path->endsWith("/rules")) HueNotImplemented(path);
|
||||
else HueGlobalConfig(path);
|
||||
}
|
||||
|
||||
void HueWemoAddHandlers()
|
||||
{
|
||||
if (EMUL_WEMO == Settings.flag2.emulation) {
|
||||
WebServer->on("/upnp/control/basicevent1", HTTP_POST, HandleUpnpEvent);
|
||||
WebServer->on("/eventservice.xml", HandleUpnpService);
|
||||
WebServer->on("/metainfoservice.xml", HandleUpnpMetaService);
|
||||
WebServer->on("/setup.xml", HandleUpnpSetupWemo);
|
||||
}
|
||||
if (EMUL_HUE == Settings.flag2.emulation) {
|
||||
WebServer->on("/description.xml", HandleUpnpSetupHue);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // USE_WEBSERVER && USE_EMULATION
|
||||
|
|
Loading…
Reference in New Issue