|
|
@ -91,14 +91,15 @@ int ICACHE_FLASH_ATTR cgiSystemInfo(HttpdConnData *connData) { |
|
|
|
return HTTPD_CGI_DONE; |
|
|
|
return HTTPD_CGI_DONE; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void ICACHE_FLASH_ATTR cgiServicesSNTPInit() { |
|
|
|
void ICACHE_FLASH_ATTR cgiServicesSNTPInit() { |
|
|
|
if (flashConfig.sntp_server[0]) { |
|
|
|
if (flashConfig.sntp_server[0] != '\0') {
|
|
|
|
DBG("SNTP timesource set to %s with offset %d\n", flashConfig.sntp_server, flashConfig.timezone_offset); |
|
|
|
|
|
|
|
sntp_stop(); |
|
|
|
sntp_stop(); |
|
|
|
|
|
|
|
if (true == sntp_set_timezone(flashConfig.timezone_offset)) { |
|
|
|
sntp_setservername(0, flashConfig.sntp_server);
|
|
|
|
sntp_setservername(0, flashConfig.sntp_server);
|
|
|
|
sntp_set_timezone(flashConfig.timezone_offset); |
|
|
|
|
|
|
|
sntp_init(); |
|
|
|
sntp_init(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
DBG("SNTP timesource set to %s with offset %d\n", flashConfig.sntp_server, flashConfig.timezone_offset); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int ICACHE_FLASH_ATTR cgiServicesInfo(HttpdConnData *connData) { |
|
|
|
int ICACHE_FLASH_ATTR cgiServicesInfo(HttpdConnData *connData) { |
|
|
@ -162,34 +163,38 @@ int ICACHE_FLASH_ATTR cgiServicesSet(HttpdConnData *connData) { |
|
|
|
|
|
|
|
|
|
|
|
int8_t mdns = 0; |
|
|
|
int8_t mdns = 0; |
|
|
|
mdns |= getBoolArg(connData, "mdns_enable", &flashConfig.mdns_enable); |
|
|
|
mdns |= getBoolArg(connData, "mdns_enable", &flashConfig.mdns_enable); |
|
|
|
if (mdns < 0) return HTTPD_CGI_DONE; |
|
|
|
if (mdns < 0)
|
|
|
|
mdns |= getStringArg(connData, "mdns_servername", flashConfig.mdns_servername, sizeof(flashConfig.mdns_servername)); |
|
|
|
return HTTPD_CGI_DONE; |
|
|
|
if (mdns < 0) return HTTPD_CGI_DONE; |
|
|
|
else if (flashConfig.mdns_enable){ |
|
|
|
|
|
|
|
|
|
|
|
if (syslog > 0) { |
|
|
|
|
|
|
|
if (!flashConfig.syslog_enable) { |
|
|
|
|
|
|
|
flashConfig.syslog_host[0] = '\0'; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
syslog_init(flashConfig.syslog_host); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (sntp > 0) { |
|
|
|
|
|
|
|
cgiServicesSNTPInit(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (mdns > 0) { |
|
|
|
|
|
|
|
espconn_mdns_disable(); |
|
|
|
|
|
|
|
if (flashConfig.mdns_enable) { |
|
|
|
|
|
|
|
struct ip_info ipconfig; |
|
|
|
struct ip_info ipconfig; |
|
|
|
wifi_get_ip_info(STATION_IF, &ipconfig); |
|
|
|
wifi_get_ip_info(STATION_IF, &ipconfig); |
|
|
|
mdns_started = false; |
|
|
|
|
|
|
|
if (wifiState == wifiGotIP && ipconfig.ip.addr != 0) { |
|
|
|
if (wifiState == wifiGotIP && ipconfig.ip.addr != 0) { |
|
|
|
wifiStartMDNS(ipconfig.ip); |
|
|
|
wifiStartMDNS(ipconfig.ip); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
|
|
|
|
espconn_mdns_server_unregister(); |
|
|
|
|
|
|
|
espconn_mdns_close(); |
|
|
|
mdns_started = true; |
|
|
|
mdns_started = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mdns |= getStringArg(connData, "mdns_servername", flashConfig.mdns_servername, sizeof(flashConfig.mdns_servername)); |
|
|
|
|
|
|
|
if (mdns < 0)
|
|
|
|
|
|
|
|
return HTTPD_CGI_DONE; |
|
|
|
|
|
|
|
else if(mdns_started) { |
|
|
|
|
|
|
|
espconn_mdns_server_unregister(); |
|
|
|
|
|
|
|
espconn_mdns_close(); |
|
|
|
|
|
|
|
espconn_mdns_set_servername(flashConfig.mdns_servername); |
|
|
|
|
|
|
|
espconn_mdns_server_register(); |
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (syslog > 0) {
|
|
|
|
|
|
|
|
syslog_init(flashConfig.syslog_host); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (sntp > 0) { |
|
|
|
|
|
|
|
cgiServicesSNTPInit(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (configSave()) { |
|
|
|
if (configSave()) { |
|
|
|