using namespace std;
-#define ADDRESS "tcp://10.0.1.213:1883"
-
#define QOS 1
#define TIMEOUT 10000L
MQTTClient_message pubmsg = MQTTClient_message_initializer;
MQTTClient_deliveryToken token;
int rc;
- MQTTClient_create(&mClient, ADDRESS, mClientID.c_str(),
+ MQTTClient_create(&mClient, mBroker.c_str(), mClientID.c_str(),
MQTTCLIENT_PERSISTENCE_NONE, NULL);
if ((rc = MQTTClient_setCallbacks(mClient, this, connlost, msgarrvd, delivered)) != MQTTCLIENT_SUCCESS)
void SetHeatingController(std::unique_ptr<HeatingController>&& aController) { mHeatingController = std::move(aController); }
void SetMeasurementInterval(std::chrono::milliseconds aMS) { mMeasurementInterval = aMS; }
void SetTopic(const std::string& aTopic) { mTopic = aTopic; }
+ void SetBroker(const std::string& aBroker) { mBroker = aBroker; }
void SetSetpoint(float aTemperature);
std::condition_variable mSetpointUpdateCV;
std::chrono::milliseconds mMeasurementInterval;
std::string mTopic;
+ std::string mBroker;
};
\ No newline at end of file
exit(EXIT_FAILURE);
}
- string line, topic, clientid;
+ string line, topic, clientid, broker;
unique_ptr<TemperatureSupplier> tempSupplier;
unique_ptr<HeatingController> heatingController;
uint32_t measurementInterval;
else if (key == "clientid") {
clientid = value;
}
+ else if (key == "broker") {
+ broker = value;
+ }
else if (key == "gpio heating pin") {
gpioHeatingPin = stoi(value);
}
MQTTThermostat::instance().SetMeasurementInterval(chrono::milliseconds{ measurementInterval });
MQTTThermostat::instance().SetTopic(topic);
MQTTThermostat::instance().SetClientID(clientid);
+ MQTTThermostat::instance().SetBroker(broker);
}
void daemonize()
MQTTThermostat::instance().SetMeasurementInterval(2000ms);
MQTTThermostat::instance().SetTopic("bedroom-staging/thermostat/");
MQTTThermostat::instance().SetClientID("bedroom-staging");
+ MQTTThermostat::instance().SetBroker("10.0.1.225");
MQTTThermostat::instance().Start();
return 0;
heating controller=dummy
measurement interval=2000
topic=staging/thermostat/
-clientid=staging
\ No newline at end of file
+clientid=staging
+broker=127.0.0.1
\ No newline at end of file