mirror of
https://github.com/alexandrebobkov/ESP-Nodes.git
synced 2024-10-05 20:47:50 -04:00
.
This commit is contained in:
parent
8a49add96b
commit
7474894b25
@ -190,7 +190,7 @@ void mosquitto_connect ()
|
||||
connection.setServer(mqtt_server, 8883);
|
||||
connection.setKeepAlive(60);
|
||||
while (!connection.connected()) {
|
||||
String client_id = "ESP32-U-" + String(WiFi.macAddress());
|
||||
String client_id = "ESP32-WROOM-" + String(WiFi.macAddress());
|
||||
Serial.printf("Connecting to MQTT Brocker as %s ... \n", client_id.c_str());
|
||||
if (connection.connect(client_id.c_str(), mqtt_username, mqtt_password)) {
|
||||
Serial.println("Connected to MQTT Broker");
|
||||
@ -363,12 +363,31 @@ void setup() {
|
||||
Serial.println(connection.state());
|
||||
#endif
|
||||
#ifdef MQTT_SSL // MOSQUITTO MQTT port 8883
|
||||
Serial.println(":8883");
|
||||
espClientSSL.setCACert(NODE_CERT_CA);
|
||||
connection.setServer(mqtt_server, 8883);
|
||||
connection.setKeepAlive(60);
|
||||
while (!connection.connected()) {
|
||||
String client_id = "ESP32-WROOM-" + String(WiFi.macAddress());
|
||||
Serial.printf("Connecting to MQTT Brocker as %s ... \n", client_id.c_str());
|
||||
if (connection.connect(client_id.c_str(), mqtt_username, mqtt_password)) {
|
||||
Serial.println("Connected to MQTT Broker");
|
||||
}
|
||||
else {
|
||||
Serial.print("Failed to connect, rc=");
|
||||
Serial.print(connection.state());
|
||||
Serial.println(" Retrying in 5 seconds.");
|
||||
delay(5000);
|
||||
}
|
||||
}
|
||||
/**
|
||||
Serial.println(":8883");
|
||||
connection.setServer(mqtt_server, 8883);
|
||||
espClientSSL.setCACert(NODE_CERT_CA);
|
||||
espClientSSL.setCertificate(NODE_CERT_CRT);
|
||||
//espClientSSL.setPrivateKey(NODE_CERT_PRIVATE);
|
||||
//connection.setCallback(mosquito_callback);
|
||||
**/
|
||||
if(connection.connect("esp32")) {
|
||||
Serial.println("Mosquitto Connected!");
|
||||
connection.subscribe("esp32/sw1");
|
||||
@ -430,7 +449,7 @@ void loop() {
|
||||
Serial.print(bme.readPressure() / 100.0F);
|
||||
Serial.println(" hPa");
|
||||
Serial.println("========\n");
|
||||
delay(2500);
|
||||
delay(5000);
|
||||
connection.loop();
|
||||
|
||||
// Blink status LED when status is OK
|
||||
|
Loading…
Reference in New Issue
Block a user