Page 1 of 1

updateAndReport() issues possibly a bug?

Posted: Sun Nov 17, 2024 5:44 pm
by themindfactory
I have tested this extensively and hence I am thinking maybe a bug.

I have a toggle switch defined and shows up as such in the RM app.

When I toggle the switch I get messages in the callback to its new state.

When the code starts it sets the switch on with value(true)

Code: Select all

showPosition = Param("Show Position", ESP_RMAKER_PARAM_CCT, value(true), PROP_FLAG_READ | PROP_FLAG_WRITE);
setValue(showPosition, value(true));
showPosition.addUIType(ESP_RMAKER_UI_TOGGLE);
my_setup->addParam(showPosition);
After 10 seconds the code calls setValue with value(false) ie. setValue(value(false)) and I see the switch in the RM app move to off.

I then toggle that switch back on and I see the message in the callback say the state is now true.

The code then again sends the same value to setValue ie. setValue(value(false)) however this time the switch does not return to off in the RM app. No matter how many times you send setValue(value(false)) it will never again show the off state in the app. It only turns the toggle off the first time.

Code: Select all

void setValue(Param &p, param_val_t v) {
  values[p.getParamName()] = v;  // std::map<const char*, param_val_t>
  p.updateAndReport(v);
  Serial.printf("Manually Set %s to '%s'\n", p.getParamName(), value(p).c_str()); // this is an overloaded value(Param) function that returns the state in a String
}