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 | |
| parent | 6a1a3e6877053b1b72adb3c1446f4f077ad3b03e (diff) | |
rework event handling to allow sending data
Diffstat (limited to 'src')
| -rw-r--r-- | src/bus.rs | 8 | ||||
| -rw-r--r-- | src/consts.rs | 44 | ||||
| -rw-r--r-- | src/control.rs | 19 | ||||
| -rw-r--r-- | src/events.rs | 111 | ||||
| -rw-r--r-- | src/ioctl.rs | 6 | ||||
| -rw-r--r-- | src/lib.rs | 13 | ||||
| -rw-r--r-- | src/runner.rs | 33 |
7 files changed, 192 insertions, 42 deletions
diff --git a/src/bus.rs b/src/bus.rs index add346b2f..e26f11120 100644 --- a/src/bus.rs +++ b/src/bus.rs | |||
| @@ -1,11 +1,10 @@ | |||
| 1 | use core::slice; | ||
| 2 | |||
| 3 | use embassy_futures::yield_now; | 1 | use embassy_futures::yield_now; |
| 4 | use embassy_time::{Duration, Timer}; | 2 | use embassy_time::{Duration, Timer}; |
| 5 | use embedded_hal_1::digital::OutputPin; | 3 | use embedded_hal_1::digital::OutputPin; |
| 6 | use futures::FutureExt; | 4 | use futures::FutureExt; |
| 7 | 5 | ||
| 8 | use crate::consts::*; | 6 | use crate::consts::*; |
| 7 | use crate::slice8_mut; | ||
| 9 | 8 | ||
| 10 | /// Custom Spi Trait that _only_ supports the bus operation of the cyw43 | 9 | /// Custom Spi Trait that _only_ supports the bus operation of the cyw43 |
| 11 | /// Implementors are expected to hold the CS pin low during an operation. | 10 | /// Implementors are expected to hold the CS pin low during an operation. |
| @@ -327,8 +326,3 @@ fn swap16(x: u32) -> u32 { | |||
| 327 | fn cmd_word(write: bool, incr: bool, func: u32, addr: u32, len: u32) -> u32 { | 326 | fn cmd_word(write: bool, incr: bool, func: u32, addr: u32, len: u32) -> u32 { |
| 328 | (write as u32) << 31 | (incr as u32) << 30 | (func & 0b11) << 28 | (addr & 0x1FFFF) << 11 | (len & 0x7FF) | 327 | (write as u32) << 31 | (incr as u32) << 30 | (func & 0b11) << 28 | (addr & 0x1FFFF) << 11 | (len & 0x7FF) |
| 329 | } | 328 | } |
| 330 | |||
| 331 | fn slice8_mut(x: &mut [u32]) -> &mut [u8] { | ||
| 332 | let len = x.len() * 4; | ||
| 333 | unsafe { slice::from_raw_parts_mut(x.as_mut_ptr() as _, len) } | ||
| 334 | } | ||
diff --git a/src/consts.rs b/src/consts.rs index fee2d01ab..18502bd1a 100644 --- a/src/consts.rs +++ b/src/consts.rs | |||
| @@ -109,6 +109,50 @@ pub(crate) const READ: bool = false; | |||
| 109 | pub(crate) const INC_ADDR: bool = true; | 109 | pub(crate) const INC_ADDR: bool = true; |
| 110 | pub(crate) const FIXED_ADDR: bool = false; | 110 | pub(crate) const FIXED_ADDR: bool = false; |
| 111 | 111 | ||
| 112 | #[allow(non_camel_case_types)] | ||
| 113 | #[derive(Copy, Clone)] | ||
| 114 | #[repr(u8)] | ||
| 115 | pub enum EStatus { | ||
| 116 | /// operation was successful | ||
| 117 | SUCCESS = 0, | ||
| 118 | /// operation failed | ||
| 119 | FAIL = 1, | ||
| 120 | /// operation timed out | ||
| 121 | TIMEOUT = 2, | ||
| 122 | /// failed due to no matching network found | ||
| 123 | NO_NETWORKS = 3, | ||
| 124 | /// operation was aborted | ||
| 125 | ABORT = 4, | ||
| 126 | /// protocol failure: packet not ack'd | ||
| 127 | NO_ACK = 5, | ||
| 128 | /// AUTH or ASSOC packet was unsolicited | ||
| 129 | UNSOLICITED = 6, | ||
| 130 | /// attempt to assoc to an auto auth configuration | ||
| 131 | ATTEMPT = 7, | ||
| 132 | /// scan results are incomplete | ||
| 133 | PARTIAL = 8, | ||
| 134 | /// scan aborted by another scan | ||
| 135 | NEWSCAN = 9, | ||
| 136 | /// scan aborted due to assoc in progress | ||
| 137 | NEWASSOC = 10, | ||
| 138 | /// 802.11h quiet period started | ||
| 139 | _11HQUIET = 11, | ||
| 140 | /// user disabled scanning (WLC_SET_SCANSUPPRESS) | ||
| 141 | SUPPRESS = 12, | ||
| 142 | /// no allowable channels to scan | ||
| 143 | NOCHANS = 13, | ||
| 144 | /// scan aborted due to CCX fast roam | ||
| 145 | CCXFASTRM = 14, | ||
| 146 | /// abort channel select | ||
| 147 | CS_ABORT = 15, | ||
| 148 | } | ||
| 149 | |||
| 150 | impl PartialEq<EStatus> for u32 { | ||
| 151 | fn eq(&self, other: &EStatus) -> bool { | ||
| 152 | *self == *other as Self | ||
| 153 | } | ||
| 154 | } | ||
| 155 | |||
| 112 | #[allow(dead_code)] | 156 | #[allow(dead_code)] |
| 113 | pub(crate) struct FormatStatus(pub u32); | 157 | pub(crate) struct FormatStatus(pub u32); |
| 114 | 158 | ||
diff --git a/src/control.rs b/src/control.rs index 30d5d0924..824c55125 100644 --- a/src/control.rs +++ b/src/control.rs | |||
| @@ -6,7 +6,7 @@ use embassy_time::{Duration, Timer}; | |||
| 6 | 6 | ||
| 7 | pub use crate::bus::SpiBusCyw43; | 7 | pub use crate::bus::SpiBusCyw43; |
| 8 | use crate::consts::*; | 8 | use crate::consts::*; |
| 9 | use crate::events::{Event, EventQueue}; | 9 | use crate::events::{Event, Events}; |
| 10 | use crate::fmt::Bytes; | 10 | use crate::fmt::Bytes; |
| 11 | use crate::ioctl::{IoctlState, IoctlType}; | 11 | use crate::ioctl::{IoctlState, IoctlType}; |
| 12 | use crate::structs::*; | 12 | use crate::structs::*; |
| @@ -14,15 +14,15 @@ use crate::{countries, PowerManagementMode}; | |||
| 14 | 14 | ||
| 15 | pub struct Control<'a> { | 15 | pub struct Control<'a> { |
| 16 | state_ch: ch::StateRunner<'a>, | 16 | state_ch: ch::StateRunner<'a>, |
| 17 | event_sub: &'a EventQueue, | 17 | events: &'a Events, |
| 18 | ioctl_state: &'a IoctlState, | 18 | ioctl_state: &'a IoctlState, |
| 19 | } | 19 | } |
| 20 | 20 | ||
| 21 | impl<'a> Control<'a> { | 21 | impl<'a> Control<'a> { |
| 22 | pub(crate) fn new(state_ch: ch::StateRunner<'a>, event_sub: &'a EventQueue, ioctl_state: &'a IoctlState) -> Self { | 22 | pub(crate) fn new(state_ch: ch::StateRunner<'a>, event_sub: &'a Events, ioctl_state: &'a IoctlState) -> Self { |
| 23 | Self { | 23 | Self { |
| 24 | state_ch, | 24 | state_ch, |
| 25 | event_sub, | 25 | events: event_sub, |
| 26 | ioctl_state, | 26 | ioctl_state, |
| 27 | } | 27 | } |
| 28 | } | 28 | } |
| @@ -195,24 +195,25 @@ impl<'a> Control<'a> { | |||
| 195 | } | 195 | } |
| 196 | 196 | ||
| 197 | async fn wait_for_join(&mut self, i: SsidInfo) { | 197 | async fn wait_for_join(&mut self, i: SsidInfo) { |
| 198 | let mut subscriber = self.event_sub.subscriber().unwrap(); | 198 | self.events.mask.enable(&[Event::JOIN, Event::AUTH]); |
| 199 | let mut subscriber = self.events.queue.subscriber().unwrap(); | ||
| 199 | self.ioctl(IoctlType::Set, IOCTL_CMD_SET_SSID, 0, &mut i.to_bytes()) | 200 | self.ioctl(IoctlType::Set, IOCTL_CMD_SET_SSID, 0, &mut i.to_bytes()) |
| 200 | .await; | 201 | .await; |
| 201 | // set_ssid | 202 | // set_ssid |
| 202 | 203 | ||
| 203 | loop { | 204 | loop { |
| 204 | let msg = subscriber.next_message_pure().await; | 205 | let msg = subscriber.next_message_pure().await; |
| 205 | if msg.event_type == Event::AUTH && msg.status != 0 { | 206 | if msg.header.event_type == Event::AUTH && msg.header.status != 0 { |
| 206 | // retry | 207 | // retry |
| 207 | warn!("JOIN failed with status={}", msg.status); | 208 | warn!("JOIN failed with status={}", msg.header.status); |
| 208 | self.ioctl(IoctlType::Set, IOCTL_CMD_SET_SSID, 0, &mut i.to_bytes()) | 209 | self.ioctl(IoctlType::Set, IOCTL_CMD_SET_SSID, 0, &mut i.to_bytes()) |
| 209 | .await; | 210 | .await; |
| 210 | } else if msg.event_type == Event::JOIN && msg.status == 0 { | 211 | } else if msg.header.event_type == Event::JOIN && msg.header.status == 0 { |
| 211 | // successful join | 212 | // successful join |
| 212 | break; | 213 | break; |
| 213 | } | 214 | } |
| 214 | } | 215 | } |
| 215 | 216 | self.events.mask.disable_all(); | |
| 216 | self.state_ch.set_link_state(LinkState::Up); | 217 | self.state_ch.set_link_state(LinkState::Up); |
| 217 | info!("JOINED"); | 218 | info!("JOINED"); |
| 218 | } | 219 | } |
diff --git a/src/events.rs b/src/events.rs index 87f6c01a3..fbdfbc888 100644 --- a/src/events.rs +++ b/src/events.rs | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | #![allow(unused)] | 1 | #![allow(unused)] |
| 2 | #![allow(non_camel_case_types)] | 2 | #![allow(non_camel_case_types)] |
| 3 | 3 | ||
| 4 | use core::num; | 4 | use core::cell::RefCell; |
| 5 | 5 | ||
| 6 | use embassy_sync::blocking_mutex::raw::NoopRawMutex; | 6 | use embassy_sync::blocking_mutex::raw::NoopRawMutex; |
| 7 | use embassy_sync::pubsub::{PubSubChannel, Publisher, Subscriber}; | 7 | use embassy_sync::pubsub::{PubSubChannel, Publisher, Subscriber}; |
| @@ -284,13 +284,114 @@ pub enum Event { | |||
| 284 | LAST = 190, | 284 | LAST = 190, |
| 285 | } | 285 | } |
| 286 | 286 | ||
| 287 | pub type EventQueue = PubSubChannel<NoopRawMutex, EventStatus, 2, 1, 1>; | 287 | // TODO this PubSub can probably be replaced with shared memory to make it a bit more efficient. |
| 288 | pub type EventPublisher<'a> = Publisher<'a, NoopRawMutex, EventStatus, 2, 1, 1>; | 288 | pub type EventQueue = PubSubChannel<NoopRawMutex, Message, 2, 1, 1>; |
| 289 | pub type EventSubscriber<'a> = Subscriber<'a, NoopRawMutex, EventStatus, 2, 1, 1>; | 289 | pub type EventPublisher<'a> = Publisher<'a, NoopRawMutex, Message, 2, 1, 1>; |
| 290 | pub type EventSubscriber<'a> = Subscriber<'a, NoopRawMutex, Message, 2, 1, 1>; | ||
| 291 | |||
| 292 | pub struct Events { | ||
| 293 | pub queue: EventQueue, | ||
| 294 | pub mask: SharedEventMask, | ||
| 295 | } | ||
| 296 | |||
| 297 | impl Events { | ||
| 298 | pub fn new() -> Self { | ||
| 299 | Self { | ||
| 300 | queue: EventQueue::new(), | ||
| 301 | mask: SharedEventMask::default(), | ||
| 302 | } | ||
| 303 | } | ||
| 304 | } | ||
| 290 | 305 | ||
| 291 | #[derive(Clone, Copy)] | 306 | #[derive(Clone, Copy)] |
| 292 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | 307 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] |
| 293 | pub struct EventStatus { | 308 | pub struct Status { |
| 294 | pub event_type: Event, | 309 | pub event_type: Event, |
| 295 | pub status: u32, | 310 | pub status: u32, |
| 296 | } | 311 | } |
| 312 | |||
| 313 | #[derive(Clone, Copy)] | ||
| 314 | pub enum Payload { | ||
| 315 | None, | ||
| 316 | } | ||
| 317 | |||
| 318 | #[derive(Clone, Copy)] | ||
| 319 | |||
| 320 | pub struct Message { | ||
| 321 | pub header: Status, | ||
| 322 | pub payload: Payload, | ||
| 323 | } | ||
| 324 | |||
| 325 | impl Message { | ||
| 326 | pub fn new(status: Status, payload: Payload) -> Self { | ||
| 327 | Self { | ||
| 328 | header: status, | ||
| 329 | payload, | ||
| 330 | } | ||
| 331 | } | ||
| 332 | } | ||
| 333 | |||
| 334 | const EVENT_BITS: usize = ((Event::LAST as usize + 31) & !31) / 32; | ||
| 335 | |||
| 336 | #[derive(Default)] | ||
| 337 | struct EventMask { | ||
| 338 | mask: [u32; EVENT_BITS], | ||
| 339 | } | ||
| 340 | |||
| 341 | impl EventMask { | ||
| 342 | fn enable(&mut self, event: Event) { | ||
| 343 | let n = event as u32; | ||
| 344 | let word = n >> 5; | ||
| 345 | let bit = n & 0b11111; | ||
| 346 | |||
| 347 | self.mask[word as usize] |= (1 << bit); | ||
| 348 | } | ||
| 349 | |||
| 350 | fn disable(&mut self, event: Event) { | ||
| 351 | let n = event as u32; | ||
| 352 | let word = n >> 5; | ||
| 353 | let bit = n & 0b11111; | ||
| 354 | |||
| 355 | self.mask[word as usize] &= !(1 << bit); | ||
| 356 | } | ||
| 357 | |||
| 358 | fn is_enabled(&self, event: Event) -> bool { | ||
| 359 | let n = event as u32; | ||
| 360 | let word = n >> 5; | ||
| 361 | let bit = n & 0b11111; | ||
| 362 | |||
| 363 | self.mask[word as usize] & (1 << bit) > 0 | ||
| 364 | } | ||
| 365 | } | ||
| 366 | |||
| 367 | #[derive(Default)] | ||
| 368 | |||
| 369 | pub struct SharedEventMask { | ||
| 370 | mask: RefCell<EventMask>, | ||
| 371 | } | ||
| 372 | |||
| 373 | impl SharedEventMask { | ||
| 374 | pub fn enable(&self, events: &[Event]) { | ||
| 375 | let mut mask = self.mask.borrow_mut(); | ||
| 376 | for event in events { | ||
| 377 | mask.enable(*event); | ||
| 378 | } | ||
| 379 | } | ||
| 380 | |||
| 381 | pub fn disable(&self, events: &[Event]) { | ||
| 382 | let mut mask = self.mask.borrow_mut(); | ||
| 383 | for event in events { | ||
| 384 | mask.disable(*event); | ||
| 385 | } | ||
| 386 | } | ||
| 387 | |||
| 388 | pub fn disable_all(&self) { | ||
| 389 | let mut mask = self.mask.borrow_mut(); | ||
| 390 | mask.mask = Default::default(); | ||
| 391 | } | ||
| 392 | |||
| 393 | pub fn is_enabled(&self, event: Event) -> bool { | ||
| 394 | let mask = self.mask.borrow(); | ||
| 395 | mask.is_enabled(event) | ||
| 396 | } | ||
| 397 | } | ||
diff --git a/src/ioctl.rs b/src/ioctl.rs index 89b20a2d6..803934cf9 100644 --- a/src/ioctl.rs +++ b/src/ioctl.rs | |||
| @@ -4,6 +4,8 @@ use core::task::{Poll, Waker}; | |||
| 4 | 4 | ||
| 5 | use embassy_sync::waitqueue::WakerRegistration; | 5 | use embassy_sync::waitqueue::WakerRegistration; |
| 6 | 6 | ||
| 7 | use crate::fmt::Bytes; | ||
| 8 | |||
| 7 | #[derive(Clone, Copy)] | 9 | #[derive(Clone, Copy)] |
| 8 | pub enum IoctlType { | 10 | pub enum IoctlType { |
| 9 | Get = 0, | 11 | Get = 0, |
| @@ -100,6 +102,8 @@ impl IoctlState { | |||
| 100 | 102 | ||
| 101 | pub fn ioctl_done(&self, response: &[u8]) { | 103 | pub fn ioctl_done(&self, response: &[u8]) { |
| 102 | if let IoctlStateInner::Sent { buf } = self.state.get() { | 104 | if let IoctlStateInner::Sent { buf } = self.state.get() { |
| 105 | info!("IOCTL Response: {:02x}", Bytes(response)); | ||
| 106 | |||
| 103 | // TODO fix this | 107 | // TODO fix this |
| 104 | (unsafe { &mut *buf }[..response.len()]).copy_from_slice(response); | 108 | (unsafe { &mut *buf }[..response.len()]).copy_from_slice(response); |
| 105 | 109 | ||
| @@ -107,6 +111,8 @@ impl IoctlState { | |||
| 107 | resp_len: response.len(), | 111 | resp_len: response.len(), |
| 108 | }); | 112 | }); |
| 109 | self.wake_control(); | 113 | self.wake_control(); |
| 114 | } else { | ||
| 115 | warn!("IOCTL Response but no pending Ioctl"); | ||
| 110 | } | 116 | } |
| 111 | } | 117 | } |
| 112 | } | 118 | } |
diff --git a/src/lib.rs b/src/lib.rs index 069ca40f4..f9244bddb 100644 --- a/src/lib.rs +++ b/src/lib.rs | |||
| @@ -18,9 +18,11 @@ mod control; | |||
| 18 | mod nvram; | 18 | mod nvram; |
| 19 | mod runner; | 19 | mod runner; |
| 20 | 20 | ||
| 21 | use core::slice; | ||
| 22 | |||
| 21 | use embassy_net_driver_channel as ch; | 23 | use embassy_net_driver_channel as ch; |
| 22 | use embedded_hal_1::digital::OutputPin; | 24 | use embedded_hal_1::digital::OutputPin; |
| 23 | use events::EventQueue; | 25 | use events::Events; |
| 24 | use ioctl::IoctlState; | 26 | use ioctl::IoctlState; |
| 25 | 27 | ||
| 26 | use crate::bus::Bus; | 28 | use crate::bus::Bus; |
| @@ -103,7 +105,7 @@ const CHIP: Chip = Chip { | |||
| 103 | pub struct State { | 105 | pub struct State { |
| 104 | ioctl_state: IoctlState, | 106 | ioctl_state: IoctlState, |
| 105 | ch: ch::State<MTU, 4, 4>, | 107 | ch: ch::State<MTU, 4, 4>, |
| 106 | events: EventQueue, | 108 | events: Events, |
| 107 | } | 109 | } |
| 108 | 110 | ||
| 109 | impl State { | 111 | impl State { |
| @@ -111,7 +113,7 @@ impl State { | |||
| 111 | Self { | 113 | Self { |
| 112 | ioctl_state: IoctlState::new(), | 114 | ioctl_state: IoctlState::new(), |
| 113 | ch: ch::State::new(), | 115 | ch: ch::State::new(), |
| 114 | events: EventQueue::new(), | 116 | events: Events::new(), |
| 115 | } | 117 | } |
| 116 | } | 118 | } |
| 117 | } | 119 | } |
| @@ -225,3 +227,8 @@ where | |||
| 225 | runner, | 227 | runner, |
| 226 | ) | 228 | ) |
| 227 | } | 229 | } |
| 230 | |||
| 231 | fn slice8_mut(x: &mut [u32]) -> &mut [u8] { | ||
| 232 | let len = x.len() * 4; | ||
| 233 | unsafe { slice::from_raw_parts_mut(x.as_mut_ptr() as _, len) } | ||
| 234 | } | ||
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 | } | ||
