Wi-Fi 基础接口

[English]

公共头文件: #include "brookesia/hal_interface/interfaces/wifi/basic.hpp"

类名: WifiBasicIface

WifiBasicIface 暴露共享 Wi-Fi 控制面,包括初始化、反初始化、 启动/停止、重置,以及通用 action/event 回调。连接策略由上层 Wi-Fi service 负责, HAL 只执行单次动作并上报事件。

API 参考

Header File

Classes

class BasicIface : public esp_brookesia::hal::Interface

Basic Wi-Fi controller interface for shared lifecycle and runtime context.

Public Functions

inline BasicIface()

Construct a basic Wi-Fi interface.

virtual ~BasicIface() = default

Virtual destructor for polymorphic interfaces.

virtual bool configure(RuntimeContext runtime, Callbacks callbacks) = 0

Configure runtime resources and callbacks.

参数
  • runtime -- [in] Runtime context shared with the Wi-Fi backend.

  • callbacks -- [in] Callback hooks used to report basic Wi-Fi state.

返回

true on success; otherwise false.

virtual void clear_callbacks() = 0

Clear all configured callbacks.

virtual bool init() = 0

Initialize Wi-Fi resources.

返回

true on success; otherwise false.

virtual void deinit() = 0

Deinitialize Wi-Fi resources.

virtual bool start() = 0

Start the Wi-Fi subsystem.

返回

true on success; otherwise false.

virtual void stop() = 0

Stop the Wi-Fi subsystem.

virtual void reset_data() = 0

Reset backend runtime data.

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

Request a basic Wi-Fi action.

参数
  • action -- [in] Action to execute.

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

返回

true on success; otherwise false.

virtual bool is_action_running(BasicAction action) = 0

Check whether a basic Wi-Fi action is running.

参数

action -- [in] Action to query.

返回

true if the action is running; otherwise false.

virtual bool is_event_ready(BasicEvent event) = 0

Check whether a basic Wi-Fi event is ready.

参数

event -- [in] Event to query.

返回

true if the event is ready; otherwise false.

Public Static Attributes

static constexpr const char *NAME = "WifiBasic"

Interface registry name.

struct Callbacks

Public Members

std::function<void(BasicAction)> on_action

Called when a basic action is triggered.

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

Called when a basic event happens.

std::function<void()> on_error

Called when a basic action fails.

struct RuntimeContext

Public Members

std::shared_ptr<lib_utils::TaskScheduler> task_scheduler

Scheduler used for async Wi-Fi work.

lib_utils::TaskScheduler::Group task_group

Scheduler group used by the Wi-Fi service.