diff --git a/main/main.ino b/main/main.ino index 964282781c..1705fa6f17 100644 --- a/main/main.ino +++ b/main/main.ino @@ -289,7 +289,7 @@ void pub(const char* topicori, const char* payload, bool retainFlag) { void pub(const char* topicori, JsonObject& data) { Log.notice(F("Subject: %s" CR), topicori); digitalWrite(LED_SEND_RECEIVE, LED_SEND_RECEIVE_ON); - logJson(data); + logJson("Sent: ", data); if (client.connected()) { String topic = String(mqtt_topic) + String(gateway_name) + String(topicori); #ifdef valueAsASubject @@ -457,14 +457,18 @@ void pubMQTT(String topic, unsigned long payload) { client.publish(topic.c_str(), val); } -void logJson(JsonObject& jsondata) { +void logJson(String comment, JsonObject& jsondata) { #if defined(ESP8266) || defined(ESP32) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1280__) char JSONmessageBuffer[jsondata.measureLength() + 1]; #else char JSONmessageBuffer[JSON_MSG_BUFFER]; #endif jsondata.printTo(JSONmessageBuffer, sizeof(JSONmessageBuffer)); - Log.notice(F("Received json : %s" CR), JSONmessageBuffer); + Log.notice("%s%s\n", comment.c_str(), JSONmessageBuffer); +} + +void logJson(JsonObject& jsondata) { + logJson("Json: ", jsondata); } bool cmpToMainTopic(const char* topicOri, const char* toAdd) { @@ -1615,7 +1619,7 @@ void receivingMQTT(char* topicOri, char* datacallback) { if (jsondata.success()) { // json object ok -> json decoding // log the received json - logJson(jsondata); + logJson("Received: ", jsondata); #ifdef ZgatewayPilight // ZgatewayPilight is only defined with json publishing due to its numerous parameters MQTTtoPilight(topicOri, jsondata); #endif