publication temp int + etat online
This commit is contained in:
parent
67e6d1cfaa
commit
8f60e9c38c
@ -144,4 +144,12 @@ add_custom_target(ota_latest
|
||||
\"bin\":\"${OTA_BIN_NAME}\" }"
|
||||
> ${OTA_DIR}/latest.json
|
||||
DEPENDS ota_push
|
||||
)
|
||||
)
|
||||
|
||||
add_custom_target(ota_to_mqtt
|
||||
COMMAND podman run --rm eclipse-mosquitto:alpine
|
||||
mosquitto_pub
|
||||
-h 192.168.0.10
|
||||
-t devices/esp32p4_01/ota/update
|
||||
-m '{"version":"${FW_VERSION}","url":"https://192.168.0.9:8443/${OTA_BIN_NAME}","sha256":"","force":true}'
|
||||
)
|
||||
|
||||
@ -176,6 +176,10 @@ void send_event(domo_events evt, void* pDatas) {
|
||||
ihmEvt->eEventType = IHM_EVT_HUMID_TEMP;
|
||||
ihmEvt->pvData = msg_copy4;
|
||||
ihmEvt->bNeedToFreeData = true;
|
||||
|
||||
//On envoie les données via mqtt
|
||||
esp_mqtt_client_publish(client, topicTempInt, pDatas, 0, 0, 0);
|
||||
|
||||
break;
|
||||
|
||||
case EVT_HAUTEUR_CUVE: {
|
||||
|
||||
@ -42,3 +42,12 @@ typedef enum domo_events{
|
||||
void startEvtManager();
|
||||
QueueHandle_t getIHMQueueHandle();
|
||||
void send_event(domo_events evt, void *pDatas);
|
||||
|
||||
#define topicTempExt "house/temp/282A802600008059"
|
||||
#define topicHauteurCuve "house/cuve/hauteur"
|
||||
#define topicTempInt "house/temp/287DCF1E00008020"
|
||||
#define topicHauteurCuveEvol "house/cuve/hauteurEvol"
|
||||
#define topicConsoElec "energy/puissance_5mn"
|
||||
#define topicEtatMachine "energy/machine_en_route"
|
||||
#define topicdomoticCommand "domotic/cmd"
|
||||
#define topicTest "test"
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
#include "esp_log.h"
|
||||
#include "mqtt_client.h"
|
||||
#include "stateManagement.h"
|
||||
#include "eventsManager.h"
|
||||
#if CONFIG_IDF_TARGET_ESP32P4
|
||||
#include "esp_wifi.h"
|
||||
#endif
|
||||
@ -183,8 +184,8 @@ void splitIt(char *payload, unsigned int length, float *datas)
|
||||
|
||||
mqtt_callback mqttcb;
|
||||
|
||||
void mqtt_publish(const char *topic, const char *datas){
|
||||
esp_mqtt_client_publish(client, topic, datas, 0, 1, 0);
|
||||
void mqtt_publish(const char *topic, const char *datas, bool retain){
|
||||
esp_mqtt_client_publish(client, topic, datas, 0, 1, retain);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -289,7 +290,13 @@ void mqtt_app_start(mqtt_callback callback, EventGroupHandle_t domotic_event_gro
|
||||
mqttcb=callback;
|
||||
esp_mqtt_client_config_t mqtt_cfg = {
|
||||
.broker.address.uri = "mqtt://192.168.0.10",
|
||||
.network.timeout_ms = 1000};
|
||||
.network.timeout_ms = 1000,
|
||||
.session.keepalive=30,
|
||||
.session.last_will.topic="esp32p4_domotic/binary_sensor/online/state",
|
||||
.session.last_will.msg = "offline",
|
||||
.session.last_will.qos = 1,
|
||||
.session.last_will.retain = 1
|
||||
};
|
||||
#if CONFIG_BROKER_URL_FROM_STDIN
|
||||
char line[128];
|
||||
|
||||
|
||||
@ -16,14 +16,6 @@ typedef void (*wifi_callback)(wifi_evt evt);
|
||||
typedef void (*mqtt_callback)(mqtt_evt evt, esp_mqtt_event_handle_t evt_data);
|
||||
void wifi_init_sta(wifi_callback cb);
|
||||
void mqtt_app_start(mqtt_callback cb, EventGroupHandle_t evtGroup);
|
||||
void mqtt_publish(const char *topic, const char *datas);
|
||||
void mqtt_publish(const char *topic, const char *datas, bool retain);
|
||||
|
||||
#define topicTempExt "house/temp/282A802600008059"
|
||||
#define topicHauteurCuve "house/cuve/hauteur"
|
||||
#define topicTempInt "house/temp/287DCF1E00008020"
|
||||
#define topicHauteurCuveEvol "house/cuve/hauteurEvol"
|
||||
#define topicConsoElec "energy/puissance_5mn"
|
||||
#define topicEtatMachine "energy/machine_en_route"
|
||||
#define topicdomoticCommand "domotic/cmd"
|
||||
#define topicTest "test"
|
||||
|
||||
|
||||
21
main/main.c
21
main/main.c
@ -1011,6 +1011,21 @@ void lightSensorTask(void *pvParameter){
|
||||
*/
|
||||
}
|
||||
|
||||
static void heartbeat_task(void *arg)
|
||||
{
|
||||
const char *topic = "esp32p4_domotic/binary_sensor/online/state";
|
||||
|
||||
while (1) {
|
||||
mqtt_publish(
|
||||
topic,
|
||||
"online",
|
||||
true);
|
||||
|
||||
vTaskDelay(pdMS_TO_TICKS(30000)); // 30 s
|
||||
}
|
||||
}
|
||||
|
||||
#define BUILD_TIME __DATE__ " " __TIME__
|
||||
//#include "audio.h"
|
||||
void app_main(void)
|
||||
{
|
||||
@ -1076,6 +1091,12 @@ void app_main(void)
|
||||
#endif
|
||||
|
||||
esp_ota_mark_app_valid_cancel_rollback();
|
||||
esp_app_desc_t *appDesc = esp_app_get_description();
|
||||
char buff[300];
|
||||
snprintf(buff,300,"%s %s %s", BUILD_TIME, appDesc->version, appDesc->idf_ver);
|
||||
mqtt_publish("esp32p4_domotic/sensor/firmware/state",buff, true);
|
||||
|
||||
xTaskCreate(heartbeat_task, "heartbeat_task", 4096, NULL, 5, NULL);
|
||||
|
||||
start_webserver();
|
||||
}
|
||||
|
||||
@ -1 +1 @@
|
||||
0.0.3
|
||||
0.0.5
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user