diff --git a/src/main.rs b/src/main.rs index 5505f79..d1b3ab4 100644 --- a/src/main.rs +++ b/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(); diff --git a/src/net/cmd_handler.rs b/src/net/cmd_handler.rs index ed6bdfb..fc5728a 100644 --- a/src/net/cmd_handler.rs +++ b/src/net/cmd_handler.rs @@ -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) => {