Wi-Fi Guide
Overview
ameba_wifi is the Rust Wi-Fi stack for RTL8721F. The AP core (KM4TZ, running this crate) talks to the Wi-Fi firmware on the NP core over WHC (Wi-Fi Host Controller) IPC, split into two channels: channel 7 (API, control plane — wifi_on/wifi_connect/wifi_start_ap/…) and channel 6 (TRX, data plane — RX/TX packets). ameba_wifi::net::WhcDevice wraps channel 6 as both a raw smoltcp::Device and an embassy_net_driver::Driver, so application code can build either a hand-rolled smoltcp interface or an embassy-net Stack on top of it.
Scope and Limitations
STA connect: Open and WPA2-PSK only.
wifi_connectsupportsSecurityType::OpenandSecurityType::Wpa2AesPsk(4-way handshake, PBKDF2-SHA1-4096 PMK derivation, key install — see STA Connect (WPA2-PSK)). WPA3/SAE is not implemented, and there is no automatic reconnect on disconnect.Scan results are not retrievable.
wifi_scan()/wifi_scan_abort()can trigger or abort a scan, but NP’s scan-result callback (API_D2H_SCAN_USER_CALLBACK) has no handler inrun_blk_api()— it falls through to the unknown-event branch, so there is currently no way to read back a scan result list from Rust.No DNS or TLS. The
embassy-netstack is built without a DNS resolver, so remote hosts must be addressed by IPv4 literal, and no TLS layer is provided.No power-save toggle, roaming, regulatory-domain, or CSI-capture APIs.
ips_enable/lps_enableare fixed at boot time inside thewifi_user_confblob sent duringwifi_on— there is no runtime API to change them, and roaming / regulatory domain / CSI capture have no code path at all yet.
Architecture
AP core (KM4TZ, ameba-wifi crate)
│
├── ch7 API (control plane) wifi_on / wifi_connect / wifi_start_ap / wifi_scan / ...
│ — send_api_req() blocks until NP ACKs
│ — NP→AP events (WifiEvent) arrive via run_blk_api()
│
└── ch6 TRX (data plane) WhcDevice — smoltcp::Device + embassy_net_driver::Driver
│
▼
NP core (Wi-Fi firmware)
Quick Start
Every Wi-Fi program starts with the same init sequence, regardless of whether it ends up as a STA or a SoftAP:
#[embassy_executor::task]
async fn whc_task() {
ameba_wifi::run_blk_api().await;
}
// 1. HAL init: sys_timer (embassy-time) + IPC_CPU0_IRQ.
ameba_hal::init(ameba_hal::Config::default());
// 2. Register WHC IPC channel handlers (ch6 TRX + ch7 API).
ameba_wifi::init();
// 3. Spawn the background task that processes NP→AP requests.
spawner.spawn(whc_task()).unwrap();
// 4. Turn on the WiFi NP. `wifi_on` boots the STA interface, ...
let rc = ameba_wifi::wifi::wifi_on().await;
From here, see the SoftAP section below to start an access point, the STA Connect section to join an existing network, the MQTT Client section for running an MQTT session over the resulting embassy-net stack, or the Wi-Fi Events section for how WifiEvent delivery works.
SoftAP
wifi_start_ap/wifi_stop_ap start and stop a basic access point. This is v1.0 scope: single client group, broadcast SSID only, and either open or WPA2-AES-PSK security — no multi-client management, hidden SSID, WPA3-AP, or STA+AP concurrent operation yet.
pub async fn wifi_start_ap(
ssid: &str,
password: &str,
security: SecurityType,
channel: u8,
) -> i32
securitymust beSecurityType::OpenorSecurityType::Wpa2AesPsk.ssidmust be 1..=32 bytes.passwordmust be empty forOpen, or 8..=64 bytes forWpa2AesPsk.Returns the
retNP wrote (0 = success).
wifi_stop_ap() tears the AP interface down, and NP handles _wifi_off_ap internally, so there is no separate deinit call to make.
Application Example
The Rust SDK provides one example, wifi-ap: it starts an open SoftAP, watches for station associate events for 30 seconds, then stops the AP.
const AP_SSID: &str = "ameba-rust-ap";
const AP_PASSWORD: &str = "";
const AP_CHANNEL: u8 = 1;
// ... after ameba_hal::init / ameba_wifi::init / whc_task spawn / wifi_on ...
let rc = ameba_wifi::wifi::wifi_start_ap(
AP_SSID,
AP_PASSWORD,
SecurityType::Open,
AP_CHANNEL,
)
.await;
// 6. Observe station associate/disassociate events for a fixed window.
// `with_timeout` wraps the whole loop: it cancels the loop (dropping
// whichever `receive().await` is in flight) once the window elapses,
// regardless of how many events were handled inside.
println!("[ap] observing for {}s ...", AP_OBSERVE_WINDOW.as_secs());
let _ = embassy_time::with_timeout(AP_OBSERVE_WINDOW, async {
loop {
let evt: WifiEvent = ameba_wifi::EVENT_CHAN.receive().await;
match evt.event_code {
event_code::AP_STA_ASSOC => {
let mac = if evt.evt_info != 0 {
Some(unsafe { read_ap_sta_mac(evt.evt_info) })
} else {
None
};
// ...
}
event_code::AP_STA_DISASSOC => {
// ...
}
other => println!("[ap] event: code={} (other)", other),
}
}
})
.await;
let rc = ameba_wifi::wifi::wifi_stop_ap().await;
Expected serial output:
[build] <build timestamp>
[wifi] init
[wifi] on: 0
[ap] starting SSID="ameba-rust-ap" channel=1 ...
[ap] start_ap returned: 0
[PASS] softap: start_ap accepted
[ap] observing for 30s ...
[ap] event: code=0 (STA_ASSOC) mac=xx:xx:xx:xx:xx:xx
[ap] stop_ap returned: 0
[PASS] softap: stop_ap accepted
The [ap] event: line only appears if a station joins during the window. Debug lines from the Wi-Fi core such as [blk_api] and [WLAN-A] are interleaved with the output above.
Note
Build and flash the example with cargo xtask run example --name wifi-ap --port <serial-port>.
STA Connect (WPA2-PSK)
wifi_connect associates the STA interface to an AP.
pub async fn wifi_connect(
ssid: &str,
password: &str,
security: SecurityType,
) -> i32
ssidmust be ≤ 32 bytes;passwordmust be ≤ 63 bytes.Only
SecurityType::OpenandSecurityType::Wpa2AesPskwork end to end. Unlikewifi_start_ap,wifi_connectdoes not reject otherSecurityTypevalues up front — passingWpa3AesPsk/Wpa2Wpa3Mixstill reaches NP, but the PMK-derivation step below only recognizes the WPA/WPA2-PSK security bitmask combinations, so the PMK is never derived and the join stalls or fails; SAE (WPA3) is not implemented.Returns 0 if NP accepted the request — this is not the connect result. The actual outcome (success/fail/disconnect) arrives asynchronously as a
JOIN_STATUSWifiEvent(see Wi-Fi Events below).
WPA2-PSK Handshake
For a Wpa2AesPsk connection, NP drives a PMK request and a full 4-way handshake through three event codes (108, 104, 106) before the STA is actually on the network. These are handled entirely inside run_blk_api(), synchronously, before that event’s ACK is sent to NP — application code never sees them on EVENT_CHAN:
API_D2H_WIFI_EVENT => {
let event_code = params[0];
let evt_info = params[1]; // pointer to extra event info (may be 0)
...
if event_code == crate::wifi::events::event_code::WPA_SET_PSK_INFO {
crate::wifi::psk::handle_set_psk_info(evt_info).await;
} else if event_code == crate::wifi::events::event_code::WPA_STA_4WAY_START {
crate::wifi::handshake::handle_4way_start(evt_info, true).await;
} else if event_code == crate::wifi::events::event_code::WPA_STA_4WAY_RECV {
crate::wifi::handshake::handle_4way_recv(evt_info).await;
} else {
// ... non-handshake events go to EVENT_CHAN ...
}
}
108 (PMK request): NP sends the SSID/passphrase pair back to the AP core;
psk::handle_set_psk_infoderives the PMK withpbkdf2_hmac::<Sha1>(passphrase, ssid, 4096, ..)(measured ≈361ms at 240MHz — a one-shot cost per connection, not a per-packet one), then unconditionally sendsWHC_API_WIFI_START_JOIN_CMDto let NP continue 802.11 association.104/106 (4-way handshake): once associated,
handshake::handle_4way_start/handle_4way_recvrun the PTK derivation (PRF-384 over the PMK, AP/STA MACs and nonces), verify each frame’s MIC, unwrap the GTK from M3’s AES-Key-Wrapped Key Data, install both keys viaWHC_API_WIFI_ADD_KEY, and send M2/M4 back throughWHC_API_WIFI_SEND_EAPOL.
The only externally visible effect is that join_status now passes through two additional states while this runs: HANDSHAKING (7) after 104, then HANDSHAKE_DONE (8) followed immediately by SUCCESS (9) after M4 is sent in 106. A full connection’s status sequence is SCANNING → AUTHENTICATING → AUTHENTICATED → ASSOCIATED → HANDSHAKING → HANDSHAKE_DONE → SUCCESS. AUTHENTICATING can appear twice when the AP deauthenticates the first attempt and the Wi-Fi core retries; STARTING is not reported in practice.
Note
Only STA-side handshake events (104/106/108) are wired up. The SoftAP-side equivalents (105/107, WPA_AP_4WAY_START/WPA_AP_4WAY_RECV) are defined but have no handler in run_blk_api(). wifi_start_ap accepts Wpa2AesPsk, but the wifi-ap example exercises Open security only, see SoftAP above.
No Automatic Reconnect
There is no reconnect-on-disconnect behavior anywhere in the stack: neither the Wi-Fi core firmware nor ameba_wifi reconnects automatically. After a join_status::DISCONNECT or FAIL event, application code must call wifi_connect again itself — see the retry branch in the example below.
Application Example
The Rust SDK provides one example, wifi-connect: it connects to a Wpa2AesPsk network, waits for JOIN_STATUS to reach ASSOCIATED/SUCCESS (retrying on FAIL), then hands EVENT_CHAN off to a permanent consumer task before bringing up DHCP.
const WIFI_SSID: &str = "your-ssid";
const WIFI_PASSWORD: &str = "your-password";
/// TCP port probed on the DHCP gateway; the check passes only if it is open.
const TCP_PORT: u16 = 8080;
// ... after ameba_hal::init / ameba_wifi::init / whc_task spawn / wifi_on ...
// 5. Connect — WPA2-AES-PSK.
println!("[wifi] connecting to \"{}\" ...", WIFI_SSID);
let rc =
ameba_wifi::wifi::wifi_connect(WIFI_SSID, WIFI_PASSWORD, SecurityType::Wpa2AesPsk).await;
println!("[wifi] connect returned: {}", rc);
// 6. Wait for the JOIN_STATUS event (event_code 2 = RTW_EVENT_JOIN_STATUS).
// NP fires this event for every status transition; we loop until we see
// ASSOCIATED/SUCCESS, FAIL (retry), or DISCONNECT.
loop {
let evt: WifiEvent = ameba_wifi::EVENT_CHAN.receive().await;
println!("[wifi] event: code={}", evt.event_code);
if evt.event_code == event_code::JOIN_STATUS {
let status = if evt.evt_info != 0 {
unsafe { read_join_status(evt.evt_info) }
} else {
join_status::UNKNOWN
};
println!("[wifi] join_status={}", status as u32);
match status {
join_status::ASSOCIATED | join_status::SUCCESS => {
ameba_wifi::net::set_link_up(true);
println!("[NET] WiFi connected");
break;
}
join_status::FAIL => {
println!("[wifi] connect failed, retrying in 3s ...");
Timer::after(Duration::from_secs(3)).await;
let rc = ameba_wifi::wifi::wifi_connect(
WIFI_SSID,
WIFI_PASSWORD,
SecurityType::Wpa2AesPsk,
)
.await;
println!("[wifi] connect returned: {}", rc);
}
join_status::DISCONNECT => {
ameba_wifi::net::set_link_up(false);
println!("[FAIL] embassy-net: WiFi disconnected before association");
return;
}
_ => {} // intermediate status (SCANNING, ASSOCIATING, etc.)
}
}
}
// 6b. Hand off EVENT_CHAN to a permanent consumer so a later disconnect
// (or any other WIFI_EVENT) never stalls run_blk_api's ACK to NP.
spawner.spawn(event_task()).unwrap();
// ... 7-10: MAC query, embassy-net Stack setup, DHCP, TCP connect test ...
The permanent event consumer handed off to in step 6b:
#[embassy_executor::task]
async fn event_task() -> ! {
loop {
let evt: WifiEvent = ameba_wifi::EVENT_CHAN.receive().await;
if evt.event_code == event_code::JOIN_STATUS {
let status = if evt.evt_info != 0 {
unsafe { read_join_status(evt.evt_info) }
} else {
join_status::UNKNOWN
};
println!("[wifi] event: code={} join_status={}", evt.event_code, status as u32);
match status {
join_status::ASSOCIATED | join_status::SUCCESS => {
ameba_wifi::net::set_link_up(true);
println!("[NET] WiFi (re)connected");
}
join_status::DISCONNECT => {
ameba_wifi::net::set_link_up(false);
println!("[NET] WiFi disconnected");
}
_ => {}
}
} else {
println!("[wifi] event: code={}", evt.event_code);
}
}
}
Expected serial output:
[build] <build timestamp>
[wifi] init
[wifi] on: 0
[wifi] connecting to "<ssid>" ...
[wifi] connect returned: 0
[wifi] join_status=6
[NET] WiFi connected
[NET] MAC: xx:xx:xx:xx:xx:xx
[PASS] noused keep-list: wifi_get_mac_address matches
[PASS] noused keep-list: wifi_scan_abort returned <n> (not stubbed)
[NET] DHCP: IP=192.168.x.x
[NET] TCP: connecting to 192.168.x.1:8080 ...
[NET] TCP: connected
[PASS] embassy-net: TCP connected
Intermediate [wifi] event: code=... and [wifi] join_status=... lines appear while the join progresses, interleaved with debug lines from the Wi-Fi core and the ameba_wifi driver such as [api], [blk_api] and [WLAN-A]. The TCP step only succeeds if something on the gateway is listening on TCP_PORT (src/main.rs, default 8080), for example an HTTP server running on the gateway device. If nothing is listening there, the last line is instead [FAIL] embassy-net: TCP connect failed: ConnectionReset, or [FAIL] embassy-net: TCP connect timed out after 10s if the gateway does not answer; DHCP has already succeeded at that point, so the Wi-Fi link and the IP stack are working.
Note
Set WIFI_SSID and WIFI_PASSWORD at the top of src/main.rs, then build and flash the example with cargo xtask run example --name wifi-connect --port <serial-port>.
MQTT Client
ameba_wifi does not include an MQTT client of its own. Because WhcDevice implements embassy_net_driver::Driver, an application opens an ordinary embassy_net::tcp::TcpSocket and runs any no_std MQTT client crate on top of it. The SDK’s example uses rust-mqtt (MQTT v5).
Scope and limitations of the example:
Plain TCP only. TLS is not supported, so the broker must accept unencrypted connections on port 1883.
IPv4 literal broker address. The DNS resolver is not enabled, so
BROKER_IPmust be an IPv4 address. When it isNone, the DHCP gateway is used as the broker.QoS 0. Subscribe and publish both use
QualityOfService::QoS0.No reconnect. If the Wi-Fi link, the TCP connection or the MQTT session drops, the example prints a
[FAIL]line and stops; reset the board to start over.
Application Example
The Rust SDK provides one example, mqtt: it joins a WPA2-PSK network, obtains an address over DHCP, connects to the broker, subscribes to ameba/cmd, publishes hello from ameba to the same topic and waits for it to come back through the broker, then publishes a counter to ameba/status every 2 seconds while printing any message arriving on ameba/cmd.
The Wi-Fi join and DHCP steps are the same as in the wifi-connect example (see STA Connect (WPA2-PSK)). Once the stack has an address, the example opens a TCP connection to the broker:
const WIFI_SSID: &str = "your-ssid";
const WIFI_PASSWORD: &str = "your-password";
/// Broker address. `None` = use the DHCP gateway.
const BROKER_IP: Option<[u8; 4]> = None;
const BROKER_PORT: u16 = 1883;
const TOPIC_CMD: &str = "ameba/cmd";
const TOPIC_STATUS: &str = "ameba/status";
const CLIENT_ID: &str = "ameba-rtl8721f";
// ... Wi-Fi join, embassy-net stack and DHCP, as in wifi-connect ...
let broker = match BROKER_IP {
Some(b) => Ipv4Address::new(b[0], b[1], b[2], b[3]),
None => match cfg.and_then(|c| c.gateway) {
Some(gw) => gw,
None => {
println!("[FAIL] mqtt: no gateway from DHCP and BROKER_IP unset");
return;
}
},
};
// TCP.
let mut rx_buf = [0u8; 1024];
let mut tx_buf = [0u8; 1024];
let mut socket = TcpSocket::new(stack, &mut rx_buf, &mut tx_buf);
socket.set_timeout(Some(Duration::from_secs(30)));
println!("[MQTT] connecting to {}:{} ...", broker, BROKER_PORT);
match embassy_time::with_timeout(
Duration::from_secs(10),
socket.connect((broker, BROKER_PORT)),
)
.await
{
// ...
}
The connected socket is then handed to the MQTT client:
// MQTT session.
const KEEP_ALIVE_S: u16 = 20;
let mut config = ClientConfig::<'_, 5, _>::new(MqttVersion::MQTTv5, PacketIds(seed & 0x7fff));
config.add_client_id(CLIENT_ID);
config.add_max_subscribe_qos(QualityOfService::QoS0);
config.keep_alive = KEEP_ALIVE_S;
config.max_packet_size = 256;
let mut write_buf = [0u8; 256];
let mut recv_buf = [0u8; 256];
let mut client =
MqttClient::<_, 5, _>::new(socket, &mut write_buf, 256, &mut recv_buf, 256, config);
if let Err(e) = client.connect_to_broker().await {
println!("[FAIL] mqtt: broker CONNECT rejected: {:?}", e);
return;
}
println!("[MQTT] connected");
if let Err(e) = client.subscribe_to_topic(TOPIC_CMD).await {
println!("[FAIL] mqtt: subscribe failed: {:?}", e);
return;
}
println!("[MQTT] subscribed: {}", TOPIC_CMD);
rust-mqtt uses its random-number source only for packet identifiers, so the example passes a simple counter type, PacketIds, seeded from the TRNG, instead of a cryptographic RNG.
In the steady state, the loop polls for incoming messages without blocking, then publishes the counter:
// Steady state: publish a counter, echo incoming commands.
let mut count: u32 = 0;
loop {
match client.receive_message_if_ready().await {
Ok(Some((topic, payload))) => {
println!(
"[MQTT] received: {} = \"{}\"",
topic,
core::str::from_utf8(payload).unwrap_or("<binary>")
);
}
Ok(None) => {}
Err(e) => {
println!("[FAIL] mqtt: receive failed: {:?}", e);
return;
}
}
let mut msg = String::<24>::new();
let _ = core::fmt::Write::write_fmt(&mut msg, format_args!("count={}", count));
if let Err(e) = client
.send_message(TOPIC_STATUS, msg.as_bytes(), QualityOfService::QoS0, false)
.await
{
println!("[FAIL] mqtt: publish failed: {:?}", e);
return;
}
println!("[MQTT] published: {} = \"{}\"", TOPIC_STATUS, msg.as_str());
count = count.wrapping_add(1);
Timer::after(Duration::from_secs(2)).await;
}
Incoming messages are checked once per 2-second cycle, so a command can take up to 2 seconds to appear.
Broker setup: the example has been tested with Mosquitto 2.1. A minimal configuration that accepts anonymous plain-TCP connections:
listener 1883 0.0.0.0
allow_anonymous true
From another MQTT client on the same network, you can watch the board and send it commands:
$ mosquitto_sub -h <broker-ip> -t 'ameba/#' -v
$ mosquitto_pub -h <broker-ip> -t ameba/cmd -m hi
Expected serial output:
[build] <build timestamp>
[wifi] on: 0
[wifi] connecting to "<ssid>" ...
[wifi] connect returned: 0
[wifi] join_status=6
[NET] WiFi connected
[NET] DHCP: IP=192.168.x.x
[MQTT] connecting to 192.168.x.x:1883 ...
[MQTT] connected
[MQTT] subscribed: ameba/cmd
[MQTT] published: ameba/cmd = "hello from ameba"
[MQTT] received: ameba/cmd = "hello from ameba"
[PASS] mqtt: loopback
[MQTT] published: ameba/status = "count=0"
[MQTT] published: ameba/status = "count=1"
...
Debug lines from the Wi-Fi core and driver such as [api], [blk_api] and [WLAN-A] are interleaved with the output above, and [NET] WiFi (re)connected is printed once more after the link comes up.
After mosquitto_pub -t ameba/cmd -m hi, a [MQTT] received: ameba/cmd = "hi" line appears. If the broker cannot be reached (wrong address, broker not running, or a firewall blocking inbound port 1883 on the broker host), the last line is [FAIL] mqtt: TCP connect timed out after 10s.
Note
Set WIFI_SSID and WIFI_PASSWORD (and BROKER_IP if the broker is not on the DHCP gateway) at the top of src/main.rs, then build and flash the example with cargo xtask run example --name mqtt --port <serial-port>.
Wi-Fi Events
NP forwards Wi-Fi events to the AP core through the ch7 API channel, and run_blk_api() decodes them and pushes a WifiEvent onto ameba_wifi::EVENT_CHAN, a 4-slot embassy_sync::channel::Channel. Application code drains it with ameba_wifi::EVENT_CHAN.receive().await.
pub struct WifiEvent {
pub event_code: u32,
pub evt_info: u32, // *const u8 in NP SRAM; 0 if unused
}
The channel has 4 slots and is fed via try_send from the run_blk_api() task — if the application does not drain events promptly, new events are dropped rather than blocking NP.
Wired Event Codes
These three of the nine defined 0-8 event_code constants have real producers and arrive on EVENT_CHAN; the rest (CSI_DONE/WPS_START/WPS_FINISH/EAPOL_START/EAPOL_RECVD/DHCP_STATUS) are defined but not yet exercised by any Rust-side handling. The STA-side WPA2-PSK handshake codes 104/106/108 are also wired up, but handled synchronously inside run_blk_api() rather than delivered through EVENT_CHAN — see STA Connect (WPA2-PSK) below. Their SoftAP-side counterparts, 105/107, remain unhandled.
event_code::JOIN_STATUS(STA connection status change)evt_infopoints at NP SRAM, read the status byte withread_join_status(evt_info), which returns one of thejoin_status::*constants (STARTING,SCANNING,AUTHENTICATING,AUTHENTICATED,ASSOCIATING,ASSOCIATED,HANDSHAKING,HANDSHAKE_DONE,SUCCESS,FAIL,DISCONNECT, orUNKNOWN).loop { let evt: WifiEvent = ameba_wifi::EVENT_CHAN.receive().await; if evt.event_code == event_code::JOIN_STATUS { let status = if evt.evt_info != 0 { unsafe { read_join_status(evt.evt_info) } } else { join_status::UNKNOWN }; match status { join_status::ASSOCIATED | join_status::SUCCESS => { ameba_wifi::net::set_link_up(true); break; } join_status::FAIL => { // ... retry wifi_connect() ... } join_status::DISCONNECT => { ameba_wifi::net::set_link_up(false); return; } _ => {} // intermediate status (SCANNING, ASSOCIATING, etc.) } } }
event_code::AP_STA_ASSOC/event_code::AP_STA_DISASSOC(SoftAP station join/leave)evt_infopoints at 6 bytes of the station’s MAC (both event structs start with a plainu8 sta_mac[ETH_ALEN]). Read it withread_ap_sta_mac(evt_info).match evt.event_code { event_code::AP_STA_ASSOC => { let mac = if evt.evt_info != 0 { Some(unsafe { read_ap_sta_mac(evt.evt_info) }) } else { None }; // ... } event_code::AP_STA_DISASSOC => { // same shape } other => println!("[ap] event: code={} (other)", other), }
Both read_join_status and read_ap_sta_mac are unsafe: the caller must guarantee evt_info is a valid NP SRAM pointer for the expected byte count, which holds whenever it comes straight from a received WifiEvent for the matching event code.
API Reference
Quick Usage
use ameba_wifi::WifiEvent;
use ameba_wifi::wifi::SecurityType;
use ameba_wifi::wifi::events::{event_code, join_status, read_join_status};
ameba_hal::init(ameba_hal::Config::default());
ameba_wifi::init();
spawner.spawn(whc_task()).unwrap(); // async fn whc_task() { ameba_wifi::run_blk_api().await; }
ameba_wifi::wifi::wifi_on().await;
ameba_wifi::wifi::wifi_connect("MySSID", "", SecurityType::Open).await;
let evt: WifiEvent = ameba_wifi::EVENT_CHAN.receive().await;
if evt.event_code == event_code::JOIN_STATUS {
let status = unsafe { read_join_status(evt.evt_info) };
// ...
}
let mac = ameba_wifi::wifi::netif_mac(); // Option<[u8; 6]>, set once wifi_on's SET_NETIF_INFO arrives