From b7ffddb5832277c7ee5e8b81a3e9519eff0fdef1 Mon Sep 17 00:00:00 2001 From: Dmitriy Shilin Date: Mon, 11 Nov 2024 13:09:21 +0100 Subject: [PATCH] sht41: add HTTP API for sensor reset --- ocs-esp-components | 2 +- projects/bonsai-growlab/main/project_pipeline.cpp | 5 ++++- projects/bonsai-growlab/main/sht41_pipeline.cpp | 9 ++++++++- projects/bonsai-growlab/main/sht41_pipeline.h | 7 ++++++- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/ocs-esp-components b/ocs-esp-components index e35f9b3..b46d85c 160000 --- a/ocs-esp-components +++ b/ocs-esp-components @@ -1 +1 @@ -Subproject commit e35f9b36cbf7fd99d8496e1ef511fb5aa998f0de +Subproject commit b46d85cc2087bd35fcb05d37338f03d78d56a4a7 diff --git a/projects/bonsai-growlab/main/project_pipeline.cpp b/projects/bonsai-growlab/main/project_pipeline.cpp index a4149af..ad1075e 100644 --- a/projects/bonsai-growlab/main/project_pipeline.cpp +++ b/projects/bonsai-growlab/main/project_pipeline.cpp @@ -104,7 +104,10 @@ ProjectPipeline::ProjectPipeline() { #ifdef CONFIG_BONSAI_FIRMWARE_SENSOR_SHT41_ENABLE sht41_pipeline_.reset(new (std::nothrow) SHT41Pipeline( i2c_master_store_pipeline_->get_store(), system_pipeline_->get_task_scheduler(), - json_data_pipeline_->get_telemetry_formatter())); + system_pipeline_->get_func_scheduler(), + json_data_pipeline_->get_telemetry_formatter(), + http_pipeline_->get_server_pipeline().server(), + http_pipeline_->get_server_pipeline().mdns())); configASSERT(sht41_pipeline_); #endif // CONFIG_BONSAI_FIRMWARE_SENSOR_SHT41_ENABLE diff --git a/projects/bonsai-growlab/main/sht41_pipeline.cpp b/projects/bonsai-growlab/main/sht41_pipeline.cpp index dd40b38..f4ff79e 100644 --- a/projects/bonsai-growlab/main/sht41_pipeline.cpp +++ b/projects/bonsai-growlab/main/sht41_pipeline.cpp @@ -15,7 +15,10 @@ namespace bonsai { SHT41Pipeline::SHT41Pipeline(io::i2c::IStore& i2c_store, scheduler::ITaskScheduler& task_scheduler, - fmt::json::FanoutFormatter& telemetry_formatter) { + scheduler::AsyncFuncScheduler& func_scheduler, + fmt::json::FanoutFormatter& telemetry_formatter, + http::Server& http_server, + net::MdnsProvider& mdns_provider) { sensor_pipeline_.reset(new (std::nothrow) sensor::sht41::SensorPipeline( i2c_store, task_scheduler, sensor::sht41::SensorPipeline::Params { @@ -31,6 +34,10 @@ SHT41Pipeline::SHT41Pipeline(io::i2c::IStore& i2c_store, configASSERT(sensor_json_formatter_); telemetry_formatter.add(*sensor_json_formatter_); + + sensor_http_handler_.reset(new (std::nothrow) pipeline::httpserver::SHT41Handler( + func_scheduler, http_server, mdns_provider, sensor_pipeline_->get_sensor())); + configASSERT(sensor_http_handler_); } } // namespace bonsai diff --git a/projects/bonsai-growlab/main/sht41_pipeline.h b/projects/bonsai-growlab/main/sht41_pipeline.h index fd7e644..3acba9c 100644 --- a/projects/bonsai-growlab/main/sht41_pipeline.h +++ b/projects/bonsai-growlab/main/sht41_pipeline.h @@ -14,6 +14,7 @@ #include "ocs_fmt/json/fanout_formatter.h" #include "ocs_fmt/json/iformatter.h" #include "ocs_io/i2c/istore.h" +#include "ocs_pipeline/httpserver/sht41_handler.h" #include "ocs_scheduler/itask_scheduler.h" #include "ocs_sensor/sht41/sensor_pipeline.h" @@ -25,11 +26,15 @@ class SHT41Pipeline : public core::NonCopyable<> { //! Initialize. SHT41Pipeline(io::i2c::IStore& i2c_store, scheduler::ITaskScheduler& task_scheduler, - fmt::json::FanoutFormatter& telemetry_formatter); + scheduler::AsyncFuncScheduler& func_scheduler, + fmt::json::FanoutFormatter& telemetry_formatter, + http::Server& server, + net::MdnsProvider& mdns_provider); private: std::unique_ptr sensor_pipeline_; std::unique_ptr sensor_json_formatter_; + std::unique_ptr sensor_http_handler_; }; } // namespace bonsai