mqttclient small fix

This commit is contained in:
Klaus K Wilting 2020-10-10 00:49:55 +02:00
parent b5502f9edb
commit 2ff80fa360

View File

@ -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)) {