Prepare the path for OTA implementation
This commit is contained in:
		@@ -293,6 +293,16 @@ impl AppConfig {
 | 
			
		||||
    pub fn log_of_day(&self, day: u64) -> PathBuf {
 | 
			
		||||
        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)]
 | 
			
		||||
 
 | 
			
		||||
@@ -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().energy_consumption_history()).unwrap();
 | 
			
		||||
    create_directory_if_missing(AppConfig::get().logs_dir()).unwrap();
 | 
			
		||||
    create_directory_if_missing(AppConfig::get().ota_dir()).unwrap();
 | 
			
		||||
 | 
			
		||||
    // Initialize PKI
 | 
			
		||||
    pki::initialize_root_ca().expect("Failed to initialize Root CA!");
 | 
			
		||||
 
 | 
			
		||||
@@ -180,6 +180,13 @@ pub async fn secure_server(energy_actor: EnergyActorAddr) -> anyhow::Result<()>
 | 
			
		||||
                "/web_api/device/{id}",
 | 
			
		||||
                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
 | 
			
		||||
            .route(
 | 
			
		||||
                "/web_api/logging/logs",
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user