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.
*/
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");
}
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");
return rc;
@ -316,8 +317,9 @@ bool AutoConnect::_configSTA(const IPAddress& ip, const IPAddress& gateway, cons
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());
if (!(rc = WiFi.config(ip, gateway, netmask, dns1, dns2)))
if (!(rc = WiFi.config(ip, gateway, netmask, dns1, dns2))) {
AC_DBG("failed\n");
}
#ifdef ARDUINO_ARCH_ESP8266
AC_DBG("DHCP client(%s)\n", wifi_station_dhcpc_status() == DHCP_STOPPED ? "STOPPED" : "STARTED");
#endif
@ -524,17 +526,20 @@ void AutoConnect::handleRequest(void) {
// Save current credential
if (_apConfig.autoSave == AC_SAVECREDENTIAL_AUTO) {
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));
else
}
else {
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.
_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));
}
// Activate AutoConnectUpdate if it is attached and incorporate
// it into the AutoConnect menu.

@ -303,8 +303,9 @@ void AutoConnectAux::upload(const String& requestUri, const HTTPUpload& upload)
_upload = _uploadHandler;
AC_DBG_DUMB("enabled\n");
}
else
else {
AC_DBG_DUMB("missing\n");
}
}
}

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

@ -309,64 +309,73 @@ class AutoConnectTextJson : public AutoConnectElementJson, public AutoConnectTex
*/
template<>
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());
}
return *(reinterpret_cast<AutoConnectButtonJson*>(this));
}
template<>
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());
}
return *(reinterpret_cast<AutoConnectCheckboxJson*>(this));
}
template<>
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());
}
return *(reinterpret_cast<AutoConnectFileJson*>(this));
}
template<>
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());
}
return *(reinterpret_cast<AutoConnectInputJson*>(this));
}
template<>
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());
}
return *(reinterpret_cast<AutoConnectRadioJson*>(this));
}
template<>
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());
}
return *(reinterpret_cast<AutoConnectSelectJson*>(this));
}
template<>
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());
}
return *(reinterpret_cast<AutoConnectStyleJson*>(this));
}
template<>
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());
}
return *(reinterpret_cast<AutoConnectSubmitJson*>(this));
}
template<>
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());
}
return *(reinterpret_cast<AutoConnectTextJson*>(this));
}

Loading…
Cancel
Save