 |
EnigmaIOT
0.9.3
Secure sensor and gateway platform based on ESP8266 and ESP32
|
Go to the documentation of this file.
11 #ifndef _GWOUTPUT_MQTT_h
12 #define _GWOUTPUT_MQTT_h
14 #if defined(ARDUINO) && ARDUINO >= 100
22 #include <ESPAsyncWiFiManager.h>
24 #include <PubSubClient.h>
27 #include <WiFiClientSecure.h>
29 #include <WiFiClient.h>
34 #define GET_VERSION "get/version"
35 #define GET_VERSION_ANS "result/version"
36 #define GET_SLEEP "get/sleeptime"
37 #define GET_SLEEP_ANS "result/sleeptime"
38 #define SET_SLEEP "set/sleeptime"
39 #define SET_OTA "set/ota"
40 #define SET_OTA_ANS "result/ota"
41 #define SET_IDENTIFY "set/identify"
42 #define SET_RESET_CONFIG "set/reset"
43 #define SET_RESET_ANS "result/reset"
44 #define GET_RSSI "get/rssi"
45 #define GET_RSSI_ANS "result/rssi"
46 #define GET_NAME "get/name"
47 #define SET_NAME "set/name"
48 #define GET_NAME_ANS "result/name"
49 #define SET_USER_DATA "set/data"
50 #define GET_USER_DATA "get/data"
51 #define NODE_DATA "data"
52 #define LOST_MESSAGES "debug/lostmessages"
53 #define NODE_STATUS "status"
54 #define GW_STATUS "/gateway/status"
92 BearSSL::X509List certificate;
109 #endif // SECURE_MQTT
126 bool addMQTTqueue (
const char* topic,
char* payload,
size_t len,
bool retain =
false);
146 bool publishMQTT (
const char* topic,
const char* payload,
size_t len,
bool retain =
false);
154 static void onDlData (
char* topic, uint8_t*
data,
unsigned int len);
161 #if defined ESP8266 && defined SECURE_MQTT
162 certificate (DSTroot_CA),
205 bool newNodeSend (
char* address, uint16_t node_id);
233 #endif // _GWOUTPUT_MQTT_h
bool nodeDisconnectedSend(char *address, gwInvalidateReason_t reason)
Send node disconnection notification.
void configManagerStart(EnigmaIOTGatewayClass *enigmaIotGw)
Called when wifi manager starts config portal.
AsyncWiFiManagerParameter * mqttPassParam
Configuration field for MQTT server password.
bool newNodeSend(char *address, uint16_t node_id)
Send new node notification.
Main gateway class. Manages communication with nodes and sends data to upper layer.
Generic Gateway output module template.
void reconnect()
This is called anytime MQTT client is disconnected.
static void onDlData(char *topic, uint8_t *data, unsigned int len)
Function that processes downlink data from network to node.
AsyncWiFiManagerParameter * mqttPortParam
Configuration field for MQTT server port.
bool begin()
Starts output module.
void popMQTTqueue()
Deletes next item in the queue.
AsyncWiFiManagerParameter * mqttServerParam
Configuration field for MQTT server address.
void loop()
Should be called regularly for module management.
bool outputDataSend(char *address, char *data, size_t length, GwOutput_data_type_t type=data)
Send data from nodes.
mqttgw_config_t mqttgw_config
MQTT server configuration data.
bool shouldSaveConfig
Flag to indicate if configuration should be saved.
constexpr auto CONFIG_FILE
MQTT outout configuration file name.
void configManagerExit(bool status)
Called when wifi manager exits config portal.
mqtt_queue_item_t * getMQTTqueue()
Gets next item in the queue.
enum GwOutput_data_type GwOutput_data_type_t
bool outputControlSend(char *address, uint8_t *data, size_t length)
Send control data from nodes.
GwOutput_MQTT()
Constructor to initialize MQTT client.
AsyncWiFiManagerParameter * mqttUserParam
Configuration field for MQTT server user name.
WiFiClient espClient
TCP client.
bool addMQTTqueue(const char *topic, char *payload, size_t len, bool retain=false)
Add MQTT message to queue.
PubSubClient mqtt_client
MQTT client.
bool saveConfig()
Saves output module configuration.
Library to build a gateway for EnigmaIoT system.
gwInvalidateReason_t
Key invalidation reason definition.
std::queue< mqtt_queue_item_t * > mqtt_queue
Output MQTT messages queue. It acts as a FIFO queue.
bool loadConfig()
Loads output module configuration.
bool publishMQTT(const char *topic, const char *payload, size_t len, bool retain=false)
Publishes data over MQTT.