aboutsummaryrefslogtreecommitdiff
path: root/src/runner.rs
diff options
context:
space:
mode:
authorkbleeke <[email protected]>2023-04-02 20:19:47 +0200
committerkbleeke <[email protected]>2023-04-25 19:14:00 +0200
commit2d7ba44621fa35abad07d2ddb8b253e815ce2c1f (patch)
tree999561ce27e3662a22ee2590c79eaa0791099953 /src/runner.rs
parent6a1a3e6877053b1b72adb3c1446f4f077ad3b03e (diff)
rework event handling to allow sending data
Diffstat (limited to 'src/runner.rs')
-rw-r--r--src/runner.rs33
1 files changed, 15 insertions, 18 deletions
diff --git a/src/runner.rs b/src/runner.rs
index f0f6fceeb..554a711d8 100644
--- a/src/runner.rs
+++ b/src/runner.rs
@@ -1,5 +1,3 @@
1use core::slice;
2
3use embassy_futures::select::{select3, Either3}; 1use embassy_futures::select::{select3, Either3};
4use embassy_net_driver_channel as ch; 2use embassy_net_driver_channel as ch;
5use embassy_sync::pubsub::PubSubBehavior; 3use embassy_sync::pubsub::PubSubBehavior;
@@ -9,12 +7,12 @@ use embedded_hal_1::digital::OutputPin;
9use crate::bus::Bus; 7use crate::bus::Bus;
10pub use crate::bus::SpiBusCyw43; 8pub use crate::bus::SpiBusCyw43;
11use crate::consts::*; 9use crate::consts::*;
12use crate::events::{EventQueue, EventStatus}; 10use crate::events::{Events, Status};
13use crate::fmt::Bytes; 11use crate::fmt::Bytes;
14use crate::ioctl::{IoctlState, IoctlType, PendingIoctl}; 12use crate::ioctl::{IoctlState, IoctlType, PendingIoctl};
15use crate::nvram::NVRAM; 13use crate::nvram::NVRAM;
16use crate::structs::*; 14use crate::structs::*;
17use crate::{events, Core, CHIP, MTU}; 15use crate::{events, slice8_mut, Core, CHIP, MTU};
18 16
19#[cfg(feature = "firmware-logs")] 17#[cfg(feature = "firmware-logs")]
20struct LogState { 18struct LogState {
@@ -45,7 +43,7 @@ pub struct Runner<'a, PWR, SPI> {
45 sdpcm_seq: u8, 43 sdpcm_seq: u8,
46 sdpcm_seq_max: u8, 44 sdpcm_seq_max: u8,
47 45
48 events: &'a EventQueue, 46 events: &'a Events,
49 47
50 #[cfg(feature = "firmware-logs")] 48 #[cfg(feature = "firmware-logs")]
51 log: LogState, 49 log: LogState,
@@ -60,7 +58,7 @@ where
60 ch: ch::Runner<'a, MTU>, 58 ch: ch::Runner<'a, MTU>,
61 bus: Bus<PWR, SPI>, 59 bus: Bus<PWR, SPI>,
62 ioctl_state: &'a IoctlState, 60 ioctl_state: &'a IoctlState,
63 events: &'a EventQueue, 61 events: &'a Events,
64 ) -> Self { 62 ) -> Self {
65 Self { 63 Self {
66 ch, 64 ch,
@@ -353,8 +351,6 @@ where
353 panic!("IOCTL error {}", cdc_header.status as i32); 351 panic!("IOCTL error {}", cdc_header.status as i32);
354 } 352 }
355 353
356 info!("IOCTL Response: {:02x}", Bytes(response));
357
358 self.ioctl_state.ioctl_done(response); 354 self.ioctl_state.ioctl_done(response);
359 } 355 }
360 } 356 }
@@ -406,11 +402,17 @@ where
406 Bytes(evt_data) 402 Bytes(evt_data)
407 ); 403 );
408 404
409 if evt_type == events::Event::AUTH || evt_type == events::Event::JOIN { 405 if self.events.mask.is_enabled(evt_type) {
410 self.events.publish_immediate(EventStatus { 406 let status = event_packet.msg.status;
411 status: event_packet.msg.status, 407 let event_payload = events::Payload::None;
412 event_type: evt_type, 408
413 }); 409 self.events.queue.publish_immediate(events::Message::new(
410 Status {
411 event_type: evt_type,
412 status,
413 },
414 event_payload,
415 ));
414 } 416 }
415 } 417 }
416 CHANNEL_TYPE_DATA => { 418 CHANNEL_TYPE_DATA => {
@@ -548,8 +550,3 @@ where
548 true 550 true
549 } 551 }
550} 552}
551
552fn slice8_mut(x: &mut [u32]) -> &mut [u8] {
553 let len = x.len() * 4;
554 unsafe { slice::from_raw_parts_mut(x.as_mut_ptr() as _, len) }
555}