“ESP8266 WiFi”的版本间的差异

来自YFRobotwiki
跳转至: 导航搜索
第1行: 第1行:
{| border="0" cellpadding="10" width="100%"
+
 
|width="100%" valign="top" align="left"|
+
 
<font color="orange" size="+2">'''WiFi类'''</font><br>
 
<font color="orange" size="+2">'''WiFi类'''</font><br>
  
第8行: 第7行:
 
:设置wifi模块工作模式WIFI_AP,WIFI_STA,WIFI_AP_STA
 
:设置wifi模块工作模式WIFI_AP,WIFI_STA,WIFI_AP_STA
  
 +
{| border="0" cellpadding="10" width="100%"
 +
|width="50%" valign="top" align="left"|
 
----  
 
----  
 
Wifi AP  
 
Wifi AP  
第45行: 第46行:
 
:获取MAC地址,用于AP模式
 
:获取MAC地址,用于AP模式
 
:返回:String
 
:返回:String
 
+
|width="50%" valign="top" align="left"|
 
----  
 
----  
 
Wifi STA
 
Wifi STA
第92行: 第93行:
 
:返回:bool
 
:返回:bool
  
- <font color="forestgreen">WiFi.waitForConnectResult(bool autoReconnect)</font>
+
- <font color="forestgreen">WiFi.waitForConnectResult()</font>
: Wait for WiFi connection to reach a resultreturns the status reached or disconnect if STA is off
+
: Wait for WiFi connection to reach a result returns the status reached or disconnect if STA is off
 
:返回:连接状态
 
:返回:连接状态
 
::WL_CONNECTED
 
::WL_CONNECTED
第102行: 第103行:
  
 
- <font color="forestgreen">WiFi.localIP()</font>
 
- <font color="forestgreen">WiFi.localIP()</font>
: 设置IP 地址,用于STA模式
+
: 获取IP 地址,用于STA模式
 +
:返回:IPAddress
  
- <font color="forestgreen">WiFi.softAP(ssid,password)</font>
+
- <font color="forestgreen">WiFi.macAddress(uint8_t* mac)</font>
: 设置一个WPA2-PSK的网络(密码至少8个字符)
+
: 获取MAC地址,用于STA模式
  
- <font color="forestgreen">WiFi.softAP(ssid,password)</font>
+
- <font color="forestgreen">WiFi.macAddress(void)</font>
::设置一个WPA2-PSK的网络(密码至少8个字符)
+
: 获取MAC地址,用于STA模式
  
- <font color="forestgreen">WiFi.softAP(ssid,password)</font>
+
- <font color="forestgreen">WiFi.subnetMask()</font>
: 设置一个WPA2-PSK的网络(密码至少8个字符)
+
: Get the interface subnet mask address.
 +
:返回:IPAddress
 +
 
 +
- <font color="forestgreen">WiFi.gatewayIP()</font>
 +
: Get the gateway ip address.
 +
:返回:IPAddress
  
 
:-[[WiFi.begin()| begin()]]
 
:-[[WiFi.begin()| begin()]]
第137行: 第144行:
 
:-[[WiFi.macAddress()| macAddress()]]
 
:-[[WiFi.macAddress()| macAddress()]]
 
<br>
 
<br>
 +
|}
 +
 +
{| border="0" cellpadding="10" width="100%"
 +
|width="100%" valign="top" align="left"|
 +
 
<font color="orange" size="+2">'''Server 类'''</font><br>
 
<font color="orange" size="+2">'''Server 类'''</font><br>
  

2016年3月25日 (五) 11:10的版本

WiFi类

The WiFi class initializes the ethernet library and network settings.

- WiFi.mode()

设置wifi模块工作模式WIFI_AP,WIFI_STA,WIFI_AP_STA

Wifi AP


- WiFi.softAP(ssid,[password],[channel],[ssid_hidden])

设置AP模式参数
参数
ssid:网络名称(最长63字符)
password:密码,至少8个字符,NULL为开放网络(可选参数)
channel:通道号,1 - 13(可选参数,缺省情况下为1)
ssid_hidden:网络是否可见,0为可见网络,1为隐藏网络(可选参数,缺省情况下为0)
返回值:bool

- WiFi.softAPConfig(local_ip,gateway,subnet)

配置AP
参数
local_ip:ap ip(类型:IPAddress-例192,168,0,1)
gateway:网关ip(类型:IPAddress)
subnet:子网掩码(类型:IPAddress)
返回值:bool

- WiFi.softAPdisconnect(wifioff)

断开网络,关闭AP

- WiFi.softAPgetStationNum()

Get the count of the Station / client that are connected to the softAP interface

- WiFi.softAPIP()

获取IP地址,用于AP模式
返回IP地址

- WiFi.softAPmacAddress(mac)

获取MAC地址,用于AP模式
返回:uint8_t*

- WiFi.softAPmacAddress(void)

获取MAC地址,用于AP模式
返回:String

Wifi 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)

Change IP configuration settings disabling the dhcp client
参数
local_ip Static ip configuration
gateway Static gateway configuration
subnet Static Subnet mask
dns1 Static DNS server 1
dns2 Static DNS server 2
返回:bool

- WiFi.reconnect()

will force a disconnect and then start reconnecting to AP
返回:bool

- WiFi.disconnect(bool wifioff)

Disconnect from the network
返回:bool

- WiFi.isConnected()

检查是否已连接
返回:bool

- WiFi.setAutoConnect(bool autoConnect)

设置是否复位自动连接,默认自动连接
返回:bool

- WiFi.setAutoConnect()

检查是否设置了复位自动连接
返回: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
返回:连接状态
WL_CONNECTED
WL_NO_SSID_AVAIL;
WL_CONNECT_FAILED;
WL_IDLE_STATUS;
WL_DISCONNECTED;

- WiFi.localIP()

获取IP地址,用于STA模式
返回:IPAddress

- WiFi.macAddress(uint8_t* mac)

获取MAC地址,用于STA模式

- WiFi.macAddress(void)

获取MAC地址,用于STA模式

- WiFi.subnetMask()

Get the interface subnet mask address.
返回:IPAddress

- WiFi.gatewayIP()

Get the gateway ip address.
返回:IPAddress
- begin()
- disconnect()
- config()
- setDNS()
- SSID()
- BSSID()
- RSSID()
- encryptionType()
- scanNetworks()
- status()
- getSocket()
- macAddress()


Server 类

The Server class creates servers which can send data to and receive data from connected clients (programs running on other computers or devices).

- Server
- WiFiServer
- begin()
- available()
- write()
- print()
- println()


Client 类

The client class creates clients that can connect to servers and send and receive data.

- Client
- WiFiClient()
- connected()
- connect()
- write()
- print()
- println()
- available()
- read()
- flush()
- stop()



UDP 类

The UDP class enables UDP message to be sent and received.

-WiFiUDP
-begin()
-available()
-beginPacket()
-endPacket()
-write()
-parsePacket()
-peek()
-read()
-flush()
-stop()
-remoteIP()
-remotePort()




返回ESP8266 Libraries

返回首页

更多建议和问题欢迎反馈至 YFRobot论坛