From 2ff80fa3608a88a189fa62f8ba79908c8a9024bb Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Sat, 10 Oct 2020 00:49:55 +0200 Subject: [PATCH] mqttclient small fix --- src/mqttclient.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/mqttclient.cpp b/src/mqttclient.cpp index 9eb2567f..c17fd049 100644 --- a/src/mqttclient.cpp +++ b/src/mqttclient.cpp @@ -16,8 +16,8 @@ esp_err_t mqtt_init(void) { // setup network connection WiFi.onEvent(NetworkEvent); ETH.begin(); - //WiFi.mode(WIFI_STA); - //WiFi.begin("SSID", "PASSWORD"); + // WiFi.mode(WIFI_STA); + // WiFi.begin("SSID", "PASSWORD"); // setup mqtt client mqttClient.begin(MQTT_SERVER, MQTT_PORT, netClient); @@ -69,6 +69,8 @@ int mqtt_connect(const char *my_host, const uint16_t my_port) { ESP_LOGW(TAG, "MQTT server not responding, retrying later"); return -1; } + + return 0; } void NetworkEvent(WiFiEvent_t event) { @@ -122,7 +124,7 @@ void mqtt_client_task(void *param) { if (mqttClient.connected()) { char buffer[PAYLOAD_BUFFER_SIZE + 3]; - snprintf(buffer, msg.MessageSize + 3, "%s/%s", msg.MessagePort, + snprintf(buffer, msg.MessageSize + 3, "%s/%u", msg.MessagePort, msg.Message); if (mqttClient.publish(MQTT_OUTTOPIC, buffer)) {