You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
#include "mqtt_config.hpp"
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <string>
using namespace std; using namespace nlohmann; using namespace iflytop;
void MQTTConfig::initialize(string file_name) { std::ifstream jfile(file_name); jfile >> m_mqttConfigJson; jfile.close(); try { m_address = m_mqttConfigJson["address"]; m_username = m_mqttConfigJson["username"]; m_password = m_mqttConfigJson["password"]; m_clientid = m_mqttConfigJson["clientid"]; m_qos = m_mqttConfigJson["qos"]; m_topic = m_mqttConfigJson["topic"]; m_timeout = m_mqttConfigJson["timeout"]; } catch (const std::exception& e) { std::cerr << "mqtt_config_read error: " << e.what() << '\n'; } }
string MQTTConfig::dump() { sstream ret; ret << "==========================mqtt_config_dump_start===========================" << endl; ret << "address = " << getAddress() << endl; ret << "username = " << getUsername() << endl; ret << "password = " << getPassword() << endl; ret << "clientid = " << getClientid() << endl; ret << "qos = " << getQos() << endl; ret << "topic = " << getTopic() << endl; ret << "timeout = " << getTimeout() << endl; ret << "===========================mqtt_config_dump_end============================" << endl; return ret.str(); }
string MQTTConfig::getAddress() { return m_address; } string MQTTConfig::getUsername() { return m_username; } string MQTTConfig::getPassword() { return m_password; } string MQTTConfig::getClientid() { return m_clientid; } int MQTTConfig::getQos() { return m_qos; } string MQTTConfig::getTopic() { return m_topic; } int MQTTConfig::getTimeout() { return m_timeout; }
|