#include #include #include #include #include #include #include #include #include #include class ESPMegaIoT { public: ESPMegaIoT(); void intr_begin(ExpansionCard *cards[]); void loop(); void registerCard(uint8_t card_id); void deregisterCard(uint8_t card_id); void publishCard(uint8_t card_id); // Publish topic appended with base topic void publishRelative(char *topic, char *payload); // Subscribe topic appended with base topic void subscribeRelative(char *topic); void subscribeToTopic(char *topic); void unsubscribeFromTopic(char *topic); void connectToWifi(char *ssid, char *password); void connectToWifi(char *ssid); void disconnectFromWifi(); bool wifiConnected(); bool connectToMqtt(char *client_id, char *mqtt_server, uint16_t mqtt_port, char *mqtt_user, char *mqtt_password); bool connectToMqtt(char *client_id, char *mqtt_server, uint16_t mqtt_port); void disconnectFromMqtt(); void publishToTopic(char *topic, char *payload); void registerMqttCallback(void (*callback)(char *, char *)); void registerRelativeMqttCallback(void (*callback)(char *, char *)); void setBaseTopic(char *base_topic); IPAddress getETHIp(); private: WiFiClient tcpClient; void sessionKeepAlive(); bool mqttReconnect(); void wifiReconnect(); void mqttSubscribe(); void mqttCallback(char *topic, byte *payload, unsigned int length); void (*user_mqtt_callback)(char *, char *); void (*user_relative_mqtt_callback)(char *, char *); void publishRelative(uint8_t card_id, char *topic, char *payload); bool active; PubSubClient mqtt; IoTComponent *components[255]; char payload_buffer[200]; char base_topic[100]; uint8_t base_topic_length; ExpansionCard **cards; // Points to card array in ESPMegaPRO Core // MQTT Connection Parameters char *mqtt_server; uint16_t mqtt_port; char *mqtt_user; char *mqtt_password; char *client_id; bool mqtt_useauth; bool mqtt_connected; };