Skip to content

Commit

Permalink
[MQTT] fppd_status add additional fields
Browse files Browse the repository at this point in the history
Add Hostname, Description, and Platform.
This addresses part of the requirements in #1782
  • Loading branch information
ghormann committed Mar 31, 2024
1 parent 40e657d commit 35bb00a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
6 changes: 6 additions & 0 deletions src/common.cpp
Expand Up @@ -673,4 +673,10 @@ void SetThreadName(const std::string& name) {
#else
pthread_setname_np(pthread_self(), name.c_str());
#endif
}

std::string getPlatform() {
std::string platform = GetFileContents("/etc/fpp/platform");
TrimWhiteSpace(platform);
return platform;
}
18 changes: 10 additions & 8 deletions src/common.h
Expand Up @@ -28,14 +28,14 @@

#define PRINTF_BINARY_PATTERN_INT8 "%c%c%c%c%c%c%c%c"
#define PRINTF_BYTE_TO_BINARY_INT8(i) \
(((i) & 0x80ll) ? '1' : '0'), \
(((i) & 0x40ll) ? '1' : '0'), \
(((i) & 0x20ll) ? '1' : '0'), \
(((i) & 0x10ll) ? '1' : '0'), \
(((i) & 0x08ll) ? '1' : '0'), \
(((i) & 0x04ll) ? '1' : '0'), \
(((i) & 0x02ll) ? '1' : '0'), \
(((i) & 0x01ll) ? '1' : '0')
(((i)&0x80ll) ? '1' : '0'), \
(((i)&0x40ll) ? '1' : '0'), \
(((i)&0x20ll) ? '1' : '0'), \
(((i)&0x10ll) ? '1' : '0'), \
(((i)&0x08ll) ? '1' : '0'), \
(((i)&0x04ll) ? '1' : '0'), \
(((i)&0x02ll) ? '1' : '0'), \
(((i)&0x01ll) ? '1' : '0')

#define PRINTF_BINARY_PATTERN_INT16 \
PRINTF_BINARY_PATTERN_INT8 PRINTF_BINARY_PATTERN_INT8
Expand Down Expand Up @@ -89,6 +89,8 @@ void RegisterShutdownHandler(const std::function<void(bool)> hook);

void GetCurrentFPPDStatus(Json::Value& result);

std::string getPlatform();

inline std::string toStdStringAndFree(char* v) {
std::string s = v;
free(v);
Expand Down
6 changes: 6 additions & 0 deletions src/httpAPI.cpp
Expand Up @@ -63,14 +63,20 @@ static std::time_t startupTime = std::time(nullptr);
*/
void GetCurrentFPPDStatus(Json::Value& result) {
static std::string UUID = getSetting("SystemUUID");
static std::string host_name = getSetting("HostName");
static std::string host_description = getSetting("HostDescription");
static std::string fpp_version = getFPPVersion();
static std::string fppd_branch = getFPPBranch();
static std::string platform = getPlatform();

int mode = getFPPmode();
result["fppd"] = "running";
result["version"] = fpp_version;
result["branch"] = fppd_branch;
result["platform"] = platform;
result["uuid"] = UUID;
result["host_name"] = host_name;
result["host_description"] = host_description;
result["mode"] = mode;
result["mode_name"] = toStdStringAndFree(modeToString(getFPPmode()));
result["status"] = Player::INSTANCE.GetStatus();
Expand Down

0 comments on commit 35bb00a

Please sign in to comment.