Remove compiler warnings by adding some braces.

pull/144/head
Sven Steckmann 5 years ago
parent 88f4447777
commit c7ffe5d4c7
  1. 15
      src/AutoConnect.cpp
  2. 3
      src/AutoConnectAux.cpp
  3. 24
      src/AutoConnectAuxImpl.h
  4. 27
      src/AutoConnectElementJson.h

@ -295,8 +295,9 @@ bool AutoConnect::config(AutoConnectConfig& Config) {
* by Config method. * by Config method.
*/ */
bool AutoConnect::_config(void) { bool AutoConnect::_config(void) {
if (static_cast<uint32_t>(_apConfig.apip) == 0U || static_cast<uint32_t>(_apConfig.gateway) == 0U || static_cast<uint32_t>(_apConfig.netmask) == 0U) if (static_cast<uint32_t>(_apConfig.apip) == 0U || static_cast<uint32_t>(_apConfig.gateway) == 0U || static_cast<uint32_t>(_apConfig.netmask) == 0U) {
AC_DBG("Warning: Contains invalid SoftAPIP address(es).\n"); AC_DBG("Warning: Contains invalid SoftAPIP address(es).\n");
}
bool rc = WiFi.softAPConfig(_apConfig.apip, _apConfig.gateway, _apConfig.netmask); bool rc = WiFi.softAPConfig(_apConfig.apip, _apConfig.gateway, _apConfig.netmask);
AC_DBG("SoftAP configure %s, %s, %s %s\n", _apConfig.apip.toString().c_str(), _apConfig.gateway.toString().c_str(), _apConfig.netmask.toString().c_str(), rc ? "" : "failed"); AC_DBG("SoftAP configure %s, %s, %s %s\n", _apConfig.apip.toString().c_str(), _apConfig.gateway.toString().c_str(), _apConfig.netmask.toString().c_str(), rc ? "" : "failed");
return rc; return rc;
@ -316,8 +317,9 @@ bool AutoConnect::_configSTA(const IPAddress& ip, const IPAddress& gateway, cons
bool rc; bool rc;
AC_DBG("WiFi.config(IP=%s, Gateway=%s, Subnetmask=%s, DNS1=%s, DNS2=%s)\n", ip.toString().c_str(), gateway.toString().c_str(), netmask.toString().c_str(), dns1.toString().c_str(), dns2.toString().c_str()); AC_DBG("WiFi.config(IP=%s, Gateway=%s, Subnetmask=%s, DNS1=%s, DNS2=%s)\n", ip.toString().c_str(), gateway.toString().c_str(), netmask.toString().c_str(), dns1.toString().c_str(), dns2.toString().c_str());
if (!(rc = WiFi.config(ip, gateway, netmask, dns1, dns2))) if (!(rc = WiFi.config(ip, gateway, netmask, dns1, dns2))) {
AC_DBG("failed\n"); AC_DBG("failed\n");
}
#ifdef ARDUINO_ARCH_ESP8266 #ifdef ARDUINO_ARCH_ESP8266
AC_DBG("DHCP client(%s)\n", wifi_station_dhcpc_status() == DHCP_STOPPED ? "STOPPED" : "STARTED"); AC_DBG("DHCP client(%s)\n", wifi_station_dhcpc_status() == DHCP_STOPPED ? "STOPPED" : "STARTED");
#endif #endif
@ -524,17 +526,20 @@ void AutoConnect::handleRequest(void) {
// Save current credential // Save current credential
if (_apConfig.autoSave == AC_SAVECREDENTIAL_AUTO) { if (_apConfig.autoSave == AC_SAVECREDENTIAL_AUTO) {
AutoConnectCredential credit(_apConfig.boundaryOffset); AutoConnectCredential credit(_apConfig.boundaryOffset);
if (credit.save(&_credential)) if (credit.save(&_credential)) {
AC_DBG("%.*s credential saved\n", sizeof(_credential.ssid), reinterpret_cast<const char*>(_credential.ssid)); AC_DBG("%.*s credential saved\n", sizeof(_credential.ssid), reinterpret_cast<const char*>(_credential.ssid));
else }
else {
AC_DBG("credential %.*s save failed\n", sizeof(_credential.ssid), reinterpret_cast<const char*>(_credential.ssid)); AC_DBG("credential %.*s save failed\n", sizeof(_credential.ssid), reinterpret_cast<const char*>(_credential.ssid));
} }
}
// Ensures that keeps a connection with the current AP while the portal behaves. // Ensures that keeps a connection with the current AP while the portal behaves.
_setReconnect(AC_RECONNECT_SET); _setReconnect(AC_RECONNECT_SET);
} }
else else {
AC_DBG("%.*s has no BSSID, saving is unavailable\n", sizeof(_credential.ssid), reinterpret_cast<const char*>(_credential.ssid)); AC_DBG("%.*s has no BSSID, saving is unavailable\n", sizeof(_credential.ssid), reinterpret_cast<const char*>(_credential.ssid));
}
// Activate AutoConnectUpdate if it is attached and incorporate // Activate AutoConnectUpdate if it is attached and incorporate
// it into the AutoConnect menu. // it into the AutoConnect menu.

@ -303,10 +303,11 @@ void AutoConnectAux::upload(const String& requestUri, const HTTPUpload& upload)
_upload = _uploadHandler; _upload = _uploadHandler;
AC_DBG_DUMB("enabled\n"); AC_DBG_DUMB("enabled\n");
} }
else else {
AC_DBG_DUMB("missing\n"); AC_DBG_DUMB("missing\n");
} }
} }
}
// Invokes upload handler // Invokes upload handler
if (_upload) { if (_upload) {

@ -272,9 +272,10 @@ AutoConnectButtonJson& AutoConnectAux::getElement(const String& name) {
if (elm) { if (elm) {
if (elm->typeOf() == AC_Button) if (elm->typeOf() == AC_Button)
return *(reinterpret_cast<AutoConnectButtonJson*>(elm)); return *(reinterpret_cast<AutoConnectButtonJson*>(elm));
else else {
AC_DBG("Element<%s> type mismatch<%d>\n", name.c_str(), elm->typeOf()); AC_DBG("Element<%s> type mismatch<%d>\n", name.c_str(), elm->typeOf());
} }
}
return reinterpret_cast<AutoConnectButtonJson&>(_nullElement()); return reinterpret_cast<AutoConnectButtonJson&>(_nullElement());
} }
@ -289,9 +290,10 @@ AutoConnectCheckboxJson& AutoConnectAux::getElement(const String& name) {
if (elm) { if (elm) {
if (elm->typeOf() == AC_Checkbox) if (elm->typeOf() == AC_Checkbox)
return *(reinterpret_cast<AutoConnectCheckboxJson*>(elm)); return *(reinterpret_cast<AutoConnectCheckboxJson*>(elm));
else else {
AC_DBG("Element<%s> type mismatch<%d>\n", name.c_str(), elm->typeOf()); AC_DBG("Element<%s> type mismatch<%d>\n", name.c_str(), elm->typeOf());
} }
}
return reinterpret_cast<AutoConnectCheckboxJson&>(_nullElement()); return reinterpret_cast<AutoConnectCheckboxJson&>(_nullElement());
} }
@ -306,9 +308,10 @@ AutoConnectFileJson& AutoConnectAux::getElement(const String& name) {
if (elm) { if (elm) {
if (elm->typeOf() == AC_File) if (elm->typeOf() == AC_File)
return *(reinterpret_cast<AutoConnectFileJson*>(elm)); return *(reinterpret_cast<AutoConnectFileJson*>(elm));
else else {
AC_DBG("Element<%s> type mismatch<%d>\n", name.c_str(), elm->typeOf()); AC_DBG("Element<%s> type mismatch<%d>\n", name.c_str(), elm->typeOf());
} }
}
return reinterpret_cast<AutoConnectFileJson&>(_nullElement()); return reinterpret_cast<AutoConnectFileJson&>(_nullElement());
} }
@ -323,9 +326,10 @@ AutoConnectInputJson& AutoConnectAux::getElement(const String& name) {
if (elm) { if (elm) {
if (elm->typeOf() == AC_Input) if (elm->typeOf() == AC_Input)
return *(reinterpret_cast<AutoConnectInputJson*>(elm)); return *(reinterpret_cast<AutoConnectInputJson*>(elm));
else else {
AC_DBG("Element<%s> type mismatch<%d>\n", name.c_str(), elm->typeOf()); AC_DBG("Element<%s> type mismatch<%d>\n", name.c_str(), elm->typeOf());
} }
}
return reinterpret_cast<AutoConnectInputJson&>(_nullElement()); return reinterpret_cast<AutoConnectInputJson&>(_nullElement());
} }
@ -340,9 +344,10 @@ AutoConnectRadioJson& AutoConnectAux::getElement(const String& name) {
if (elm) { if (elm) {
if (elm->typeOf() == AC_Radio) if (elm->typeOf() == AC_Radio)
return *(reinterpret_cast<AutoConnectRadioJson*>(elm)); return *(reinterpret_cast<AutoConnectRadioJson*>(elm));
else else {
AC_DBG("Element<%s> type mismatch<%d>\n", name.c_str(), elm->typeOf()); AC_DBG("Element<%s> type mismatch<%d>\n", name.c_str(), elm->typeOf());
} }
}
return reinterpret_cast<AutoConnectRadioJson&>(_nullElement()); return reinterpret_cast<AutoConnectRadioJson&>(_nullElement());
} }
@ -357,9 +362,10 @@ AutoConnectSelectJson& AutoConnectAux::getElement(const String& name) {
if (elm) { if (elm) {
if (elm->typeOf() == AC_Select) if (elm->typeOf() == AC_Select)
return *(reinterpret_cast<AutoConnectSelectJson*>(elm)); return *(reinterpret_cast<AutoConnectSelectJson*>(elm));
else else {
AC_DBG("Element<%s> type mismatch<%d>\n", name.c_str(), elm->typeOf()); AC_DBG("Element<%s> type mismatch<%d>\n", name.c_str(), elm->typeOf());
} }
}
return reinterpret_cast<AutoConnectSelectJson&>(_nullElement()); return reinterpret_cast<AutoConnectSelectJson&>(_nullElement());
} }
@ -374,9 +380,10 @@ AutoConnectSubmitJson& AutoConnectAux::getElement(const String& name) {
if (elm) { if (elm) {
if (elm->typeOf() == AC_Submit) if (elm->typeOf() == AC_Submit)
return *(reinterpret_cast<AutoConnectSubmitJson*>(elm)); return *(reinterpret_cast<AutoConnectSubmitJson*>(elm));
else else {
AC_DBG("Element<%s> type mismatch<%d>\n", name.c_str(), elm->typeOf()); AC_DBG("Element<%s> type mismatch<%d>\n", name.c_str(), elm->typeOf());
} }
}
return reinterpret_cast<AutoConnectSubmitJson&>(_nullElement()); return reinterpret_cast<AutoConnectSubmitJson&>(_nullElement());
} }
@ -391,9 +398,10 @@ AutoConnectTextJson& AutoConnectAux::getElement(const String& name) {
if (elm) { if (elm) {
if (elm->typeOf() == AC_Text) if (elm->typeOf() == AC_Text)
return *(reinterpret_cast<AutoConnectTextJson*>(elm)); return *(reinterpret_cast<AutoConnectTextJson*>(elm));
else else {
AC_DBG("Element<%s> type mismatch<%d>\n", name.c_str(), elm->typeOf()); AC_DBG("Element<%s> type mismatch<%d>\n", name.c_str(), elm->typeOf());
} }
}
return reinterpret_cast<AutoConnectTextJson&>(_nullElement()); return reinterpret_cast<AutoConnectTextJson&>(_nullElement());
} }

@ -309,64 +309,73 @@ class AutoConnectTextJson : public AutoConnectElementJson, public AutoConnectTex
*/ */
template<> template<>
inline AutoConnectButtonJson& AutoConnectElementJson::as<AutoConnectButtonJson>(void) { inline AutoConnectButtonJson& AutoConnectElementJson::as<AutoConnectButtonJson>(void) {
if (typeOf() != AC_Button) if (typeOf() != AC_Button) {
AC_DBG("%s mismatched type as <%d>\n", name.c_str(), (int)typeOf()); AC_DBG("%s mismatched type as <%d>\n", name.c_str(), (int)typeOf());
}
return *(reinterpret_cast<AutoConnectButtonJson*>(this)); return *(reinterpret_cast<AutoConnectButtonJson*>(this));
} }
template<> template<>
inline AutoConnectCheckboxJson& AutoConnectElementJson::as<AutoConnectCheckboxJson>(void) { inline AutoConnectCheckboxJson& AutoConnectElementJson::as<AutoConnectCheckboxJson>(void) {
if (typeOf() != AC_Checkbox) if (typeOf() != AC_Checkbox) {
AC_DBG("%s mismatched type as <%d>\n", name.c_str(), (int)typeOf()); AC_DBG("%s mismatched type as <%d>\n", name.c_str(), (int)typeOf());
}
return *(reinterpret_cast<AutoConnectCheckboxJson*>(this)); return *(reinterpret_cast<AutoConnectCheckboxJson*>(this));
} }
template<> template<>
inline AutoConnectFileJson& AutoConnectElementJson::as<AutoConnectFileJson>(void) { inline AutoConnectFileJson& AutoConnectElementJson::as<AutoConnectFileJson>(void) {
if (typeOf() != AC_File) if (typeOf() != AC_File) {
AC_DBG("%s mismatched type as <%d>\n", name.c_str(), (int)typeOf()); AC_DBG("%s mismatched type as <%d>\n", name.c_str(), (int)typeOf());
}
return *(reinterpret_cast<AutoConnectFileJson*>(this)); return *(reinterpret_cast<AutoConnectFileJson*>(this));
} }
template<> template<>
inline AutoConnectInputJson& AutoConnectElementJson::as<AutoConnectInputJson>(void) { inline AutoConnectInputJson& AutoConnectElementJson::as<AutoConnectInputJson>(void) {
if (typeOf() != AC_Input) if (typeOf() != AC_Input) {
AC_DBG("%s mismatched type as <%d>\n", name.c_str(), (int)typeOf()); AC_DBG("%s mismatched type as <%d>\n", name.c_str(), (int)typeOf());
}
return *(reinterpret_cast<AutoConnectInputJson*>(this)); return *(reinterpret_cast<AutoConnectInputJson*>(this));
} }
template<> template<>
inline AutoConnectRadioJson& AutoConnectElementJson::as<AutoConnectRadioJson>(void) { inline AutoConnectRadioJson& AutoConnectElementJson::as<AutoConnectRadioJson>(void) {
if (typeOf() != AC_Radio) if (typeOf() != AC_Radio) {
AC_DBG("%s mismatched type as <%d>\n", name.c_str(), (int)typeOf()); AC_DBG("%s mismatched type as <%d>\n", name.c_str(), (int)typeOf());
}
return *(reinterpret_cast<AutoConnectRadioJson*>(this)); return *(reinterpret_cast<AutoConnectRadioJson*>(this));
} }
template<> template<>
inline AutoConnectSelectJson& AutoConnectElementJson::as<AutoConnectSelectJson>(void) { inline AutoConnectSelectJson& AutoConnectElementJson::as<AutoConnectSelectJson>(void) {
if (typeOf() != AC_Select) if (typeOf() != AC_Select) {
AC_DBG("%s mismatched type as <%d>\n", name.c_str(), (int)typeOf()); AC_DBG("%s mismatched type as <%d>\n", name.c_str(), (int)typeOf());
}
return *(reinterpret_cast<AutoConnectSelectJson*>(this)); return *(reinterpret_cast<AutoConnectSelectJson*>(this));
} }
template<> template<>
inline AutoConnectStyleJson& AutoConnectElementJson::as<AutoConnectStyleJson>(void) { inline AutoConnectStyleJson& AutoConnectElementJson::as<AutoConnectStyleJson>(void) {
if (typeOf() != AC_Style) if (typeOf() != AC_Style) {
AC_DBG("%s mismatched type as <%d>\n", name.c_str(), (int)typeOf()); AC_DBG("%s mismatched type as <%d>\n", name.c_str(), (int)typeOf());
}
return *(reinterpret_cast<AutoConnectStyleJson*>(this)); return *(reinterpret_cast<AutoConnectStyleJson*>(this));
} }
template<> template<>
inline AutoConnectSubmitJson& AutoConnectElementJson::as<AutoConnectSubmitJson>(void) { inline AutoConnectSubmitJson& AutoConnectElementJson::as<AutoConnectSubmitJson>(void) {
if (typeOf() != AC_Submit) if (typeOf() != AC_Submit) {
AC_DBG("%s mismatched type as <%d>\n", name.c_str(), (int)typeOf()); AC_DBG("%s mismatched type as <%d>\n", name.c_str(), (int)typeOf());
}
return *(reinterpret_cast<AutoConnectSubmitJson*>(this)); return *(reinterpret_cast<AutoConnectSubmitJson*>(this));
} }
template<> template<>
inline AutoConnectTextJson& AutoConnectElementJson::as<AutoConnectTextJson>(void) { inline AutoConnectTextJson& AutoConnectElementJson::as<AutoConnectTextJson>(void) {
if (typeOf() != AC_Text) if (typeOf() != AC_Text) {
AC_DBG("%s mismatched type as <%d>\n", name.c_str(), (int)typeOf()); AC_DBG("%s mismatched type as <%d>\n", name.c_str(), (int)typeOf());
}
return *(reinterpret_cast<AutoConnectTextJson*>(this)); return *(reinterpret_cast<AutoConnectTextJson*>(this));
} }

Loading…
Cancel
Save