23 lines
768 B
C++
23 lines
768 B
C++
#include <HAControllableDevice.hpp>
|
|
|
|
HAControllableDevice::HAControllableDevice(PubSubClient &client,
|
|
const char *device_type,
|
|
const char *name,
|
|
const char *unique_id)
|
|
: HADevice(client, device_type, name, unique_id) {
|
|
setupCommandTopic();
|
|
}
|
|
|
|
void HAControllableDevice::setupCommandTopic() {
|
|
command_topic_size = strlen(device_topic) + 4 + 1;
|
|
command_topic = (char *)malloc(command_topic_size);
|
|
|
|
strcpy(command_topic, device_topic);
|
|
strcat(command_topic, "/cmd");
|
|
}
|
|
|
|
void HAControllableDevice::subscribeToCommandTopic() {
|
|
Serial.print("Subscribe to ");
|
|
Serial.println(command_topic);
|
|
client.subscribe(command_topic);
|
|
}; |