Set MQTT username and password
This commit is contained in:
@@ -3,10 +3,15 @@
|
||||
|
||||
// TODO: make this a config.h
|
||||
|
||||
// WI-FI
|
||||
#define SSID "your_wifi_ssid"
|
||||
#define PASSWORD "your_wifi_password"
|
||||
#define AUTH_MODE WIFI_AUTH_WPA2_PSK
|
||||
|
||||
// MQTT
|
||||
#define MQTT_ADDR "mqtt://yourmqttserver"
|
||||
#define MQTT_PORT 1883
|
||||
#define MQTT_USER "your_username"
|
||||
#define MQTT_PASS "your_password"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -66,6 +66,8 @@ static void mqtt_init(void) {
|
||||
|
||||
mqtt_cfg.broker.address.uri = MQTT_ADDR;
|
||||
mqtt_cfg.broker.address.port = MQTT_PORT;
|
||||
mqtt_cfg.credentials.username = MQTT_USER;
|
||||
mqtt_cfg.credentials.authentication.password = MQTT_PASS;
|
||||
|
||||
mqtt_client = esp_mqtt_client_init(&mqtt_cfg);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user