Closer to a working model. 2-way communication is working and devices can report temperature readings. Need to get the actual control logic done and clean this garbage up.
32 lines
787 B
C++
32 lines
787 B
C++
#ifndef MyClass_h
|
|
#define MyClass_h
|
|
|
|
#include <PubSubClient.h>
|
|
#include <ArduinoJson.h>
|
|
#include <ESP8266WiFi.h>
|
|
|
|
#include <Global.h>
|
|
#include <secrets.h>
|
|
|
|
#define CALLBACK_SIGNATURE void (*mqttCallback)(char *topic, byte *payload, unsigned int length)
|
|
|
|
class Communicator {
|
|
public:
|
|
Communicator(WiFiClient&);
|
|
Communicator(WiFiClient&, CALLBACK_SIGNATURE);
|
|
|
|
CALLBACK_SIGNATURE;
|
|
void connectCallback(CALLBACK_SIGNATURE);
|
|
bool ConnectMQTT(const String&, const String&, const String&, const String&);
|
|
void mqtt_discovery(const String, StaticJsonDocument<1536>&);
|
|
void publish_data(String topic, String value);
|
|
void publish_data(String topic, int value);
|
|
void Subscribe(const char* topic);
|
|
void loop();
|
|
|
|
private:
|
|
PubSubClient _mqtt_client;
|
|
WiFiClient _net;
|
|
};
|
|
#endif
|