Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions esp-radio/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

### Added
- It's now possible to obtain the access point info of the currently connected AP, by using `WifiController::ap_info(&self)` (#4401)


### Changed
Expand Down
26 changes: 26 additions & 0 deletions esp-radio/src/wifi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ use crate::binary::{
esp_wifi_set_mode,
esp_wifi_set_protocol,
esp_wifi_set_tx_done_cb,
esp_wifi_sta_get_ap_info,
esp_wifi_sta_get_rssi,
esp_wifi_start,
esp_wifi_stop,
Expand Down Expand Up @@ -3135,6 +3136,31 @@ impl WifiController<'_> {
}
}

/// Get the Access Point information of AP to which the device is associated with.
/// The value is obtained from the last beacon.
///
/// <div class="warning">
///
/// - Use this API only in STA or AP-STA mode.
/// - This API should be called after the station has connected to an access point.
/// </div>
///
/// # Errors
/// This function returns [`WifiError::Unsupported`] if the STA side isn't
/// running. For example, when configured for AP only.
pub fn ap_info(&self) -> Result<AccessPointInfo, WifiError> {
if self.mode()?.is_sta() {
let mut record: MaybeUninit<include::wifi_ap_record_t> = MaybeUninit::uninit();
esp_wifi_result!(unsafe { esp_wifi_sta_get_ap_info(record.as_mut_ptr()) })?;

let record = unsafe { MaybeUninit::assume_init(record) };
let ap_info = convert_ap_info(&record);
Ok(ap_info)
} else {
Err(WifiError::Unsupported)
}
}

/// Get the supported capabilities of the controller.
pub fn capabilities(&self) -> Result<EnumSet<crate::wifi::Capability>, WifiError> {
let caps =
Expand Down
Loading