comment some choices for current event handling
This commit is contained in:
parent
582a15a693
commit
9e96655757
2 changed files with 8 additions and 2 deletions
|
@ -197,18 +197,20 @@ impl<'a> Control<'a> {
|
||||||
async fn wait_for_join(&mut self, i: SsidInfo) {
|
async fn wait_for_join(&mut self, i: SsidInfo) {
|
||||||
self.events.mask.enable(&[Event::JOIN, Event::AUTH]);
|
self.events.mask.enable(&[Event::JOIN, Event::AUTH]);
|
||||||
let mut subscriber = self.events.queue.subscriber().unwrap();
|
let mut subscriber = self.events.queue.subscriber().unwrap();
|
||||||
|
// the actual join operation starts here
|
||||||
|
// we make sure to enable events before so we don't miss any
|
||||||
self.ioctl(IoctlType::Set, IOCTL_CMD_SET_SSID, 0, &mut i.to_bytes())
|
self.ioctl(IoctlType::Set, IOCTL_CMD_SET_SSID, 0, &mut i.to_bytes())
|
||||||
.await;
|
.await;
|
||||||
// set_ssid
|
// set_ssid
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let msg = subscriber.next_message_pure().await;
|
let msg = subscriber.next_message_pure().await;
|
||||||
if msg.header.event_type == Event::AUTH && msg.header.status != 0 {
|
if msg.header.event_type == Event::AUTH && msg.header.status != EStatus::SUCCESS {
|
||||||
// retry
|
// retry
|
||||||
warn!("JOIN failed with status={}", msg.header.status);
|
warn!("JOIN failed with status={}", msg.header.status);
|
||||||
self.ioctl(IoctlType::Set, IOCTL_CMD_SET_SSID, 0, &mut i.to_bytes())
|
self.ioctl(IoctlType::Set, IOCTL_CMD_SET_SSID, 0, &mut i.to_bytes())
|
||||||
.await;
|
.await;
|
||||||
} else if msg.header.event_type == Event::JOIN && msg.header.status == 0 {
|
} else if msg.header.event_type == Event::JOIN && msg.header.status == EStatus::SUCCESS {
|
||||||
// successful join
|
// successful join
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -406,6 +406,10 @@ where
|
||||||
let status = event_packet.msg.status;
|
let status = event_packet.msg.status;
|
||||||
let event_payload = events::Payload::None;
|
let event_payload = events::Payload::None;
|
||||||
|
|
||||||
|
// this intentionally uses the non-blocking publish immediate
|
||||||
|
// publish() is a deadlock risk in the current design as awaiting here prevents ioctls
|
||||||
|
// The `Runner` always yields when accessing the device, so consumers always have a chance to receive the event
|
||||||
|
// (if they are actively awaiting the queue)
|
||||||
self.events.queue.publish_immediate(events::Message::new(
|
self.events.queue.publish_immediate(events::Message::new(
|
||||||
Status {
|
Status {
|
||||||
event_type: evt_type,
|
event_type: evt_type,
|
||||||
|
|
Loading…
Reference in a new issue