EnigmaIOT
0.9.8
Secure sensor and gateway platform based on ESP8266 and ESP32
|
#include <GwOutput_mqtt.h>
Public Member Functions | |
GwOutput_MQTT () | |
Constructor to initialize MQTT client. More... | |
void | configManagerStart (EnigmaIOTGatewayClass *enigmaIotGw) |
Called when wifi manager starts config portal. More... | |
void | configManagerExit (bool status) |
Called when wifi manager exits config portal. More... | |
bool | begin () |
Starts output module. More... | |
bool | loadConfig () |
Loads output module configuration. More... | |
bool | outputControlSend (char *address, uint8_t *data, size_t length) |
Send control data from nodes. More... | |
bool | newNodeSend (char *address, uint16_t node_id) |
Send new node notification. More... | |
bool | nodeDisconnectedSend (char *address, gwInvalidateReason_t reason) |
Send node disconnection notification. More... | |
bool | outputDataSend (char *address, char *data, size_t length, GwOutput_data_type_t type=data) |
Send data from nodes. More... | |
void | loop () |
Should be called regularly for module management. More... | |
Public Member Functions inherited from GatewayOutput_generic | |
void | setDlCallback (onDlData_t cb) |
Set data processing function. More... | |
Protected Member Functions | |
bool | saveConfig () |
Saves output module configuration. More... | |
void | setClock () |
Synchronizes time over NTP to check certifitate expiration time. More... | |
void | reconnect () |
This is called anytime MQTT client is disconnected. More... | |
bool | addMQTTqueue (const char *topic, char *payload, size_t len, bool retain=false) |
Add MQTT message to queue. More... | |
mqtt_queue_item_t * | getMQTTqueue () |
Gets next item in the queue. More... | |
void | popMQTTqueue () |
Deletes next item in the queue. More... | |
bool | publishMQTT (const char *topic, const char *payload, size_t len, bool retain=false) |
Publishes data over MQTT. More... | |
Static Protected Member Functions | |
static void | onDlData (char *topic, uint8_t *data, unsigned int len) |
Function that processes downlink data from network to node. More... | |
Protected Attributes | |
AsyncWiFiManagerParameter * | mqttServerParam = NULL |
Configuration field for MQTT server address. More... | |
AsyncWiFiManagerParameter * | mqttPortParam = NULL |
Configuration field for MQTT server port. More... | |
AsyncWiFiManagerParameter * | mqttUserParam = NULL |
Configuration field for MQTT server user name. More... | |
AsyncWiFiManagerParameter * | mqttPassParam = NULL |
Configuration field for MQTT server password. More... | |
EnigmaIOTRingBuffer< mqtt_queue_item_t > | mqtt_queue |
mqttgw_config_t | mqttgw_config |
MQTT server configuration data. More... | |
bool | shouldSaveConfig = false |
Flag to indicate if configuration should be saved. More... | |
WiFiClient | espClient |
TCP client. More... | |
PubSubClient | mqtt_client |
MQTT client. More... | |
Protected Attributes inherited from GatewayOutput_generic | |
EnigmaIOTGatewayClass * | enigmaIotGateway |
Pointer to EnigmaIOT gateway instance. More... | |
onDlData_t | downlinkCb |
downlink processing function handle More... | |
Additional Inherited Members | |
Public Attributes inherited from GatewayOutput_generic | |
String | netName |
EnigmaIOT network name. More... | |
String | clientId |
MQTT clientId. More... | |
String | gwTopic |
MQTT topic for gateway. More... | |
Definition at line 85 of file GwOutput_mqtt.h.
|
inline |
Constructor to initialize MQTT client.
Definition at line 169 of file GwOutput_mqtt.h.
|
protected |
Add MQTT message to queue.
topic | MQTT message topic |
payload | MQTT message payload |
len | MQTT payload length |
retain | Message retain flag |
Definition at line 484 of file GwOutput_mqtt.cpp.
|
virtual |
Starts output module.
true
if successful. false
otherwise Implements GatewayOutput_generic.
Definition at line 203 of file GwOutput_mqtt.cpp.
|
virtual |
Called when wifi manager exits config portal.
status | true if configuration was successful |
Implements GatewayOutput_generic.
Definition at line 166 of file GwOutput_mqtt.cpp.
|
virtual |
Called when wifi manager starts config portal.
enigmaIotGw | Pointer to EnigmaIOT gateway instance |
Implements GatewayOutput_generic.
Definition at line 43 of file GwOutput_mqtt.cpp.
|
protected |
Gets next item in the queue.
Definition at line 507 of file GwOutput_mqtt.cpp.
|
virtual |
Loads output module configuration.
true
if load was successful. false
otherwise Implements GatewayOutput_generic.
Definition at line 101 of file GwOutput_mqtt.cpp.
|
virtual |
Should be called regularly for module management.
Implements GatewayOutput_generic.
Definition at line 433 of file GwOutput_mqtt.cpp.
|
virtual |
Send new node notification.
true
if sending was successful. false
otherwise Implements GatewayOutput_generic.
Definition at line 678 of file GwOutput_mqtt.cpp.
|
virtual |
Send node disconnection notification.
address | Node Address |
reason | Disconnection reason code |
true
if sending was successful. false
otherwise Implements GatewayOutput_generic.
Definition at line 696 of file GwOutput_mqtt.cpp.
|
staticprotected |
Function that processes downlink data from network to node.
topic | Topic that indicates message type |
data | Message payload |
len | Payload length |
Definition at line 382 of file GwOutput_mqtt.cpp.
|
virtual |
Send control data from nodes.
address | Node Address |
data | Message data buffer |
length | Data buffer length |
true
if sending was successful. false
otherwise Implements GatewayOutput_generic.
Definition at line 574 of file GwOutput_mqtt.cpp.
|
virtual |
Send data from nodes.
address | Node Address |
data | Message data buffer |
length | Data buffer length |
type | Type of message |
true
if sending was successful. false
otherwise Implements GatewayOutput_generic.
Definition at line 551 of file GwOutput_mqtt.cpp.
|
protected |
Deletes next item in the queue.
Definition at line 515 of file GwOutput_mqtt.cpp.
|
protected |
Publishes data over MQTT.
topic | Topic that indicates message type |
payload | Message payload data |
len | Payload length |
retain | true if message should be retained |
Definition at line 456 of file GwOutput_mqtt.cpp.
|
protected |
This is called anytime MQTT client is disconnected.
It tries to connect to MQTT broker. After reconnection is done it resubscribes to network topics. It waits for connection and times out after 5 seconds
Definition at line 235 of file GwOutput_mqtt.cpp.
|
protectedvirtual |
Saves output module configuration.
true
if save was successful. false
otherwise Implements GatewayOutput_generic.
Definition at line 59 of file GwOutput_mqtt.cpp.
|
protected |
Synchronizes time over NTP to check certifitate expiration time.
Definition at line 467 of file GwOutput_mqtt.cpp.
|
protected |
TCP client.
Definition at line 104 of file GwOutput_mqtt.h.
|
protected |
MQTT client.
Definition at line 106 of file GwOutput_mqtt.h.
|
protected |
Definition at line 93 of file GwOutput_mqtt.h.
|
protected |
MQTT server configuration data.
Definition at line 95 of file GwOutput_mqtt.h.
|
protected |
Configuration field for MQTT server password.
Definition at line 90 of file GwOutput_mqtt.h.
|
protected |
Configuration field for MQTT server port.
Definition at line 88 of file GwOutput_mqtt.h.
|
protected |
Configuration field for MQTT server address.
Definition at line 87 of file GwOutput_mqtt.h.
|
protected |
Configuration field for MQTT server user name.
Definition at line 89 of file GwOutput_mqtt.h.
|
protected |
Flag to indicate if configuration should be saved.
Definition at line 96 of file GwOutput_mqtt.h.