initializer changes
This commit is contained in:
parent
9fa8cbc4b1
commit
17160e586b
|
@ -5,7 +5,7 @@ class AnalogIoT : public IoTComponent {
|
|||
public:
|
||||
AnalogIoT();
|
||||
~AnalogIoT();
|
||||
bool begin(AnalogCard *card);
|
||||
bool begin(AnalogCard *card, void (*publishRelative)(uint8_t, char *, char *), PubSubClient *mqtt, char *base_topic);
|
||||
void handleMqttMessage(char *topic, char *payload);
|
||||
void publishADCs();
|
||||
void setADCsPublishInterval(uint32_t interval);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
class DigitalInputIoT : public IoTComponent {
|
||||
public:
|
||||
bool begin(DigitalInputCard *card);
|
||||
bool begin(DigitalInputCard *card, void (*publishRelative)(uint8_t, char *, char *), PubSubClient *mqtt, char *base_topic);
|
||||
void handleMqttMessage(char *topic, char *payload);
|
||||
void publishDigitalInputs();
|
||||
void setDigitalInputsPublishEnabled(bool enabled);
|
||||
|
@ -15,6 +15,5 @@ class DigitalInputIoT : public IoTComponent {
|
|||
uint8_t getType();
|
||||
private:
|
||||
bool digital_inputs_publish_enabled = false;
|
||||
|
||||
DigitalInputCard *card;
|
||||
};
|
|
@ -10,7 +10,10 @@ DigitalOutputIoT::~DigitalOutputIoT() {
|
|||
delete[] this->value_report_topic;
|
||||
}
|
||||
|
||||
bool DigitalOutputIoT::begin(ExpansionCard *card) {
|
||||
bool DigitalOutputIoT::begin(ExpansionCard *card, void (*publishRelative)(uint8_t, char *, char *), PubSubClient *mqtt, char *base_topic) {
|
||||
this->mqtt = mqtt;
|
||||
this->base_topic = base_topic;
|
||||
this->publishRelative = publishRelative;
|
||||
this->card = (DigitalOutputCard *) card;
|
||||
this->set_state_length = strlen(SET_STATE_TOPIC);
|
||||
this->set_value_length = strlen(SET_VALUE_TOPIC);
|
||||
|
|
|
@ -7,7 +7,7 @@ class DigitalOutputIoT : public IoTComponent {
|
|||
public:
|
||||
DigitalOutputIoT();
|
||||
~DigitalOutputIoT();
|
||||
bool begin(ExpansionCard *card);
|
||||
bool begin(ExpansionCard *card, void (*publishRelative)(uint8_t, char *, char *), PubSubClient *mqtt, char *base_topic);
|
||||
void handleMqttMessage(char *topic, char *payload);
|
||||
void publishDigitalOutputs();
|
||||
void publishDigitalOutput(uint8_t pin);
|
||||
|
|
|
@ -19,3 +19,28 @@ void ESPMegaIoT::mqttCallback(char *topic, byte *payload, unsigned int length) {
|
|||
components[card_id]->handleMqttMessage(topic_without_base + 3, payload_buffer);
|
||||
}
|
||||
|
||||
void ESPMegaIoT::setBaseTopic(char *base_topic) {
|
||||
strcpy(this->base_topic, base_topic);
|
||||
base_topic_length = strlen(base_topic);
|
||||
}
|
||||
|
||||
void ESPMegaIoT::begin() {
|
||||
|
||||
}
|
||||
void ESPMegaIoT::loop();
|
||||
void ESPMegaIoT::registerCard(uint8_t card_id);
|
||||
void ESPMegaIoT::deregisterCard(uint8_t card_id);
|
||||
void ESPMegaIoT::publishCard(uint8_t card_id);
|
||||
void ESPMegaIoT::subscribeToTopic(char *topic);
|
||||
void ESPMegaIoT::unsubscribeFromTopic(char *topic);
|
||||
void ESPMegaIoT::connectToEthernet();
|
||||
bool ESPMegaIoT::ethernetConnected();
|
||||
void ESPMegaIoT::connectToWifi(char *ssid, char *password);
|
||||
void ESPMegaIoT::connectToWifi(char *ssid);
|
||||
void ESPMegaIoT::disconnectFromWifi();
|
||||
bool ESPMegaIoT::wifiConnected();
|
||||
void ESPMegaIoT::connectToMqtt(char *mqtt_server, uint16_t mqtt_port, char *mqtt_user, char *mqtt_password);
|
||||
void ESPMegaIoT::connectToMqtt(char *mqtt_server, uint16_t mqtt_port);
|
||||
void ESPMegaIoT::disconnectFromMqtt();
|
||||
void ESPMegaIoT::publishToTopic(char *topic, char *payload);
|
||||
void ESPMegaIoT::registerMqttCallback(void (*callback)(char *, char *));
|
||||
|
|
|
@ -30,15 +30,19 @@ class ESPMegaIoT
|
|||
void disconnectFromMqtt();
|
||||
void publishToTopic(char *topic, char *payload);
|
||||
void registerMqttCallback(void (*callback)(char *, char *));
|
||||
void setBaseTopic(char *base_topic);
|
||||
|
||||
|
||||
private:
|
||||
void sessionKeepAlive();
|
||||
void mqttReconnect();
|
||||
void wifiReconnect();
|
||||
void mqttCallback(char *topic, byte *payload, unsigned int length);
|
||||
void publishRelative(char *topic, char *payload);
|
||||
PubSubClient mqtt;
|
||||
IoTComponent *components[255];
|
||||
bool card_publish_enabled[255];
|
||||
char payload_buffer[200];
|
||||
char base_topic[100];
|
||||
uint8_t base_topic_length;
|
||||
};
|
|
@ -3,11 +3,13 @@
|
|||
#include <PubSubClient.h>
|
||||
class IoTComponent {
|
||||
public:
|
||||
virtual bool begin(ExpansionCard *card);
|
||||
virtual bool begin(ExpansionCard *card, void (*publishRelative)(uint8_t, char *, char *), PubSubClient *mqtt, char *base_topic);
|
||||
virtual void handleMqttMessage(char *topic, char *payload);
|
||||
void setMqttClient(PubSubClient *mqtt);
|
||||
virtual void publishReport();
|
||||
virtual uint8_t getType();
|
||||
protected:
|
||||
char *base_topic;
|
||||
void (*publishRelative)(uint8_t, char *, char *);
|
||||
PubSubClient *mqtt;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue