|
|
@ -98,7 +98,7 @@ void ICACHE_FLASH_ATTR cgiServicesSNTPInit() { |
|
|
|
sntp_setservername(0, flashConfig.sntp_server);
|
|
|
|
sntp_setservername(0, flashConfig.sntp_server);
|
|
|
|
sntp_init(); |
|
|
|
sntp_init(); |
|
|
|
} |
|
|
|
} |
|
|
|
DBG("SNTP timesource set to %s with offset %d\n", flashConfig.sntp_server, flashConfig.timezone_offset); |
|
|
|
DBG("SNTP timesource set to %s with offset %d", flashConfig.sntp_server, flashConfig.timezone_offset); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -151,46 +151,56 @@ int ICACHE_FLASH_ATTR cgiServicesSet(HttpdConnData *connData) { |
|
|
|
syslog |= getBoolArg(connData, "syslog_showdate", &flashConfig.syslog_showdate); |
|
|
|
syslog |= getBoolArg(connData, "syslog_showdate", &flashConfig.syslog_showdate); |
|
|
|
if (syslog < 0) return HTTPD_CGI_DONE; |
|
|
|
if (syslog < 0) return HTTPD_CGI_DONE; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (syslog > 0) { |
|
|
|
|
|
|
|
syslog_init(flashConfig.syslog_host); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int8_t sntp = 0; |
|
|
|
int8_t sntp = 0; |
|
|
|
sntp |= getInt8Arg(connData, "timezone_offset", &flashConfig.timezone_offset); |
|
|
|
sntp |= getInt8Arg(connData, "timezone_offset", &flashConfig.timezone_offset); |
|
|
|
if (sntp < 0) return HTTPD_CGI_DONE; |
|
|
|
if (sntp < 0) return HTTPD_CGI_DONE; |
|
|
|
sntp |= getStringArg(connData, "sntp_server", flashConfig.sntp_server, sizeof(flashConfig.sntp_server)); |
|
|
|
sntp |= getStringArg(connData, "sntp_server", flashConfig.sntp_server, sizeof(flashConfig.sntp_server)); |
|
|
|
if (sntp < 0) return HTTPD_CGI_DONE; |
|
|
|
if (sntp < 0) return HTTPD_CGI_DONE; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (sntp > 0) { |
|
|
|
|
|
|
|
cgiServicesSNTPInit(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
if (mdns < 0) return HTTPD_CGI_DONE; |
|
|
|
return HTTPD_CGI_DONE; |
|
|
|
|
|
|
|
else if (flashConfig.mdns_enable){ |
|
|
|
if (mdns > 0) { |
|
|
|
struct ip_info ipconfig; |
|
|
|
if (flashConfig.mdns_enable){ |
|
|
|
wifi_get_ip_info(STATION_IF, &ipconfig); |
|
|
|
DBG("Services: MDNS Enabled\n"); |
|
|
|
|
|
|
|
struct ip_info ipconfig; |
|
|
|
if (wifiState == wifiGotIP && ipconfig.ip.addr != 0) { |
|
|
|
wifi_get_ip_info(STATION_IF, &ipconfig); |
|
|
|
wifiStartMDNS(ipconfig.ip); |
|
|
|
|
|
|
|
|
|
|
|
if (wifiState == wifiGotIP && ipconfig.ip.addr != 0) { |
|
|
|
|
|
|
|
wifiStartMDNS(ipconfig.ip); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
DBG("Services: MDNS Disabled\n"); |
|
|
|
|
|
|
|
espconn_mdns_server_unregister(); |
|
|
|
|
|
|
|
espconn_mdns_close(); |
|
|
|
|
|
|
|
mdns_started = true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
espconn_mdns_server_unregister(); |
|
|
|
mdns |= getStringArg(connData, "mdns_servername", flashConfig.mdns_servername, sizeof(flashConfig.mdns_servername)); |
|
|
|
espconn_mdns_close(); |
|
|
|
if (mdns < 0) return HTTPD_CGI_DONE; |
|
|
|
mdns_started = true; |
|
|
|
|
|
|
|
} |
|
|
|
if (mdns > 0 && mdns_started) { |
|
|
|
|
|
|
|
DBG("Services: MDNS Servername Updated\n"); |
|
|
|
mdns |= getStringArg(connData, "mdns_servername", flashConfig.mdns_servername, sizeof(flashConfig.mdns_servername)); |
|
|
|
espconn_mdns_server_unregister(); |
|
|
|
if (mdns < 0)
|
|
|
|
espconn_mdns_close(); |
|
|
|
return HTTPD_CGI_DONE; |
|
|
|
struct ip_info ipconfig; |
|
|
|
else if(mdns_started) { |
|
|
|
wifi_get_ip_info(STATION_IF, &ipconfig); |
|
|
|
espconn_mdns_server_unregister(); |
|
|
|
|
|
|
|
espconn_mdns_close(); |
|
|
|
if (wifiState == wifiGotIP && ipconfig.ip.addr != 0) { |
|
|
|
espconn_mdns_set_servername(flashConfig.mdns_servername); |
|
|
|
wifiStartMDNS(ipconfig.ip); |
|
|
|
espconn_mdns_server_register(); |
|
|
|
} |
|
|
|
}
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (syslog > 0) {
|
|
|
|
|
|
|
|
syslog_init(flashConfig.syslog_host); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (sntp > 0) { |
|
|
|
|
|
|
|
cgiServicesSNTPInit(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (configSave()) { |
|
|
|
if (configSave()) { |
|
|
|