0
0
Fork 0

wifi: Move setup to radio module

This commit is contained in:
Jannik Beyerstedt 2026-07-20 11:48:15 +02:00
commit 055b03850b
2 changed files with 7 additions and 13 deletions

View file

@ -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| {

View file

@ -1,9 +1,6 @@
//! IEEE 802.11p C-ITS Capture with ESP32-C5
#![allow(unused)]
#[cfg(feature = "esp")]
use esp_radio::wifi::sniffer;
// -----------------------------
// missing interface definitions
// -----------------------------
@ -77,8 +74,8 @@ impl PromiscuousPktType {
/// Configure WiFi Sniffer to a certain 802.11p channel
pub fn setup_wifi_sniffer(
channel: Channel,
sniffer: &mut sniffer::Sniffer,
callback: fn(sniffer::PromiscuousPkt<'_>),
sniffer: &mut esp_radio::wifi::sniffer::Sniffer,
callback: fn(esp_radio::wifi::sniffer::PromiscuousPkt<'_>),
) -> Result<(), alloc::string::String> {
sniffer
.set_promiscuous_mode(true)
@ -106,7 +103,7 @@ pub fn setup_wifi_sniffer(
/// # Errors
/// Fails when MAC is not the right size or returns frame send error
pub fn send_80211_bcast_frame(
sniffer: &mut sniffer::Sniffer,
sniffer: &mut esp_radio::wifi::sniffer::Sniffer,
mac_addr: &[u8],
data: &[u8],
) -> Result<(), alloc::string::String> {