Skip to content

Commit

Permalink
Send success/failed message on config.
Browse files Browse the repository at this point in the history
  • Loading branch information
shajen committed Oct 6, 2023
1 parent b723daf commit 3ad52da
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions sources/network/remote_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,18 @@ constexpr auto STATUS = "status";
constexpr auto CONFIG = "config";
constexpr auto MANUAL_RECORDING = "manual_recording";
constexpr auto RESTART = "restart";
constexpr auto SUCCESS = "success";
constexpr auto FAILED = "failed";

std::string generateTopic(const std::string& subtopic, const std::string& id = "") {
std::string generateTopic(const std::string& subtopic, const std::string& id = "", const std::string& subtopic2 = "") {
if (id.empty()) {
return "sdr/" + subtopic;
} else {
return "sdr/" + subtopic + "/" + id;
if (subtopic2.empty()) {
return "sdr/" + subtopic + "/" + id;
} else {
return "sdr/" + subtopic + "/" + id + "/" + subtopic2;
}
}
}

Expand Down Expand Up @@ -94,8 +100,10 @@ void RemoteController::configCallback(const std::string& data) {
try {
m_config.updateConfig(data);
m_reloadConfig = true;
m_mqtt.publish(generateTopic(CONFIG, m_id, SUCCESS), "", 2);
} catch (const std::exception& e) {
Logger::warn("rc", "invalid config");
m_mqtt.publish(generateTopic(CONFIG, m_id, FAILED), "", 2);
}
}

Expand Down

0 comments on commit 3ad52da

Please sign in to comment.