Add cmd to Store IP Settings in Flash

- Cmds Setup Flow: Set IP -> Save Settings to Flash -> Issue HardRst
This commit is contained in:
linuswck 2024-03-05 16:44:28 +08:00
parent 911d9a7bc9
commit 65b757ac3c
1 changed files with 13 additions and 1 deletions

View File

@ -19,12 +19,13 @@ use crate::thermostat::thermostat::{Thermostat, ThermostatSettingsSummary};
use crate::thermostat::pid_state::PidSettings::*;
use crate::device::{dfu, sys_timer};
use log::info;
use crate::{DeviceSettings, State};
use crate::{DeviceSettings, State, IpSettings};
#[derive(Deserialize, Serialize, Copy, Clone, Default, Debug)]
enum DeviceCmd {
#[default]
Reserved,
SetIPSettings,
SetActiveReportMode,
GetStatusReport,
GetSettingsSummary,
@ -96,6 +97,7 @@ pub struct CmdJsonObj{
data_f32: Option<f32>,
data_f64: Option<f64>,
temp_adc_filter: Option<TempAdcFilter>,
ip_settings: Option<IpSettings>,
}
#[derive(Deserialize, Serialize, Copy, Clone, Debug, Default, Tree)]
pub struct Cmd {
@ -185,6 +187,16 @@ pub fn execute_cmd(buffer: &mut [u8], buffer_size: usize, mut laser: LdDrive, mu
info!("############ Device Command Received {:?}", cmd.json.device_cmd);
match cmd.json.device_cmd {
Some(DeviceCmd::SetIPSettings) => {
match cmd.json.ip_settings {
Some(val) => {
device_settings.ip_settings = val;
}
None => {
info!("Wrong Data type is received")
}
}
}
Some(DeviceCmd::Dfu) => {
unsafe {
dfu::set_dfu_trigger();