mirror of
https://github.com/alexandrebobkov/ESP-Nodes.git
synced 2025-10-19 23:26:59 +00:00
mqtt
This commit is contained in:
@@ -12,6 +12,26 @@
|
|||||||
#include "mqtt_client.h"
|
#include "mqtt_client.h"
|
||||||
#include "mqttronix.h"
|
#include "mqttronix.h"
|
||||||
|
|
||||||
|
static void mqtt_event_handler(void *handler_args, esp_event_base_t base, int32_t event_id, void *event_data) {
|
||||||
|
|
||||||
|
esp_mqtt_event_handle_t event = event_data;
|
||||||
|
esp_mqtt_client_handle_t client = event->client;
|
||||||
|
|
||||||
|
switch ((esp_mqtt_event_id_t)event_id) {
|
||||||
|
case MQTT_EVENT_CONNECTED:
|
||||||
|
ESP_LOGI(MQTT_TAG, "MQTT_EVENT_CONNECTED");
|
||||||
|
esp_mqtt_client_publish(client, "nodes/outdoor/foxie2/temperature", "1.0", 0, 1, 0);
|
||||||
|
mqtt_client = client;
|
||||||
|
xTaskCreate(mqtt_publish_task, "mqtt_publish_task", 8192, NULL, 5, NULL);
|
||||||
|
break;
|
||||||
|
case MQTT_EVENT_DISCONNECTED:
|
||||||
|
ESP_LOGI(MQTT_TAG, "MQTT_EVENT_DISCONNECTED");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void mqttronix_start(void) {
|
void mqttronix_start(void) {
|
||||||
esp_mqtt_client_config_t mqtt_cfg = {
|
esp_mqtt_client_config_t mqtt_cfg = {
|
||||||
.broker.address.uri = MQTT_BROKER_URI,
|
.broker.address.uri = MQTT_BROKER_URI,
|
||||||
|
Reference in New Issue
Block a user