wpan/mac: use lifetimes to control events
This commit is contained in:
@ -73,8 +73,10 @@ async fn main(spawner: Spawner) {
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
let evt = mbox.mac_subsystem.read().await;
|
||||
defmt::info!("{:#x}", evt);
|
||||
{
|
||||
let evt = mbox.mac_subsystem.read().await;
|
||||
defmt::info!("{:#x}", evt.mac_event());
|
||||
}
|
||||
|
||||
info!("setting extended address");
|
||||
let extended_address: u64 = 0xACDE480000000001;
|
||||
@ -85,8 +87,10 @@ async fn main(spawner: Spawner) {
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
let evt = mbox.mac_subsystem.read().await;
|
||||
defmt::info!("{:#x}", evt);
|
||||
{
|
||||
let evt = mbox.mac_subsystem.read().await;
|
||||
defmt::info!("{:#x}", evt.mac_event());
|
||||
}
|
||||
|
||||
info!("setting short address");
|
||||
let short_address: u16 = 0x1122;
|
||||
@ -97,8 +101,10 @@ async fn main(spawner: Spawner) {
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
let evt = mbox.mac_subsystem.read().await;
|
||||
defmt::info!("{:#x}", evt);
|
||||
{
|
||||
let evt = mbox.mac_subsystem.read().await;
|
||||
defmt::info!("{:#x}", evt.mac_event());
|
||||
}
|
||||
|
||||
info!("setting association permit");
|
||||
let association_permit: bool = true;
|
||||
@ -109,8 +115,10 @@ async fn main(spawner: Spawner) {
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
let evt = mbox.mac_subsystem.read().await;
|
||||
defmt::info!("{:#x}", evt);
|
||||
{
|
||||
let evt = mbox.mac_subsystem.read().await;
|
||||
defmt::info!("{:#x}", evt.mac_event());
|
||||
}
|
||||
|
||||
info!("setting TX power");
|
||||
let transmit_power: i8 = 2;
|
||||
@ -121,8 +129,10 @@ async fn main(spawner: Spawner) {
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
let evt = mbox.mac_subsystem.read().await;
|
||||
defmt::info!("{:#x}", evt);
|
||||
{
|
||||
let evt = mbox.mac_subsystem.read().await;
|
||||
defmt::info!("{:#x}", evt.mac_event());
|
||||
}
|
||||
|
||||
info!("starting FFD device");
|
||||
mbox.mac_subsystem
|
||||
@ -137,8 +147,10 @@ async fn main(spawner: Spawner) {
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
let evt = mbox.mac_subsystem.read().await;
|
||||
defmt::info!("{:#x}", evt);
|
||||
{
|
||||
let evt = mbox.mac_subsystem.read().await;
|
||||
defmt::info!("{:#x}", evt.mac_event());
|
||||
}
|
||||
|
||||
info!("setting RX on when idle");
|
||||
let rx_on_while_idle: bool = true;
|
||||
@ -149,14 +161,16 @@ async fn main(spawner: Spawner) {
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
let evt = mbox.mac_subsystem.read().await;
|
||||
defmt::info!("{:#x}", evt);
|
||||
{
|
||||
let evt = mbox.mac_subsystem.read().await;
|
||||
defmt::info!("{:#x}", evt.mac_event());
|
||||
}
|
||||
|
||||
loop {
|
||||
let evt = mbox.mac_subsystem.read().await;
|
||||
defmt::info!("{:#x}", evt);
|
||||
defmt::info!("{:#x}", evt.mac_event());
|
||||
|
||||
if let Ok(evt) = evt {
|
||||
if let Ok(evt) = evt.mac_event() {
|
||||
match evt {
|
||||
MacEvent::MlmeAssociateInd(association) => mbox
|
||||
.mac_subsystem
|
||||
|
@ -75,8 +75,10 @@ async fn main(spawner: Spawner) {
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
let evt = mbox.mac_subsystem.read().await;
|
||||
info!("{:#x}", evt);
|
||||
{
|
||||
let evt = mbox.mac_subsystem.read().await;
|
||||
defmt::info!("{:#x}", evt.mac_event());
|
||||
}
|
||||
|
||||
info!("setting extended address");
|
||||
let extended_address: u64 = 0xACDE480000000002;
|
||||
@ -87,8 +89,10 @@ async fn main(spawner: Spawner) {
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
let evt = mbox.mac_subsystem.read().await;
|
||||
info!("{:#x}", evt);
|
||||
{
|
||||
let evt = mbox.mac_subsystem.read().await;
|
||||
defmt::info!("{:#x}", evt.mac_event());
|
||||
}
|
||||
|
||||
info!("getting extended address");
|
||||
mbox.mac_subsystem
|
||||
@ -98,14 +102,17 @@ async fn main(spawner: Spawner) {
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
let evt = mbox.mac_subsystem.read().await;
|
||||
info!("{:#x}", evt);
|
||||
|
||||
if let Ok(MacEvent::MlmeGetCnf(evt)) = evt {
|
||||
if evt.pib_attribute_value_len == 8 {
|
||||
let value = unsafe { core::ptr::read_unaligned(evt.pib_attribute_value_ptr as *const u64) };
|
||||
{
|
||||
let evt = mbox.mac_subsystem.read().await;
|
||||
info!("{:#x}", evt.mac_event());
|
||||
|
||||
info!("value {:#x}", value)
|
||||
if let Ok(MacEvent::MlmeGetCnf(evt)) = evt.mac_event() {
|
||||
if evt.pib_attribute_value_len == 8 {
|
||||
let value = unsafe { core::ptr::read_unaligned(evt.pib_attribute_value_ptr as *const u64) };
|
||||
|
||||
info!("value {:#x}", value)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -124,13 +131,15 @@ async fn main(spawner: Spawner) {
|
||||
};
|
||||
info!("{}", a);
|
||||
mbox.mac_subsystem.send_command(&a).await.unwrap();
|
||||
let evt = mbox.mac_subsystem.read().await;
|
||||
info!("{:#x}", evt);
|
||||
let short_addr = {
|
||||
let evt = mbox.mac_subsystem.read().await;
|
||||
info!("{:#x}", evt.mac_event());
|
||||
|
||||
let short_addr = if let Ok(MacEvent::MlmeAssociateCnf(conf)) = evt {
|
||||
conf.assoc_short_address
|
||||
} else {
|
||||
defmt::panic!()
|
||||
if let Ok(MacEvent::MlmeAssociateCnf(conf)) = evt.mac_event() {
|
||||
conf.assoc_short_address
|
||||
} else {
|
||||
defmt::panic!()
|
||||
}
|
||||
};
|
||||
|
||||
info!("setting short address");
|
||||
@ -141,8 +150,10 @@ async fn main(spawner: Spawner) {
|
||||
})
|
||||
.await
|
||||
.unwrap();
|
||||
let evt = mbox.mac_subsystem.read().await;
|
||||
info!("{:#x}", evt);
|
||||
{
|
||||
let evt = mbox.mac_subsystem.read().await;
|
||||
info!("{:#x}", evt.mac_event());
|
||||
}
|
||||
|
||||
info!("sending data");
|
||||
let data = b"Hello from embassy!";
|
||||
@ -163,11 +174,13 @@ async fn main(spawner: Spawner) {
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
let evt = mbox.mac_subsystem.read().await;
|
||||
info!("{:#x}", evt);
|
||||
{
|
||||
let evt = mbox.mac_subsystem.read().await;
|
||||
info!("{:#x}", evt.mac_event());
|
||||
}
|
||||
|
||||
loop {
|
||||
let evt = mbox.mac_subsystem.read().await;
|
||||
info!("{:#x}", evt);
|
||||
info!("{:#x}", evt.mac_event());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user