diff --git a/src/lib/ebus/symbol.cpp b/src/lib/ebus/symbol.cpp index c98027f6..9a979958 100644 --- a/src/lib/ebus/symbol.cpp +++ b/src/lib/ebus/symbol.cpp @@ -187,3 +187,7 @@ bool isMaster(unsigned char addr) { && ((addrLo == 0x0) || (addrLo == 0x1) || (addrLo == 0x3) || (addrLo == 0x7) || (addrLo == 0xF)); } +bool isValidAddress(unsigned char addr, bool allowBroadcast) { + return addr != SYN && addr != ESC && (allowBroadcast == true || addr != BROADCAST); +} + diff --git a/src/lib/ebus/symbol.h b/src/lib/ebus/symbol.h index 98b74d3d..db48095f 100644 --- a/src/lib/ebus/symbol.h +++ b/src/lib/ebus/symbol.h @@ -135,4 +135,12 @@ private: */ bool isMaster(unsigned char addr); +/** + * Returns whether the address is a valid bus address. + * @param addr the address to check. + * @param allowBroadcast whether to also allow @a addr to be the broadcast address (default true). + * @return true if the specified address is a valid bus address. + */ +bool isValidAddress(unsigned char addr, bool allowBroadcast=true); + #endif // LIBEBUS_SYMBOL_H_