Prepare the path for OTA implementation

This commit is contained in:
Pierre HUBERT 2024-10-03 21:16:51 +02:00
parent 436bcd5677
commit 06659404c1
3 changed files with 18 additions and 0 deletions

View File

@ -293,6 +293,16 @@ impl AppConfig {
pub fn log_of_day(&self, day: u64) -> PathBuf { pub fn log_of_day(&self, day: u64) -> PathBuf {
self.logs_dir().join(format!("{day}.log")) self.logs_dir().join(format!("{day}.log"))
} }
/// Get the directory that will store OTA updates
pub fn ota_dir(&self) -> PathBuf {
self.logs_dir().join("ota")
}
/// Get the directory that will store OTA updates of a given device reference
pub fn ota_of_device(&self, dev_ref: &str) -> PathBuf {
self.ota_dir().join(dev_ref)
}
} }
#[cfg(test)] #[cfg(test)]

View File

@ -20,6 +20,7 @@ async fn main() -> std::io::Result<()> {
create_directory_if_missing(AppConfig::get().relays_runtime_stats_storage_path()).unwrap(); create_directory_if_missing(AppConfig::get().relays_runtime_stats_storage_path()).unwrap();
create_directory_if_missing(AppConfig::get().energy_consumption_history()).unwrap(); create_directory_if_missing(AppConfig::get().energy_consumption_history()).unwrap();
create_directory_if_missing(AppConfig::get().logs_dir()).unwrap(); create_directory_if_missing(AppConfig::get().logs_dir()).unwrap();
create_directory_if_missing(AppConfig::get().ota_dir()).unwrap();
// Initialize PKI // Initialize PKI
pki::initialize_root_ca().expect("Failed to initialize Root CA!"); pki::initialize_root_ca().expect("Failed to initialize Root CA!");

View File

@ -180,6 +180,13 @@ pub async fn secure_server(energy_actor: EnergyActorAddr) -> anyhow::Result<()>
"/web_api/device/{id}", "/web_api/device/{id}",
web::delete().to(devices_controller::delete_device), web::delete().to(devices_controller::delete_device),
) )
// OTA API
// TODO : list supported platform references
// TODO : upload a new software update
// TODO : list ota software update per platform
// TODO : download a OTA file
// TODO : delete an OTA file
// TODO : deploy an update to a device
// Logging controller API // Logging controller API
.route( .route(
"/web_api/logging/logs", "/web_api/logging/logs",