rename folders
This commit is contained in:
parent
1ec8effe90
commit
1815597374
63 changed files with 1 additions and 0 deletions
114
ESPMegaPRO-firmware/lib/ESPMegaPRO/ESPMegaIoT.hpp
Normal file
114
ESPMegaPRO-firmware/lib/ESPMegaPRO/ESPMegaIoT.hpp
Normal file
|
@ -0,0 +1,114 @@
|
|||
#pragma once
|
||||
#include <ExpansionCard.hpp>
|
||||
#include <AnalogCard.hpp>
|
||||
#include <AnalogIoT.hpp>
|
||||
#include <DigitalInputCard.hpp>
|
||||
#include <DigitalInputIoT.hpp>
|
||||
#include <DigitalOutputCard.hpp>
|
||||
#include <DigitalOutputIoT.hpp>
|
||||
#include <IoTComponent.hpp>
|
||||
#include <PubSubClient.h>
|
||||
#include <ETH.h>
|
||||
#include <WiFi.h>
|
||||
#include <FRAM.h>
|
||||
|
||||
struct NetworkConfig
|
||||
{
|
||||
IPAddress ip;
|
||||
IPAddress gateway;
|
||||
IPAddress subnet;
|
||||
IPAddress dns1;
|
||||
IPAddress dns2;
|
||||
char hostname[32];
|
||||
bool useStaticIp;
|
||||
bool useWifi;
|
||||
bool wifiUseAuth;
|
||||
char ssid[32];
|
||||
char password[32];
|
||||
};
|
||||
|
||||
struct MqttConfig
|
||||
{
|
||||
char mqtt_server[32];
|
||||
uint16_t mqtt_port;
|
||||
char mqtt_user[32];
|
||||
char mqtt_password[32];
|
||||
bool mqtt_useauth;
|
||||
char base_topic[32];
|
||||
};
|
||||
|
||||
class ESPMegaIoT
|
||||
{
|
||||
public:
|
||||
ESPMegaIoT();
|
||||
~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();
|
||||
void ethernetBegin();
|
||||
void loadNetworkConfig();
|
||||
void saveNetworkConfig();
|
||||
NetworkConfig* getNetworkConfig();
|
||||
MqttConfig* getMqttConfig();
|
||||
void setMqttConfig(MqttConfig mqtt_config);
|
||||
void saveMqttConfig();
|
||||
void loadMqttConfig();
|
||||
void connectNetwork();
|
||||
void setNetworkConfig(NetworkConfig network_config);
|
||||
void connectToMqtt();
|
||||
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);
|
||||
bool mqttConnected();
|
||||
void disconnectFromMqtt();
|
||||
void publishToTopic(char *topic, char *payload);
|
||||
void registerMqttCallback(void (*callback)(char *, char *));
|
||||
void registerRelativeMqttCallback(void (*callback)(char *, char *));
|
||||
void registerSubscribeCallback(void (*callback)(void));
|
||||
void setBaseTopic(char *base_topic);
|
||||
void bindEthernetInterface(ETHClass *ethernetIface);
|
||||
bool networkConnected();
|
||||
|
||||
IoTComponent* getComponent(uint8_t card_id);
|
||||
IPAddress getETHIp();
|
||||
|
||||
private:
|
||||
FRAM *fram;
|
||||
bool useWifi;
|
||||
bool WifiUseAuth;
|
||||
char ssid[32];
|
||||
char password[32];
|
||||
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 (*user_subscribe_callback)(void);
|
||||
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
|
||||
bool mqtt_connected;
|
||||
NetworkConfig network_config;
|
||||
MqttConfig mqtt_config;
|
||||
ETHClass *ethernetIface;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue