Skip to content

Commit

Permalink
sht41: add HTTP API for sensor reset
Browse files Browse the repository at this point in the history
  • Loading branch information
dshil committed Nov 11, 2024
1 parent 41e0133 commit b7ffddb
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ocs-esp-components
5 changes: 4 additions & 1 deletion projects/bonsai-growlab/main/project_pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 8 additions & 1 deletion projects/bonsai-growlab/main/sht41_pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down
7 changes: 6 additions & 1 deletion projects/bonsai-growlab/main/sht41_pipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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::sht41::SensorPipeline> sensor_pipeline_;
std::unique_ptr<fmt::json::IFormatter> sensor_json_formatter_;
std::unique_ptr<pipeline::httpserver::SHT41Handler> sensor_http_handler_;
};

} // namespace bonsai
Expand Down

0 comments on commit b7ffddb

Please sign in to comment.