Perform the MQTT connection during the setup

This commit is contained in:
2025-11-27 13:23:58 +01:00
parent 517ed64d31
commit 8dffe8747f
2 changed files with 1 additions and 2 deletions

View File

@@ -23,7 +23,7 @@ void setup() {
Serial.println("ERROR: The config file could not be loaded");
connect_wlan(config);
connect_mqtt(mqtt_client, config);
initialize_sensor(sensor, error_code, error_msg);
}

View File

@@ -56,7 +56,6 @@ size_t construct_json(float *data, char *buffer, int buffer_size) {
void mqtt_transfer(PubSubClient &client, Config *config, float *data) {
char buffer[100];
connect_mqtt(client, config);
size_t payload_size = construct_json(data, buffer, 100);
client.publish(config->topic, buffer, payload_size);
Serial.println("Data transferred successfully");