After some googling around I settled on using the https://github.com/me-no-dev/ESPAsyncWebServer library to implement a small web server for a heat regulation unit.
One concern however is that the template API of that library uses C++ Strings all around, I am wondering if that won't lead to memory issues, and how to best avoid them?
After reading this page: https://cpp4arduino.com/2018/11/21/eigh ... ently.html
I came up with the approach below... am I on the right track?
Thanks!
Franck
Code: Select all
String RegulControl::getvar(const String &var)
{
if (var == "REGUL_MODE") {
switch (_state.mode) {
case RegulMode::REGUL:
return F("REGUL");
case RegulMode::SAFETY:
return F("SAFETY");
case RegulMode::FORCED:
String result = F("FORCED[");
switch (_state.forced) {
case ForcedState::OFF:
result += F("OFF]");
break;
case ForcedState::F1:
result += F("1h]");
break;
case ForcedState::F2:
result += F("2h]");
break;
case ForcedState::F4:
result += F("4h]");
break;
case ForcedState::F8:
result += F("8h]");
break;
case ForcedState::F24:
result += F("24h]");
break;
case ForcedState::PERM:
result += F("PERM]");
break;
}
return result;
}
}
return var;
}