libxr
1.0
Want to be the best embedded framework
|
ESP32 平台的 WiFi 客户端实现 / WiFi client implementation for ESP32. More...
#include <esp_wifi_client.hpp>
Public Member Functions | |
bool | Enable () override |
启用网络接口(WiFi) / Enable the network interface | |
void | Disable () override |
禁用网络接口(WiFi) / Disable the network interface | |
WifiError | Connect (const Config &config) override |
连接到指定 WiFi 网络 / Connect to a WiFi network | |
WifiError | Disconnect () override |
断开当前 WiFi 连接 / Disconnect from the WiFi network | |
bool | IsConnected () const override |
检查是否已连接 / Check if currently connected | |
IPAddressRaw | GetIPAddress () const override |
获取当前 IP 地址 / Get current IP address | |
MACAddressRaw | GetMACAddress () const override |
获取当前 MAC 地址 / Get MAC address | |
WifiError | Scan (ScanResult *out_list, size_t max_count, size_t &out_found) override |
扫描可用网络 / Scan for available WiFi networks | |
int | GetRSSI () const override |
获取当前 WiFi 信号强度(RSSI) / Get current signal strength | |
![]() | |
virtual | ~WifiClient ()=default |
析构函数 / Destructor | |
![]() |
Static Private Member Functions | |
static void | EventHandler (void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data) |
事件处理回调 / Event handler callback | |
Private Attributes | |
bool | enabled_ = false |
是否启用 / Whether WiFi is enabled | |
bool | connected_ = false |
是否连接 / Whether WiFi is connected | |
bool | got_ip_ = false |
是否获取 IP / Whether IP is acquired | |
char | ip_str_ [16] = {} |
当前 IP 字符串 / Current IP string | |
uint8_t | mac_ [6] = {} |
当前 MAC 缓存 / Cached MAC address | |
LibXR::Semaphore | semaphore_ |
状态同步信号量 / Event wait semaphore | |
Static Private Attributes | |
static bool | is_initialized_ |
ESP 网络是否已初始化 / Netif initialized. | |
static esp_netif_t * | netif_ = nullptr |
ESP 默认 netif 对象 / Default netif. | |
Additional Inherited Members | |
![]() | |
enum class | WifiError { NONE , ALREADY_ENABLED , NOT_ENABLED , CONNECTION_TIMEOUT , AUTHENTICATION_FAILED , DHCP_FAILED , SSID_NOT_FOUND , INVALID_CONFIG , HARDWARE_FAILURE , SCAN_FAILED , UNKNOWN } |
WiFi 错误码 / Enumeration of WiFi error codes. More... | |
enum class | Security { OPEN , WPA2_PSK , WPA2_ENTERPRISE , UNKNOWN } |
WiFi 安全类型 / WiFi security types. More... | |
using | WifiCallback = LibXR::Callback<WifiError> |
WiFi 状态回调类型 / Callback type for WiFi status. | |
ESP32 平台的 WiFi 客户端实现 / WiFi client implementation for ESP32.
提供基于 ESP-IDF 的 WiFi 接口实现,包含连接、断开、扫描、RSSI 查询等功能, 继承自抽象类 WifiClient 并实现其所有接口。
Definition at line 18 of file esp_wifi_client.hpp.
LibXR::ESP32WifiClient::ESP32WifiClient | ( | ) |
Definition at line 14 of file esp_wifi_client.cpp.
|
override |
Definition at line 29 of file esp_wifi_client.cpp.
|
overridevirtual |
连接到指定 WiFi 网络 / Connect to a WiFi network
[in] | config | WiFi 连接配置 / Configuration parameters |
Implements LibXR::WifiClient.
Definition at line 89 of file esp_wifi_client.cpp.
|
overridevirtual |
禁用网络接口(WiFi) / Disable the network interface
Implements LibXR::WifiClient.
Definition at line 80 of file esp_wifi_client.cpp.
|
overridevirtual |
断开当前 WiFi 连接 / Disconnect from the WiFi network
Implements LibXR::WifiClient.
Definition at line 114 of file esp_wifi_client.cpp.
|
overridevirtual |
启用网络接口(WiFi) / Enable the network interface
Implements LibXR::WifiClient.
Definition at line 37 of file esp_wifi_client.cpp.
|
staticprivate |
事件处理回调 / Event handler callback
arg | 用户数据 / User pointer |
event_base | 事件域 / Event base type |
event_id | 事件编号 / Event ID |
event_data | 附加数据 / Event payload |
Definition at line 175 of file esp_wifi_client.cpp.
|
overridevirtual |
获取当前 IP 地址 / Get current IP address
Implements LibXR::WifiClient.
Definition at line 130 of file esp_wifi_client.cpp.
|
overridevirtual |
获取当前 MAC 地址 / Get MAC address
Implements LibXR::WifiClient.
Definition at line 135 of file esp_wifi_client.cpp.
|
overridevirtual |
获取当前 WiFi 信号强度(RSSI) / Get current signal strength
Implements LibXR::WifiClient.
Definition at line 216 of file esp_wifi_client.cpp.
|
overridevirtual |
检查是否已连接 / Check if currently connected
Implements LibXR::WifiClient.
Definition at line 128 of file esp_wifi_client.cpp.
|
overridevirtual |
扫描可用网络 / Scan for available WiFi networks
[out] | out_list | 扫描结果数组 / Output list buffer |
[in] | max_count | 最大可填入数量 / Max result count |
[out] | out_found | 实际找到数量 / Number found |
Implements LibXR::WifiClient.
Definition at line 144 of file esp_wifi_client.cpp.
|
private |
是否连接 / Whether WiFi is connected
Definition at line 59 of file esp_wifi_client.hpp.
|
private |
是否启用 / Whether WiFi is enabled
Definition at line 58 of file esp_wifi_client.hpp.
|
private |
是否获取 IP / Whether IP is acquired
Definition at line 60 of file esp_wifi_client.hpp.
|
private |
|
inlinestaticprivate |
ESP 网络是否已初始化 / Netif initialized.
Definition at line 54 of file esp_wifi_client.hpp.
|
private |
|
inlinestaticprivate |
ESP 默认 netif 对象 / Default netif.
Definition at line 56 of file esp_wifi_client.hpp.
|
private |
状态同步信号量 / Event wait semaphore
Definition at line 64 of file esp_wifi_client.hpp.