fixed climate card mqtt crash bug
This commit is contained in:
parent
9cd5b7132b
commit
4c77474a94
8 changed files with 128 additions and 50 deletions
|
@ -13,6 +13,10 @@
|
|||
#include <ETH.h>
|
||||
#include <WiFi.h>
|
||||
#include <FRAM.h>
|
||||
#include <map>
|
||||
|
||||
#define TCP_TIMEOUT_SEC 5
|
||||
#define MQTT_RECONNECT_INTERVAL 30000
|
||||
|
||||
// FRAM Address for ESPMegaPROIoT
|
||||
// Starts from 34
|
||||
|
@ -80,10 +84,13 @@ public:
|
|||
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 publish(const char *topic, const char *payload);
|
||||
uint8_t registerMqttCallback(std::function<void(char *, char *)> callback);
|
||||
void unregisterMqttCallback(uint8_t handler);
|
||||
uint8_t registerRelativeMqttCallback(std::function<void(char *, char *)> callback);
|
||||
void unregisterRelativeMqttCallback(uint8_t handler);
|
||||
uint8_t registerSubscribeCallback(std::function<void(void)> callback);
|
||||
void unregisterSubscribeCallback(uint8_t handler);
|
||||
void setBaseTopic(char *base_topic);
|
||||
void bindEthernetInterface(ETHClass *ethernetIface);
|
||||
bool networkConnected();
|
||||
|
@ -104,15 +111,17 @@ private:
|
|||
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);
|
||||
uint8_t mqtt_callbacks_handler_index;
|
||||
uint8_t mqtt_relative_callbacks_handler_index;
|
||||
uint8_t subscribe_callbacks_handler_index;
|
||||
std::map<uint8_t, std::function<void(char*, char*)>> mqtt_callbacks;
|
||||
std::map<uint8_t, std::function<void(char*, char*)>> mqtt_relative_callbacks;
|
||||
std::map<uint8_t, std::function<void(void)>> subscribe_callbacks;
|
||||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue