main: Add PrepareForDfu state

This commit is contained in:
linuswck 2024-09-04 15:56:45 +08:00
parent 6d4b1b0574
commit 1896e2534b
2 changed files with 23 additions and 1 deletions

View File

@ -52,6 +52,7 @@ pub enum State {
SaveLdThermostatSettings,
SaveDeviceSettings,
PrepareForHardReset,
PrepareForDfu,
HardReset,
}
@ -299,6 +300,26 @@ fn main() -> ! {
}
});
}
State::PrepareForDfu => {
// State Transition
state = State::HardReset;
wd.feed();
laser.power_down();
thermostat.power_down();
net::net::for_each(|mut socket, _| {
if net::net::eth_is_socket_active(socket) {
net::cmd_handler::send_response(
eth_data_buffer,
net::cmd_handler::ResponseEnum::Dfu,
None,
&mut socket,
);
net::net::eth_poll_iface();
}
});
}
State::HardReset => {
wd.feed();
laser.power_down();

View File

@ -31,6 +31,7 @@ pub enum ResponseEnum {
InvalidDatatype,
InvalidCmd,
HardReset,
Dfu,
ConnectionClose,
}
@ -324,7 +325,7 @@ pub fn execute_cmd(
dfu::set_dfu_trigger();
}
net::eth_poll_iface();
*state = State::HardReset;
*state = State::PrepareForDfu;
}
Some(DeviceCmd::SetActiveReportMode) => match cmd.json.data_bool {
Some(val) => {