forked from M-Labs/kirdy
main: Add PrepareForDfu state
This commit is contained in:
parent
6d4b1b0574
commit
1896e2534b
21
src/main.rs
21
src/main.rs
|
@ -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();
|
||||
|
|
|
@ -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) => {
|
||||
|
|
Loading…
Reference in New Issue