mqtt test message with url and topics

This commit is contained in:
Bogdan Pilyugin 2023-03-31 23:00:51 +02:00
parent e1acb81289
commit fc53cee0ad
2 changed files with 11 additions and 2 deletions

View File

@ -403,6 +403,7 @@ api_json_err:
mqtt_app_err_t PublicTestMQTT(int idx)
{
char tmp[10];
char resp[256];
char JSONMess[512];
jwOpen(JSONMess, MAX_ERROR_JSON, JW_OBJECT, JW_PRETTY);
@ -410,8 +411,16 @@ mqtt_app_err_t PublicTestMQTT(int idx)
time(&now);
jwObj_int("time", (unsigned int) now);
jwObj_string("event", "MQTT_TEST_MESSAGE)");
strcpy(resp, "mqtt://");
strcat(resp, GetSysConf()->mqttStation[idx].ServerAddr);
itoa(GetSysConf()->mqttStation[idx].ServerPort, tmp, 10);
strcat(resp, ":");
strcat(resp, tmp);
jwObj_string("url", resp);
ComposeTopic(resp, idx, "SYSTEM", "UPLINK");
jwObj_string("tx_topic", resp);
ComposeTopic(resp, idx, "SYSTEM", "DWLINK");
jwObj_string("resp_topic", resp);
jwObj_string("rx_topic", resp);
jwEnd();
jwClose();
char *buf = (char*) malloc(strlen(JSONMess) + 1);

View File

@ -19,7 +19,7 @@
* Description:
*/
#include <WebGUIAppMain.h>
#include "WebGUIAppMain.h"
#include "esp_log.h"
#include "Helpers.h"
#include "esp_system.h"