ESPMegaPRO-v3-SDK/Template Project/lib/ESPMegaPRO/IoTComponent.cpp

22 lines
613 B
C++

#include <IoTComponent.hpp>
void IoTComponent::setMqttClient(PubSubClient *mqtt) {
this->mqtt = mqtt;
}
void IoTComponent::publishRelative(char *topic, char *payload) {
char absolute_topic[100];
sprintf(absolute_topic, "%s/%d/%s", base_topic, card_id, topic);
mqtt->publish(absolute_topic, payload);
}
void IoTComponent::subscribeRelative(char *topic) {
Serial.println("Subscribe relative");
char absolute_topic[50];
sprintf(absolute_topic, "%s/%d/%s", base_topic, card_id, topic);
mqtt->subscribe(absolute_topic);
}
void IoTComponent::loop() {
// Placeholder, Do nothing
}