updated webguiapp component, added example of mqtt send back message
This commit is contained in:
parent
adf162d2ce
commit
2f17b193c4
|
|
@ -1 +1 @@
|
|||
Subproject commit 724c7a437606d27fc41694de95da5523dd581ab5
|
||||
Subproject commit 267a7de82ac60a1d0a4e8caed0324e8c5600bfd9
|
||||
|
|
@ -24,6 +24,32 @@
|
|||
#include "webguiapp.h"
|
||||
#define TAG "MQTTCustom"
|
||||
|
||||
esp_err_t UserMQTTSendExample(int idx)
|
||||
{
|
||||
const char resp[] = { "Got MQTT data in topic USER" };
|
||||
char *buf = (char*) malloc(strlen(resp) + 1);
|
||||
if (buf)
|
||||
{
|
||||
memcpy(buf, resp, strlen(resp));
|
||||
DATA_SEND_STRUCT DSS;
|
||||
ComposeTopic(DSS.topic,
|
||||
GetSysConf()->mqttStation[idx].RootTopic,
|
||||
"UPLINK",
|
||||
GetSysConf()->mqttStation[idx].ClientID,
|
||||
"USER");
|
||||
DSS.raw_data_ptr = buf;
|
||||
DSS.data_length = strlen(resp);
|
||||
if (xQueueSend(GetMQTTHandlesPool(idx)->mqtt_queue, &DSS, pdMS_TO_TICKS(1000)) == pdPASS)
|
||||
return ESP_OK;
|
||||
else
|
||||
{
|
||||
free(buf);
|
||||
return ESP_ERR_TIMEOUT;
|
||||
}
|
||||
|
||||
}
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
void UserMQTTEventHndlr(void *handler_args, esp_event_base_t base, int32_t event_id, void *event_data)
|
||||
{
|
||||
|
|
@ -54,6 +80,7 @@ void UserMQTTEventHndlr(void *handler_args, esp_event_base_t base, int32_t event
|
|||
if (!memcmp(topic, event->topic, event->topic_len))
|
||||
{
|
||||
//Here data for service called "USER"
|
||||
UserMQTTSendExample(ctx->mqtt_index);
|
||||
ESP_LOGI(TAG, "USER data handler on client %d", ctx->mqtt_index);
|
||||
}
|
||||
break;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user