This commit is contained in:
Shawn A
2018-02-20 11:54:14 -06:00
parent 39f20a6adc
commit e01101eff1
3 changed files with 23 additions and 11 deletions
+16 -10
View File
@@ -31,6 +31,10 @@ WiFiManagerParameter::WiFiManagerParameter(const char *custom) {
_customHTML = custom;
}
WiFiManagerParameter::WiFiManagerParameter(const char *id, const char *placeholder) {
init(id, placeholder, "", 0, "", WFM_LABEL_BEFORE);
}
WiFiManagerParameter::WiFiManagerParameter(const char *id, const char *placeholder, const char *defaultValue, int length) {
init(id, placeholder, defaultValue, length, "", WFM_LABEL_BEFORE);
}
@@ -46,17 +50,9 @@ WiFiManagerParameter::WiFiManagerParameter(const char *id, const char *placehold
void WiFiManagerParameter::init(const char *id, const char *placeholder, const char *defaultValue, int length, const char *custom, int labelPlacement) {
_id = id;
_placeholder = placeholder;
_length = length;
_labelPlacement = labelPlacement;
_value = new char[length + 1];
for (int i = 0; i < length + 1; i++) {
_value[i] = 0;
}
if (defaultValue != NULL) {
strncpy(_value, defaultValue, length + 1); // length+1 due to null terminated string
}
_customHTML = custom;
_customHTML = custom;
setValue(defaultValue,length);
}
WiFiManagerParameter::~WiFiManagerParameter() {
@@ -65,6 +61,16 @@ WiFiManagerParameter::~WiFiManagerParameter() {
}
}
void WiFiManagerParameter::setValue(const char *defaultValue, int length) {
_length = length;
_value = new char[length + 1];
for (int i = 0; i < length + 1; i++) {
_value[i] = 0;
}
if (defaultValue != NULL) {
strncpy(_value, defaultValue, length + 1); // length+1 due to null terminated string
}
}
const char* WiFiManagerParameter::getValue() {
return _value;
}