Add MQTT port selection and MQTT user/password auth support

This commit is contained in:
theFeiter 2022-06-25 20:50:21 +02:00
parent 3818d88dd5
commit ec0da25bfe
8 changed files with 84 additions and 4 deletions

View File

@ -34,6 +34,13 @@
#define WIFI_SSID "Your SSID" #define WIFI_SSID "Your SSID"
#define WIFI_PASS "Your Password" #define WIFI_PASS "Your Password"
#define MQTT_ADDR "192.168.0.8" #define MQTT_ADDR "192.168.0.8"
#define MQTT_PORT 1883 // Default MQTT port is 1883
//MQTT Credentials -- Needed only if MQTT broker requires authentication
//#define MQTT_AUTH
//#define MQTT_USER "Your MQTT Username"
//#define MQTT_PASS "Your MQTT Password"
// MQTT Topics // MQTT Topics
#define TOPIC_DATA "fdrs/data" #define TOPIC_DATA "fdrs/data"
#define TOPIC_STATUS "fdrs/status" #define TOPIC_STATUS "fdrs/status"

View File

@ -14,12 +14,18 @@
#define FDRS_WIFI_SSID GLOBAL_SSID #define FDRS_WIFI_SSID GLOBAL_SSID
#define FDRS_WIFI_PASS GLOBAL_PASS #define FDRS_WIFI_PASS GLOBAL_PASS
#define FDRS_MQTT_ADDR GLOBAL_MQTT_ADDR #define FDRS_MQTT_ADDR GLOBAL_MQTT_ADDR
#define FDRS_MQTT_PORT GLOBAL_MQTT_PORT
#define FDRS_MQTT_USER GLOBAL_MQTT_USER
#define FDRS_MQTT_PASS GLOBAL_MQTT_PASS
#define FDRS_BAND GLOBAL_BAND #define FDRS_BAND GLOBAL_BAND
#define FDRS_SF GLOBAL_SF #define FDRS_SF GLOBAL_SF
#else #else
#define FDRS_WIFI_SSID WIFI_SSID #define FDRS_WIFI_SSID WIFI_SSID
#define FDRS_WIFI_PASS WIFI_PASS #define FDRS_WIFI_PASS WIFI_PASS
#define FDRS_MQTT_ADDR MQTT_ADDR #define FDRS_MQTT_ADDR MQTT_ADDR
#define FDRS_MQTT_PORT MQTT_PORT
#define FDRS_MQTT_USER MQTT_USER
#define FDRS_MQTT_PASS MQTT_PASS
#define FDRS_BAND BAND #define FDRS_BAND BAND
#define FDRS_SF SF #define FDRS_SF SF
#endif #endif
@ -100,8 +106,15 @@ PubSubClient client(espClient);
const char* ssid = FDRS_WIFI_SSID; const char* ssid = FDRS_WIFI_SSID;
const char* password = FDRS_WIFI_PASS; const char* password = FDRS_WIFI_PASS;
const char* mqtt_server = FDRS_MQTT_ADDR; const char* mqtt_server = FDRS_MQTT_ADDR;
const int mqtt_port = FDRS_MQTT_PORT;
#endif
#ifdef MQTT_AUTH
const char* mqtt_user = FDRS_MQTT_USER;
const char* mqtt_pass = FDRS_MQTT_PASS;
#else
const char* mqtt_user = null;
const char* mqtt_pass = null;
#endif #endif
// Set ESP-NOW send and receive callbacks for either ESP8266 or ESP32 // Set ESP-NOW send and receive callbacks for either ESP8266 or ESP32
#if defined(ESP8266) #if defined(ESP8266)

View File

@ -34,6 +34,13 @@
#define WIFI_SSID "Your SSID" #define WIFI_SSID "Your SSID"
#define WIFI_PASS "Your Password" #define WIFI_PASS "Your Password"
#define MQTT_ADDR "192.168.0.8" #define MQTT_ADDR "192.168.0.8"
#define MQTT_PORT 1883 // Default MQTT port is 1883
//MQTT Credentials -- Needed only if MQTT broker requires authentication
//#define MQTT_AUTH
//#define MQTT_USER "Your MQTT Username"
//#define MQTT_PASS "Your MQTT Password"
// MQTT Topics // MQTT Topics
#define TOPIC_DATA "fdrs/data" #define TOPIC_DATA "fdrs/data"
#define TOPIC_STATUS "fdrs/status" #define TOPIC_STATUS "fdrs/status"

View File

@ -14,12 +14,18 @@
#define FDRS_WIFI_SSID GLOBAL_SSID #define FDRS_WIFI_SSID GLOBAL_SSID
#define FDRS_WIFI_PASS GLOBAL_PASS #define FDRS_WIFI_PASS GLOBAL_PASS
#define FDRS_MQTT_ADDR GLOBAL_MQTT_ADDR #define FDRS_MQTT_ADDR GLOBAL_MQTT_ADDR
#define FDRS_MQTT_PORT GLOBAL_MQTT_PORT
#define FDRS_MQTT_USER GLOBAL_MQTT_USER
#define FDRS_MQTT_PASS GLOBAL_MQTT_PASS
#define FDRS_BAND GLOBAL_BAND #define FDRS_BAND GLOBAL_BAND
#define FDRS_SF GLOBAL_SF #define FDRS_SF GLOBAL_SF
#else #else
#define FDRS_WIFI_SSID WIFI_SSID #define FDRS_WIFI_SSID WIFI_SSID
#define FDRS_WIFI_PASS WIFI_PASS #define FDRS_WIFI_PASS WIFI_PASS
#define FDRS_MQTT_ADDR MQTT_ADDR #define FDRS_MQTT_ADDR MQTT_ADDR
#define FDRS_MQTT_PORT MQTT_PORT
#define FDRS_MQTT_USER MQTT_USER
#define FDRS_MQTT_PASS MQTT_PASS
#define FDRS_BAND BAND #define FDRS_BAND BAND
#define FDRS_SF SF #define FDRS_SF SF
#endif #endif
@ -100,8 +106,15 @@ PubSubClient client(espClient);
const char* ssid = FDRS_WIFI_SSID; const char* ssid = FDRS_WIFI_SSID;
const char* password = FDRS_WIFI_PASS; const char* password = FDRS_WIFI_PASS;
const char* mqtt_server = FDRS_MQTT_ADDR; const char* mqtt_server = FDRS_MQTT_ADDR;
const int mqtt_port = FDRS_MQTT_PORT;
#endif
#ifdef MQTT_AUTH
const char* mqtt_user = FDRS_MQTT_USER;
const char* mqtt_pass = FDRS_MQTT_PASS;
#else
const char* mqtt_user = null;
const char* mqtt_pass = null;
#endif #endif
// Set ESP-NOW send and receive callbacks for either ESP8266 or ESP32 // Set ESP-NOW send and receive callbacks for either ESP8266 or ESP32
#if defined(ESP8266) #if defined(ESP8266)

View File

@ -67,6 +67,13 @@
#define WIFI_SSID "Your SSID" #define WIFI_SSID "Your SSID"
#define WIFI_PASS "Your Password" #define WIFI_PASS "Your Password"
#define MQTT_ADDR "192.168.0.8" #define MQTT_ADDR "192.168.0.8"
#define MQTT_PORT 1883 // Default MQTT port is 1883
//MQTT Credentials -- Needed only if MQTT broker requires authentication
//#define MQTT_AUTH
//#define MQTT_USER "Your MQTT Username"
//#define MQTT_PASS "Your MQTT Password"
// MQTT Topics // MQTT Topics
#define TOPIC_DATA "fdrs/data" #define TOPIC_DATA "fdrs/data"
#define TOPIC_STATUS "fdrs/status" #define TOPIC_STATUS "fdrs/status"

View File

@ -14,12 +14,18 @@
#define FDRS_WIFI_SSID GLOBAL_SSID #define FDRS_WIFI_SSID GLOBAL_SSID
#define FDRS_WIFI_PASS GLOBAL_PASS #define FDRS_WIFI_PASS GLOBAL_PASS
#define FDRS_MQTT_ADDR GLOBAL_MQTT_ADDR #define FDRS_MQTT_ADDR GLOBAL_MQTT_ADDR
#define FDRS_MQTT_PORT GLOBAL_MQTT_PORT
#define FDRS_MQTT_USER GLOBAL_MQTT_USER
#define FDRS_MQTT_PASS GLOBAL_MQTT_PASS
#define FDRS_BAND GLOBAL_BAND #define FDRS_BAND GLOBAL_BAND
#define FDRS_SF GLOBAL_SF #define FDRS_SF GLOBAL_SF
#else #else
#define FDRS_WIFI_SSID WIFI_SSID #define FDRS_WIFI_SSID WIFI_SSID
#define FDRS_WIFI_PASS WIFI_PASS #define FDRS_WIFI_PASS WIFI_PASS
#define FDRS_MQTT_ADDR MQTT_ADDR #define FDRS_MQTT_ADDR MQTT_ADDR
#define FDRS_MQTT_PORT MQTT_PORT
#define FDRS_MQTT_USER MQTT_USER
#define FDRS_MQTT_PASS MQTT_PASS
#define FDRS_BAND BAND #define FDRS_BAND BAND
#define FDRS_SF SF #define FDRS_SF SF
#endif #endif
@ -100,8 +106,15 @@ PubSubClient client(espClient);
const char* ssid = FDRS_WIFI_SSID; const char* ssid = FDRS_WIFI_SSID;
const char* password = FDRS_WIFI_PASS; const char* password = FDRS_WIFI_PASS;
const char* mqtt_server = FDRS_MQTT_ADDR; const char* mqtt_server = FDRS_MQTT_ADDR;
const int mqtt_port = FDRS_MQTT_PORT;
#endif
#ifdef MQTT_AUTH
const char* mqtt_user = FDRS_MQTT_USER;
const char* mqtt_pass = FDRS_MQTT_PASS;
#else
const char* mqtt_user = null;
const char* mqtt_pass = null;
#endif #endif
// Set ESP-NOW send and receive callbacks for either ESP8266 or ESP32 // Set ESP-NOW send and receive callbacks for either ESP8266 or ESP32
#if defined(ESP8266) #if defined(ESP8266)

View File

@ -67,6 +67,13 @@
#define WIFI_SSID "Your SSID" #define WIFI_SSID "Your SSID"
#define WIFI_PASS "Your Password" #define WIFI_PASS "Your Password"
#define MQTT_ADDR "192.168.0.8" #define MQTT_ADDR "192.168.0.8"
#define MQTT_PORT 1883 // Default MQTT port is 1883
//MQTT Credentials -- Needed only if MQTT broker requires authentication
//#define MQTT_AUTH
//#define MQTT_USER "Your MQTT Username"
//#define MQTT_PASS "Your MQTT Password"
// MQTT Topics // MQTT Topics
#define TOPIC_DATA "fdrs/data" #define TOPIC_DATA "fdrs/data"
#define TOPIC_STATUS "fdrs/status" #define TOPIC_STATUS "fdrs/status"

View File

@ -19,12 +19,18 @@
#define FDRS_WIFI_SSID GLOBAL_SSID #define FDRS_WIFI_SSID GLOBAL_SSID
#define FDRS_WIFI_PASS GLOBAL_PASS #define FDRS_WIFI_PASS GLOBAL_PASS
#define FDRS_MQTT_ADDR GLOBAL_MQTT_ADDR #define FDRS_MQTT_ADDR GLOBAL_MQTT_ADDR
#define FDRS_MQTT_PORT GLOBAL_MQTT_PORT
#define FDRS_MQTT_USER GLOBAL_MQTT_USER
#define FDRS_MQTT_PASS GLOBAL_MQTT_PASS
#define FDRS_BAND GLOBAL_BAND #define FDRS_BAND GLOBAL_BAND
#define FDRS_SF GLOBAL_SF #define FDRS_SF GLOBAL_SF
#else #else
#define FDRS_WIFI_SSID WIFI_SSID #define FDRS_WIFI_SSID WIFI_SSID
#define FDRS_WIFI_PASS WIFI_PASS #define FDRS_WIFI_PASS WIFI_PASS
#define FDRS_MQTT_ADDR MQTT_ADDR #define FDRS_MQTT_ADDR MQTT_ADDR
#define FDRS_MQTT_PORT MQTT_PORT
#define FDRS_MQTT_USER MQTT_USER
#define FDRS_MQTT_PASS MQTT_PASS
#define FDRS_BAND BAND #define FDRS_BAND BAND
#define FDRS_SF SF #define FDRS_SF SF
#endif #endif
@ -105,8 +111,15 @@ PubSubClient client(espClient);
const char* ssid = FDRS_WIFI_SSID; const char* ssid = FDRS_WIFI_SSID;
const char* password = FDRS_WIFI_PASS; const char* password = FDRS_WIFI_PASS;
const char* mqtt_server = FDRS_MQTT_ADDR; const char* mqtt_server = FDRS_MQTT_ADDR;
const int mqtt_port = FDRS_MQTT_PORT;
#endif
#ifdef MQTT_AUTH
const char* mqtt_user = FDRS_MQTT_USER;
const char* mqtt_pass = FDRS_MQTT_PASS;
#else
const char* mqtt_user = null;
const char* mqtt_pass = null;
#endif #endif
// Set ESP-NOW send and receive callbacks for either ESP8266 or ESP32 // Set ESP-NOW send and receive callbacks for either ESP8266 or ESP32
#if defined(ESP8266) #if defined(ESP8266)