mqttmsg;
+ char mqtttopic[MQTTBUFFER];
+ char mqttpayload[MQTTBUFFER];
- bool connect();
+ void connect();
void subscribe();
- void publishCallback(char* topic, byte* payload, int length);
+ void publishCallback(char* topic, char* payload, AsyncMqttClientMessageProperties properties, size_t length, size_t index, size_t total);
+ void publishLoop(void);
+ void connectCallback(bool sessionPresent);
void publish(
const String& topic,
const MiLightRemoteConfig& remoteConfig,
diff --git a/lib/Settings/Settings.cpp b/lib/Settings/Settings.cpp
index 8582b0c1..19c660e5 100644
--- a/lib/Settings/Settings.cpp
+++ b/lib/Settings/Settings.cpp
@@ -97,6 +97,8 @@ void Settings::patch(JsonObject& parsedSettings) {
this->setIfPresent(parsedSettings, "mqtt_topic_pattern", mqttTopicPattern);
this->setIfPresent(parsedSettings, "mqtt_update_topic_pattern", mqttUpdateTopicPattern);
this->setIfPresent(parsedSettings, "mqtt_state_topic_pattern", mqttStateTopicPattern);
+ this->setIfPresent(parsedSettings, "mqtt_secure", mqttSecure);
+ this->setIfPresent(parsedSettings, "mqtt_server_fingerprint", mqttServerFingerprint);
this->setIfPresent(parsedSettings, "discovery_port", discoveryPort);
this->setIfPresent(parsedSettings, "listen_repeats", listenRepeats);
this->setIfPresent(parsedSettings, "state_flush_interval", stateFlushInterval);
@@ -192,6 +194,8 @@ void Settings::serialize(Stream& stream, const bool prettyPrint) {
root["mqtt_topic_pattern"] = this->mqttTopicPattern;
root["mqtt_update_topic_pattern"] = this->mqttUpdateTopicPattern;
root["mqtt_state_topic_pattern"] = this->mqttStateTopicPattern;
+ root["mqtt_secure"] = this->mqttSecure;
+ root["mqtt_server_fingerprint"] = this->mqttServerFingerprint;
root["discovery_port"] = this->discoveryPort;
root["listen_repeats"] = this->listenRepeats;
root["state_flush_interval"] = this->stateFlushInterval;
diff --git a/lib/Settings/Settings.h b/lib/Settings/Settings.h
index 9aad3a0b..18848ba0 100644
--- a/lib/Settings/Settings.h
+++ b/lib/Settings/Settings.h
@@ -152,6 +152,8 @@ class Settings {
String mqttTopicPattern;
String mqttUpdateTopicPattern;
String mqttStateTopicPattern;
+ bool mqttSecure;
+ String mqttServerFingerprint;
GroupStateField *groupStateFields;
size_t numGroupStateFields;
uint16_t discoveryPort;
diff --git a/platformio.ini b/platformio.ini
index e5f2116f..0068481b 100644
--- a/platformio.ini
+++ b/platformio.ini
@@ -19,7 +19,7 @@ lib_deps_external =
; WiFiManager
https://github.com/cmidgley/WiFiManager
ArduinoJson
- PubSubClient
+ AsyncMqttClient
https://github.com/ratkins/RGBConverter
Hash
WebSockets
@@ -27,7 +27,7 @@ lib_deps_external =
ESP8266WebServer
extra_scripts =
pre:.build_web.py
-build_flags = !python .get_version.py -DMQTT_MAX_PACKET_SIZE=200 -DHTTP_UPLOAD_BUFLEN=128 -Idist -Ilib/DataStructures
+build_flags = !python .get_version.py -DMQTT_MAX_PACKET_SIZE=200 -DHTTP_UPLOAD_BUFLEN=128 -Idist -Ilib/DataStructures -DASYNC_TCP_SSL_ENABLED
# -D DEBUG_PRINTF
# -D MQTT_DEBUG
# -D MILIGHT_UDP_DEBUG
diff --git a/web/src/js/script.js b/web/src/js/script.js
index ce1bcf03..6df14908 100644
--- a/web/src/js/script.js
+++ b/web/src/js/script.js
@@ -120,6 +120,18 @@ var UI_FIELDS = [ {
help: "Password to log into MQTT server",
type: "string",
tab: "tab-mqtt"
+ }, {
+ tag: "mqtt_secure",
+ friendly: "MQTT secure",
+ help: "Whether or not to use SSL.",
+ type: "mqtt_secure",
+ tab: "tab-mqtt"
+ }, {
+ tag: "mqtt_server_fingerprint",
+ friendly: "MQTT server fingerprint",
+ help: "Adds an acceptable server fingerprint (SHA1). Example 2fd4e1c67a2d28fced849ee1bb76e7391b93eb12",
+ type: "string",
+ tab: "tab-mqtt"
}, {
tag: "radio_interface_type",
friendly: "Radio interface type",
@@ -833,6 +845,15 @@ $(function() {
' Disable' +
'' +
'';
+ } else if (k.type == 'mqtt_secure') {
+ elmt += '' +
+ ''+
+ '' +
+ '
';
} else {
elmt += '';
}