Can set device desired version
This commit is contained in:
central_backend/src
central_frontend/src
esp32_device
@@ -9,7 +9,7 @@ use std::collections::{HashMap, HashSet};
|
||||
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
|
||||
pub struct DeviceInfo {
|
||||
/// Device reference
|
||||
reference: String,
|
||||
pub reference: String,
|
||||
/// Device firmware / software version
|
||||
version: semver::Version,
|
||||
/// Maximum number of relay that the device can support
|
||||
@@ -62,6 +62,9 @@ pub struct Device {
|
||||
///
|
||||
/// There cannot be more than [info.max_relays] relays
|
||||
pub relays: Vec<DeviceRelay>,
|
||||
/// Desired version, ie. the version of the software we would to seen run on the device
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub desired_version: Option<semver::Version>,
|
||||
}
|
||||
|
||||
/// Structure that contains information about the minimal expected execution
|
||||
|
@@ -84,6 +84,7 @@ impl DevicesList {
|
||||
validated: false,
|
||||
enabled: false,
|
||||
relays: vec![],
|
||||
desired_version: None,
|
||||
};
|
||||
|
||||
// First, write CSR
|
||||
@@ -186,6 +187,24 @@ impl DevicesList {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Set a device desired version
|
||||
pub fn set_desired_version(
|
||||
&mut self,
|
||||
id: &DeviceId,
|
||||
version: Option<semver::Version>,
|
||||
) -> anyhow::Result<()> {
|
||||
let dev = self
|
||||
.0
|
||||
.get_mut(id)
|
||||
.ok_or(DevicesListError::UpdateDeviceFailedDeviceNotFound)?;
|
||||
|
||||
dev.desired_version = version;
|
||||
|
||||
self.persist_dev_config(id)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Get single certificate information
|
||||
fn get_cert(&self, id: &DeviceId) -> anyhow::Result<X509> {
|
||||
let dev = self
|
||||
|
Reference in New Issue
Block a user