Wi-Fi Station Interface

[中文]

Public header: #include "brookesia/hal_interface/interfaces/wifi/station.hpp"

Class: StationIface

StationIface defines station-mode actions, AP metadata persistence hooks, scan configuration, scan control, and scan/AP update callbacks. It does not own retry, fallback, or auto-connect policy.

API Reference

Header File

Classes

class StationIface : public esp_brookesia::hal::Interface

Wi-Fi station interface for AP connection and scanning.

Public Functions

inline StationIface()

Construct a station Wi-Fi interface.

virtual ~StationIface() = default

Virtual destructor for polymorphic interfaces.

virtual bool configure(Callbacks callbacks) = 0

Configure station callbacks.

Parameters

callbacks -- [in] Callback hooks used to report station state and data.

Returns

true on success; otherwise false.

virtual void clear_callbacks() = 0

Clear all configured callbacks.

virtual bool do_action(StationAction action, bool is_force = false) = 0

Request a station action.

Parameters
  • action -- [in] Action to execute.

  • is_force -- [in] Whether to force the action even if state checks would normally skip it.

Returns

true on success; otherwise false.

virtual bool is_action_running(StationAction action) = 0

Check whether a station action is running.

Parameters

action -- [in] Action to query.

Returns

true if the action is running; otherwise false.

virtual bool is_event_ready(StationEvent event) = 0

Check whether a station event is ready.

Parameters

event -- [in] Event to query.

Returns

true if the event is ready; otherwise false.

virtual void mark_target_connect_ap_info_connectable(bool connectable) = 0

Mark whether the target AP is currently connectable.

Parameters

connectable -- [in] Whether the target AP can be used for connection attempts.

virtual bool set_target_connect_ap_info(const ConnectApInfo &ap_info) = 0

Set the target AP connection information.

Parameters

ap_info -- [in] Target AP connection information.

Returns

true on success; otherwise false.

virtual bool set_last_connected_ap_info(const ConnectApInfo &ap_info) = 0

Set the last connected AP information.

Parameters

ap_info -- [in] Last connected AP information.

Returns

true on success; otherwise false.

virtual bool set_connected_ap_infos(const ConnectApInfoList &ap_infos) = 0

Set the persisted known AP list.

Parameters

ap_infos -- [in] Known AP list.

Returns

true on success; otherwise false.

virtual const ConnectApInfo &get_target_connect_ap_info() const = 0

Get the target AP connection information.

Returns

Target AP connection information.

virtual const ConnectApInfo &get_last_connected_ap_info() const = 0

Get the last connected AP information.

Returns

Last connected AP information.

virtual const ConnectApInfoList &get_connected_ap_infos() const = 0

Get the persisted known AP list.

Returns

Known AP list.

virtual bool set_scan_params(const ScanParams &params) = 0

Set periodic scan parameters.

Parameters

params -- [in] Scan parameters.

Returns

true on success; otherwise false.

virtual const ScanParams &get_scan_params() const = 0

Get periodic scan parameters.

Returns

Scan parameters.

virtual bool start_scan() = 0

Start periodic AP scanning.

Returns

true on success; otherwise false.

virtual void stop_scan() = 0

Stop periodic AP scanning.

Public Static Attributes

static constexpr const char *NAME = "WifiStation"

Interface registry name.

struct Callbacks

Public Members

std::function<void(StationAction)> on_action

Called when a station action is triggered.

std::function<void(StationEvent, bool)> on_event

Called when a station event happens.

std::function<void()> on_error

Called when a station action fails.

std::function<bool(StationAction)> on_action_requested

Called when backend requests a station action.

std::function<void(bool)> on_scan_state_changed

Called when periodic scan state changes.

std::function<void(std::span<const ScanApInfo>)> on_scan_ap_infos_updated

Called with scan results.

std::function<void(const ConnectApInfo&)> on_last_connected_ap_info_updated

Persist last AP.

std::function<void(const ConnectApInfoList&)> on_connected_ap_infos_updated

Persist known APs.