Fixed mdns settings bug

pull/72/head
Benjamin Runnels 9 years ago
parent ac04cc58a8
commit a6a8866bfe
  1. 42
      esp-link/cgiservices.c

@ -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,17 +151,27 @@ 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) {
if (flashConfig.mdns_enable){
DBG("Services: MDNS Enabled\n");
struct ip_info ipconfig; struct ip_info ipconfig;
wifi_get_ip_info(STATION_IF, &ipconfig); wifi_get_ip_info(STATION_IF, &ipconfig);
@ -170,27 +180,27 @@ int ICACHE_FLASH_ATTR cgiServicesSet(HttpdConnData *connData) {
} }
} }
else { else {
DBG("Services: MDNS Disabled\n");
espconn_mdns_server_unregister(); espconn_mdns_server_unregister();
espconn_mdns_close(); espconn_mdns_close();
mdns_started = true; mdns_started = true;
} }
}
else {
mdns |= getStringArg(connData, "mdns_servername", flashConfig.mdns_servername, sizeof(flashConfig.mdns_servername)); mdns |= getStringArg(connData, "mdns_servername", flashConfig.mdns_servername, sizeof(flashConfig.mdns_servername));
if (mdns < 0) if (mdns < 0) return HTTPD_CGI_DONE;
return HTTPD_CGI_DONE;
else if(mdns_started) { if (mdns > 0 && mdns_started) {
DBG("Services: MDNS Servername Updated\n");
espconn_mdns_server_unregister(); espconn_mdns_server_unregister();
espconn_mdns_close(); espconn_mdns_close();
espconn_mdns_set_servername(flashConfig.mdns_servername); struct ip_info ipconfig;
espconn_mdns_server_register(); wifi_get_ip_info(STATION_IF, &ipconfig);
}
if (syslog > 0) { if (wifiState == wifiGotIP && ipconfig.ip.addr != 0) {
syslog_init(flashConfig.syslog_host); wifiStartMDNS(ipconfig.ip);
}
} }
if (sntp > 0) {
cgiServicesSNTPInit();
} }
if (configSave()) { if (configSave()) {

Loading…
Cancel
Save