2021-04-03 06:54:10 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "configuration.h"
|
|
|
|
|
|
|
|
#include <PubSubClient.h>
|
|
|
|
#include <WiFiClient.h>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Our wrapper/singleton for sending/receiving MQTT "udp" packets. This object isolates the MQTT protocol implementation from
|
|
|
|
* the two components that use it: MQTTPlugin and MQTTSimInterface.
|
|
|
|
*/
|
|
|
|
class MQTT
|
|
|
|
{
|
|
|
|
// supposedly the current version is busted:
|
|
|
|
// http://www.iotsharing.com/2017/08/how-to-use-esp32-mqtts-with-mqtts-mosquitto-broker-tls-ssl.html
|
|
|
|
// WiFiClientSecure wifiClient;
|
|
|
|
WiFiClient mqttClient;
|
|
|
|
PubSubClient pubSub;
|
|
|
|
|
|
|
|
public:
|
|
|
|
MQTT();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Publish a packet on the glboal MQTT server.
|
|
|
|
*/
|
2021-04-03 07:04:03 +00:00
|
|
|
void publish(const MeshPacket *mp);
|
2021-04-03 06:54:10 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
const char *getTopic(String suffix, const char *direction = "dev");
|
|
|
|
};
|
|
|
|
|
|
|
|
void mqttInit();
|
|
|
|
|
|
|
|
extern MQTT *mqtt;
|