connect via MQTTS
Signed-off-by: Peter Siegmund <developer@mars3142.org>
This commit is contained in:
@@ -3,4 +3,6 @@ idf_component_register(
|
||||
INCLUDE_DIRS "include"
|
||||
PRIV_REQUIRES
|
||||
persistence-manager
|
||||
my_mqtt_client
|
||||
app_update
|
||||
)
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
#include "message_manager.h"
|
||||
#include "my_mqtt_client.h"
|
||||
#include <esp_app_desc.h>
|
||||
#include <esp_log.h>
|
||||
#include <esp_mac.h>
|
||||
#include <esp_system.h>
|
||||
#include <freertos/FreeRTOS.h>
|
||||
#include <freertos/queue.h>
|
||||
#include <freertos/task.h>
|
||||
#include <persistence_manager.h>
|
||||
#include <sdkconfig.h>
|
||||
#include <string.h>
|
||||
|
||||
#define MESSAGE_QUEUE_LENGTH 16
|
||||
@@ -98,6 +103,15 @@ static void message_manager_task(void *param)
|
||||
message_listeners[i](&msg);
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t mac[6];
|
||||
esp_read_mac(mac, ESP_MAC_WIFI_STA);
|
||||
const esp_app_desc_t *app_desc = esp_app_get_description();
|
||||
char topic[60];
|
||||
snprintf(topic, sizeof(topic), "device/%s/%02x%02x", app_desc->project_name, mac[4], mac[5]);
|
||||
|
||||
char *data = "{\"key\":\"value\"}";
|
||||
mqtt_client_publish(topic, data, strlen(data), 0, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user