diff --git a/central_backend/src/lib.rs b/central_backend/src/lib.rs index c043b60..50d34af 100644 --- a/central_backend/src/lib.rs +++ b/central_backend/src/lib.rs @@ -4,5 +4,6 @@ pub mod crypto; pub mod devices; pub mod energy; pub mod logs; +pub mod ota; pub mod server; pub mod utils; diff --git a/central_backend/src/ota/mod.rs b/central_backend/src/ota/mod.rs new file mode 100644 index 0000000..ea34968 --- /dev/null +++ b/central_backend/src/ota/mod.rs @@ -0,0 +1 @@ +pub mod ota_update; diff --git a/central_backend/src/ota/ota_update.rs b/central_backend/src/ota/ota_update.rs new file mode 100644 index 0000000..7c993ea --- /dev/null +++ b/central_backend/src/ota/ota_update.rs @@ -0,0 +1,5 @@ +#[derive(serde::Serialize, serde::Deserialize, Debug, Copy, Clone, Eq, PartialEq)] +pub enum OTAPlatform { + #[serde(rename = "Wt32-Eth01")] + Wt32Eth01, +} diff --git a/central_backend/src/server/servers.rs b/central_backend/src/server/servers.rs index 39ba213..9fb7421 100644 --- a/central_backend/src/server/servers.rs +++ b/central_backend/src/server/servers.rs @@ -181,7 +181,10 @@ pub async fn secure_server(energy_actor: EnergyActorAddr) -> anyhow::Result<()> web::delete().to(devices_controller::delete_device), ) // OTA API - // TODO : list supported platform references + .route( + "/web_api/ota/supported_platforms", + web::get().to(ota_controller::supported_platforms), + ) // TODO : upload a new software update // TODO : list ota software update per platform // TODO : download a OTA file diff --git a/central_backend/src/server/web_api/mod.rs b/central_backend/src/server/web_api/mod.rs index 5b75fab..a967058 100644 --- a/central_backend/src/server/web_api/mod.rs +++ b/central_backend/src/server/web_api/mod.rs @@ -2,5 +2,6 @@ pub mod auth_controller; pub mod devices_controller; pub mod energy_controller; pub mod logging_controller; +pub mod ota_controller; pub mod relays_controller; pub mod server_controller; diff --git a/central_backend/src/server/web_api/ota_controller.rs b/central_backend/src/server/web_api/ota_controller.rs new file mode 100644 index 0000000..9329ad3 --- /dev/null +++ b/central_backend/src/server/web_api/ota_controller.rs @@ -0,0 +1,7 @@ +use crate::ota::ota_update::OTAPlatform; +use crate::server::custom_error::HttpResult; +use actix_web::HttpResponse; + +pub async fn supported_platforms() -> HttpResult { + Ok(HttpResponse::Ok().json(vec![OTAPlatform::Wt32Eth01])) +}