refactor: Move MQTT broker config to secrets.h.example
This commit is contained in:
parent
5fe3d3da8c
commit
5b45347914
|
@ -16,8 +16,9 @@ String deviceName;
|
|||
#define OUTPUT_PIN 4
|
||||
|
||||
|
||||
const char broker[] = "192.168.69.106";
|
||||
int port = 1883;
|
||||
// Broker IP and port are now defined in secrets.h
|
||||
// const char broker[] = "192.168.69.106";
|
||||
// int port = 1883;
|
||||
String topic; // Changed from const char[]
|
||||
#define QOS_2 2
|
||||
|
||||
|
@ -103,9 +104,9 @@ void setup() {
|
|||
mqttClient.setId(deviceName.c_str());
|
||||
|
||||
Serial.print("[MQTT] Attempting to connect to the MQTT broker: ");
|
||||
Serial.println(broker);
|
||||
Serial.println(SECRET_MQTT_BROKER_IP);
|
||||
|
||||
if (!mqttClient.connect(broker, port)) {
|
||||
if (!mqttClient.connect(SECRET_MQTT_BROKER_IP, SECRET_MQTT_PORT)) {
|
||||
Serial.print("MQTT connection failed! Error code = ");
|
||||
Serial.println(mqttClient.connectError());
|
||||
Serial.println("Reseting...");
|
||||
|
@ -137,7 +138,7 @@ void loop() {
|
|||
Serial.print("[MQTT] Not connected! Error code = ");
|
||||
Serial.println(mqttClient.connectError());
|
||||
Serial.println("[MQTT] Reconnecting...");
|
||||
mqttClient.connect(broker, port);
|
||||
mqttClient.connect(SECRET_MQTT_BROKER_IP, SECRET_MQTT_PORT);
|
||||
delay(5000);
|
||||
|
||||
Serial.print("[MQTT] Subscribing to topic: ");
|
||||
|
|
|
@ -1,2 +1,5 @@
|
|||
#define SECRET_SSID ""
|
||||
#define SECRET_PASS ""
|
||||
|
||||
#define SECRET_MQTT_BROKER_IP "192.168.69.106"
|
||||
#define SECRET_MQTT_PORT 1883
|
||||
|
|
Loading…
Reference in New Issue
Block a user