Skip to content

Commit

Permalink
Merge pull request #7 from ayushsharma82/dev
Browse files Browse the repository at this point in the history
fix: parameter value getter-setters
  • Loading branch information
ayushsharma82 authored Jul 18, 2024
2 parents 82c7b20 + 6b886d4 commit 55e5cdd
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 8 deletions.
4 changes: 2 additions & 2 deletions examples/AsyncDemo/AsyncDemo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ void setup(void) {
Serial.println("NW onConfig Received");

// Print new parameter values
Serial.printf("Host: %s\n", nw_mqtt_host.getValue().c_str());
Serial.printf("Port: %s\n", nw_mqtt_port.getValue().c_str());
Serial.printf("Host: %s\n", nw_mqtt_host.getValueStr().c_str());
Serial.printf("Port: %s\n", nw_mqtt_port.getValueStr().c_str());
return true; // <-- return true to approve request, false to reject
});

Expand Down
4 changes: 2 additions & 2 deletions examples/Demo/Demo.ino
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ void setup(void) {
Serial.println("NW onConfig Received");

// Print new parameter values
Serial.printf("Host: %s\n", nw_mqtt_host.getValue().c_str());
Serial.printf("Port: %s\n", nw_mqtt_port.getValue().c_str());
Serial.printf("Host: %s\n", nw_mqtt_host.getValueStr().c_str());
Serial.printf("Port: %s\n", nw_mqtt_port.getValueStr().c_str());
return true; // <-- return true to approve request, false to reject
});

Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"platforms": ["espressif8266", "raspberrypi"]
}
],
"version": "1.0.5",
"version": "1.0.6",
"frameworks": "arduino",
"platforms": ["espressif32", "raspberrypi"]
}
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=NetWizard
version=1.0.5
version=1.0.6
author=Ayush Sharma
category=Communication
maintainer=Ayush Sharma <asrocks5@gmail.com>
Expand Down
14 changes: 13 additions & 1 deletion src/NetWizardParameter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,22 @@ const int NetWizardParameter::getType() {
return _type;
}

String NetWizardParameter::getValue() {
const String& NetWizardParameter::getValue() {
return _value;
}

const String& NetWizardParameter::getValueStr() {
return _value;
}

void NetWizardParameter::getValue(String& value) {
value = _value;
}

void NetWizardParameter::setValue(const String& value) {
_value = value;
}

void NetWizardParameter::setValue(const char* value) {
_value = value;
}
Expand Down
9 changes: 8 additions & 1 deletion src/NetWizardParameter.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@ class NetWizardParameter {

const int getType();

String getValue();
[[deprecated("getValue has been replaced by getValueStr()")]]
const String& getValue();

const String& getValueStr();

void getValue(String& value);

void setValue(const String& value);
void setValue(const char* value);

String getPlaceholder();
Expand Down

0 comments on commit 55e5cdd

Please sign in to comment.