17 #ifndef MQTTCOMMUNICATION_H__ 18 #define MQTTCOMMUNICATION_H__ 24 #include <CircularBuffer.h> 49 void callback(
char* topic,
byte* payload,
unsigned int length);
65 extern CircularBuffer<myJSONStr, MAX_JSON_MESSAGES_SAVED>
_buffer;
#define DEFAULT_MQTT_BROKER_IP2
broker IP distributed in 4 values
The Network class establishes a WLAN-Connection.
myJSON class handels the conversion from the JSON-Format into a struct
myJSONStr getElement(int x)
Get the Element object.
void callback(char *topic, byte *payload, unsigned int length)
If the client is used to subscribe to topics, a callback function must be provided in the constructor...
#define DEFAULT_WIFI_SSID
SSID to connect to.
bool loop()
This should be called regularly to allow the client to process incoming messages and maintain its con...
myJSON _myjson
Declare a global variable from typ myJSON so it can be accessed in callback.
#define DEFAULT_WIFI_RST
Reset pin.
#define DEFAULT_MQTT_BROKER_IP1
broker IP distributed in 4 values
Handels the MQTT connection.
void clear()
resets the whole buffer to its initial state
#define DEFAULT_WIFI_PASSWORD
Password to corresponding SSID.
file that contains the default communication configuration
#define DEFAULT_WIFI_IRQ
Interrupt pin.
myJSON Struct defines the format of the messages
#define DEFAULT_MQTT_PORT
MQTT connection port.
void connectToWiFi()
Connects to a WiFi with the given Credential.
Communication(String Hostname)
Construct a new Communication object.
void printNetworkInfo()
Prints all relevant Network-Information of the connected network to serial.
void(* funcPointer)(char *, unsigned char *, unsigned int)
functionpointer to callback-function
This class handels the MQTT connection.
bool publishMessage(const String topic, const String msg)
handles outgoing MQTT messages to Server
bool subscribe(const String topic)
subsribes to MQTT topic on Server
myJSONStr last()
Retriev data from the Tail (oldest Element) of the Buffer.
myMQTT pMymqtt
instance of myMQTT
bool loop()
This should be called regularly to allow the client to process incoming messages and maintain its con...
#define DEFAULT_WIFI_EN
Enable pin.
void init()
Intitialize WLan-Hardware.
#define DEFAULT_MQTT_BROKER_IP3
broker IP distributed in 4 values
WiFiClient pClient
instance of WiFiClient
void init(WiFiClient *myClient, void(*pToCallback)(char *, unsigned char *, unsigned int))
CircularBuffer< myJSONStr, MAX_JSON_MESSAGES_SAVED > _buffer
Declares a global Circular Buffer of type myJSONStr with max Elements of MAX_JSON_MESSAGES_SAVED.
void init()
Initializes the Hard- and Software for WLAN and MQTT-Connection.
int size()
returns the number of elements currently stored in the buffer
The Connection-class provides the interface.
Network pNetwork
instance of Network
bool isEmpty()
Check if the Buffer is empty.
#define DEFAULT_WIFI_CS
Chipselct pin.
myJSONStr shift()
Retriev data from the Head (newest Element) of the Buffer.
bool unsubscribe(const String topic)
unsubsribes from MQTT topic on Server
#define DEFAULT_MQTT_BROKER_IP4
broker IP distributed in 4 values
myJSONStr pop()
Retriev data from the Tail (oldest Element) of the Buffer.
bool subscribe(const String topic)
subsribes to MQTT topic on Server
Handels the WLAN-Connection.
bool unsubscribe(const String topic)
unsubsribes from MQTT topic on Server
bool publishMessage(const String topic, const String msg)
handles outgoing MQTT messages to Server
myJSONStr first()
Retriev data from the Head (newest Element) of the Buffer.
myJSON class handels the conversion from the JSON-Format into a struct