diff --git a/src/lib/ebus/message.cpp b/src/lib/ebus/message.cpp index a340e831..1a4e38e0 100644 --- a/src/lib/ebus/message.cpp +++ b/src/lib/ebus/message.cpp @@ -106,9 +106,8 @@ result_t Message::create(vector::iterator& it, const vector::ite char last = str[len-1]; if (last >= '0' && last <= '9') { // poll priority (=active get) pollPriority = last - '0'; - defaultName = string(str).substr(0, len-1); // cut off priority digit - } - else + defaultName = string(str).substr(0, len - 1); // cut off priority digit + } else defaultName = str; } else if (strncasecmp(str, "W", 1) == 0) { // active set isSet = true; @@ -425,7 +424,8 @@ Message* MessageMap::find(const string& clazz, const string& name, const bool is return NULL; } -deque MessageMap::findAll(const string& clazz, const string& name, const short pb, const bool completeMatch) +deque MessageMap::findAll(const string& clazz, const string& name, const short pb, const bool completeMatch, + const bool withRead, const bool withWrite, const bool withPassive) { deque ret; @@ -448,6 +448,16 @@ deque MessageMap::findAll(const string& clazz, const string& name, con } if (checkPb == true && message->getId()[0] != pb) continue; + if (message->isPassive() == true) { + if (withPassive == false) + continue; + } else if (message->isSet() == true) { + if (withWrite == false) + continue; + } else { + if (withRead == false) + continue; + } ret.push_back(message); } diff --git a/src/lib/ebus/message.h b/src/lib/ebus/message.h index fd070295..5d333662 100644 --- a/src/lib/ebus/message.h +++ b/src/lib/ebus/message.h @@ -326,12 +326,16 @@ public: * @brief Find all active get @a Message instances for the specified class and name. * @param clazz the device class, or empty for any. * @param name the message name, or empty for any. - * @param pb the primary ID byte, or -1 for any. - * @param completeMatch false to also include messages where the class and name matches only a part of the given class and name. + * @param pb the primary ID byte, or -1 for any (default any). + * @param completeMatch false to also include messages where the class and name matches only a part of the given class and name (default true). + * @param withRead true to include read messages (default true). + * @param withWrite true to include write messages (default false). + * @param withPassive true to include passive messages (default false). * @return the found @a Message instances. * Note: the caller may not free the returned instances. */ - deque findAll(const string& clazz, const string& name, const short pb, const bool completeMatch=true); + deque findAll(const string& clazz, const string& name, const short pb=-1, const bool completeMatch=true, + const bool withRead=true, const bool withWrite=false, const bool withPassive=false); /** * @brief Find the @a Message instance for the specified master data.