Skip to content

Commit

Permalink
Add some ConnectStatusCode helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
peternewman committed Dec 27, 2023
1 parent c73d3b3 commit 7c44c8b
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
5 changes: 5 additions & 0 deletions include/ola/e133/E133StatusHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_
46 changes: 46 additions & 0 deletions tools/e133/E133StatusHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 7c44c8b

Please sign in to comment.