Skip to content

Commit

Permalink
Remove internal calls to deprecated addPropertyReal
Browse files Browse the repository at this point in the history
  • Loading branch information
mirkokurt committed Feb 19, 2024
1 parent 7b125f4 commit 5675efc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 21 deletions.
10 changes: 9 additions & 1 deletion src/ArduinoIoTCloudTCP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,15 @@ Property& ArduinoIoTCloudTCP::addInternalPropertyReal(Property& property, String

void ArduinoIoTCloudTCP::addInternalPropertyReal(Property& property, String name, int tag, permissionType permission_type, long seconds, void(*fn)(void), float minDelta, void(*synFn)(Property & property))
{
_arduinoCloudThing.addPropertyReal(property, name, tag, permission_type, seconds, fn, minDelta, synFn);
Permission permission = Permission::ReadWrite;
if (permission_type == READ) {
permission = Permission::Read;
} else if (permission_type == WRITE) {
permission = Permission::Write;
} else {
permission = Permission::ReadWrite;
}
_arduinoCloudThing.addPropertyReal(property, name, tag, permission).publishOnChange(minDelta, Property::DEFAULT_MIN_TIME_BETWEEN_UPDATES_MILLIS).onUpdate(fn).onSync(synFn);
}

void ArduinoIoTCloudTCP::push()
Expand Down
21 changes: 3 additions & 18 deletions src/ArduinoIoTCloudTCPThing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,27 +105,12 @@ int ArduinoIoTCloudTCPThing::connected()
return _mqttClient->connected();
}

Property& ArduinoIoTCloudTCPThing::addPropertyReal(Property& property, String name, int tag, Permission const permission)
Property& ArduinoIoTCloudTCPThing::addPropertyReal(Property& property, String name, int tag, Permission const permission, long seconds, void(*fn)(void), float minDelta, void(*synFn)(Property & property))
{
return addPropertyToContainer(_thing_property_container, property, name, permission, tag);
}

void ArduinoIoTCloudTCPThing::addPropertyReal(Property& property, String name, int tag, permissionType permission_type, long seconds, void(*fn)(void), float minDelta, void(*synFn)(Property & property))
{
Permission permission = Permission::ReadWrite;
if (permission_type == READ) {
permission = Permission::Read;
} else if (permission_type == WRITE) {
permission = Permission::Write;
} else {
permission = Permission::ReadWrite;
}

if (seconds == ON_CHANGE) {
addPropertyToContainer(_thing_property_container, property, name, permission, tag).publishOnChange(minDelta, Property::DEFAULT_MIN_TIME_BETWEEN_UPDATES_MILLIS).onUpdate(fn).onSync(synFn);
} else {
addPropertyToContainer(_thing_property_container, property, name, permission, tag).publishEvery(seconds).onUpdate(fn).onSync(synFn);
return addPropertyToContainer(_thing_property_container, property, name, permission, tag).publishOnChange(minDelta, Property::DEFAULT_MIN_TIME_BETWEEN_UPDATES_MILLIS).onUpdate(fn).onSync(synFn);
}
return addPropertyToContainer(_thing_property_container, property, name, permission, tag).publishEvery(seconds).onUpdate(fn).onSync(synFn);
}

void ArduinoIoTCloudTCPThing::push()
Expand Down
3 changes: 1 addition & 2 deletions src/ArduinoIoTCloudTCPThing.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ class ArduinoIoTCloudTCPThing
int connected();
void updateTimezoneInfo();

void addPropertyReal(Property& property, String name, int tag, permissionType permission_type = READWRITE, long seconds = ON_CHANGE, void(*fn)(void) = NULL, float minDelta = 0.0f, void(*synFn)(Property & property) = CLOUD_WINS);
Property& addPropertyReal(Property& property, String name, int tag, Permission const permission);
Property& addPropertyReal(Property& property, String name, int tag, Permission const permission, long seconds = ON_CHANGE, void(*fn)(void) = NULL, float minDelta = 0.0f, void(*synFn)(Property & property) = CLOUD_WINS);

void push();
bool setTimestamp(String const & prop_name, unsigned long const timestamp);
Expand Down

0 comments on commit 5675efc

Please sign in to comment.