libxr  1.0
Want to be the best embedded framework
Loading...
Searching...
No Matches
esp_wifi_client.hpp
1#pragma once
2
3#include "esp_event.h"
4#include "esp_netif.h"
5#include "esp_wifi.h"
6#include "net/wifi_client.hpp"
7
8namespace LibXR
9{
10
19{
20 public:
22
23 ~ESP32WifiClient() override;
24
25 bool Enable() override;
26
27 void Disable() override;
28
29 WifiError Connect(const Config& config) override;
30
31 WifiError Disconnect() override;
32
33 bool IsConnected() const override;
34
35 IPAddressRaw GetIPAddress() const override;
36
37 MACAddressRaw GetMACAddress() const override;
38
39 WifiError Scan(ScanResult* out_list, size_t max_count, size_t& out_found) override;
40
41 int GetRSSI() const override;
42
43 private:
51 static void EventHandler(void* arg, esp_event_base_t event_base, int32_t event_id,
52 void* event_data);
53
54 static inline bool is_initialized_ =
55 false;
56 static inline esp_netif_t* netif_ = nullptr;
57
58 bool enabled_ = false;
59 bool connected_ = false;
60 bool got_ip_ = false;
61 char ip_str_[16] = {};
62 uint8_t mac_[6] = {};
63
65};
66
67} // namespace LibXR
ESP32 平台的 WiFi 客户端实现 / WiFi client implementation for ESP32.
MACAddressRaw GetMACAddress() const override
获取当前 MAC 地址 / Get MAC address
static bool is_initialized_
ESP 网络是否已初始化 / Netif initialized.
bool connected_
是否连接 / Whether WiFi is connected
IPAddressRaw GetIPAddress() const override
获取当前 IP 地址 / Get current IP address
LibXR::Semaphore semaphore_
状态同步信号量 / Event wait semaphore
WifiError Connect(const Config &config) override
连接到指定 WiFi 网络 / Connect to a WiFi network
uint8_t mac_[6]
当前 MAC 缓存 / Cached MAC address
void Disable() override
禁用网络接口(WiFi) / Disable the network interface
static esp_netif_t * netif_
ESP 默认 netif 对象 / Default netif.
bool enabled_
是否启用 / Whether WiFi is enabled
int GetRSSI() const override
获取当前 WiFi 信号强度(RSSI) / Get current signal strength
bool got_ip_
是否获取 IP / Whether IP is acquired
bool Enable() override
启用网络接口(WiFi) / Enable the network interface
WifiError Disconnect() override
断开当前 WiFi 连接 / Disconnect from the WiFi network
bool IsConnected() const override
检查是否已连接 / Check if currently connected
static void EventHandler(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data)
事件处理回调 / Event handler callback
WifiError Scan(ScanResult *out_list, size_t max_count, size_t &out_found) override
扫描可用网络 / Scan for available WiFi networks
char ip_str_[16]
当前 IP 字符串 / Current IP string
信号量类,实现线程同步机制 Semaphore class implementing thread synchronization
Definition semaphore.hpp:23
WiFi 客户端接口 / WiFi Client Interface.
WifiError
WiFi 错误码 / Enumeration of WiFi error codes.
LibXR 命名空间
Definition ch32_gpio.hpp:9
原始 IPv4 地址 / Raw IPv4 address
Definition net.hpp:17
原始 MAC 地址 / Raw MAC address
Definition net.hpp:69
WiFi 连接配置 / WiFi connection configuration.
WiFi 扫描结果 / WiFi scan result.