32#include <electro/decibel>
33#include <esp_idf_version.h>
34#include <esp_wifi_types.h>
36#include <soc/soc_caps.h>
56enum class role : uint32_t {
562#if SOC_WIFI_HE_SUPPORT
567#if SOC_WIFI_HE_SUPPORT
579#if SOC_WIFI_HE_SUPPORT
593inline constexpr bool idfxx::enable_flags_operators<idfxx::wifi::role> =
true;
595inline constexpr bool idfxx::enable_flags_operators<idfxx::wifi::protocol> =
true;
597inline constexpr bool idfxx::enable_flags_operators<idfxx::wifi::promiscuous_filter> =
true;
599inline constexpr bool idfxx::enable_flags_operators<idfxx::wifi::promiscuous_ctrl_filter> =
true;
601inline constexpr bool idfxx::enable_flags_operators<idfxx::wifi::channel_5g> =
true;
603inline constexpr bool idfxx::enable_flags_operators<idfxx::wifi::event_mask> =
true;
605inline constexpr bool idfxx::enable_flags_operators<idfxx::wifi::sae_pwe_method> =
true;
607inline constexpr bool idfxx::enable_flags_operators<idfxx::wifi::statis_module> =
true;
667 [[nodiscard]]
const char*
name() const noexcept override final;
670 [[nodiscard]] std::
string message(
int ec) const override final;
687 [[nodiscard]]
bool equivalent(
int code, const std::error_condition& condition) const noexcept override final;
714 std::array<char, 3> cc = {
'0',
'1',
'\0'};
715 uint8_t start_channel = 1;
716 uint8_t num_channels = 11;
717 electro::dbm max_tx_power{20};
719#if SOC_WIFI_SUPPORT_5G
737 std::optional<enum second_channel>
second;
834 bool capable =
false;
835 bool required =
false;
847 std::optional<mac_address> bssid = {};
852 electro::dbm rssi_threshold{-127};
854 uint16_t listen_interval = 0;
855 bool rm_enabled =
false;
856 bool btm_enabled =
false;
857 bool mbo_enabled =
false;
858 bool ft_enabled =
false;
859 bool owe_enabled =
false;
860 bool transition_disable =
false;
863 uint8_t failure_retry_cnt = 0;
877 uint8_t ssid_hidden = 0;
878 uint8_t max_connection = 4;
879 uint16_t beacon_interval = 100;
881 bool ftm_responder =
false;
895 bool show_hidden =
false;
906 std::chrono::milliseconds active_scan_min{0};
907 std::chrono::milliseconds active_scan_max{120};
908 std::chrono::milliseconds passive_scan{360};
909 std::chrono::milliseconds home_chan_dwell_time{30};
942 std::optional<enum second_channel>
second;
954 uint8_t frame_count = 0;
955 std::chrono::milliseconds burst_period{
958#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(6, 0, 0)
959 bool use_get_report_api =
false;
981#if !SOC_WIFI_HE_SUPPORT
984 bool htltf_en =
true;
985 bool stbc_htltf2_en =
true;
986 bool ltf_merge_en =
true;
987 bool channel_filter_en =
true;
988 bool manu_scale =
false;
990 bool dump_ack_en =
false;
994#elif SOC_WIFI_MAC_VERSION_NUM == 3
997 bool acquire_csi_legacy =
false;
998 bool acquire_csi_force_lltf =
false;
999 bool acquire_csi_ht20 =
false;
1000 bool acquire_csi_ht40 =
false;
1001 bool acquire_csi_vht =
false;
1002 bool acquire_csi_su =
false;
1003 bool acquire_csi_mu =
false;
1004 bool acquire_csi_dcm =
false;
1005 bool acquire_csi_beamformed =
false;
1006 uint8_t acquire_csi_he_stbc_mode = 0;
1007 uint8_t val_scale_cfg = 0;
1008 bool dump_ack_en =
false;
1009 bool lltf_bit_mode =
false;
1015 bool enable =
false;
1016 bool acquire_csi_legacy =
false;
1017 bool acquire_csi_ht20 =
false;
1018 bool acquire_csi_ht40 =
false;
1019 bool acquire_csi_su =
false;
1020 bool acquire_csi_mu =
false;
1021 bool acquire_csi_dcm =
false;
1022 bool acquire_csi_beamformed =
false;
1023 uint8_t acquire_csi_he_stbc = 0;
1024 uint8_t val_scale_cfg = 0;
1025 bool dump_ack_en =
false;
1027 [[nodiscard]]
constexpr bool operator==(
const csi_config&)
const noexcept =
default;
1420#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
1520#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
1561#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
1602#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
1697#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
1736template<
typename Rep,
typename Period>
1811template<
typename Rep,
typename Period>
1849#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
2007#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
2048#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
2132#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
2177#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
2200#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
2210void set_channel(uint8_t primary, std::optional<enum second_channel> second = std::nullopt);
2243#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
2321#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
2365#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
2406#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
2490#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
2566#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
2590#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
2635#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
2680#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
2730#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
2874#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
2935#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
2992using csi_rx_cb = void (*)(
void* ctx,
const wifi_csi_info_t* info);
2994#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
3073#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
3159#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
3281#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
3290inline void start() {
3301inline void set_roles(flags<role> roles) {
3334template<
typename Rep,
typename Period>
3335[[nodiscard]] net::ipv4_info
connect_sta(
const sta_config& cfg, std::chrono::duration<Rep, Period>
timeout) {
3355inline std::vector<ap_record>
scan(
const scan_config& cfg) {
3358inline void scan_start(
const scan_config& cfg) {
3416inline void set_channel(uint8_t primary, std::optional<enum second_channel> second) {
3424inline void set_country(
const country_config& cfg) {
3430inline void set_country_code(std::string_view cc,
bool ieee80211d_enabled) {
3534inline void tx_80211(
enum role iface, std::span<const uint8_t>
buffer,
bool en_sys_seq) {
3573inline std::vector<ftm_report_entry>
ftm_get_report(
size_t max_entries) {
3578inline void statis_dump(flags<statis_module> modules) {
3605#ifdef CONFIG_COMPILER_CXX_EXCEPTIONS
3674[[nodiscard]] std::unexpected<std::error_code> wifi_error(
esp_err_t e);
3687[[nodiscard]] std::
string to_string(
flags<wifi::role> roles);
3696[[nodiscard]] std::
string to_string(wifi::auth_mode m);
3705[[nodiscard]] std::
string to_string(wifi::cipher_type c);
3714[[nodiscard]] std::
string to_string(wifi::disconnect_reason r);
3718namespace
idfxx::wifi {
3736struct is_error_code_enum<
idfxx::wifi::errc> : true_type {};
3740#include "sdkconfig.h"
3741#ifdef CONFIG_IDFXX_STD_FORMAT
3748struct formatter<
idfxx::
flags<idfxx::wifi::role>> {
3749 constexpr auto parse(format_parse_context& ctx) {
return ctx.begin(); }
3751 template<
typename FormatContext>
3754 return std::copy(s.begin(), s.end(), ctx.out());
3759struct formatter<
idfxx::wifi::auth_mode> {
3760 constexpr auto parse(format_parse_context& ctx) {
return ctx.begin(); }
3762 template<
typename FormatContext>
3765 return std::copy(s.begin(), s.end(), ctx.out());
3770struct formatter<
idfxx::wifi::cipher_type> {
3771 constexpr auto parse(format_parse_context& ctx) {
return ctx.begin(); }
3773 template<
typename FormatContext>
3776 return std::copy(s.begin(), s.end(), ctx.out());
3781struct formatter<
idfxx::wifi::disconnect_reason> {
3782 constexpr auto parse(format_parse_context& ctx) {
return ctx.begin(); }
3784 template<
typename FormatContext>
3787 return std::copy(s.begin(), s.end(), ctx.out());
Typed event base template.
Type-safe set of flags from a scoped enum.
A MAC-48 (6-byte) hardware address.
Network interface handle.
Non-Volatile Storage handle.
Error category for WiFi errors.
std::string message(int ec) const override final
Returns a human-readable message for the given error code.
bool equivalent(int code, const std::error_condition &condition) const noexcept override final
Tests whether an errc value is equivalent to a standard condition.
const char * name() const noexcept override final
Returns the name of the error category.
Concept for types that can be both received and posted as event data.
constexpr bool operator==(const allocator< T, Caps, Alignment > &, const allocator< U, Caps, Alignment > &) noexcept
Equality comparison for allocator.
std::string to_string(core_id c)
Returns a string representation of a CPU core identifier.
constexpr idfxx::event< event_id, ap_sta_connected_event_data > ap_sta_connected
Station connected to soft-AP event.
void disable_pmf_config(enum role iface)
Disables PMF (Protected Management Frames) for the specified interface.
result< channel_info > try_get_channel()
Gets the current primary and secondary channel.
constexpr idfxx::event< event_id > nan_replied
NAN replied event.
result< void > try_set_band_mode(enum band_mode m)
Sets the WiFi band mode.
constexpr idfxx::event< event_id > btwt_teardown
Broadcast TWT teardown event.
result< enum power_save > try_get_power_save()
Gets the current power save mode.
void set_ap_config(const ap_config &cfg)
Sets the WiFi access point configuration.
constexpr idfxx::event< event_id, ftm_report_event_data > ftm_report
FTM report received event.
void deauth_sta(uint16_t aid)
Deauthenticates a station from the soft-AP.
result< void > try_set_roles(flags< role > roles)
Sets the active WiFi roles.
result< uint16_t > try_scan_get_ap_num()
Gets the number of APs found in the last scan.
result< std::string > try_get_country_code()
Gets the current country code.
result< void > try_set_csi_rx_cb(csi_rx_cb cb, void *ctx)
Registers a callback for CSI data reception.
constexpr idfxx::event< event_id, ap_sta_disconnected_event_data > ap_sta_disconnected
Station disconnected from soft-AP event.
flags< promiscuous_ctrl_filter > get_promiscuous_ctrl_filter()
Gets the current promiscuous mode control frame sub-type filter.
void ftm_end_session()
Ends the current FTM session.
void set_csi_config(const csi_config &cfg)
Sets the CSI configuration.
bandwidth
WiFi channel bandwidth.
void(*)(void *ctx, enum vendor_ie_type type, mac_address sa, const vendor_ie_data_t *ie, electro::dbm rssi) vendor_ie_cb
Callback invoked when a matching vendor-specific IE is received.
void(*)(const wifi_promiscuous_pkt_t *pkt, promiscuous_pkt_type type) promiscuous_rx_cb
Callback invoked for each packet received in promiscuous mode.
constexpr idfxx::event< event_id > connectionless_module_wake_interval_start
Connectionless module wake interval start event.
event_mask
WiFi event mask flags.
void set_rssi_threshold(electro::dbm threshold)
Sets the RSSI threshold for the sta_bss_rssi_low event.
void set_storage(enum storage s)
Sets the WiFi configuration storage location.
constexpr idfxx::event< event_id > itwt_probe
Individual TWT probe event.
void set_promiscuous(bool en)
Enables or disables promiscuous mode.
result< void > try_ftm_initiate_session(const ftm_initiator_config &cfg)
Initiates an FTM (Fine Timing Measurement) session.
constexpr idfxx::event< event_id > dpp_cfg_recvd
DPP configuration received event.
void set_max_tx_power(electro::centi_dbm power)
Sets the maximum transmit power.
void config_11b_rate(enum role iface, bool disable)
Enables or disables 802.11b rate for the specified interface.
void deinit()
Deinitializes the WiFi subsystem and frees resources.
constexpr idfxx::event< event_id > sta_stop
Station stopped event.
promiscuous_pkt_type
Promiscuous mode packet type.
constexpr idfxx::event< event_id > sta_wps_er_timeout
WPS enrollee timeout event.
void restore()
Restores WiFi stack persistent settings to defaults.
uint16_t ap_get_sta_aid(mac_address mac)
Gets the association ID for a station connected to the soft-AP.
void set_sta_config(const sta_config &cfg)
Sets the WiFi station configuration.
result< void > try_set_max_tx_power(electro::centi_dbm power)
Sets the maximum transmit power.
storage
WiFi configuration storage location.
result< void > try_config_80211_tx_rate(enum role iface, enum phy_rate rate)
Sets the 802.11 TX rate for the specified interface.
result< flags< promiscuous_filter > > try_get_promiscuous_filter()
Gets the current promiscuous mode packet type filter.
result< void > try_set_csi(bool en)
Enables or disables CSI (Channel State Information) collection.
constexpr idfxx::event< event_id > ap_wps_rg_failed
AP WPS registrar failed event.
std::vector< ap_record > scan(const scan_config &cfg={})
Performs a blocking scan for access points.
promiscuous_filter
Promiscuous mode filter flags.
result< bandwidths_config > try_get_bandwidths(enum role iface)
Gets bandwidths for dual-band operation on the specified interface.
result< void > try_set_sta_config(const sta_config &cfg)
Sets the WiFi station configuration.
result< void > try_statis_dump(flags< statis_module > modules)
Dumps WiFi statistics for the specified modules.
enum band_mode get_band_mode()
Gets the current WiFi band mode.
void set_roles(flags< role > roles)
Sets the active WiFi roles.
constexpr idfxx::event< event_id > ap_start
Soft-AP started event.
constexpr idfxx::event< event_id > twt_wakeup
TWT wakeup event.
result< void > try_config_11b_rate(enum role iface, bool disable)
Enables or disables 802.11b rate for the specified interface.
void scan_start(const scan_config &cfg={})
Starts a non-blocking scan for access points.
result< net::ipv4_info > try_connect_sta(const sta_config &cfg, std::chrono::milliseconds timeout)
Connects to an access point as a station and waits for an IPv4 address.
result< void > try_set_promiscuous(bool en)
Enables or disables promiscuous mode.
constexpr idfxx::event< event_id > roc_done
Remain-on-channel done event.
result< void > try_stop()
Stops the WiFi subsystem.
result< void > try_deinit()
Deinitializes the WiFi subsystem and frees resources.
result< flags< promiscuous_ctrl_filter > > try_get_promiscuous_ctrl_filter()
Gets the current promiscuous mode control frame sub-type filter.
result< void > try_set_inactive_time(enum role iface, std::chrono::seconds timeout)
Sets the inactive time before a station is deauthenticated.
void set_band(enum band b)
Sets the WiFi band.
result< enum band_mode > try_get_band_mode()
Gets the current WiFi band mode.
constexpr idfxx::event< event_id > ap_wrong_password
AP detected wrong password from station event.
auth_mode
WiFi authentication mode.
const event_base< event_id > events
WiFi event base.
result< void > try_ftm_resp_set_offset(int16_t offset)
Sets the FTM responder offset.
std::vector< ftm_report_entry > ftm_get_report(size_t max_entries)
Retrieves the FTM measurement report entries.
result< void > try_deauth_sta(uint16_t aid)
Deauthenticates a station from the soft-AP.
result< enum band > try_get_band()
Gets the current WiFi band.
csi_config get_csi_config()
Gets the current CSI configuration.
promiscuous_ctrl_filter
Promiscuous mode control frame sub-type filter flags.
result< void > try_set_power_save(enum power_save ps)
Sets the power save mode.
void tx_80211(enum role iface, std::span< const uint8_t > buffer, bool en_sys_seq)
Transmits a raw 802.11 frame.
constexpr idfxx::event< event_id > sta_wps_er_pbc_overlap
WPS PBC overlap detected event.
void force_wakeup_acquire()
Acquires a WiFi wakeup lock.
void set_csi_rx_cb(csi_rx_cb cb, void *ctx)
Registers a callback for CSI data reception.
result< void > try_set_country(const country_config &cfg)
Sets the WiFi country configuration.
result< void > try_set_promiscuous_ctrl_filter(flags< promiscuous_ctrl_filter > filter)
Sets the promiscuous mode control frame sub-type filter.
@ connectionless_module_wake_interval_start
@ sta_beacon_offset_unstable
result< std::vector< sta_info > > try_get_sta_list()
Gets the list of stations connected to the soft-AP.
bandwidths_config get_bandwidths(enum role iface)
Gets bandwidths for dual-band operation on the specified interface.
enum bandwidth get_bandwidth(enum role iface)
Gets the current channel bandwidth for the specified interface.
result< enum bandwidth > try_get_bandwidth(enum role iface)
Gets the current channel bandwidth for the specified interface.
sae_pk_mode
SAE-PK (Public Key) mode.
void init(const init_config &cfg={})
Initializes the WiFi subsystem.
void set_promiscuous_ctrl_filter(flags< promiscuous_ctrl_filter > filter)
Sets the promiscuous mode control frame sub-type filter.
vendor_ie_id
Vendor-specific IE index.
constexpr idfxx::event< event_id, ap_probe_req_event_data > ap_probe_req_received
Probe request received by soft-AP event.
constexpr idfxx::event< event_id > itwt_teardown
Individual TWT teardown event.
result< void > try_set_ap_config(const ap_config &cfg)
Sets the WiFi access point configuration.
result< void > try_scan_stop()
Stops an in-progress scan.
result< netif::interface > try_make_sta_netif()
Creates a default WiFi station network interface.
result< void > try_start()
Starts the WiFi subsystem.
result< void > try_tx_80211(enum role iface, std::span< const uint8_t > buffer, bool en_sys_seq)
Transmits a raw 802.11 frame.
electro::dbm get_rssi()
Gets the current RSSI of the connected AP.
bool get_promiscuous()
Gets whether promiscuous mode is enabled.
constexpr idfxx::event< event_id > itwt_setup
Individual TWT setup event.
result< void > try_set_scan_parameters(const scan_default_params ¶ms)
Sets the default scan timing parameters.
constexpr idfxx::event< event_id, disconnected_event_data > sta_disconnected
Station disconnected event with disconnection details.
protocols_config get_protocols(enum role iface)
Gets the enabled WiFi protocols for dual-band operation.
scan_method
WiFi scan method.
void register_80211_tx_cb(tx_80211_done_cb cb)
Registers a callback for 802.11 TX completion.
constexpr idfxx::event< event_id > action_tx_status
Action frame TX status event.
second_channel
WiFi secondary channel position relative to the primary channel.
statis_module
WiFi statistics module flags.
std::chrono::seconds get_inactive_time(enum role iface)
Gets the inactive time before a station is deauthenticated.
netif::interface make_ap_netif()
Creates a default WiFi access point network interface.
result< netif::interface > try_make_ap_netif()
Creates a default WiFi access point network interface.
void connect()
Connects to the configured access point.
sort_method
WiFi AP sort method for connection.
constexpr idfxx::event< event_id > ap_wps_rg_pbc_overlap
AP WPS PBC overlap detected event.
errc
Error codes for WiFi operations.
cipher_type
WiFi cipher type.
constexpr idfxx::event< event_id > sta_neighbor_rep
Station neighbor report received event.
result< csi_config > try_get_csi_config()
Gets the current CSI configuration.
result< void > try_disable_pmf_config(enum role iface)
Disables PMF (Protected Management Frames) for the specified interface.
result< uint16_t > try_ap_get_sta_aid(mac_address mac)
Gets the association ID for a station connected to the soft-AP.
sta_config get_sta_config()
Gets the current WiFi station configuration.
result< void > try_force_wakeup_release()
Releases a WiFi wakeup lock.
result< flags< event_mask > > try_get_event_mask()
Gets the current WiFi event mask.
phy_rate
WiFi PHY transmission rate.
result< void > try_set_vendor_ie_cb(vendor_ie_cb cb, void *ctx)
Registers a callback for received vendor-specific IEs.
constexpr idfxx::event< event_id, home_channel_change_event_data > home_channel_change
Home channel changed event.
void set_bandwidth(enum role iface, enum bandwidth bw)
Sets the channel bandwidth for the specified interface.
result< electro::centi_dbm > try_get_max_tx_power()
Gets the current maximum transmit power.
uint16_t sta_get_aid()
Gets the association ID assigned by the AP in station mode.
constexpr idfxx::event< event_id > btwt_setup
Broadcast TWT setup event.
void config_80211_tx_rate(enum role iface, enum phy_rate rate)
Sets the 802.11 TX rate for the specified interface.
constexpr idfxx::event< event_id > sta_wps_er_success
WPS enrollee success event.
enum band get_band()
Gets the current WiFi band.
flags< event_mask > get_event_mask()
Gets the current WiFi event mask.
result< void > try_set_bandwidths(enum role iface, const bandwidths_config &bw)
Sets bandwidths for dual-band operation on the specified interface.
result< protocols_config > try_get_protocols(enum role iface)
Gets the enabled WiFi protocols for dual-band operation.
result< void > try_set_protocol(enum role iface, flags< protocol > protos)
Sets the enabled WiFi protocols for the specified interface.
protocol
WiFi protocol flags.
result< ap_config > try_get_ap_config()
Gets the current WiFi access point configuration.
scan_default_params get_scan_parameters()
Gets the current default scan timing parameters.
enum power_save get_power_save()
Gets the current power save mode.
result< bool > try_get_promiscuous()
Gets whether promiscuous mode is enabled.
void set_promiscuous_filter(flags< promiscuous_filter > filter)
Sets the promiscuous mode packet type filter.
result< void > try_disconnect()
Disconnects from the current access point.
constexpr idfxx::event< event_id > ap_wps_rg_timeout
AP WPS registrar timeout event.
result< void > try_connectionless_module_set_wake_interval(std::chrono::milliseconds interval)
Sets the connectionless module wake interval.
void set_promiscuous_rx_cb(promiscuous_rx_cb cb)
Sets the promiscuous mode receive callback.
void statis_dump(flags< statis_module > modules)
Dumps WiFi statistics for the specified modules.
vendor_ie_type
Vendor-specific IE type.
void ftm_initiate_session(const ftm_initiator_config &cfg)
Initiates an FTM (Fine Timing Measurement) session.
result< void > try_set_protocols(enum role iface, const protocols_config &cfg)
Sets the enabled WiFi protocols for dual-band operation.
result< void > try_init(const init_config &cfg={})
Initializes the WiFi subsystem.
result< std::chrono::seconds > try_get_inactive_time(enum role iface)
Gets the inactive time before a station is deauthenticated.
void set_power_save(enum power_save ps)
Sets the power save mode.
void set_mac(enum role iface, mac_address mac)
Sets the MAC address for the specified interface.
result< uint16_t > try_sta_get_aid()
Gets the association ID assigned by the AP in station mode.
result< void > try_set_storage(enum storage s)
Sets the WiFi configuration storage location.
void connectionless_module_set_wake_interval(std::chrono::milliseconds interval)
Sets the connectionless module wake interval.
std::vector< ap_record > scan_get_results()
Retrieves results from a completed scan.
country_config get_country()
Gets the current WiFi country configuration.
void set_vendor_ie_cb(vendor_ie_cb cb, void *ctx)
Registers a callback for received vendor-specific IEs.
void set_country(const country_config &cfg)
Sets the WiFi country configuration.
constexpr idfxx::event< event_id > nan_receive
NAN receive event.
disconnect_reason
WiFi disconnection reason codes.
@ pairwise_cipher_invalid
@ no_ap_found_in_authmode_threshold
@ service_change_precludes_ts
@ no_ssp_roaming_agreement
@ no_ap_found_in_rssi_threshold
@ not_authorized_this_location
@ alterative_channel_occupied
@ assoc_comeback_time_too_long
@ invalid_ft_action_frame_count
@ bss_transition_disassoc
@ ieee_802_1x_auth_failed
@ fourway_handshake_timeout
@ transmission_link_establish_failed
@ no_ap_found_w_compatible_security
@ group_key_update_timeout
std::string get_country_code()
Gets the current country code.
result< void > try_set_mac(enum role iface, mac_address mac)
Sets the MAC address for the specified interface.
ap_record get_ap_info()
Gets information about the currently connected access point.
constexpr idfxx::event< event_id, connected_event_data > sta_connected
Station connected event with connection details.
void start()
Starts the WiFi subsystem.
void scan_stop()
Stops an in-progress scan.
void disconnect()
Disconnects from the current access point.
void clear_ap_list()
Clears the AP list stored from a previous scan.
void set_protocol(enum role iface, flags< protocol > protos)
Sets the enabled WiFi protocols for the specified interface.
void(*)(const esp_80211_tx_info_t *tx_info) tx_80211_done_cb
Callback invoked when a raw 802.11 frame transmission completes.
result< void > try_set_dynamic_cs(bool enabled)
Enables or disables dynamic CS (Carrier Sense).
result< ap_record > try_get_ap_info()
Gets information about the currently connected access point.
constexpr idfxx::event< event_id > dpp_uri_ready
DPP URI ready event.
void set_country_code(std::string_view cc, bool ieee80211d_enabled)
Sets the country code.
result< void > try_scan_start(const scan_config &cfg={})
Starts a non-blocking scan for access points.
std::vector< sta_info > get_sta_list()
Gets the list of stations connected to the soft-AP.
result< void > try_set_rssi_threshold(electro::dbm threshold)
Sets the RSSI threshold for the sta_bss_rssi_low event.
ap_config get_ap_config()
Gets the current WiFi access point configuration.
int64_t get_tsf_time(enum role iface)
Gets the TSF (Timing Synchronization Function) time for the specified interface.
netif::interface make_sta_netif()
Creates a default WiFi station network interface.
void set_dynamic_cs(bool enabled)
Enables or disables dynamic CS (Carrier Sense).
result< void > try_set_vendor_ie(bool enable, enum vendor_ie_type type, enum vendor_ie_id id, const void *vnd_ie)
Sets a vendor-specific information element.
constexpr idfxx::event< event_id > sta_wps_er_pin
WPS enrollee PIN received event.
constexpr idfxx::event< event_id, bss_rssi_low_event_data > sta_bss_rssi_low
BSS RSSI dropped below threshold event.
constexpr idfxx::event< event_id > ndp_indication
NDP indication event.
result< std::vector< ftm_report_entry > > try_ftm_get_report(size_t max_entries)
Retrieves the FTM measurement report entries.
constexpr idfxx::event< event_id > itwt_suspend
Individual TWT suspend event.
void set_protocols(enum role iface, const protocols_config &cfg)
Sets the enabled WiFi protocols for dual-band operation.
ftm_status
FTM (Fine Timing Measurement) session status.
flags< promiscuous_filter > get_promiscuous_filter()
Gets the current promiscuous mode packet type filter.
result< void > try_set_band(enum band b)
Sets the WiFi band.
power_save
WiFi power save mode.
channel_info get_channel()
Gets the current primary and secondary channel.
constexpr idfxx::event< event_id > sta_beacon_offset_unstable
Station beacon offset unstable event.
constexpr idfxx::event< event_id > nan_svc_match
NAN service match event.
role
WiFi role (station and/or access point).
void ftm_resp_set_offset(int16_t offset)
Sets the FTM responder offset.
mac_address get_mac(enum role iface)
Gets the MAC address for the specified interface.
constexpr idfxx::event< event_id, scan_done_event_data > scan_done
Scan completed event with scan results summary.
result< enum phy_mode > try_get_negotiated_phymode()
Gets the PHY mode negotiated with the connected AP.
result< void > try_set_channel(uint8_t primary, std::optional< enum second_channel > second=std::nullopt)
Sets the primary and secondary channel.
result< void > try_clear_fast_connect()
Clears the fast-connect data stored in memory.
constexpr idfxx::event< event_id > ap_wps_rg_success
AP WPS registrar success event.
void clear_fast_connect()
Clears the fast-connect data stored in memory.
result< country_config > try_get_country()
Gets the current WiFi country configuration.
constexpr idfxx::event< event_id > sta_wps_er_failed
WPS enrollee failed event.
void(*)(void *ctx, const wifi_csi_info_t *info) csi_rx_cb
Callback invoked for each received CSI (Channel State Information) record.
void set_scan_parameters(const scan_default_params ¶ms)
Sets the default scan timing parameters.
constexpr idfxx::event< event_id > sta_start
Station started event.
void set_csi(bool en)
Enables or disables CSI (Channel State Information) collection.
flags< protocol > get_protocol(enum role iface)
Gets the enabled WiFi protocols for the specified interface.
electro::centi_dbm get_max_tx_power()
Gets the current maximum transmit power.
result< sta_config > try_get_sta_config()
Gets the current WiFi station configuration.
result< void > try_set_promiscuous_filter(flags< promiscuous_filter > filter)
Sets the promiscuous mode packet type filter.
void set_event_mask(flags< event_mask > mask)
Sets the WiFi event mask.
result< void > try_set_event_mask(flags< event_mask > mask)
Sets the WiFi event mask.
result< std::vector< ap_record > > try_scan_get_results()
Retrieves results from a completed scan.
void set_channel(uint8_t primary, std::optional< enum second_channel > second=std::nullopt)
Sets the primary and secondary channel.
result< void > try_restore()
Restores WiFi stack persistent settings to defaults.
result< void > try_set_country_code(std::string_view cc, bool ieee80211d_enabled)
Sets the country code.
result< void > try_ftm_end_session()
Ends the current FTM session.
void set_band_mode(enum band_mode m)
Sets the WiFi band mode.
channel_5g
5 GHz WiFi channel flags.
flags< role > get_roles()
Gets the currently active WiFi roles.
result< scan_default_params > try_get_scan_parameters()
Gets the current default scan timing parameters.
result< void > try_set_csi_config(const csi_config &cfg)
Sets the CSI configuration.
constexpr idfxx::event< event_id > ready
WiFi ready event.
result< flags< protocol > > try_get_protocol(enum role iface)
Gets the enabled WiFi protocols for the specified interface.
void set_vendor_ie(bool enable, enum vendor_ie_type type, enum vendor_ie_id id, const void *vnd_ie)
Sets a vendor-specific information element.
result< void > try_force_wakeup_acquire()
Acquires a WiFi wakeup lock.
result< void > try_set_bandwidth(enum role iface, enum bandwidth bw)
Sets the channel bandwidth for the specified interface.
void force_wakeup_release()
Releases a WiFi wakeup lock.
constexpr idfxx::event< event_id > dpp_failed
DPP failed event.
result< void > try_connect()
Connects to the configured access point.
constexpr idfxx::event< event_id > nan_stopped
NAN stopped event.
void set_inactive_time(enum role iface, std::chrono::seconds timeout)
Sets the inactive time before a station is deauthenticated.
constexpr idfxx::event< event_id, authmode_change_event_data > sta_authmode_change
Station authentication mode changed event.
void stop()
Stops the WiFi subsystem.
result< void > try_clear_ap_list()
Clears the AP list stored from a previous scan.
constexpr idfxx::event< event_id > ap_wps_rg_pin
AP WPS registrar PIN received event.
result< void > try_register_80211_tx_cb(tx_80211_done_cb cb)
Registers a callback for 802.11 TX completion.
enum phy_mode get_negotiated_phymode()
Gets the PHY mode negotiated with the connected AP.
void set_bandwidths(enum role iface, const bandwidths_config &bw)
Sets bandwidths for dual-band operation on the specified interface.
result< flags< role > > try_get_roles()
Gets the currently active WiFi roles.
result< void > try_set_promiscuous_rx_cb(promiscuous_rx_cb cb)
Sets the promiscuous mode receive callback.
net::ipv4_info connect_sta(const sta_config &cfg, std::chrono::duration< Rep, Period > timeout)
Connects to an access point as a station and waits for an IPv4 address.
constexpr idfxx::event< event_id > ndp_terminated
NDP terminated event.
constexpr idfxx::event< event_id > ndp_confirm
NDP confirm event.
result< std::vector< ap_record > > try_scan(const scan_config &cfg={})
Performs a blocking scan for access points.
sae_pwe_method
SAE PWE (Password Element) derivation method.
result< mac_address > try_get_mac(enum role iface)
Gets the MAC address for the specified interface.
country_policy
WiFi country policy.
constexpr idfxx::event< event_id > nan_started
NAN started event.
result< electro::dbm > try_get_rssi()
Gets the current RSSI of the connected AP.
constexpr idfxx::event< event_id > sta_beacon_timeout
Station beacon timeout event.
uint16_t scan_get_ap_num()
Gets the number of APs found in the last scan.
constexpr idfxx::event< event_id > ap_stop
Soft-AP stopped event.
std::error_code make_error_code(errc e) noexcept
Creates a std::error_code from an idfxx::errc value.
const wifi::error_category & wifi_category() noexcept
Returns a reference to the WiFi error category singleton.
T unwrap(result< T > result)
Throws a std::system_error if the result is an error.
std::expected< T, std::error_code > result
result type wrapping a value or error code.
flags(E) -> flags< E >
Class template argument deduction guide.
A typed event that pairs an event ID with its data type.
IPv4 network interface information.
Configuration for WiFi access point mode.
bool operator==(const ap_config &) const =default
Information about a probe request received by the soft-AP.
constexpr bool operator==(const ap_probe_req_event_data &) const noexcept=default
Information about a discovered access point.
enum cipher_type pairwise_cipher
std::optional< enum second_channel > second
bool operator==(const ap_record &) const =default
enum cipher_type group_cipher
Information about a station connecting to the soft-AP.
constexpr bool operator==(const ap_sta_connected_event_data &) const noexcept=default
Information about a station disconnecting from the soft-AP.
constexpr bool operator==(const ap_sta_disconnected_event_data &) const noexcept=default
enum disconnect_reason reason
Information about an authentication mode change.
constexpr bool operator==(const authmode_change_event_data &) const noexcept=default
Bandwidth configuration for dual-band operation.
constexpr bool operator==(const bandwidths_config &) const noexcept=default
WiFi channel information.
std::optional< enum second_channel > second
constexpr bool operator==(const channel_info &) const noexcept=default
Information about a successful station connection.
bool operator==(const connected_event_data &) const =default
WiFi country configuration.
constexpr bool operator==(const country_config &) const noexcept=default
CSI (Channel State Information) configuration.
constexpr bool operator==(const csi_config &) const noexcept=default
Information about a station disconnection.
enum disconnect_reason reason
bool operator==(const disconnected_event_data &) const =default
FTM initiator session configuration.
constexpr bool operator==(const ftm_initiator_config &) const noexcept=default
Single FTM report measurement entry.
constexpr bool operator==(const ftm_report_entry &) const noexcept=default
Information about an FTM report.
std::vector< ftm_report_entry > entries
bool operator==(const ftm_report_event_data &) const =default
HE (High Efficiency) AP information.
constexpr bool operator==(const he_ap_info &) const noexcept=default
Information about a home channel change.
std::optional< enum second_channel > old_second
constexpr bool operator==(const home_channel_change_event_data &) const noexcept=default
std::optional< enum second_channel > new_second
Configuration for WiFi initialization.
std::optional< bool > nvs_enable
std::optional< bool > ampdu_rx_enable
std::optional< unsigned int > static_rx_buf_num
std::optional< unsigned int > dynamic_rx_buf_num
std::optional< unsigned int > rx_ba_win
constexpr bool operator==(const init_config &) const noexcept=default
std::optional< unsigned int > dynamic_tx_buf_num
std::optional< unsigned int > static_tx_buf_num
std::optional< unsigned int > cache_tx_buf_num
std::optional< bool > ampdu_tx_enable
std::optional< core_id > wifi_task_core_id
Protected Management Frame (PMF) configuration.
constexpr bool operator==(const pmf_config &) const noexcept=default
Protocol configuration for dual-band operation.
constexpr bool operator==(const protocols_config &) const noexcept=default
Configuration for a WiFi scan operation.
bool operator==(const scan_config &) const =default
Default scan timing parameters.
constexpr bool operator==(const scan_default_params &) const noexcept=default
Information about a completed scan.
constexpr bool operator==(const scan_done_event_data &) const noexcept=default
Configuration for WiFi station mode.
bool operator==(const sta_config &) const =default
Information about a station connected to the soft-AP.
constexpr bool operator==(const sta_info &) const noexcept=default