2023-12-27 20:09:41 +00:00
|
|
|
#include <ExpansionCard.hpp>
|
|
|
|
#include <AnalogCard.hpp>
|
2023-12-28 04:41:20 +00:00
|
|
|
#include <AnalogIoT.hpp>
|
2023-12-27 20:09:41 +00:00
|
|
|
#include <DigitalInputCard.hpp>
|
2023-12-28 04:41:20 +00:00
|
|
|
#include <DigitalInputIoT.hpp>
|
2023-12-27 20:09:41 +00:00
|
|
|
#include <DigitalOutputCard.hpp>
|
2023-12-28 04:41:20 +00:00
|
|
|
#include <DigitalOutputIoT.hpp>
|
2023-12-27 20:09:41 +00:00
|
|
|
#include <PubSubClient.h>
|
|
|
|
#include <ETH.h>
|
|
|
|
|
|
|
|
class ESPMegaIoT
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
void begin();
|
|
|
|
void loop();
|
|
|
|
void registerCard(uint8_t card_id);
|
|
|
|
void deregisterCard(uint8_t card_id);
|
|
|
|
void publishCard(uint8_t card_id);
|
|
|
|
void subscribeToTopic(char *topic);
|
|
|
|
void unsubscribeFromTopic(char *topic);
|
|
|
|
void connectToEthernet();
|
|
|
|
bool ethernetConnected();
|
|
|
|
void connectToWifi(char *ssid, char *password);
|
|
|
|
void connectToWifi(char *ssid);
|
|
|
|
void disconnectFromWifi();
|
|
|
|
bool wifiConnected();
|
|
|
|
void connectToMqtt(char *mqtt_server, uint16_t mqtt_port, char *mqtt_user, char *mqtt_password);
|
|
|
|
void disconnectFromMqtt();
|
|
|
|
void publishToTopic(char *topic, char *payload);
|
|
|
|
void registerMqttCallback(void (*callback)(char *, char *));
|
2023-12-28 04:41:20 +00:00
|
|
|
void checkCardType(uint8_t card_id);
|
2023-12-27 20:09:41 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
void sessionKeepAlive();
|
|
|
|
void mqttReconnect();
|
|
|
|
void wifiReconnect();
|
2023-12-28 04:41:20 +00:00
|
|
|
void mqttCallback(char *topic, byte *payload, unsigned int length);
|
2023-12-27 20:09:41 +00:00
|
|
|
PubSubClient mqtt;
|
|
|
|
ExpansionCard *expansionCards[255];
|
|
|
|
bool card_publish_enabled[255];
|
2023-12-28 04:41:20 +00:00
|
|
|
char payload_buffer[200];
|
|
|
|
char base_topic[100];
|
|
|
|
};
|