From ea5337fdaab40556111ced0e24e058f87afb1fc5 Mon Sep 17 00:00:00 2001 From: John Date: Sat, 30 Apr 2022 15:37:23 +0200 Subject: [PATCH] add option to add bits to setDataHandlerState() --- src/lib/ebus/message.cpp | 6 +++--- src/lib/ebus/message.h | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/lib/ebus/message.cpp b/src/lib/ebus/message.cpp index fde34242..c8f66ff0 100644 --- a/src/lib/ebus/message.cpp +++ b/src/lib/ebus/message.cpp @@ -1027,11 +1027,11 @@ void Message::decodeJson(bool leadingSeparator, bool appendDirectionCondition, b *output << "\n }"; } -bool Message::setDataHandlerState(int state) { - if (state == m_dataHandlerState) { +bool Message::setDataHandlerState(int state, bool addBits) { + if (addBits ? state == (m_dataHandlerState&state) : state == m_dataHandlerState) { return false; } - m_dataHandlerState = state; + m_dataHandlerState = addBits ? m_dataHandlerState|state : state; return true; } diff --git a/src/lib/ebus/message.h b/src/lib/ebus/message.h index 8092a2c1..e09ad18a 100644 --- a/src/lib/ebus/message.h +++ b/src/lib/ebus/message.h @@ -534,9 +534,10 @@ class Message : public AttributedItem { /** * Set the arbitrary state value for data handlers. * @param state the new state value. + * @param addBits true to add the new state value bits to the existing state. * @return true when the state was changed. */ - bool setDataHandlerState(int state); + bool setDataHandlerState(int state, bool addBits = false); /** * Get the time when this message was last seen with reasonable data.