aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embassy-net-esp-hosted/src/control.rs26
1 files changed, 6 insertions, 20 deletions
diff --git a/embassy-net-esp-hosted/src/control.rs b/embassy-net-esp-hosted/src/control.rs
index 255ad7045..227db0d09 100644
--- a/embassy-net-esp-hosted/src/control.rs
+++ b/embassy-net-esp-hosted/src/control.rs
@@ -1,4 +1,3 @@
1use core::marker::PhantomData;
2use embassy_net_driver_channel as ch; 1use embassy_net_driver_channel as ch;
3use embassy_net_driver_channel::driver::{HardwareAddress, LinkState}; 2use embassy_net_driver_channel::driver::{HardwareAddress, LinkState};
4use heapless::String; 3use heapless::String;
@@ -25,17 +24,6 @@ pub struct Control<'a> {
25 shared: &'a Shared, 24 shared: &'a Shared,
26} 25}
27 26
28/// Token required for doing an update
29pub struct OtaToken {
30 _d: PhantomData<()>,
31}
32
33impl OtaToken {
34 fn new() -> Self {
35 Self { _d: PhantomData }
36 }
37}
38
39/// WiFi mode. 27/// WiFi mode.
40#[allow(unused)] 28#[allow(unused)]
41#[derive(Copy, Clone, PartialEq, Eq, Debug)] 29#[derive(Copy, Clone, PartialEq, Eq, Debug)]
@@ -159,21 +147,19 @@ impl<'a> Control<'a> {
159 } 147 }
160 148
161 /// Initiate a firmware update. 149 /// Initiate a firmware update.
162 /// 150 pub async fn ota_begin(&mut self) -> Result<(), Error> {
163 /// Returns a token needed for writing and finishing.
164 pub async fn ota_begin(&mut self) -> Result<OtaToken, Error> {
165 let req = proto::CtrlMsg_Req_OTABegin {}; 151 let req = proto::CtrlMsg_Req_OTABegin {};
166 ioctl!(self, ReqOtaBegin, RespOtaBegin, req, resp); 152 ioctl!(self, ReqOtaBegin, RespOtaBegin, req, resp);
167 Ok(OtaToken::new()) 153 Ok(())
168 } 154 }
169 155
170 /// Write slice of firmware to a device. 156 /// Write slice of firmware to a device.
171 /// 157 ///
172 /// Token is required as proof that ota_begin was called. 158 /// [`ota_begin`] must be called first.
173 /// 159 ///
174 /// The slice is split into chunks that can be sent across 160 /// The slice is split into chunks that can be sent across
175 /// the ioctl protocol to the wifi adapter. 161 /// the ioctl protocol to the wifi adapter.
176 pub async fn ota_write(&mut self, _token: &OtaToken, data: &[u8]) -> Result<(), Error> { 162 pub async fn ota_write(&mut self, data: &[u8]) -> Result<(), Error> {
177 for chunk in data.chunks(256) { 163 for chunk in data.chunks(256) {
178 let req = proto::CtrlMsg_Req_OTAWrite { 164 let req = proto::CtrlMsg_Req_OTAWrite {
179 ota_data: heapless::Vec::from_slice(chunk).unwrap(), 165 ota_data: heapless::Vec::from_slice(chunk).unwrap(),
@@ -185,10 +171,10 @@ impl<'a> Control<'a> {
185 171
186 /// End the OTA session. 172 /// End the OTA session.
187 /// 173 ///
188 /// Token is required as proof that ota_begin was called. 174 /// [`ota_begin`] must be called first.
189 /// 175 ///
190 /// NOTE: Will reset the wifi adapter after 5 seconds. 176 /// NOTE: Will reset the wifi adapter after 5 seconds.
191 pub async fn ota_end(&mut self, _token: OtaToken) -> Result<(), Error> { 177 pub async fn ota_end(&mut self) -> Result<(), Error> {
192 let req = proto::CtrlMsg_Req_OTAEnd {}; 178 let req = proto::CtrlMsg_Req_OTAEnd {};
193 ioctl!(self, ReqOtaEnd, RespOtaEnd, req, resp); 179 ioctl!(self, ReqOtaEnd, RespOtaEnd, req, resp);
194 // Ensures that run loop awaits reset 180 // Ensures that run loop awaits reset