Clear map for recieved key, value pairs

This commit is contained in:
helgeerbe 2022-10-04 11:34:30 +02:00
parent 9c71652b2c
commit ba3183e10b
2 changed files with 4 additions and 10 deletions

View File

@ -173,6 +173,7 @@ void VeDirectFrameHandler::rxData(uint8_t inbyte)
void VeDirectFrameHandler::frameEndEvent(bool valid) {
if ( valid ) {
veMap = _tmpMap;
_tmpMap.clear();
setLastUpdate();
}
}

View File

@ -33,21 +33,13 @@ void MqttVedirectPublishingClass::loop()
key = it->first;
value = it->second;
// Add new key, value pairs to map and update changed values.
// Mark changed values
auto a = _kv_map.find(key);
bChanged = true;
if (a != _kv_map.end()) {
if (_kv_map[key] == value) {
bChanged = false;
}
else {
_kv_map[key] = value;
bChanged = true;
}
}
else {
_kv_map.insert(std::make_pair(key, value));
bChanged = true;
}
// publish only changed key, values pairs
@ -57,6 +49,7 @@ void MqttVedirectPublishingClass::loop()
MqttSettings.publish(topic.c_str(), value.c_str());
}
}
_kv_map = VeDirect.veMap;
_lastPublish = millis();
}
}