-
Notifications
You must be signed in to change notification settings - Fork 204
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7c44c8b
commit eb97fb4
Showing
4 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2.1 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
* | ||
* E133Helper.h | ||
* Various misc E1.33 functions. | ||
* Copyright (C) 2024 Peter Newman | ||
*/ | ||
|
||
#ifndef INCLUDE_OLA_E133_E133HELPER_H_ | ||
#define INCLUDE_OLA_E133_E133HELPER_H_ | ||
|
||
#include <stdint.h> | ||
#include <ola/e133/E133Enums.h> | ||
#include <string> | ||
|
||
namespace ola { | ||
namespace e133 { | ||
|
||
bool IntToRPTClientType(uint8_t input, | ||
ola::e133::E133RPTClientTypeCode *client_type); | ||
std::string RPTClientTypeToString(uint8_t type); | ||
} // namespace e133 | ||
} // namespace ola | ||
#endif // INCLUDE_OLA_E133_E133HELPER_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2.1 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
* | ||
* E133Helper.cpp | ||
* Various misc E1.33 functions. | ||
* Copyright (C) 2024 Peter Newman | ||
* | ||
* At some point we may want to localize this file. | ||
*/ | ||
|
||
#include <sstream> | ||
#include <string> | ||
#include <vector> | ||
#include "ola/e133/E133Enums.h" | ||
#include "ola/e133/E133Helper.h" | ||
#include "ola/StringUtils.h" | ||
|
||
namespace ola { | ||
namespace e133 { | ||
|
||
using std::ostringstream; | ||
using std::string; | ||
using std::vector; | ||
|
||
|
||
/** | ||
* Verify that the int is a valid E1.33 RPT Client Type. | ||
*/ | ||
bool IntToRPTClientType(uint8_t input, | ||
ola::e133::E133RPTClientTypeCode *client_type) { | ||
switch (input) { | ||
case ola::e133::RPT_CLIENT_TYPE_DEVICE: | ||
*client_type = ola::e133::RPT_CLIENT_TYPE_DEVICE; | ||
return true; | ||
case ola::e133::RPT_CLIENT_TYPE_CONTROLLER: | ||
*client_type = ola::e133::RPT_CLIENT_TYPE_CONTROLLER; | ||
return true; | ||
default: | ||
return false; | ||
} | ||
} | ||
|
||
|
||
/** | ||
* Convert a uint8_t representing an RPT client type to a human-readable string. | ||
* @param type the RPT client type value | ||
*/ | ||
string RPTClientTypeToString(uint8_t type) { | ||
switch (type) { | ||
case RPT_CLIENT_TYPE_DEVICE: | ||
return "Device"; | ||
case RPT_CLIENT_TYPE_CONTROLLER: | ||
return "Controller"; | ||
default: | ||
ostringstream str; | ||
str << "Unknown, was " << static_cast<int>(type); | ||
return str.str(); | ||
} | ||
} | ||
} // namespace e133 | ||
} // namespace ola |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters