43 lines
1.4 KiB
C++
43 lines
1.4 KiB
C++
#include <ExpansionCard.hpp>
|
|
#include <AnalogCard.hpp>
|
|
#include <AnalogIoT.hpp>
|
|
#include <DigitalInputCard.hpp>
|
|
#include <DigitalInputIoT.hpp>
|
|
#include <DigitalOutputCard.hpp>
|
|
#include <DigitalOutputIoT.hpp>
|
|
#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 *));
|
|
void checkCardType(uint8_t card_id);
|
|
|
|
private:
|
|
void sessionKeepAlive();
|
|
void mqttReconnect();
|
|
void wifiReconnect();
|
|
void mqttCallback(char *topic, byte *payload, unsigned int length);
|
|
PubSubClient mqtt;
|
|
ExpansionCard *expansionCards[255];
|
|
bool card_publish_enabled[255];
|
|
char payload_buffer[200];
|
|
char base_topic[100];
|
|
}; |