Add route to download firmware on device
This commit is contained in:
21
central_backend/src/server/devices_api/devices_ota.rs
Normal file
21
central_backend/src/server/devices_api/devices_ota.rs
Normal file
@ -0,0 +1,21 @@
|
||||
use crate::ota::ota_manager;
|
||||
use crate::ota::ota_update::OTAPlatform;
|
||||
use crate::server::custom_error::HttpResult;
|
||||
use actix_web::{web, HttpResponse};
|
||||
|
||||
#[derive(serde::Deserialize)]
|
||||
pub struct FirmwarePath {
|
||||
platform: OTAPlatform,
|
||||
version: semver::Version,
|
||||
}
|
||||
|
||||
/// Download firmware update
|
||||
pub async fn retrieve_firmware(path: web::Path<FirmwarePath>) -> HttpResult {
|
||||
if !ota_manager::update_exists(path.platform, &path.version)? {
|
||||
return Ok(HttpResponse::NotFound().json("The requested firmware was not found!"));
|
||||
}
|
||||
|
||||
let firmware = ota_manager::get_ota_update(path.platform, &path.version)?;
|
||||
|
||||
Ok(HttpResponse::Ok().body(firmware))
|
||||
}
|
Reference in New Issue
Block a user