mirror of
https://github.com/esp-rs/esp-hal.git
synced 2025-09-26 20:00:32 +00:00
Get rid of EspRadio
prefix in esp-radio
structs (#3869)
* get rid of `EspRadio` prefix in esp-radio structs * changelog entry + migration guide entry * reword entries * fmt run * Fix migration guide entry * edit the changelog entry to still reflect `esp-wifi` changes
This commit is contained in:
parent
a215aca629
commit
8ca0f94715
@ -16,7 +16,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
- `esp_wifi::init` no longer needs an `RNG` driver. (#3829)
|
||||
- The `builtin-scheduler` feature has been removed. Your project will have to specify a task scheduler. (#3855)
|
||||
- Rename `esp-wifi` to `esp-radio`. (#3858)
|
||||
- `esp-wifi` has been renamed to `esp-radio`. (#3858)
|
||||
- Removed `EspWifi` prefix from structs in the package codebase. (#3869)
|
||||
|
||||
### Fixed
|
||||
|
||||
|
@ -23,3 +23,10 @@ Furthermore, `esp_wifi::init` no longer requires `RNG` or a timer.
|
||||
- esp-wifi = "0.15.0"
|
||||
+ esp-radio = "{{currentVersion}}"
|
||||
```
|
||||
|
||||
## `EspWifi` prefix has been removed
|
||||
|
||||
```diff
|
||||
- use esp_wifi::EspWifiController;
|
||||
+ use esp_radio::Controller;
|
||||
```
|
||||
|
@ -1,7 +1,7 @@
|
||||
use embedded_io::{Error, ErrorType, Read, Write};
|
||||
|
||||
use super::{read_hci, read_next, send_hci};
|
||||
use crate::EspRadioController;
|
||||
use crate::Controller;
|
||||
|
||||
/// A blocking HCI connector
|
||||
pub struct BleConnector<'d> {
|
||||
@ -16,7 +16,7 @@ impl Drop for BleConnector<'_> {
|
||||
|
||||
impl<'d> BleConnector<'d> {
|
||||
pub fn new(
|
||||
_init: &'d EspRadioController<'d>,
|
||||
_init: &'d Controller<'d>,
|
||||
device: crate::hal::peripherals::BT<'d>,
|
||||
) -> BleConnector<'d> {
|
||||
crate::ble::ble_init();
|
||||
|
@ -2,7 +2,7 @@
|
||||
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
||||
/// Tunable parameters for the WiFi driver
|
||||
#[allow(unused)] // currently there are no ble tunables
|
||||
pub(crate) struct EspRadioConfig {
|
||||
pub(crate) struct Config {
|
||||
pub(crate) rx_queue_size: usize,
|
||||
pub(crate) tx_queue_size: usize,
|
||||
pub(crate) static_rx_buf_num: usize,
|
||||
|
@ -170,7 +170,7 @@ const _: () = {
|
||||
};
|
||||
};
|
||||
|
||||
pub(crate) const CONFIG: config::EspRadioConfig = config::EspRadioConfig {
|
||||
pub(crate) const CONFIG: config::Config = config::Config {
|
||||
rx_queue_size: esp_config_int!(usize, "ESP_RADIO_CONFIG_RX_QUEUE_SIZE"),
|
||||
tx_queue_size: esp_config_int!(usize, "ESP_RADIO_CONFIG_TX_QUEUE_SIZE"),
|
||||
static_rx_buf_num: esp_config_int!(usize, "ESP_RADIO_CONFIG_STATIC_RX_BUF_NUM"),
|
||||
@ -197,11 +197,11 @@ pub(crate) const CONFIG: config::EspRadioConfig = config::EspRadioConfig {
|
||||
|
||||
#[derive(Debug, PartialEq, PartialOrd)]
|
||||
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
||||
pub struct EspRadioController<'d> {
|
||||
pub struct Controller<'d> {
|
||||
_inner: PhantomData<&'d ()>,
|
||||
}
|
||||
|
||||
impl Drop for EspRadioController<'_> {
|
||||
impl Drop for Controller<'_> {
|
||||
fn drop(&mut self) {
|
||||
// Disable coexistence
|
||||
#[cfg(coex)]
|
||||
@ -220,7 +220,7 @@ impl Drop for EspRadioController<'_> {
|
||||
/// Initialize for using WiFi and or BLE.
|
||||
///
|
||||
/// Make sure to **not** call this function while interrupts are disabled.
|
||||
pub fn init<'d>() -> Result<EspRadioController<'d>, InitializationError> {
|
||||
pub fn init<'d>() -> Result<Controller<'d>, InitializationError> {
|
||||
if crate::is_interrupts_disabled() {
|
||||
return Err(InitializationError::InterruptsDisabled);
|
||||
}
|
||||
@ -257,7 +257,7 @@ pub fn init<'d>() -> Result<EspRadioController<'d>, InitializationError> {
|
||||
error => return Err(InitializationError::General(error)),
|
||||
}
|
||||
|
||||
Ok(EspRadioController {
|
||||
Ok(Controller {
|
||||
_inner: PhantomData,
|
||||
})
|
||||
}
|
||||
|
@ -62,12 +62,12 @@ use smoltcp::phy::{Device, DeviceCapabilities, RxToken, TxToken};
|
||||
pub use state::*;
|
||||
|
||||
use crate::{
|
||||
EspRadioController,
|
||||
Controller,
|
||||
common_adapter::*,
|
||||
config::PowerSaveMode,
|
||||
esp_wifi_result,
|
||||
hal::ram,
|
||||
wifi::private::EspRadioPacketBuffer,
|
||||
wifi::private::PacketBuffer,
|
||||
};
|
||||
|
||||
const MTU: usize = crate::CONFIG.mtu;
|
||||
@ -1148,11 +1148,9 @@ impl CsiConfig {
|
||||
const RX_QUEUE_SIZE: usize = crate::CONFIG.rx_queue_size;
|
||||
const TX_QUEUE_SIZE: usize = crate::CONFIG.tx_queue_size;
|
||||
|
||||
pub(crate) static DATA_QUEUE_RX_AP: Locked<VecDeque<EspRadioPacketBuffer>> =
|
||||
Locked::new(VecDeque::new());
|
||||
pub(crate) static DATA_QUEUE_RX_AP: Locked<VecDeque<PacketBuffer>> = Locked::new(VecDeque::new());
|
||||
|
||||
pub(crate) static DATA_QUEUE_RX_STA: Locked<VecDeque<EspRadioPacketBuffer>> =
|
||||
Locked::new(VecDeque::new());
|
||||
pub(crate) static DATA_QUEUE_RX_STA: Locked<VecDeque<PacketBuffer>> = Locked::new(VecDeque::new());
|
||||
|
||||
/// Common errors.
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
@ -1452,10 +1450,10 @@ unsafe extern "C" fn recv_cb_sta(
|
||||
len: u16,
|
||||
eb: *mut c_types::c_void,
|
||||
) -> esp_err_t {
|
||||
let packet = EspRadioPacketBuffer { buffer, len, eb };
|
||||
let packet = PacketBuffer { buffer, len, eb };
|
||||
// We must handle the result outside of the lock because
|
||||
// EspRadioPacketBuffer::drop must not be called in a critical section.
|
||||
// Dropping an EspRadioPacketBuffer will call `esp_wifi_internal_free_rx_buffer`
|
||||
// PacketBuffer::drop must not be called in a critical section.
|
||||
// Dropping an PacketBuffer will call `esp_wifi_internal_free_rx_buffer`
|
||||
// which will try to lock an internal mutex. If the mutex is already taken,
|
||||
// the function will try to trigger a context switch, which will fail if we
|
||||
// are in an interrupt-free context.
|
||||
@ -1483,10 +1481,10 @@ unsafe extern "C" fn recv_cb_ap(
|
||||
len: u16,
|
||||
eb: *mut c_types::c_void,
|
||||
) -> esp_err_t {
|
||||
let packet = EspRadioPacketBuffer { buffer, len, eb };
|
||||
let packet = PacketBuffer { buffer, len, eb };
|
||||
// We must handle the result outside of the critical section because
|
||||
// EspRadioPacketBuffer::drop must not be called in a critical section.
|
||||
// Dropping an EspRadioPacketBuffer will call `esp_wifi_internal_free_rx_buffer`
|
||||
// PacketBuffer::drop must not be called in a critical section.
|
||||
// Dropping an PacketBuffer will call `esp_wifi_internal_free_rx_buffer`
|
||||
// which will try to lock an internal mutex. If the mutex is already taken,
|
||||
// the function will try to trigger a context switch, which will fail if we
|
||||
// are in an interrupt-free context.
|
||||
@ -1708,27 +1706,27 @@ mod private {
|
||||
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
||||
/// Take care not to drop this while in a critical section.
|
||||
///
|
||||
/// Dropping an EspRadioPacketBuffer will call
|
||||
/// Dropping an PacketBuffer will call
|
||||
/// `esp_wifi_internal_free_rx_buffer` which will try to lock an
|
||||
/// internal mutex. If the mutex is already taken, the function will try
|
||||
/// to trigger a context switch, which will fail if we are in a critical
|
||||
/// section.
|
||||
pub struct EspRadioPacketBuffer {
|
||||
pub struct PacketBuffer {
|
||||
pub(crate) buffer: *mut c_types::c_void,
|
||||
pub(crate) len: u16,
|
||||
pub(crate) eb: *mut c_types::c_void,
|
||||
}
|
||||
|
||||
unsafe impl Send for EspRadioPacketBuffer {}
|
||||
unsafe impl Send for PacketBuffer {}
|
||||
|
||||
impl Drop for EspRadioPacketBuffer {
|
||||
impl Drop for PacketBuffer {
|
||||
fn drop(&mut self) {
|
||||
trace!("Dropping EspRadioPacketBuffer, freeing memory");
|
||||
trace!("Dropping PacketBuffer, freeing memory");
|
||||
unsafe { esp_wifi_internal_free_rx_buffer(self.eb) };
|
||||
}
|
||||
}
|
||||
|
||||
impl EspRadioPacketBuffer {
|
||||
impl PacketBuffer {
|
||||
pub fn as_slice_mut(&mut self) -> &mut [u8] {
|
||||
unsafe { core::slice::from_raw_parts_mut(self.buffer as *mut u8, self.len as usize) }
|
||||
}
|
||||
@ -1758,7 +1756,7 @@ impl WifiDeviceMode {
|
||||
}
|
||||
}
|
||||
|
||||
fn data_queue_rx(&self) -> &'static Locked<VecDeque<EspRadioPacketBuffer>> {
|
||||
fn data_queue_rx(&self) -> &'static Locked<VecDeque<PacketBuffer>> {
|
||||
match self {
|
||||
WifiDeviceMode::Sta => &DATA_QUEUE_RX_STA,
|
||||
WifiDeviceMode::Ap => &DATA_QUEUE_RX_AP,
|
||||
@ -2213,8 +2211,8 @@ impl WifiRxToken {
|
||||
});
|
||||
|
||||
// We handle the received data outside of the lock because
|
||||
// EspRadioPacketBuffer::drop must not be called in a critical section.
|
||||
// Dropping an EspRadioPacketBuffer will call `esp_wifi_internal_free_rx_buffer`
|
||||
// PacketBuffer::drop must not be called in a critical section.
|
||||
// Dropping an PacketBuffer will call `esp_wifi_internal_free_rx_buffer`
|
||||
// which will try to lock an internal mutex. If the mutex is already
|
||||
// taken, the function will try to trigger a context switch, which will
|
||||
// fail if we are in an interrupt-free context.
|
||||
@ -2652,7 +2650,7 @@ pub struct Interfaces<'d> {
|
||||
/// Make sure to **not** call this function while interrupts are disabled, or IEEE 802.15.4 is
|
||||
/// currently in use.
|
||||
pub fn new<'d>(
|
||||
_inited: &'d EspRadioController<'d>,
|
||||
_inited: &'d Controller<'d>,
|
||||
_device: crate::hal::peripherals::WIFI<'d>,
|
||||
) -> Result<(WifiController<'d>, Interfaces<'d>), WifiError> {
|
||||
if crate::is_interrupts_disabled() {
|
||||
|
@ -34,7 +34,7 @@ use esp_backtrace as _;
|
||||
use esp_hal::{clock::CpuClock, rng::Rng, timer::timg::TimerGroup};
|
||||
use esp_println::{print, println};
|
||||
use esp_radio::{
|
||||
EspRadioController,
|
||||
Controller,
|
||||
wifi::{
|
||||
AccessPointConfiguration,
|
||||
Configuration,
|
||||
@ -70,7 +70,7 @@ async fn main(spawner: Spawner) -> ! {
|
||||
let timg0 = TimerGroup::new(peripherals.TIMG0);
|
||||
esp_radio_preempt_baremetal::init(timg0.timer0);
|
||||
|
||||
let esp_wifi_ctrl = &*mk_static!(EspRadioController<'static>, esp_radio::init().unwrap());
|
||||
let esp_wifi_ctrl = &*mk_static!(Controller<'static>, esp_radio::init().unwrap());
|
||||
|
||||
let (controller, interfaces) = esp_radio::wifi::new(&esp_wifi_ctrl, peripherals.WIFI).unwrap();
|
||||
|
||||
|
@ -40,7 +40,7 @@ use esp_backtrace as _;
|
||||
use esp_hal::{clock::CpuClock, rng::Rng, timer::timg::TimerGroup};
|
||||
use esp_println::{print, println};
|
||||
use esp_radio::{
|
||||
EspRadioController,
|
||||
Controller,
|
||||
wifi::{
|
||||
AccessPointConfiguration,
|
||||
ClientConfiguration,
|
||||
@ -78,7 +78,7 @@ async fn main(spawner: Spawner) -> ! {
|
||||
let timg0 = TimerGroup::new(peripherals.TIMG0);
|
||||
esp_radio_preempt_baremetal::init(timg0.timer0);
|
||||
|
||||
let esp_wifi_ctrl = &*mk_static!(EspRadioController<'static>, esp_radio::init().unwrap());
|
||||
let esp_wifi_ctrl = &*mk_static!(Controller<'static>, esp_radio::init().unwrap());
|
||||
|
||||
let (mut controller, interfaces) =
|
||||
esp_radio::wifi::new(&esp_wifi_ctrl, peripherals.WIFI).unwrap();
|
||||
|
@ -31,7 +31,7 @@ use esp_backtrace as _;
|
||||
use esp_hal::{clock::CpuClock, rng::Rng, timer::timg::TimerGroup};
|
||||
use esp_println::println;
|
||||
use esp_radio::{
|
||||
EspRadioController,
|
||||
Controller,
|
||||
wifi::{ClientConfiguration, Configuration, WifiController, WifiDevice, WifiEvent, WifiState},
|
||||
};
|
||||
|
||||
@ -78,7 +78,7 @@ async fn main(spawner: Spawner) -> ! {
|
||||
let timg0 = TimerGroup::new(peripherals.TIMG0);
|
||||
esp_radio_preempt_baremetal::init(timg0.timer0);
|
||||
|
||||
let esp_wifi_ctrl = &*mk_static!(EspRadioController<'static>, esp_radio::init().unwrap());
|
||||
let esp_wifi_ctrl = &*mk_static!(Controller<'static>, esp_radio::init().unwrap());
|
||||
|
||||
let (mut controller, interfaces) =
|
||||
esp_radio::wifi::new(&esp_wifi_ctrl, peripherals.WIFI).unwrap();
|
||||
|
@ -37,7 +37,7 @@ use esp_hal::{
|
||||
timer::timg::TimerGroup,
|
||||
};
|
||||
use esp_println::println;
|
||||
use esp_radio::{EspRadioController, ble::controller::BleConnector};
|
||||
use esp_radio::{Controller, ble::controller::BleConnector};
|
||||
|
||||
esp_bootloader_esp_idf::esp_app_desc!();
|
||||
|
||||
@ -62,7 +62,7 @@ async fn main(_spawner: Spawner) -> ! {
|
||||
let timg0 = TimerGroup::new(peripherals.TIMG0);
|
||||
esp_radio_preempt_baremetal::init(timg0.timer0);
|
||||
|
||||
let esp_wifi_ctrl = &*mk_static!(EspRadioController<'static>, esp_radio::init().unwrap());
|
||||
let esp_wifi_ctrl = &*mk_static!(Controller<'static>, esp_radio::init().unwrap());
|
||||
|
||||
let config = InputConfig::default().with_pull(Pull::Down);
|
||||
cfg_if::cfg_if! {
|
||||
|
@ -24,7 +24,7 @@ use esp_backtrace as _;
|
||||
use esp_hal::{clock::CpuClock, rng::Rng, timer::timg::TimerGroup};
|
||||
use esp_println::println;
|
||||
use esp_radio::{
|
||||
EspRadioController,
|
||||
Controller,
|
||||
wifi::{ClientConfiguration, Configuration, WifiController, WifiDevice, WifiEvent, WifiState},
|
||||
};
|
||||
|
||||
@ -54,7 +54,7 @@ async fn main(spawner: Spawner) -> ! {
|
||||
let timg0 = TimerGroup::new(peripherals.TIMG0);
|
||||
esp_radio_preempt_baremetal::init(timg0.timer0);
|
||||
|
||||
let esp_wifi_ctrl = &*mk_static!(EspRadioController<'static>, esp_radio::init().unwrap());
|
||||
let esp_wifi_ctrl = &*mk_static!(Controller<'static>, esp_radio::init().unwrap());
|
||||
|
||||
let (controller, interfaces) = esp_radio::wifi::new(&esp_wifi_ctrl, peripherals.WIFI).unwrap();
|
||||
|
||||
|
@ -18,7 +18,7 @@ use esp_backtrace as _;
|
||||
use esp_hal::{clock::CpuClock, timer::timg::TimerGroup};
|
||||
use esp_println::println;
|
||||
use esp_radio::{
|
||||
EspRadioController,
|
||||
Controller,
|
||||
esp_now::{BROADCAST_ADDRESS, PeerInfo},
|
||||
};
|
||||
|
||||
@ -45,7 +45,7 @@ async fn main(_spawner: Spawner) -> ! {
|
||||
let timg0 = TimerGroup::new(peripherals.TIMG0);
|
||||
esp_radio_preempt_baremetal::init(timg0.timer0);
|
||||
|
||||
let esp_wifi_ctrl = &*mk_static!(EspRadioController<'static>, esp_radio::init().unwrap());
|
||||
let esp_wifi_ctrl = &*mk_static!(Controller<'static>, esp_radio::init().unwrap());
|
||||
|
||||
let wifi = peripherals.WIFI;
|
||||
let (mut controller, interfaces) = esp_radio::wifi::new(&esp_wifi_ctrl, wifi).unwrap();
|
||||
|
@ -19,7 +19,7 @@ use esp_backtrace as _;
|
||||
use esp_hal::{clock::CpuClock, timer::timg::TimerGroup};
|
||||
use esp_println::println;
|
||||
use esp_radio::{
|
||||
EspRadioController,
|
||||
Controller,
|
||||
esp_now::{BROADCAST_ADDRESS, EspNowManager, EspNowReceiver, EspNowSender, PeerInfo},
|
||||
};
|
||||
|
||||
@ -46,7 +46,7 @@ async fn main(spawner: Spawner) -> ! {
|
||||
let timg0 = TimerGroup::new(peripherals.TIMG0);
|
||||
esp_radio_preempt_baremetal::init(timg0.timer0);
|
||||
|
||||
let esp_wifi_ctrl = &*mk_static!(EspRadioController<'static>, esp_radio::init().unwrap());
|
||||
let esp_wifi_ctrl = &*mk_static!(Controller<'static>, esp_radio::init().unwrap());
|
||||
|
||||
let wifi = peripherals.WIFI;
|
||||
let (mut controller, interfaces) = esp_radio::wifi::new(&esp_wifi_ctrl, wifi).unwrap();
|
||||
|
Loading…
x
Reference in New Issue
Block a user