[package]
name = "esp-radio"
version = "0.17.0"
edition = "2024"
rust-version  = "1.88.0"
description = "A WiFi, Bluetooth and ESP-NOW driver for use with Espressif chips and bare-metal Rust"
documentation = "https://docs.espressif.com/projects/rust/esp-wifi/latest/"
keywords = ["wifi", "bluetooth", "esp-now", "esp32", "no-std"]
categories = ["embedded", "hardware-support", "no-std"]
repository = "https://github.com/esp-rs/esp-hal"
license = "MIT OR Apache-2.0"

[package.metadata.espressif]
doc-config = { features = ["esp-hal/unstable", "esp-hal/rt", "defmt"], append = [
    { if = 'chip_has("wifi")', features = ["wifi", "wifi-eap", "esp-now", "sniffer", "smoltcp/proto-ipv4", "smoltcp/proto-ipv6"] },
    { if = 'chip_has("bt")', features = ["ble"] },
    { if = 'chip_has("ieee802154")', features = ["ieee802154", "__docs_build"] },
    { if = 'chip_has("wifi") && chip_has("bt")', features = ["coex"] },
    { if = 'chip_has("wifi") || chip_has("bt") || chip_has("ieee802154")', features = ["unstable"] },
] }
check-configs = [
    { features = ["esp-hal/unstable", "esp-hal/rt"] },
    { features = ["esp-hal/unstable", "esp-hal/rt", "defmt"] },
    { features = ["esp-hal/unstable", "esp-hal/rt", "wifi"], if = 'chip_has("wifi")' },
    { features = ["esp-hal/unstable", "esp-hal/rt", "unstable", "defmt", "wifi", "wifi-eap", "esp-now", "sniffer", "smoltcp/proto-ipv4", "smoltcp/proto-ipv6"], if = 'chip_has("wifi")' },
    { features = ["esp-hal/unstable", "esp-hal/rt", "unstable", "ble"], if = 'chip_has("bt")' },
    { features = ["esp-hal/unstable", "esp-hal/rt", "unstable", "ieee802154"], if = 'chip_has("ieee802154")' },
    { features = ["esp-hal/unstable", "esp-hal/rt", "unstable", "defmt", "wifi", "wifi-eap", "esp-now", "sniffer", "smoltcp/proto-ipv4", "smoltcp/proto-ipv6", "ble", "coex"], if = 'chip_has("wifi") && chip_has("bt")' },
    { features = ["esp-hal/unstable", "esp-hal/rt", "wifi-eap", "unstable"], if = 'chip_has("wifi")' },
]
clippy-configs = [
    { features = ["esp-hal/unstable", "esp-hal/rt"] },
    { features = ["esp-hal/unstable", "esp-hal/rt", "wifi", "wifi-eap", "unstable"], if = 'chip_has("wifi")', append = [
        { features = ["ble"], if = 'chip_has("bt")' },
    ] },
]

[lib]
bench = false
test  = false

[dependencies]
cfg-if  = "1"
esp-hal = { version = "1.0.0", path = "../esp-hal", default-features = false, features = ["requires-unstable"] }
portable-atomic = { version = "1.11", default-features = false }
enumset = { version = "1.1", default-features = false, optional = true }

# ⚠️ Unstable dependencies
esp-radio-rtos-driver = { version = "0.2.0", path = "../esp-radio-rtos-driver" }
instability = "0.3.9"

# Unstable dependencies that are not (strictly) part of the public API
allocator-api2 = { version = "0.3.0", default-features = false, features = ["alloc"] }
document-features  = "0.2"
esp-alloc = { version = "0.9.0", path = "../esp-alloc", optional = true }
esp-config = { version = "0.6.1", path = "../esp-config" }
esp-metadata-generated = { version = "0.3.0", path = "../esp-metadata-generated" }
esp-sync = { version = "0.1.1", path = "../esp-sync" }
esp-phy = { version = "0.1.1", path = "../esp-phy/" }
num-derive = "0.4.2"
num-traits = { version = "0.2.19", default-features = false }
portable_atomic_enum = { version = "0.3.1", features = ["portable-atomic"] }
procmacros = { version = "0.21.0", package = "esp-hal-procmacros", path = "../esp-hal-procmacros" }
xtensa-lx-rt = { version = "0.21.0", path = "../xtensa-lx-rt", optional = true }
byte = { version = "0.2.7", optional = true }
ieee802154 = { version = "0.6.1", optional = true }
heapless = "0.9"
# Make sure these are aligned with esp-phy's dependencies, too!
esp-wifi-sys-esp32 = { git = "https://github.com/esp-rs/esp-wifi-sys", rev = "7623c8d", optional = true }
esp-wifi-sys-esp32c2 = { git = "https://github.com/esp-rs/esp-wifi-sys", rev = "7623c8d", optional = true }
esp-wifi-sys-esp32c3 = { git = "https://github.com/esp-rs/esp-wifi-sys", rev = "7623c8d", optional = true }
esp-wifi-sys-esp32c6 = { git = "https://github.com/esp-rs/esp-wifi-sys", rev = "7623c8d", optional = true }
esp-wifi-sys-esp32h2 = { git = "https://github.com/esp-rs/esp-wifi-sys", rev = "7623c8d", optional = true }
esp-wifi-sys-esp32s2 = { git = "https://github.com/esp-rs/esp-wifi-sys", rev = "7623c8d", optional = true }
esp-wifi-sys-esp32s3 = { git = "https://github.com/esp-rs/esp-wifi-sys", rev = "7623c8d", optional = true }

# Optional dependencies enabling ecosystem features
embedded-io-06 = { package = "embedded-io", version = "0.6", default-features = false, optional = true }
embedded-io-async-06 = { package = "embedded-io-async", version = "0.6", default-features = false, optional = true }
embedded-io-07 = { package = "embedded-io", version = "0.7", default-features = false, optional = true }
embedded-io-async-07 = { package = "embedded-io-async", version = "0.7", default-features = false, optional = true }
smoltcp = { version = "0.12.0", default-features = false, features = [
  "medium-ethernet",
  "socket-raw",
], optional = true }
embassy-net-driver = { version = "0.2.0", optional = true }
bt-hci = { version = "0.6.0", optional = true }

# Logging interfaces, they are mutually exclusive so they need to be behind separate features.
defmt = { version = "1.0.1", optional = true }
log-04 = { package = "log", version = "0.4.27", optional = true }

[build-dependencies]
esp-config = { version = "0.6.1", path = "../esp-config", features = ["build"] }
esp-metadata-generated = { version = "0.3.0", path = "../esp-metadata-generated", features = ["build-script"] }

[dev-dependencies]
esp-rtos = { version = "0.2.0", path = "../esp-rtos" }

[features]
default = ["esp-alloc"]

## Use `esp-alloc` with the `compat` feature for dynamic allocations.
##
## If you opt-out, you need to provide implementations for the following functions:
## - `pub extern "C" fn malloc(size: usize) -> *mut u8`
## - `pub extern "C" fn malloc_internal(size: usize) -> *mut u8`
## - `pub extern "C" fn free(ptr: *mut u8)`
## - `pub extern "C" fn free_internal(ptr: *mut u8)`
## - `pub extern "C" fn calloc(number: u32, size: usize) -> *mut u8`
## - `pub extern "C" fn calloc_internal(number: u32, size: usize) -> *mut u8`
## - `pub extern "C" fn realloc(ptr: *mut u8, new_size: usize) -> *mut u8`
## - `pub extern "C" fn get_free_internal_heap_size() -> usize;`
## 
## Note that the untyped nature of the allocator functions means that esp-alloc is likely the more memory efficient option.
esp-alloc = ["dep:esp-alloc"]

## Logs the Wi-Fi logs from the driver at log level info (needs a nightly-compiler)
sys-logs = [
    "esp-wifi-sys-esp32/sys-logs",
    "esp-wifi-sys-esp32c2/sys-logs",
    "esp-wifi-sys-esp32c3/sys-logs",
    "esp-wifi-sys-esp32c6/sys-logs",
    "esp-wifi-sys-esp32h2/sys-logs",
    "esp-wifi-sys-esp32s2/sys-logs",
    "esp-wifi-sys-esp32s3/sys-logs",
]

#! ### Chip selection
#! One of the following features must be enabled to select the target chip:

##
esp32 = [
  "esp-hal/esp32",
  "esp-rtos/esp32",
  "esp-phy/esp32",
  "dep:esp-wifi-sys-esp32",
  "esp-metadata-generated/esp32",
  "xtensa-lx-rt/float-save-restore",
]
##
esp32c2 = [
  "esp-hal/esp32c2",
  "esp-rtos/esp32c2",
  "esp-phy/esp32c2",
  "dep:esp-wifi-sys-esp32c2",
  "esp-metadata-generated/esp32c2",
]
##
esp32c3 = [
  "esp-hal/esp32c3",
  "esp-rtos/esp32c3",
  "esp-phy/esp32c3",
  "dep:esp-wifi-sys-esp32c3",
  "esp-metadata-generated/esp32c3",
]
##
esp32c6 = [
  "esp-hal/esp32c6",
  "esp-rtos/esp32c6",
  "esp-phy/esp32c6",
  "dep:esp-wifi-sys-esp32c6",
  "esp-metadata-generated/esp32c6",
]
##
esp32h2 = [
  "esp-hal/esp32h2",
  "esp-rtos/esp32h2",
  "esp-phy/esp32h2",
  "dep:esp-wifi-sys-esp32h2",
  "esp-metadata-generated/esp32h2",
]
##
esp32s2 = [
  "esp-hal/esp32s2",
  "esp-rtos/esp32s2",
  "esp-phy/esp32s2",
  "dep:esp-wifi-sys-esp32s2",
  "esp-metadata-generated/esp32s2",
  "xtensa-lx-rt/float-save-restore",
]
##
esp32s3 = [
  "esp-hal/esp32s3",
  "esp-rtos/esp32s3",
  "esp-phy/esp32s3",
  "dep:esp-wifi-sys-esp32s3",
  "esp-metadata-generated/esp32s3",
  "xtensa-lx-rt/float-save-restore",
]

#! ### Wireless Feature Flags

## Enable Wi-Fi support.
wifi = ["dep:enumset", "dep:embassy-net-driver"]

## Enable Wi-Fi Enterprise Authentication Protocol (EAP) support.
##
## ⚠️ This feature is considered unstable.
wifi-eap = ["wifi"]

## Enable ESP-NOW support.
##
## ⚠️ This feature is considered unstable.
esp-now = ["wifi"]

## Enable sniffer mode support for Wi-Fi.
##
## ⚠️ This feature is considered unstable.
sniffer = ["wifi"]

## Enable BLE support.
##
## ⚠️ This feature is considered unstable.
ble = ["esp-hal/__bluetooth", "dep:bt-hci"]

## Software controls Wi-Fi/Bluetooth coexistence.
## See [ESP-IDF Programming Guide](https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/kconfig-reference.html#config-esp-coex-sw-coexist-enable) for details.
##
## ⚠️ This feature is considered unstable.
coex = []

## Enable Wi-Fi channel state information. See [Wi-Fi Driver](https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-guides/wifi.html#wi-fi-channel-state-information).
##
## ⚠️ This feature is considered unstable.
csi = []

## Enable IEEE 802.15.4.
## Cannot be used together with Wi-Fi.
##
## ⚠️ This feature is considered unstable.
ieee802154 = ["dep:byte", "dep:ieee802154"]

#! ### Ecosystem Feature Flags

## Provide implementations of smoltcp traits.
##
## ⚠️ This feature is considered unstable.
smoltcp = ["dep:smoltcp"]

#! ### Logging Feature Flags
## Enable logging output using version 0.4 of the `log` crate.
log-04 = [
    "dep:log-04",
   "esp-hal/log-04",
   "esp-wifi-sys-esp32/log",
   "esp-wifi-sys-esp32c2/log",
   "esp-wifi-sys-esp32c3/log",
   "esp-wifi-sys-esp32c6/log",
   "esp-wifi-sys-esp32h2/log",
   "esp-wifi-sys-esp32s2/log",
   "esp-wifi-sys-esp32s3/log",
   "esp-phy/log-04",
]

## Enable logging output using `defmt` and implement `defmt::Format` on certain types.
defmt = [
    "dep:defmt",
    "smoltcp?/defmt",
    "esp-hal/defmt",
    "bt-hci?/defmt",
    "esp-wifi-sys-esp32/defmt",
    "esp-wifi-sys-esp32c2/defmt",
    "esp-wifi-sys-esp32c3/defmt",
    "esp-wifi-sys-esp32c6/defmt",
    "esp-wifi-sys-esp32h2/defmt",
    "esp-wifi-sys-esp32s2/defmt",
    "esp-wifi-sys-esp32s3/defmt",
    "enumset/defmt",
    "heapless/defmt",
    "esp-sync/defmt",
    "esp-phy/defmt",
]

#! ### Unstable APIs
#! Unstable APIs are drivers and features that are not yet ready for general use.
#! They may be incomplete, have bugs, or be subject to change without notice.

## Enables APIs that are not stable and thus come with no stability guarantees.
## Never enable this feature in a library crate using esp-radio.
unstable = [
  "dep:embedded-io-06",
  "dep:embedded-io-async-06",
  "dep:embedded-io-07",
  "dep:embedded-io-async-07",
]

## Libraries that depend on `esp-radio` should enable this feature to indicate their use of unstable APIs.
## However, they must **not** enable the `unstable` feature themselves.
##
## For development you can enable the `unstable` and the chip feature by adding esp-radio as a dev-dependency.
requires-unstable = []

# These features are considered private and unstable. They are not covered by
# semver guarantees and may change or be removed without notice.
__docs_build = []

[package.metadata.docs.rs]
features = [
  "esp32c6",
  "wifi",
  "ble",
  "coex",
  "esp-hal/default",
]
default-target = "riscv32imac-unknown-none-elf"

# `esp-alloc` and `xtensa-lx-rt` are hidden behind features so `cargo machete` incorrectly marks it as unused.
[package.metadata.cargo-machete]
ignored = ["esp-alloc", "xtensa-lx-rt"]
