Skip to content
This repository has been archived by the owner on Apr 28, 2022. It is now read-only.

Add tls support to amqtt #425

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Arduino/McLighting/McLighting.ino
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,12 @@ void setup() {
if (mqtt_user != "" or mqtt_pass != "") amqttClient.setCredentials(mqtt_user, mqtt_pass);
amqttClient.setClientId(mqtt_clientid);
amqttClient.setWill(mqtt_will_topic, 2, true, mqtt_will_payload, 0);
#if ASYNC_TCP_SSL_ENABLED
amqttClient.setSecure(MQTT_SECURE);
if (MQTT_SECURE) {
amqttClient.addServerFingerprint((const uint8_t[])MQTT_SERVER_FINGERPRINT);
}
#endif

connectToMqtt();
}
Expand Down Expand Up @@ -640,6 +646,14 @@ void setup() {
#ifdef ENABLE_MQTT
json["mqtt"] = "ON";
#endif
#if defined(ENABLE_MQTT) or defined(ENABLE_AMQTT)
json["mqtt_host"] = mqtt_host;
json["mqtt_port"] = mqtt_port;
json["mqtt_user"] = mqtt_user;
#if ASYNC_TCP_SSL_ENABLED
json["mqtt_tls"] = (MQTT_SECURE ? "ON" : "OFF");
#endif
#endif
#ifdef ENABLE_HOMEASSISTANT
json["home_assistant"] = "ON";
#else
Expand Down
5 changes: 5 additions & 0 deletions Arduino/McLighting/definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@
uint8_t _sn[4] = {255,255,255,0};
#endif

#if ASYNC_TCP_SSL_ENABLED
#define MQTT_SECURE true
#define MQTT_SERVER_FINGERPRINT {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff, 0x00, 0x11, 0x22, 0x33, 0x44}
#endif

#ifdef MQTT_HOME_ASSISTANT_SUPPORT
#define MQTT_HOME_ASSISTANT_0_87_SUPPORT // Comment if using HA version < 0.87
#endif
Expand Down