“ESP8266 WiFi”的版本间的差异
(未显示1个用户的8个中间版本) | |||
第1行: | 第1行: | ||
− | <font color="orange" size="+2">'''ESP8266 WiFi 库'''</font><br> | + | ==<font color="orange" size="+2">'''ESP8266 WiFi 库'''</font>== |
+ | <br> | ||
'''The WiFi class initializes the ethernet library and network settings.''' | '''The WiFi class initializes the ethernet library and network settings.''' | ||
− | + | ||
- <font color="forestgreen">WiFi.mode()</font> | - <font color="forestgreen">WiFi.mode()</font> | ||
− | + | ||
+ | 设置wifi模块工作模式WIFI_AP,WIFI_STA,WIFI_AP_STA | ||
{| border="0" cellpadding="10" width="100%" | {| border="0" cellpadding="10" width="100%" | ||
第15行: | 第17行: | ||
- <font color="forestgreen">WiFi.softAP(ssid,[password],[channel],[ssid_hidden])</font> | - <font color="forestgreen">WiFi.softAP(ssid,[password],[channel],[ssid_hidden])</font> | ||
− | + | ||
− | + | 设置AP模式参数 | |
− | + | ||
− | + | 参数 | |
− | + | :ssid:网络名称(最长63字符) | |
− | + | :password:密码,至少8个字符,NULL为开放网络(可选参数) | |
− | + | :channel:通道号,1 - 13(可选参数,缺省情况下为1) | |
+ | :ssid_hidden:网络是否可见,0为可见网络,1为隐藏网络(可选参数,缺省情况下为0) | ||
+ | |||
+ | 返回值:bool | ||
- <font color="forestgreen">WiFi.softAPConfig(local_ip,gateway,subnet)</font> | - <font color="forestgreen">WiFi.softAPConfig(local_ip,gateway,subnet)</font> | ||
− | + | ||
− | + | 配置AP | |
− | + | ||
− | + | 参数 | |
− | + | :local_ip:ap ip(类型:IPAddress-例192,168,0,1) | |
− | + | :gateway:网关ip(类型:IPAddress) | |
+ | :subnet:子网掩码(类型:IPAddress) | ||
+ | |||
+ | 返回值:bool | ||
- <font color="forestgreen">WiFi.softAPdisconnect(wifioff)</font> | - <font color="forestgreen">WiFi.softAPdisconnect(wifioff)</font> | ||
− | + | ||
+ | 断开网络,关闭AP | ||
- <font color="forestgreen">WiFi.softAPgetStationNum()</font> | - <font color="forestgreen">WiFi.softAPgetStationNum()</font> | ||
− | + | ||
+ | 获取AP模式下已连接终端的数量 | ||
- <font color="forestgreen">WiFi.softAPIP()</font> | - <font color="forestgreen">WiFi.softAPIP()</font> | ||
− | + | ||
− | + | 获取IP地址,用于AP模式 | |
+ | |||
+ | 返 回:IP 地址 | ||
- <font color="forestgreen">WiFi.softAPmacAddress(mac)</font> | - <font color="forestgreen">WiFi.softAPmacAddress(mac)</font> | ||
− | + | ||
− | + | 获取MAC地址,用于AP模式 | |
+ | |||
+ | 返回:uint8_t* | ||
- <font color="forestgreen">WiFi.softAPmacAddress(void)</font> | - <font color="forestgreen">WiFi.softAPmacAddress(void)</font> | ||
− | + | ||
− | + | 获取MAC地址,用于AP模式 | |
+ | |||
+ | 返回:String | ||
+ | |||
+ | <!---------------------------------------------------ESP8266 wifi sta---------------------------------------------------------------------> | ||
+ | |||
|width="50%" valign="top" align="left"| | |width="50%" valign="top" align="left"| | ||
<font color="orange" size="+1">ESP8266WiFi STA</font><br> | <font color="orange" size="+1">ESP8266WiFi STA</font><br> | ||
− | WL_CONNECTED | + | <font color="deepskyblue">WL_CONNECTED</font> |
− | WL_NO_SSID_AVAIL | + | <font color="deepskyblue">WL_NO_SSID_AVAIL</font> |
− | WL_CONNECT_FAILED | + | <font color="deepskyblue">WL_CONNECT_FAILED</font> |
− | WL_IDLE_STATUS | + | <font color="deepskyblue">WL_IDLE_STATUS</font> |
− | WL_DISCONNECTED | + | <font color="deepskyblue">WL_DISCONNECTED</font> |
- <font color="forestgreen">WiFi.begin()</font> | - <font color="forestgreen">WiFi.begin()</font> | ||
− | + | ||
+ | 开始wifi连接 | ||
- <font color="forestgreen">WiFi.config(local_ip, gateway, subnet, dns1, dns2)</font> | - <font color="forestgreen">WiFi.config(local_ip, gateway, subnet, dns1, dns2)</font> | ||
− | + | ||
− | + | 更改IP配置设置禁用DHCP客户端 | |
− | + | ||
− | + | 参数 | |
− | + | : local_ip Static ip configuration | |
− | + | : gateway Static gateway configuration | |
− | + | : subnet Static Subnet mask | |
− | + | : dns1 Static DNS server 1 | |
+ | : dns2 Static DNS server 2 | ||
+ | |||
+ | 返回:bool | ||
- <font color="forestgreen">WiFi.reconnect()</font> | - <font color="forestgreen">WiFi.reconnect()</font> | ||
− | + | ||
− | + | 将强制断开连接,然后重新连接到AP | |
+ | |||
+ | 返回:bool | ||
- <font color="forestgreen">WiFi.disconnect(bool wifioff)</font> | - <font color="forestgreen">WiFi.disconnect(bool wifioff)</font> | ||
− | + | ||
− | + | Disconnect from the network | |
+ | 断开网络 | ||
+ | |||
+ | 返回:bool | ||
- <font color="forestgreen">WiFi.isConnected()</font> | - <font color="forestgreen">WiFi.isConnected()</font> | ||
− | + | ||
− | + | 检查是否已连接 | |
+ | |||
+ | 返回:bool | ||
- <font color="forestgreen">WiFi.setAutoConnect(bool autoConnect)</font> | - <font color="forestgreen">WiFi.setAutoConnect(bool autoConnect)</font> | ||
− | |||
− | |||
− | - <font color="forestgreen">WiFi. | + | 设置是否复位自动连接,默认自动连接 |
− | + | ||
− | + | 返回:bool | |
+ | |||
+ | - <font color="forestgreen">WiFi.getAutoConnect()</font> | ||
+ | |||
+ | 检查是否设置了复位自动连接 | ||
+ | |||
+ | 返回:bool | ||
- <font color="forestgreen">WiFi.setAutoReconnect(bool autoReconnect)</font> | - <font color="forestgreen">WiFi.setAutoReconnect(bool autoReconnect)</font> | ||
− | + | ||
− | + | 设置当连接断开时是否重新连接 | |
+ | |||
+ | 返回:bool | ||
- <font color="forestgreen">WiFi.waitForConnectResult()</font> | - <font color="forestgreen">WiFi.waitForConnectResult()</font> | ||
− | + | ||
− | + | Wait for WiFi connection to reach a result returns the status reached or disconnect if STA is off | |
− | + | ||
− | + | 返回:连接状态 | |
− | + | :WL_CONNECTED | |
− | + | :WL_NO_SSID_AVAIL | |
− | + | :WL_CONNECT_FAILED | |
+ | :WL_IDLE_STATUS | ||
+ | :WL_DISCONNECTED | ||
- <font color="forestgreen">WiFi.localIP()</font> | - <font color="forestgreen">WiFi.localIP()</font> | ||
− | + | ||
− | + | 获取IP地址,用于STA模式 | |
+ | |||
+ | 返回:IPAddress | ||
- <font color="forestgreen">WiFi.macAddress(uint8_t* mac)</font> | - <font color="forestgreen">WiFi.macAddress(uint8_t* mac)</font> | ||
− | + | ||
+ | 获取MAC地址,用于STA模式 | ||
+ | |||
+ | 返回:uint8_t* | ||
- <font color="forestgreen">WiFi.macAddress(void)</font> | - <font color="forestgreen">WiFi.macAddress(void)</font> | ||
− | + | ||
+ | 获取MAC地址,用于STA模式 | ||
+ | |||
+ | 返回:String | ||
- <font color="forestgreen">WiFi.subnetMask()</font> | - <font color="forestgreen">WiFi.subnetMask()</font> | ||
− | + | ||
− | + | Get the interface subnet mask address. | |
+ | 获取接口子网掩码地址 | ||
+ | |||
+ | 返回:IPAddress | ||
- <font color="forestgreen">WiFi.gatewayIP()</font> | - <font color="forestgreen">WiFi.gatewayIP()</font> | ||
− | + | ||
− | + | Get the gateway ip address. | |
+ | 获取网关地址 | ||
+ | |||
+ | 返回:IPAddress | ||
- <font color="forestgreen">WiFi.dnsIP(uint8_t dns_no)</font> | - <font color="forestgreen">WiFi.dnsIP(uint8_t dns_no)</font> | ||
− | + | ||
− | + | Get the DNS ip address. | |
+ | 获取DNS ip 地址 | ||
+ | |||
+ | 返回:IPAddress | ||
- <font color="forestgreen">WiFi.hostname(void)</font> | - <font color="forestgreen">WiFi.hostname(void)</font> | ||
− | + | ||
− | + | Get ESP8266 station DHCP hostname | |
+ | |||
+ | 获取ESP8266 SAT DHCP主机名 | ||
+ | |||
+ | 返回:String | ||
- <font color="forestgreen">WiFi.hostname(char* aHostname)</font> | - <font color="forestgreen">WiFi.hostname(char* aHostname)</font> | ||
− | + | ||
− | + | Set ESP8266 station DHCP hostname | |
+ | 设置ESP8266 STA DHCP主机名 | ||
+ | |||
+ | 参数类型:char* | ||
+ | |||
+ | 返回:bool | ||
- <font color="forestgreen">WiFi.hostname(const char* aHostname)</font> | - <font color="forestgreen">WiFi.hostname(const char* aHostname)</font> | ||
− | + | ||
− | + | Set ESP8266 station DHCP hostname | |
+ | |||
+ | 参数类型:const char* | ||
+ | |||
+ | 返回:bool | ||
- <font color="forestgreen">WiFi.hostname(String aHostname)</font> | - <font color="forestgreen">WiFi.hostname(String aHostname)</font> | ||
− | + | ||
− | + | Set ESP8266 station DHCP hostname | |
+ | |||
+ | 参数类型:String | ||
+ | |||
+ | 返回:bool | ||
- <font color="forestgreen">WiFi.SSID()</font> | - <font color="forestgreen">WiFi.SSID()</font> | ||
− | + | ||
− | + | 获取当前连接网络的SSID | |
+ | |||
+ | 返回:String | ||
- <font color="forestgreen">WiFi.psk()</font> | - <font color="forestgreen">WiFi.psk()</font> | ||
− | + | ||
− | + | 获取当前连接网络的共享秘钥 | |
+ | |||
+ | 返回:String | ||
- <font color="forestgreen">WiFi.BSSID(void)</font> | - <font color="forestgreen">WiFi.BSSID(void)</font> | ||
− | + | ||
− | + | Return the current bssid / mac associated with the network if configured | |
+ | |||
+ | 返回:uint8_t* | ||
- <font color="forestgreen">WiFi.BSSIDstr(void)</font> | - <font color="forestgreen">WiFi.BSSIDstr(void)</font> | ||
− | + | ||
− | + | Return the current bssid / mac associated with the network if configured | |
+ | |||
+ | 返回:String | ||
- <font color="forestgreen">WiFi.RSSI(void)</font> | - <font color="forestgreen">WiFi.RSSI(void)</font> | ||
− | |||
− | |||
− | <font color=" | + | Return the current network RSSI. |
+ | |||
+ | 返回:int32_t (RSSI value) | ||
+ | |||
+ | <font color="orange" size="+0.5">STA远程配置</font><br> | ||
+ | |||
- <font color="forestgreen">WiFi.beginWPSConfig(void)</font> | - <font color="forestgreen">WiFi.beginWPSConfig(void)</font> | ||
− | + | ||
− | + | WPS配置(so far only WPS_TYPE_PBC is supported (SDK 1.2.0)) | |
+ | |||
+ | 返回:bool | ||
- <font color="forestgreen">WiFi.beginSmartConfig()</font> | - <font color="forestgreen">WiFi.beginSmartConfig()</font> | ||
− | + | ||
− | + | 开始 SmartConfig | |
+ | |||
+ | 返回:bool | ||
- <font color="forestgreen">WiFi.stopSmartConfig()</font> | - <font color="forestgreen">WiFi.stopSmartConfig()</font> | ||
− | + | ||
− | + | 停止 SmartConfig | |
+ | |||
+ | 返回:bool | ||
- <font color="forestgreen">WiFi.smartConfigDone()</font> | - <font color="forestgreen">WiFi.smartConfigDone()</font> | ||
− | + | ||
− | + | 查询 SmartConfig 状态,决定何时停止配置 | |
+ | |||
+ | 返回:bool | ||
<br> | <br> | ||
|} | |} | ||
− | + | <!--------------------------------------------------------------ESP8266 wifi server---------------------------------------------------------------> | |
− | + | {| border="0" cellpadding="10" width="100%" | |
+ | |width="33%" valign="top" align="left"| | ||
− | + | <font color="orange" size="+1">ESP8266WiFi Server</font><br> | |
− | + | '''The Server class creates servers which can send data to and receive data from connected clients (programs running on other computers or devices).''' | |
− | + | - <font color="forestgreen">WiFiServer wifiServer(IPAddress addr, uint16_t port)</font> | |
− | + | 开启服务 | |
− | : | + | 参数 |
+ | :addr:ip地址 | ||
+ | :port:端口 | ||
− | + | - <font color="forestgreen">WiFiServer wifiServer(uint16_t port)</font> | |
− | + | 开启服务 | |
− | : | + | 参数 |
+ | :port:端口 | ||
− | + | - <font color="forestgreen">wifiServer.begin()</font> | |
− | + | - <font color="forestgreen">wifiServer.setNoDelay(bool nodelay)</font> | |
− | + | - <font color="forestgreen">wifiServer.getNoDelay()</font> | |
− | + | ||
− | <font color=" | + | - <font color="forestgreen">wifiServer.hasClient()</font> |
− | + | - <font color="forestgreen">wifiServer.available()</font> | |
− | + | - <font color="forestgreen">wifiServer.status()</font> | |
− | + | - <font color="forestgreen">wifiServer.close()</font> | |
− | + | - <font color="forestgreen">wifiServer.stop()</font> | |
− | + | - <font color="forestgreen">wifiServer.write(uint8_t b)</font> | |
− | + | - <font color="forestgreen">wifiServer.write(const uint8_t *buffer, size_t size)</font> | |
− | |||
− | |||
<br> | <br> | ||
+ | |||
+ | <!-------------------------------------------------------------ESP8266 wifi client----------------------------------------------------------------> | ||
|width="33%" valign="top" align="left"| | |width="33%" valign="top" align="left"| | ||
<font color="orange" size="+1">ESP8266WiFi Client</font><br> | <font color="orange" size="+1">ESP8266WiFi Client</font><br> | ||
第236行: | 第330行: | ||
'''The client class creates clients that can connect to servers and send and receive data.''' | '''The client class creates clients that can connect to servers and send and receive data.''' | ||
− | + | - <font color="forestgreen">WiFiClient wifiClient()</font> | |
− | + | - <font color="forestgreen">WiFiClient wifiClient(const WiFiClient& other)</font> | |
− | + | - <font color="forestgreen">WiFiClient operator=(const WiFiClient& other)</font> | |
− | + | - <font color="forestgreen">wifiClient.connect(const char* host, uint16_t port)</font> | |
− | + | - <font color="forestgreen">wifiClient.connect(IPAddress ip, uint16_t port)</font> | |
− | + | - <font color="forestgreen">wifiClient.setNoDelay(bool nodelay)</font> | |
− | + | - <font color="forestgreen">wifiClient.getNoDelay()</font> | |
− | + | - <font color="forestgreen">wifiClient.write(uint8_t b)</font> | |
− | + | - <font color="forestgreen">wifiClient.write(const uint8_t *buf, size_t size)</font> | |
− | + | - <font color="forestgreen">wifiClient.write_P(PGM_P buf, size_t size)</font> | |
+ | |||
+ | - <font color="forestgreen">wifiClient.available()</font> | ||
+ | |||
+ | - <font color="forestgreen">wifiClient.read()</font> | ||
+ | |||
+ | - <font color="forestgreen">wifiClient.read(uint8_t* buf, size_t size)</font> | ||
+ | |||
+ | - <font color="forestgreen">wifiClient.peekBytes(uint8_t *buffer, size_t length)</font> | ||
+ | |||
+ | - <font color="forestgreen">wifiClient.flush()</font> | ||
+ | |||
+ | - <font color="forestgreen">wifiClient.stop()</font> | ||
+ | |||
+ | - <font color="forestgreen">wifiClient.connected()</font> | ||
+ | |||
+ | - <font color="forestgreen">wifiClient.status()</font> | ||
+ | |||
+ | - <font color="forestgreen">wifiClient.remoteIP()</font> | ||
+ | |||
+ | - <font color="forestgreen">wifiClient.remotePort()</font> | ||
+ | |||
+ | - <font color="forestgreen">wifiClient.localIP()</font> | ||
+ | |||
+ | - <font color="forestgreen">wifiClient.localPort()</font> | ||
+ | |||
+ | - <font color="forestgreen">wifiClient.stopAll()</font> | ||
+ | |||
+ | - <font color="forestgreen">wifiClient.stopAllExcept(WiFiClient * exC)</font> | ||
− | |||
<br><br> | <br><br> | ||
+ | <!---------------------------------------------------------------ESP8266 wifi udp--------------------------------------------------------------> | ||
|width="33%" valign="top" align="left"| | |width="33%" valign="top" align="left"| | ||
<font color="orange" size="+1">ESP8266WiFi Udp</font><br> | <font color="orange" size="+1">ESP8266WiFi Udp</font><br> | ||
'''The UDP class enables UDP message to be sent and received.''' | '''The UDP class enables UDP message to be sent and received.''' | ||
− | |||
− | + | - <font color="forestgreen">WiFiUDP wifiUDP(const WiFiUDP& other)</font> | |
+ | |||
+ | 构造函数 -- 例如:WiFiUDP UDP; | ||
+ | |||
+ | - <font color="forestgreen">wifiUDP.begin(uint16_t port)</font> | ||
+ | |||
+ | 初始化、启动监听指定的端口 -- 例如:UDP.begin(5000); | ||
+ | |||
+ | 成功返回1,否则返回0 | ||
+ | |||
+ | - <font color="forestgreen">wifiUDP.beginMulticast(IPAddress interfaceAddr, IPAddress multicast, uint16_t port)</font> | ||
+ | |||
+ | 加入一个多路广播组并监听端口 | ||
+ | |||
+ | - <font color="forestgreen">wifiUDP.available()</font> | ||
+ | |||
+ | 当前数据包中的数据字节数 | ||
+ | |||
+ | - <font color="forestgreen">wifiUDP.stop()</font> | ||
+ | |||
+ | 结束UDP连接 | ||
+ | |||
+ | - <font color="forestgreen">wifiUDP.beginPacket(const char *host, uint16_t port)</font> | ||
+ | |||
+ | 开始建立一个发送到特定主机和端口的远程主机的数据包 | ||
+ | |||
+ | 成功返回1,否则返回0 | ||
+ | |||
+ | - <font color="forestgreen">wifiUDP.beginPacket(IPAddress ip, uint16_t port)</font> | ||
+ | |||
+ | 开始建立一个发送到特定IP和端口的远程主机的数据包 | ||
+ | |||
+ | 成功返回1,否则返回0 | ||
+ | |||
+ | - <font color="forestgreen">wifiUDP.beginPacketMulticast(IPAddress multicastAddress, uint16_t port,IPAddress interfaceAddress, int ttl)</font> | ||
+ | |||
+ | 开始建立一个数据包发送到多播地址 | ||
+ | |||
+ | 成功返回1,否则返回0 | ||
+ | |||
+ | - <font color="forestgreen">wifiUDP.endPacket()</font> | ||
+ | |||
+ | 完成数据包建立并发送 | ||
+ | |||
+ | 发送成功返回1,否则返回0 | ||
+ | |||
+ | - <font color="forestgreen">wifiUDP.write(uint8_t byte)</font> | ||
+ | |||
+ | 写单字节到数据包 | ||
+ | |||
+ | - <font color="forestgreen">wifiUDP.write(const uint8_t *buffer, size_t size)</font> | ||
+ | |||
+ | 写多字节到数据包 | ||
+ | |||
+ | - <font color="forestgreen">wifiUDP.parsePacket()</font> | ||
+ | |||
+ | 开始处理下一个传入的可用数据包 | ||
+ | |||
+ | 返回数据包大小,如果没有数据包则返回0 | ||
+ | |||
+ | - <font color="forestgreen">wifiUDP.read()</font> | ||
+ | |||
+ | 从当前数据包中读取单字节 | ||
+ | |||
+ | - <font color="forestgreen">wifiUDP.read(unsigned char* buffer, size_t len)</font> | ||
+ | |||
+ | 从当前数据包中读取len长度字节并存储到buffer中 | ||
+ | |||
+ | 返回读取字节数,没有则返回0 | ||
+ | |||
+ | - <font color="forestgreen">wifiUDP.peek()</font> | ||
+ | |||
+ | 从当前数据包中读取单字节,并不移动到下一个字节 | ||
+ | |||
+ | - <font color="forestgreen">wifiUDP.flush()</font> | ||
+ | |||
+ | 读完当前数据包 | ||
+ | |||
+ | - <font color="forestgreen">wifiUDP.remoteIP()</font> | ||
− | + | 返回发送传入当前数据包的主机的IP地址 | |
− | + | - <font color="forestgreen">wifiUDP.remotePort()</font> | |
− | + | 返回发送传入当前数据包的主机的端口号 | |
− | + | - <font color="forestgreen">wifiUDP.destinationIP()</font> | |
− | + | 返回传入数据包的目的地址,区分多路广播和普通数据包有用 | |
− | + | - <font color="forestgreen">wifiUDP.localPort()</font> | |
− | + | 返回输出数据包的本地端口 | |
− | + | - <font color="forestgreen">wifiUDP.stopAll()</font> | |
− | + | - <font color="forestgreen">wifiUDP.stopAllExcept(WiFiUDP * exC)</font> | |
− | |||
− | |||
|} | |} | ||
2016年7月13日 (三) 14:10的最后版本
ESP8266 WiFi 库
The WiFi class initializes the ethernet library and network settings.
- WiFi.mode()
设置wifi模块工作模式WIFI_AP,WIFI_STA,WIFI_AP_STA
ESP8266WiFi AP - WiFi.softAP(ssid,[password],[channel],[ssid_hidden]) 设置AP模式参数 参数
返回值:bool - WiFi.softAPConfig(local_ip,gateway,subnet) 配置AP 参数
返回值:bool - WiFi.softAPdisconnect(wifioff) 断开网络,关闭AP - WiFi.softAPgetStationNum() 获取AP模式下已连接终端的数量 - WiFi.softAPIP() 获取IP地址,用于AP模式 返回:IP地址 - WiFi.softAPmacAddress(mac) 获取MAC地址,用于AP模式 返回:uint8_t* - WiFi.softAPmacAddress(void) 获取MAC地址,用于AP模式 返回:String
|
ESP8266WiFi STA WL_CONNECTED WL_NO_SSID_AVAIL WL_CONNECT_FAILED WL_IDLE_STATUS WL_DISCONNECTED - WiFi.begin() 开始wifi连接 - WiFi.config(local_ip, gateway, subnet, dns1, dns2) 更改IP配置设置禁用DHCP客户端 参数
返回:bool - WiFi.reconnect() 将强制断开连接,然后重新连接到AP 返回:bool - WiFi.disconnect(bool wifioff) Disconnect from the network 断开网络 返回:bool - WiFi.isConnected() 检查是否已连接 返回:bool - WiFi.setAutoConnect(bool autoConnect) 设置是否复位自动连接,默认自动连接 返回:bool - WiFi.getAutoConnect() 检查是否设置了复位自动连接 返回:bool - WiFi.setAutoReconnect(bool autoReconnect) 设置当连接断开时是否重新连接 返回:bool - WiFi.waitForConnectResult() Wait for WiFi connection to reach a result returns the status reached or disconnect if STA is off 返回:连接状态
- WiFi.localIP() 获取IP地址,用于STA模式 返回:IPAddress - WiFi.macAddress(uint8_t* mac) 获取MAC地址,用于STA模式 返回:uint8_t* - WiFi.macAddress(void) 获取MAC地址,用于STA模式 返回:String - WiFi.subnetMask() Get the interface subnet mask address. 获取接口子网掩码地址 返回:IPAddress - WiFi.gatewayIP() Get the gateway ip address. 获取网关地址 返回:IPAddress - WiFi.dnsIP(uint8_t dns_no) Get the DNS ip address. 获取DNS ip 地址 返回:IPAddress - WiFi.hostname(void) Get ESP8266 station DHCP hostname 获取ESP8266 SAT DHCP主机名 返回:String - WiFi.hostname(char* aHostname) Set ESP8266 station DHCP hostname 设置ESP8266 STA DHCP主机名 参数类型:char* 返回:bool - WiFi.hostname(const char* aHostname) Set ESP8266 station DHCP hostname 参数类型:const char* 返回:bool - WiFi.hostname(String aHostname) Set ESP8266 station DHCP hostname 参数类型:String 返回:bool - WiFi.SSID() 获取当前连接网络的SSID 返回:String - WiFi.psk() 获取当前连接网络的共享秘钥 返回:String - WiFi.BSSID(void) Return the current bssid / mac associated with the network if configured 返回:uint8_t* - WiFi.BSSIDstr(void) Return the current bssid / mac associated with the network if configured 返回:String - WiFi.RSSI(void) Return the current network RSSI. 返回:int32_t (RSSI value) STA远程配置 - WiFi.beginWPSConfig(void) WPS配置(so far only WPS_TYPE_PBC is supported (SDK 1.2.0)) 返回:bool - WiFi.beginSmartConfig() 开始 SmartConfig 返回:bool - WiFi.stopSmartConfig() 停止 SmartConfig 返回:bool - WiFi.smartConfigDone() 查询 SmartConfig 状态,决定何时停止配置 返回:bool
|
ESP8266WiFi Server The Server class creates servers which can send data to and receive data from connected clients (programs running on other computers or devices). - WiFiServer wifiServer(IPAddress addr, uint16_t port) 开启服务 参数
- WiFiServer wifiServer(uint16_t port) 开启服务 参数
- wifiServer.begin() - wifiServer.setNoDelay(bool nodelay) - wifiServer.getNoDelay() - wifiServer.hasClient() - wifiServer.available() - wifiServer.status() - wifiServer.close() - wifiServer.stop() - wifiServer.write(uint8_t b) - wifiServer.write(const uint8_t *buffer, size_t size)
|
ESP8266WiFi Client The client class creates clients that can connect to servers and send and receive data. - WiFiClient wifiClient() - WiFiClient wifiClient(const WiFiClient& other) - WiFiClient operator=(const WiFiClient& other) - wifiClient.connect(const char* host, uint16_t port) - wifiClient.connect(IPAddress ip, uint16_t port) - wifiClient.setNoDelay(bool nodelay) - wifiClient.getNoDelay() - wifiClient.write(uint8_t b) - wifiClient.write(const uint8_t *buf, size_t size) - wifiClient.write_P(PGM_P buf, size_t size) - wifiClient.available() - wifiClient.read() - wifiClient.read(uint8_t* buf, size_t size) - wifiClient.peekBytes(uint8_t *buffer, size_t length) - wifiClient.flush() - wifiClient.stop() - wifiClient.connected() - wifiClient.status() - wifiClient.remoteIP() - wifiClient.remotePort() - wifiClient.localIP() - wifiClient.localPort() - wifiClient.stopAll() - wifiClient.stopAllExcept(WiFiClient * exC)
|
ESP8266WiFi Udp The UDP class enables UDP message to be sent and received. - WiFiUDP wifiUDP(const WiFiUDP& other) 构造函数 -- 例如:WiFiUDP UDP; - wifiUDP.begin(uint16_t port) 初始化、启动监听指定的端口 -- 例如:UDP.begin(5000); 成功返回1,否则返回0 - wifiUDP.beginMulticast(IPAddress interfaceAddr, IPAddress multicast, uint16_t port) 加入一个多路广播组并监听端口 - wifiUDP.available() 当前数据包中的数据字节数 - wifiUDP.stop() 结束UDP连接 - wifiUDP.beginPacket(const char *host, uint16_t port) 开始建立一个发送到特定主机和端口的远程主机的数据包 成功返回1,否则返回0 - wifiUDP.beginPacket(IPAddress ip, uint16_t port) 开始建立一个发送到特定IP和端口的远程主机的数据包 成功返回1,否则返回0 - wifiUDP.beginPacketMulticast(IPAddress multicastAddress, uint16_t port,IPAddress interfaceAddress, int ttl) 开始建立一个数据包发送到多播地址 成功返回1,否则返回0 - wifiUDP.endPacket() 完成数据包建立并发送 发送成功返回1,否则返回0 - wifiUDP.write(uint8_t byte) 写单字节到数据包 - wifiUDP.write(const uint8_t *buffer, size_t size) 写多字节到数据包 - wifiUDP.parsePacket() 开始处理下一个传入的可用数据包 返回数据包大小,如果没有数据包则返回0 - wifiUDP.read() 从当前数据包中读取单字节 - wifiUDP.read(unsigned char* buffer, size_t len) 从当前数据包中读取len长度字节并存储到buffer中 返回读取字节数,没有则返回0 - wifiUDP.peek() 从当前数据包中读取单字节,并不移动到下一个字节 - wifiUDP.flush() 读完当前数据包 - wifiUDP.remoteIP() 返回发送传入当前数据包的主机的IP地址 - wifiUDP.remotePort() 返回发送传入当前数据包的主机的端口号 - wifiUDP.destinationIP() 返回传入数据包的目的地址,区分多路广播和普通数据包有用 - wifiUDP.localPort() 返回输出数据包的本地端口 - wifiUDP.stopAll() - wifiUDP.stopAllExcept(WiFiUDP * exC)
|
更多建议和问题欢迎反馈至 YFRobot论坛