Skip to content

Commit

Permalink
Update control components
Browse files Browse the repository at this point in the history
  • Loading branch information
dshil committed Nov 29, 2024
1 parent a472252 commit 4eb0c52
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 21 deletions.
5 changes: 2 additions & 3 deletions projects/bonsai-growlab/main/ds18b20_pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,15 @@ DS18B20Pipeline::DS18B20Pipeline(core::IClock& clock,
scheduler::ITaskScheduler& task_scheduler,
fmt::json::FanoutFormatter& telemetry_formatter,
system::ISuspender& suspender,
http::Server& http_server,
net::IMdnsDriver& mdns_driver) {
http::Server& http_server) {
storage_ = storage_builder.make("ds18b20_sensors");
configASSERT(storage_);

store_.reset(new (std::nothrow) sensor::ds18b20::Store(8));
configASSERT(store_);

sensor_http_handler_.reset(new (std::nothrow) pipeline::httpserver::DS18B20Handler(
http_server, mdns_driver, suspender, *store_));
http_server, suspender, *store_));
configASSERT(sensor_http_handler_);

#ifdef CONFIG_BONSAI_FIRMWARE_SENSOR_DS18B20_SOIL_TEMPERATURE_ENABLE
Expand Down
4 changes: 1 addition & 3 deletions projects/bonsai-growlab/main/ds18b20_pipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include "ocs_fmt/json/fanout_formatter.h"
#include "ocs_fmt/json/iformatter.h"
#include "ocs_http/server.h"
#include "ocs_net/imdns_driver.h"
#include "ocs_pipeline/httpserver/ds18b20_handler.h"
#include "ocs_scheduler/idelay_estimator.h"
#include "ocs_scheduler/itask_scheduler.h"
Expand All @@ -32,8 +31,7 @@ class DS18B20Pipeline : public core::NonCopyable<> {
scheduler::ITaskScheduler& task_scheduler,
fmt::json::FanoutFormatter& telemetry_formatter,
system::ISuspender& suspender,
http::Server& http_server,
net::IMdnsDriver& mdns_driver);
http::Server& http_server);

private:
std::unique_ptr<storage::IStorage> storage_;
Expand Down
10 changes: 5 additions & 5 deletions projects/bonsai-growlab/main/project_pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,6 @@ ProjectPipeline::ProjectPipeline() {
}));
configASSERT(http_pipeline_);

web_gui_pipeline_.reset(new (std::nothrow) pipeline::httpserver::WebGuiPipeline(
http_pipeline_->get_server(), mdns_pipeline_->get_driver()));
configASSERT(web_gui_pipeline_);

adc_store_.reset(new (std::nothrow)
io::adc::DefaultStore(io::adc::DefaultStore::Params {
.unit = ADC_UNIT_1,
Expand Down Expand Up @@ -143,10 +139,14 @@ ProjectPipeline::ProjectPipeline() {
system_pipeline_->get_clock(), system_pipeline_->get_storage_builder(),
system_pipeline_->get_task_scheduler(),
json_data_pipeline_->get_telemetry_formatter(), system_pipeline_->get_suspender(),
http_pipeline_->get_server(), mdns_pipeline_->get_driver()));
http_pipeline_->get_server()));
configASSERT(ds18b20_pipeline_);
#endif // defined(CONFIG_BONSAI_FIRMWARE_SENSOR_DS18B20_SOIL_TEMPERATURE_ENABLE) ||
// defined(CONFIG_BONSAI_FIRMWARE_SENSOR_DS18B20_OUTSIDE_TEMPERATURE_ENABLE)

web_gui_pipeline_.reset(new (std::nothrow) pipeline::httpserver::WebGuiPipeline(
http_pipeline_->get_server()));
configASSERT(web_gui_pipeline_);
}

status::StatusCode ProjectPipeline::start() {
Expand Down
3 changes: 2 additions & 1 deletion projects/bonsai-growlab/main/project_pipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ class ProjectPipeline : public core::NonCopyable<> {
std::unique_ptr<pipeline::network::LocalNetworkJsonPipeline> network_json_pipeline_;
std::unique_ptr<net::MdnsPipeline> mdns_pipeline_;
std::unique_ptr<pipeline::httpserver::HttpPipeline> http_pipeline_;
std::unique_ptr<pipeline::httpserver::WebGuiPipeline> web_gui_pipeline_;

std::unique_ptr<io::adc::IStore> adc_store_;
std::unique_ptr<io::i2c::MasterStorePipeline> i2c_master_store_pipeline_;
Expand All @@ -86,6 +85,8 @@ class ProjectPipeline : public core::NonCopyable<> {
std::unique_ptr<DS18B20Pipeline> ds18b20_pipeline_;
#endif // defined(CONFIG_BONSAI_FIRMWARE_SENSOR_DS18B20_SOIL_TEMPERATURE_ENABLE) ||
// defined(CONFIG_BONSAI_FIRMWARE_SENSOR_DS18B20_OUTSIDE_TEMPERATURE_ENABLE)

std::unique_ptr<pipeline::httpserver::WebGuiPipeline> web_gui_pipeline_;
};

} // namespace bonsai
Expand Down
3 changes: 1 addition & 2 deletions projects/bonsai-growlab/main/sht41_pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ SHT41Pipeline::SHT41Pipeline(io::i2c::IStore& i2c_store,
storage::StorageBuilder& storage_builder,
fmt::json::FanoutFormatter& telemetry_formatter,
http::Server& http_server,
net::IMdnsDriver& mdns_driver,
core::Time read_interval) {
sensor_pipeline_.reset(new (std::nothrow) sensor::sht41::SensorPipeline(
i2c_store, task_scheduler, storage_builder,
Expand All @@ -38,7 +37,7 @@ SHT41Pipeline::SHT41Pipeline(io::i2c::IStore& i2c_store,
telemetry_formatter.add(*sensor_json_formatter_);

sensor_http_handler_.reset(new (std::nothrow) pipeline::httpserver::SHT41Handler(
func_scheduler, http_server, mdns_driver, sensor_pipeline_->get_sensor()));
func_scheduler, http_server, sensor_pipeline_->get_sensor()));
configASSERT(sensor_http_handler_);
}

Expand Down
1 change: 0 additions & 1 deletion projects/bonsai-growlab/main/sht41_pipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class SHT41Pipeline : public core::NonCopyable<> {
storage::StorageBuilder& storage_builder,
fmt::json::FanoutFormatter& telemetry_formatter,
http::Server& server,
net::IMdnsDriver& mdns_driver,
core::Time read_interval);

private:
Expand Down
4 changes: 2 additions & 2 deletions projects/bonsai-growlab/web-gui/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<link rel="icon" type="image/svg+xml" href="/ico.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + Preact</title>
<title>Bonsai GrowLab Web GUI</title>
</head>
<body>
<div id="app"></div>
Expand Down
2 changes: 1 addition & 1 deletion projects/bonsai-growlab/web-gui/src/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Telemetry } from "./telemetry.jsx";
import { Registration } from "./registration.jsx";

// Base URL.
const API_BASE_URL = "";
const API_BASE_URL = "api/v1";

// Default interval to fetch the telemetry data, 10 seconds.
const TELEMETRY_FETCH_INTERVAL = 10 * 1000;
Expand Down
4 changes: 2 additions & 2 deletions projects/bonsai-growlab/web-gui/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ export default defineConfig({
],
server: {
proxy: {
"/telemetry": {
"/api/v1/telemetry": {
target: "http://192.168.4.1",
changeOrigin: true, // Fixes cross-origin issues
},
"/registration": {
"/api/v1/registration": {
target: "http://192.168.4.1",
changeOrigin: true, // Fix cross-origin issues
},
Expand Down

0 comments on commit 4eb0c52

Please sign in to comment.