@@ -15,29 +15,28 @@ constexpr auto LABEL = "remote";
1515
1616using namespace std ::placeholders;
1717
18- RemoteController::RemoteController (const Config& config, const std::string& id, Mqtt& mqtt, std::function<void (const nlohmann::json&)> configCallback)
19- : m_config(config), m_id(id), m_mqtt(mqtt), m_configCallback(configCallback) {
18+ RemoteController::RemoteController (const Config& config, Mqtt& mqtt, std::function<void (const nlohmann::json&)> configCallback) : m_config(config), m_mqtt(mqtt), m_configCallback(configCallback) {
2019 mqtt.setMessageCallback (fmt::format (" sdr/{}" , LIST), std::bind (&RemoteController::listCallback, this , _1));
21- mqtt.setMessageCallback (fmt::format (" sdr/{}/{}" , CONFIG, m_id ), std::bind (&RemoteController::configCallback, this , _1));
20+ mqtt.setMessageCallback (fmt::format (" sdr/{}/{}" , CONFIG, m_config. getId () ), std::bind (&RemoteController::configCallback, this , _1));
2221 mqtt.setMessageCallback (fmt::format (" sdr/{}" , MANUAL_RECORDING), std::bind (&RemoteController::manualRecordingCallback, this , _1));
23- mqtt.setMessageCallback (fmt::format (" sdr/{}/{}" , RESTART, m_id ), std::bind (&RemoteController::restartCallback, this , _1));
24- Logger::info (LABEL, " started, id: {}" , colored (GREEN, " {}" , m_id ));
22+ mqtt.setMessageCallback (fmt::format (" sdr/{}/{}" , RESTART, m_config. getId () ), std::bind (&RemoteController::restartCallback, this , _1));
23+ Logger::info (LABEL, " started, id: {}" , colored (GREEN, " {}" , m_config. getId () ));
2524}
2625
2726void RemoteController::listCallback (const std::string&) {
2827 Logger::info (LABEL, " received list" );
29- m_mqtt.publish (fmt::format (" sdr/{}/{}" , STATUS, m_id ), m_config.json ().dump (), 2 );
28+ m_mqtt.publish (fmt::format (" sdr/{}/{}" , STATUS, m_config. getId () ), m_config.json ().dump (), 2 );
3029}
3130
3231void RemoteController::configCallback (const std::string& data) {
3332 Logger::info (LABEL, " received config" );
3433 try {
3534 const auto json = nlohmann::json::parse (data);
3635 m_configCallback (json);
37- m_mqtt.publish (fmt::format (" sdr/{}/{}/{}" , CONFIG, m_id , SUCCESS), " " , 2 );
36+ m_mqtt.publish (fmt::format (" sdr/{}/{}/{}" , CONFIG, m_config. getId () , SUCCESS), " " , 2 );
3837 } catch (const std::exception& e) {
3938 Logger::warn (LABEL, " invalid config" );
40- m_mqtt.publish (fmt::format (" sdr/{}/{}/{}" , CONFIG, m_id , FAILED), " " , 2 );
39+ m_mqtt.publish (fmt::format (" sdr/{}/{}/{}" , CONFIG, m_config. getId () , FAILED), " " , 2 );
4140 }
4241}
4342
0 commit comments