diff options
| author | kbleeke <[email protected]> | 2023-04-02 20:19:47 +0200 |
|---|---|---|
| committer | kbleeke <[email protected]> | 2023-04-25 19:14:00 +0200 |
| commit | 2d7ba44621fa35abad07d2ddb8b253e815ce2c1f (patch) | |
| tree | 999561ce27e3662a22ee2590c79eaa0791099953 /src/runner.rs | |
| parent | 6a1a3e6877053b1b72adb3c1446f4f077ad3b03e (diff) | |
rework event handling to allow sending data
Diffstat (limited to 'src/runner.rs')
| -rw-r--r-- | src/runner.rs | 33 |
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 @@ | |||
| 1 | use core::slice; | ||
| 2 | |||
| 3 | use embassy_futures::select::{select3, Either3}; | 1 | use embassy_futures::select::{select3, Either3}; |
| 4 | use embassy_net_driver_channel as ch; | 2 | use embassy_net_driver_channel as ch; |
| 5 | use embassy_sync::pubsub::PubSubBehavior; | 3 | use embassy_sync::pubsub::PubSubBehavior; |
| @@ -9,12 +7,12 @@ use embedded_hal_1::digital::OutputPin; | |||
| 9 | use crate::bus::Bus; | 7 | use crate::bus::Bus; |
| 10 | pub use crate::bus::SpiBusCyw43; | 8 | pub use crate::bus::SpiBusCyw43; |
| 11 | use crate::consts::*; | 9 | use crate::consts::*; |
| 12 | use crate::events::{EventQueue, EventStatus}; | 10 | use crate::events::{Events, Status}; |
| 13 | use crate::fmt::Bytes; | 11 | use crate::fmt::Bytes; |
| 14 | use crate::ioctl::{IoctlState, IoctlType, PendingIoctl}; | 12 | use crate::ioctl::{IoctlState, IoctlType, PendingIoctl}; |
| 15 | use crate::nvram::NVRAM; | 13 | use crate::nvram::NVRAM; |
| 16 | use crate::structs::*; | 14 | use crate::structs::*; |
| 17 | use crate::{events, Core, CHIP, MTU}; | 15 | use crate::{events, slice8_mut, Core, CHIP, MTU}; |
| 18 | 16 | ||
| 19 | #[cfg(feature = "firmware-logs")] | 17 | #[cfg(feature = "firmware-logs")] |
| 20 | struct LogState { | 18 | struct 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 | |||
| 552 | fn 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 | } | ||
