diff --git a/firmware/firmware.ino b/firmware/firmware.ino index 3adb8d5..7b335f1 100644 --- a/firmware/firmware.ino +++ b/firmware/firmware.ino @@ -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: "); diff --git a/firmware/secrets.h.example b/firmware/secrets.h.example index 0c9fdd5..d1936da 100644 --- a/firmware/secrets.h.example +++ b/firmware/secrets.h.example @@ -1,2 +1,5 @@ #define SECRET_SSID "" #define SECRET_PASS "" + +#define SECRET_MQTT_BROKER_IP "192.168.69.106" +#define SECRET_MQTT_PORT 1883