fundamentum_sdk_mqtt/models/commands/
firmware_update.rs

1//! `Firmware Update` module
2//!
3
4use std::hash::{Hash, Hasher};
5
6use serde::{Deserialize, Serialize};
7
8/// `FirmwareUpdateParameters` definition
9/// See <https://dimonoff.atlassian.net/wiki/spaces/F2/pages/306437652531/Devices+Commands#Firmware-Update>
10#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
11pub struct FirmwareUpdateParameters {
12    /// Identifiers of the device targeted by this firmware update.
13    pub target_device: TargetDeviceConfig,
14    /// Configuration and identifiers for this firmware version.
15    pub version: VersionConfig,
16}
17
18/// `TargetDeviceConfig` definition
19#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
20pub struct TargetDeviceConfig {
21    /// Unique-by-registry identifier given to a device during provisioning.
22    pub serial_number: String,
23}
24
25/// `VersionConfig` definition
26#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
27pub struct VersionConfig {
28    /// Database identifier of the version to install.
29    pub id: u32,
30    /// Name of the version.
31    pub name: String,
32    /// String identifier of the version.
33    pub identifier: String,
34    /// URLs where the firmware files included in this update can be downloaded.
35    #[serde(rename = "configuration_file_url")]
36    pub urls: Vec<String>,
37    /// Metadata providing additionnal information about the firmware file.
38    #[serde(rename = "configuration")]
39    pub metadata: serde_json::Value,
40}
41
42impl Hash for VersionConfig {
43    fn hash<H: Hasher>(&self, state: &mut H) {
44        self.id.hash(state);
45        self.name.hash(state);
46        self.identifier.hash(state);
47        self.urls.hash(state);
48        self.metadata.to_string().hash(state);
49    }
50}