Skip to content
This repository was archived by the owner on Aug 18, 2020. It is now read-only.

fix_boolean_management #49

Merged
merged 2 commits into from
Dec 16, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/ArduinoCloudProperty.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,18 @@ void ArduinoCloudProperty::setAttributesFromCloud(LinkedList<CborMapData *> *map

void ArduinoCloudProperty::setAttributeReal(bool& value, String attributeName) {
setAttributeReal(attributeName, [&value](CborMapData * md) {
value = md->bool_val.get();
// Manage the case to have boolean values received as integers 0/1
if (md->bool_val.isSet()) {
value = md->bool_val.get();
} else if (md->val.isSet()) {
if (md->val.get() == 0) {
value = false;
} else if (md->val.get() == 1) {
value = true;
} else {
/* This should not happen. Leave the previous value */
}
}
});
}

Expand Down