macro_rules! init_wifi { ($ssid:expr, $password:expr, $peripherals:ident, $system:ident, $clocks:ident) => { ... }; }
Expand description
Macro to initialize the WiFi interface with the given SSID and password in
mqtt
(or async) configuration. This macro configures the WiFi controller
and initializes the WiFi interface.
Example:
let peripherals = take_periph!();
let system = take_system!(peripherals);
let (clocks, pins) = init_chip!(peripherals, system);
let timer = get_timer(peripherals, clocks);
let mut socket_set_entries: [smoltcp::iface::SocketStorage; 3] = Default::default();
embassy::init(&clocks, timer);
let (mut wifi_interface, controller) =
init_wifi!(SSID, PASS, peripherals, system, clocks, socket_set_entries);
§Non-async version of function (mqtt
feature disabled)
Initializes the WiFi interface with the given SSID and password. This macro sets up the WiFi controller, starts the WiFi subsystem, and connects to the specified network. It also initiates a WiFi scan and waits for an IP address to be assigned.
§Arguments
$ssid
- The SSID of the WiFi network to connect to.$password
- The password of the WiFi network.$peripherals
- The ESP peripherals instance, providing access to the device’s peripherals.$system
- The system peripheral instance, used for system-level configurations.$clocks
- The clocks configuration, used for timing and delays.$sock_entries
- Mutable reference to the socket entries, used for network socket management.
§Returns
Returns a tuple containing the initialized WifiStack
, along with two
buffers for network operations.
§Usage
This macro is intended to be used for setting up WiFi connectivity in environments where asynchronous operations are NOT used.
§Example
let (wifi_stack, rx_buffer, tx_buffer) =
init_wifi!(SSID, PASSWORD, peripherals, system, clocks, sock_entries);