diff --git a/WiFiManager.cpp b/WiFiManager.cpp index 3b435f5..44cb18d 100644 --- a/WiFiManager.cpp +++ b/WiFiManager.cpp @@ -12,7 +12,8 @@ #include "WiFiManager.h" -WiFiManagerParameter::WiFiManagerParameter(const char *id, const char *placeholder, const char *defaultValue, int length) { + +WiFiManagerParameter::WiFiManagerParameter(const char *id, const char *placeholder, const char *defaultValue, int length, int rofield) { _id = id; _placeholder = placeholder; _length = length; @@ -23,6 +24,25 @@ WiFiManagerParameter::WiFiManagerParameter(const char *id, const char *placehold if (defaultValue != NULL) { strncpy(_value, defaultValue, length); } + if (rofield == 0) { + _rofield = " readonly"; + } else { + _rofield = ""; + } +} + +WiFiManagerParameter::WiFiManagerParameter(const char *id, const char *placeholder, const char *defaultValue, int length) { + _id = id; + _placeholder = placeholder; + _length = length; + _value = new char[length + 1]; + for (int i = 0; i < length; i++) { + _value[i] = 0; + } + if (defaultValue != NULL) { + strncpy(_value, defaultValue, length); + } + _rofield = ""; } const char* WiFiManagerParameter::getValue() { @@ -37,6 +57,9 @@ const char* WiFiManagerParameter::getPlaceholder() { int WiFiManagerParameter::getValueLength() { return _length; } +const char* WiFiManagerParameter::getRofield() { + return _rofield; +} WiFiManager::WiFiManager() { } @@ -426,6 +449,7 @@ void WiFiManager::handleWifi(boolean scan) { snprintf(parLength, 2, "%d", _params[i]->getValueLength()); pitem.replace("{l}", parLength); pitem.replace("{v}", _params[i]->getValue()); + pitem.replace("{r}", _params[i]->getRofield()); page += pitem; } @@ -690,5 +714,3 @@ String WiFiManager::toStringIp(IPAddress ip) { res += String(((ip >> 8 * 3)) & 0xFF); return res; } - - diff --git a/WiFiManager.h b/WiFiManager.h index 10dc176..a2fbba8 100644 --- a/WiFiManager.h +++ b/WiFiManager.h @@ -31,7 +31,7 @@ const char HTTP_PORTAL_OPTIONS[] PROGMEM = "
Scan"; @@ -43,16 +43,19 @@ const char HTTP_END[] PROGMEM = ""; class WiFiManagerParameter { public: WiFiManagerParameter(const char *id, const char *placeholder, const char *defaultValue, int length); + WiFiManagerParameter(const char *id, const char *placeholder, const char *defaultValue, int length, int rofield); const char *getID(); const char *getValue(); const char *getPlaceholder(); int getValueLength(); + const char *getRofield(); private: const char *_id; const char *_placeholder; char *_value; int _length; + const char *_rofield; friend class WiFiManager; };