parsing MAC structs
This commit is contained in:
@ -7,7 +7,7 @@ use embassy_executor::Spawner;
|
||||
use embassy_stm32::bind_interrupts;
|
||||
use embassy_stm32::ipcc::{Config, ReceiveInterruptHandler, TransmitInterruptHandler};
|
||||
use embassy_stm32_wpan::sub::mac::commands::{ResetRequest, SetRequest, StartRequest};
|
||||
use embassy_stm32_wpan::sub::mac::typedefs::PibId;
|
||||
use embassy_stm32_wpan::sub::mac::typedefs::{MacChannel, PibId};
|
||||
use embassy_stm32_wpan::sub::mm;
|
||||
use embassy_stm32_wpan::TlMbox;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
@ -65,109 +65,92 @@ async fn main(spawner: Spawner) {
|
||||
info!("initialized mac: {}", result);
|
||||
|
||||
info!("resetting");
|
||||
let response = mbox
|
||||
.mac_subsystem
|
||||
mbox.mac_subsystem
|
||||
.send_command(ResetRequest { set_default_pib: true })
|
||||
.await;
|
||||
info!("{}", response);
|
||||
.await
|
||||
.unwrap();
|
||||
let evt = mbox.mac_subsystem.read().await;
|
||||
defmt::info!("{:#x}", evt);
|
||||
|
||||
info!("setting extended address");
|
||||
let extended_address: u64 = 0xACDE480000000001;
|
||||
let response = mbox
|
||||
.mac_subsystem
|
||||
mbox.mac_subsystem
|
||||
.send_command(SetRequest {
|
||||
pib_attribute_ptr: &extended_address as *const _ as *const u8,
|
||||
pib_attribute: PibId::ExtendedAddress,
|
||||
})
|
||||
.await;
|
||||
info!("{}", response);
|
||||
.await
|
||||
.unwrap();
|
||||
let evt = mbox.mac_subsystem.read().await;
|
||||
defmt::info!("{:#x}", evt);
|
||||
|
||||
info!("setting short address");
|
||||
let short_address: u16 = 0x1122;
|
||||
let response = mbox
|
||||
.mac_subsystem
|
||||
mbox.mac_subsystem
|
||||
.send_command(SetRequest {
|
||||
pib_attribute_ptr: &short_address as *const _ as *const u8,
|
||||
pib_attribute: PibId::ShortAddress,
|
||||
})
|
||||
.await;
|
||||
info!("{}", response);
|
||||
.await
|
||||
.unwrap();
|
||||
let evt = mbox.mac_subsystem.read().await;
|
||||
defmt::info!("{:#x}", evt);
|
||||
|
||||
info!("setting association permit");
|
||||
let association_permit: bool = true;
|
||||
let response = mbox
|
||||
.mac_subsystem
|
||||
mbox.mac_subsystem
|
||||
.send_command(SetRequest {
|
||||
pib_attribute_ptr: &association_permit as *const _ as *const u8,
|
||||
pib_attribute: PibId::AssociationPermit,
|
||||
})
|
||||
.await;
|
||||
info!("{}", response);
|
||||
.await
|
||||
.unwrap();
|
||||
let evt = mbox.mac_subsystem.read().await;
|
||||
defmt::info!("{:#x}", evt);
|
||||
|
||||
info!("setting TX power");
|
||||
let transmit_power: i8 = 2;
|
||||
let response = mbox
|
||||
.mac_subsystem
|
||||
mbox.mac_subsystem
|
||||
.send_command(SetRequest {
|
||||
pib_attribute_ptr: &transmit_power as *const _ as *const u8,
|
||||
pib_attribute: PibId::TransmitPower,
|
||||
})
|
||||
.await;
|
||||
info!("{}", response);
|
||||
.await
|
||||
.unwrap();
|
||||
let evt = mbox.mac_subsystem.read().await;
|
||||
defmt::info!("{:#x}", evt);
|
||||
|
||||
info!("starting FFD device");
|
||||
let response = mbox
|
||||
.mac_subsystem
|
||||
mbox.mac_subsystem
|
||||
.send_command(StartRequest {
|
||||
channel_number: 16,
|
||||
channel_number: MacChannel::Channel16,
|
||||
beacon_order: 0x0F,
|
||||
superframe_order: 0x0F,
|
||||
pan_coordinator: true,
|
||||
battery_life_extension: false,
|
||||
..Default::default()
|
||||
})
|
||||
.await;
|
||||
info!("{}", response);
|
||||
.await
|
||||
.unwrap();
|
||||
let evt = mbox.mac_subsystem.read().await;
|
||||
defmt::info!("{:#x}", evt);
|
||||
|
||||
info!("setting RX on when idle");
|
||||
let rx_on_while_idle: bool = true;
|
||||
let response = mbox
|
||||
.mac_subsystem
|
||||
mbox.mac_subsystem
|
||||
.send_command(SetRequest {
|
||||
pib_attribute_ptr: &rx_on_while_idle as *const _ as *const u8,
|
||||
pib_attribute: PibId::RxOnWhenIdle,
|
||||
})
|
||||
.await;
|
||||
info!("{}", response);
|
||||
.await
|
||||
.unwrap();
|
||||
let evt = mbox.mac_subsystem.read().await;
|
||||
defmt::info!("{:#x}", evt);
|
||||
|
||||
// info!("association request");
|
||||
// mbox.mac_subsystem
|
||||
// .send_command(AssociateRequest {
|
||||
// channel_number: 16,
|
||||
// channel_page: 0,
|
||||
// coord_addr_mode: 2,
|
||||
// coord_address: MacAddress { short: [0x22, 0x11] },
|
||||
// capability_information: 0x80,
|
||||
// coord_pan_id: [0xAA, 0x1A],
|
||||
// security_level: 0,
|
||||
|
||||
// key_id_mode: 0,
|
||||
// key_index: 0,
|
||||
// key_source: [0; 8],
|
||||
// })
|
||||
// .await;
|
||||
// info!("reading");
|
||||
// let result = mbox.mac_subsystem.read().await;
|
||||
// info!("{}", result.payload());
|
||||
|
||||
//
|
||||
// info!("starting ble...");
|
||||
// mbox.ble_subsystem.t_write(0x0c, &[]).await;
|
||||
//
|
||||
// info!("waiting for ble...");
|
||||
// let ble_event = mbox.ble_subsystem.tl_read().await;
|
||||
//
|
||||
// info!("ble event: {}", ble_event.payload());
|
||||
loop {
|
||||
let evt = mbox.mac_subsystem.read().await;
|
||||
defmt::info!("{:#x}", evt);
|
||||
}
|
||||
|
||||
info!("Test OK");
|
||||
cortex_m::asm::bkpt();
|
||||
|
@ -7,7 +7,9 @@ use embassy_executor::Spawner;
|
||||
use embassy_stm32::bind_interrupts;
|
||||
use embassy_stm32::ipcc::{Config, ReceiveInterruptHandler, TransmitInterruptHandler};
|
||||
use embassy_stm32_wpan::sub::mac::commands::{AssociateRequest, ResetRequest, SetRequest, StartRequest};
|
||||
use embassy_stm32_wpan::sub::mac::typedefs::{AddressMode, MacAddress, PibId};
|
||||
use embassy_stm32_wpan::sub::mac::typedefs::{
|
||||
AddressMode, Capabilities, KeyIdMode, MacAddress, MacChannel, PibId, SecurityLevel,
|
||||
};
|
||||
use embassy_stm32_wpan::sub::mm;
|
||||
use embassy_stm32_wpan::TlMbox;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
@ -86,14 +88,14 @@ async fn main(spawner: Spawner) {
|
||||
let response = mbox
|
||||
.mac_subsystem
|
||||
.send_command(AssociateRequest {
|
||||
channel_number: 16,
|
||||
channel_number: MacChannel::Channel16,
|
||||
channel_page: 0,
|
||||
coord_addr_mode: AddressMode::Short,
|
||||
coord_address: MacAddress { short: [0x22, 0x11] },
|
||||
capability_information: 0x80,
|
||||
coord_address: MacAddress::Short([0x22, 0x11]),
|
||||
capability_information: Capabilities::ALLOCATE_ADDRESS,
|
||||
coord_pan_id: [0xAA, 0x1A],
|
||||
security_level: 0x00,
|
||||
key_id_mode: 0,
|
||||
security_level: SecurityLevel::Unsecure,
|
||||
key_id_mode: KeyIdMode::Implicite,
|
||||
key_source: [0; 8],
|
||||
key_index: 0,
|
||||
})
|
||||
|
Reference in New Issue
Block a user