From 7c44c8b9dd58cb99885082f1a15e5e751310b5aa Mon Sep 17 00:00:00 2001 From: Peter Newman Date: Wed, 27 Dec 2023 00:14:27 +0000 Subject: [PATCH] Add some ConnectStatusCode helpers --- include/ola/e133/E133StatusHelper.h | 5 ++++ tools/e133/E133StatusHelper.cpp | 46 +++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/include/ola/e133/E133StatusHelper.h b/include/ola/e133/E133StatusHelper.h index cd9680b029..7ca19412df 100644 --- a/include/ola/e133/E133StatusHelper.h +++ b/include/ola/e133/E133StatusHelper.h @@ -30,9 +30,14 @@ namespace e133 { using std::string; using ola::e133::E133StatusCode; +using ola::e133::E133ConnectStatusCode; bool IntToStatusCode(uint16_t input, E133StatusCode *status_code); string StatusCodeToString(E133StatusCode status_code); + +bool IntToConnectStatusCode(uint16_t input, + E133ConnectStatusCode *connect_status_code); +string ConnectStatusCodeToString(E133ConnectStatusCode connect_status_code); } // namespace e133 } // namespace ola #endif // INCLUDE_OLA_E133_E133STATUSHELPER_H_ diff --git a/tools/e133/E133StatusHelper.cpp b/tools/e133/E133StatusHelper.cpp index a87376425a..a1ec71627c 100644 --- a/tools/e133/E133StatusHelper.cpp +++ b/tools/e133/E133StatusHelper.cpp @@ -96,5 +96,51 @@ string StatusCodeToString(E133StatusCode status_code) { } return "Unknown E1.33 Status Code"; } + + +bool IntToConnectStatusCode(uint16_t input, + E133ConnectStatusCode *connect_status_code) { + switch (input) { + case ola::e133::CONNECT_OK: + *connect_status_code = ola::e133::CONNECT_OK; + return true; + case ola::e133::CONNECT_SCOPE_MISMATCH: + *connect_status_code = ola::e133::CONNECT_SCOPE_MISMATCH; + return true; + case ola::e133::CONNECT_CAPACITY_EXCEEDED: + *connect_status_code = ola::e133::CONNECT_CAPACITY_EXCEEDED; + return true; + case ola::e133::CONNECT_DUPLICATE_UID: + *connect_status_code = ola::e133::CONNECT_DUPLICATE_UID; + return true; + case ola::e133::CONNECT_INVALID_CLIENT_ENTRY: + *connect_status_code = ola::e133::CONNECT_INVALID_CLIENT_ENTRY; + return true; + case ola::e133::CONNECT_INVALID_UID: + *connect_status_code = ola::e133::CONNECT_INVALID_UID; + return true; + default: + return false; + } +} + + +string ConnectStatusCodeToString(E133ConnectStatusCode connect_status_code) { + switch (connect_status_code) { + case ola::e133::CONNECT_OK: + return "Ok"; + case ola::e133::CONNECT_SCOPE_MISMATCH: + return "Scope mismatch"; + case ola::e133::CONNECT_CAPACITY_EXCEEDED: + return "Capacity exceeded"; + case ola::e133::CONNECT_DUPLICATE_UID: + return "Duplicate UID"; + case ola::e133::CONNECT_INVALID_CLIENT_ENTRY: + return "Invalid client entry"; + case ola::e133::CONNECT_INVALID_UID: + return "Invalid UID"; + } + return "Unknown E1.33 Connect Status Code"; +} } // namespace e133 } // namespace ola