libxr 1.0
Want to be the best embedded framework
Loading...
Searching...
No Matches
wifi_client.hpp
1#pragma once
2
3#include <string>
4#include <vector>
5
6#include "libxr_def.hpp"
7#include "libxr_rw.hpp"
8
9namespace LibXR
10{
11
16{
17 public:
35
39 enum class Security
40 {
41 OPEN,
42 WPA2_PSK,
44 UNKNOWN,
45 };
46
51 {
52 std::string identity;
53 std::string username;
54 std::string password;
55 std::string ca_cert;
56 std::string client_cert;
57 std::string client_key;
58 };
59
64 {
65 std::string ip;
66 std::string gateway;
67 std::string netmask;
68 std::string dns;
69 };
70
74 struct Config
75 {
76 std::string ssid;
77 std::string password;
79
81 nullptr;
82
84 nullptr;
85
86 bool use_dhcp = true;
87 };
88
93 {
94 std::string ssid;
95 int rssi;
97 };
98
103
104 virtual ~WifiClient() = default;
105
109 virtual WifiError Enable() = 0;
110
114 virtual WifiError Disable() = 0;
115
120 virtual WifiError Connect(const Config& config) = 0;
121
125 virtual WifiError Disconnect() = 0;
126
131 virtual bool IsConnected() const = 0;
132
137 virtual const char* GetIPAddress() const = 0;
138
143 virtual WifiError Scan(std::vector<ScanResult>& results) = 0;
144
150 virtual int GetRSSI() const = 0;
151};
152
153} // namespace LibXR
提供一个通用的回调包装,支持动态参数传递。 Provides a generic callback wrapper, supporting dynamic argument passing.
Definition libxr_cb.hpp:125
Wifi 客户端接口类 / Interface class for WiFi client management.
virtual bool IsConnected() const =0
检查是否已连接 / Check if currently connected
virtual WifiError Connect(const Config &config)=0
连接到 WiFi 网络 / Connect to a WiFi network
virtual WifiError Disable()=0
禁用 WiFi 模块 / Disable the WiFi module
Security
WiFi 安全类型 / WiFi security types.
@ WPA2_PSK
WPA2-PSK / WPA2-PSK.
@ OPEN
开放网络 / Open network
@ WPA2_ENTERPRISE
WPA2 企业认证 / WPA2 Enterprise.
virtual WifiError Enable()=0
启用 WiFi 模块 / Enable the WiFi module
WifiError
WiFi 错误码枚举 / Enumeration of WiFi error codes.
@ DHCP_FAILED
DHCP 获取失败 / DHCP acquisition failed.
@ INVALID_CONFIG
配置无效 / Invalid configuration
@ AUTHENTICATION_FAILED
身份验证失败 / Authentication failed
@ UNKNOWN
未知错误 / Unknown error
@ HARDWARE_FAILURE
硬件故障 / Hardware failure
@ SCAN_FAILED
扫描失败 / Scan failed
@ ALREADY_ENABLED
已启用 / Already enabled
@ NOT_ENABLED
未启用 / Not enabled
@ NONE
无错误 / No error
@ CONNECTION_TIMEOUT
连接超时 / Connection timeout
@ SSID_NOT_FOUND
找不到 SSID / SSID not found
virtual WifiError Disconnect()=0
断开当前 WiFi 连接 / Disconnect from the current WiFi connection
virtual const char * GetIPAddress() const =0
获取当前 IP 地址 / Get the current IP address
virtual WifiError Scan(std::vector< ScanResult > &results)=0
扫描可用 WiFi 网络 / Scan for available WiFi networks
virtual int GetRSSI() const =0
获取当前 WiFi 信号强度 / Get the current WiFi signal strength
LibXR Color Control Library / LibXR终端颜色控制库
Definition esp_gpio.hpp:8
constexpr auto min(T1 a, T2 b) -> typename std::common_type< T1, T2 >::type
计算两个数的最小值
WiFi 连接配置 / WiFi connection configuration.
bool use_dhcp
是否使用 DHCP / Whether to use DHCP
std::string password
密码 / Password
std::string ssid
SSID 名称 / SSID name.
Security security
安全类型 / Security type
StaticIPConfig * static_ip_config
静态 IP 配置(可选) / Static IP config (optional)
EnterpriseConfig * enterprise_config
企业认证配置(可选) / Enterprise authentication config (optional)
企业 WiFi 配置 / Enterprise WiFi configuration
std::string identity
EAP 身份标识 / EAP identity.
std::string client_key
客户端密钥路径 / Client key path
std::string ca_cert
CA 证书路径 / CA certificate path.
std::string username
用户名 / Username
std::string password
密码 / Password
std::string client_cert
客户端证书路径 / Client certificate path
WiFi 扫描结果 / WiFi scan result.
std::string ssid
发现的 SSID / Detected SSID
int rssi
信号强度 / Signal strength (RSSI)
Security security
安全类型 / Security type
静态 IP 配置 / Static IP configuration
std::string gateway
网关地址 / Gateway address
std::string netmask
子网掩码 / Netmask
std::string ip
IP 地址 / IP address.
std::string dns
DNS 服务器 / DNS server.