wifi: Move setup to radio module
This commit is contained in:
parent
d7eeb67538
commit
055b03850b
2 changed files with 7 additions and 13 deletions
11
src/main.rs
11
src/main.rs
|
|
@ -112,7 +112,8 @@ async fn main(spawner: Spawner) -> ! {
|
|||
};
|
||||
|
||||
// Setup WiFi
|
||||
let (mut wifi_controller, interfaces) = esp_radio::wifi::new(
|
||||
// sadly, it doesn't work any more when we move `esp_radio::wifi::new` to `setup_wifi_sniffer`
|
||||
let (mut wifi_controller, mut interfaces) = esp_radio::wifi::new(
|
||||
peripherals.WIFI,
|
||||
esp_radio::wifi::ControllerConfig::default(),
|
||||
)
|
||||
|
|
@ -124,9 +125,7 @@ async fn main(spawner: Spawner) -> ! {
|
|||
critical_section::with(|cs| {
|
||||
WIFI_RX_QUEUE.borrow(cs).replace(Some(ArrayQueue::new(2)));
|
||||
});
|
||||
|
||||
let mut sniffer = interfaces.sniffer;
|
||||
radio::setup_wifi_sniffer(WIFI_CHANNEL, &mut sniffer, handle_frame)
|
||||
radio::setup_wifi_sniffer(WIFI_CHANNEL, &mut interfaces.sniffer, handle_frame)
|
||||
.expect("Fatal error initializing 802.11p sniffer");
|
||||
|
||||
info!("WiFi promiscuous mode on channel {WIFI_CHANNEL} running");
|
||||
|
|
@ -276,9 +275,7 @@ fn handle_frame(frame: wifi::sniffer::PromiscuousPkt<'_>) {
|
|||
warn!("Received frame has RX error: {}", frame.rx_cntl.rx_state);
|
||||
return;
|
||||
}
|
||||
|
||||
if !radio::PromiscuousPktType::Data.matches(frame.frame_type) {
|
||||
debug!("Received frame is not a DATA frame: {}", frame.frame_type);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -296,7 +293,7 @@ fn handle_frame(frame: wifi::sniffer::PromiscuousPkt<'_>) {
|
|||
return;
|
||||
}
|
||||
|
||||
debug!("Received frame with {} bytes", frame.len);
|
||||
// info!("Received frame with {} bytes", frame.len);
|
||||
|
||||
// Send data to main thread
|
||||
critical_section::with(|cs| {
|
||||
|
|
|
|||
Loading…
Reference in a new issue