Wi-Fi Helper

[English]

  • 公共头文件: #include "brookesia/service_helper/wifi.hpp"

概述

本页用于查看 Wi-Fi helper 的原始 Doxygen API,包括公共类型、枚举、方法与相关宏定义。

API 参考

Header File

Classes

class Wifi : public esp_brookesia::service::helper::Base<Wifi>

Helper schema definitions for the Wi-Fi service.

Public Types

enum class GeneralAction

General Wi-Fi control actions.

Values:

enumerator Init

Initialize Wi-Fi resources.

enumerator Deinit

Deinitialize Wi-Fi resources.

enumerator Start

Start Wi-Fi subsystem.

enumerator Stop

Stop Wi-Fi subsystem.

enumerator Connect

Connect to configured AP.

enumerator Disconnect

Disconnect from current AP.

enumerator Max

Sentinel value.

enum class GeneralEvent

General Wi-Fi lifecycle events.

Values:

enumerator Deinited

Wi-Fi has been deinitialized.

enumerator Inited

Wi-Fi has been initialized.

enumerator Stopped

Wi-Fi has been stopped.

enumerator Started

Wi-Fi has started.

enumerator Disconnected

Wi-Fi disconnected from AP.

enumerator Connected

Wi-Fi connected to AP.

enumerator Max

Sentinel value.

enum class GeneralState

General state for WiFi state machine.

Stable states: Idle, Inited, Started, Connected Transient states: Initing, Deiniting, Starting, Stopping, Connecting, Disconnecting

Values:

enumerator Idle

Stable: Wi-Fi is not initialized.

enumerator Initing

Transient: Wi-Fi is initializing.

enumerator Inited

Stable: Wi-Fi initialized but not started.

enumerator Deiniting

Transient: Wi-Fi is deinitializing.

enumerator Starting

Transient: Wi-Fi is starting.

enumerator Started

Stable: Wi-Fi started but not connected.

enumerator Stopping

Transient: Wi-Fi is stopping.

enumerator Connecting

Transient: Wi-Fi is connecting.

enumerator Connected

Stable: Wi-Fi is connected.

enumerator Disconnecting

Transient: Wi-Fi is disconnecting.

enumerator Max

Sentinel value.

enum class ScanApSignalLevel

Signal-strength bucket for a scanned AP.

Values:

enumerator LEVEL_0

RSSI <= -81 dBm.

enumerator LEVEL_1

RSSI in [-80, -71] dBm.

enumerator LEVEL_2

RSSI in [-70, -61] dBm.

enumerator LEVEL_3

RSSI in [-60, -51] dBm.

enumerator LEVEL_4

RSSI >= -50 dBm.

enum class SoftApEvent

SoftAP lifecycle events.

Values:

enumerator Started

SoftAP started.

enumerator Stopped

SoftAP stopped.

enumerator Max

Sentinel value.

enum class FunctionId

Wi-Fi service function identifiers.

Values:

enumerator TriggerGeneralAction
enumerator GetGeneralState
enumerator SetConnectAp
enumerator GetConnectAp
enumerator GetConnectedAps
enumerator SetScanParams
enumerator TriggerScanStart
enumerator TriggerScanStop
enumerator SetSoftApParams
enumerator GetSoftApParams
enumerator TriggerSoftApStart
enumerator TriggerSoftApStop
enumerator TriggerSoftApProvisionStart
enumerator TriggerSoftApProvisionStop
enumerator ResetData
enumerator Max
enum class EventId

Wi-Fi service event identifiers.

Values:

enumerator GeneralActionTriggered
enumerator GeneralEventHappened
enumerator ScanStateChanged
enumerator ScanApInfosUpdated
enumerator SoftApEventHappened
enumerator Max
enum class FunctionTriggerGeneralActionParam

Parameter keys for FunctionId::TriggerGeneralAction.

Values:

enumerator Action
enum class FunctionSetConnectApParam

Parameter keys for FunctionId::SetConnectAp.

Values:

enumerator SSID
enumerator Password
enum class FunctionSetScanParamsParam

Parameter keys for FunctionId::SetScanParams.

Values:

enumerator Param
enum class FunctionSetSoftApParamsParam

Parameter keys for FunctionId::SetSoftApParams.

Values:

enumerator Param
enum class EventGeneralActionTriggeredParam

Item keys for EventId::GeneralActionTriggered.

Values:

enumerator Action
enum class EventGeneralEventHappenedParam

Item keys for EventId::GeneralEventHappened.

Values:

enumerator Event
enumerator IsUnexpected
enum class EventScanStateChangedParam

Item keys for EventId::ScanStateChanged.

Values:

enumerator IsRunning
enum class EventScanApInfosUpdatedParam

Item keys for EventId::ScanApInfosUpdated.

Values:

enumerator ApInfos
enum class EventSoftApEventHappenedParam

Item keys for EventId::SoftApEventHappened.

Values:

enumerator Event

Public Static Functions

static inline constexpr std::string_view get_name()

Get helper contract name.

返回

Constant service name string.

static inline std::span<const FunctionSchema> get_function_schemas()

Get all function schemas exposed by this helper.

返回

Read-only span of function schemas.

static inline std::span<const EventSchema> get_event_schemas()

Get all event schemas exposed by this helper.

返回

Read-only span of event schemas.

struct ConnectApInfo

Target AP connection info.

Public Members

std::string ssid

AP SSID.

std::string password

AP password.

bool is_connectable = true

Whether this AP is considered connectable.

struct ScanApInfo

One scanned AP entry.

Public Members

std::string ssid

AP SSID.

bool is_locked

Whether AP authentication is required.

int rssi

Signal strength in dBm.

ScanApSignalLevel signal_level

Bucketed signal level derived from RSSI.

uint8_t channel

RF channel.

Public Static Functions

static inline ScanApSignalLevel get_signal_level(int rssi)

Convert RSSI to a signal-level bucket.

参数

rssi[in] RSSI value in dBm.

返回

Corresponding ScanApSignalLevel.

struct ScanParams

Parameters for periodic AP scanning.

Public Members

size_t ap_count = 20

Maximum number of AP entries to keep.

uint32_t interval_ms = 10000

Scan interval in milliseconds.

uint32_t timeout_ms = 60000

Total scan timeout in milliseconds.

struct SoftApParams

SoftAP runtime configuration.

Public Members

std::string ssid = ""

SoftAP SSID.

std::string password = ""

SoftAP password.

uint8_t max_connection = 4

Maximum station connections.

std::optional<uint8_t> channel = std::nullopt

Optional fixed channel.