“ESP8266 WiFi”的版本间的差异
第19行: | 第19行: | ||
设置AP模式参数 | 设置AP模式参数 | ||
+ | |||
参数 | 参数 | ||
:ssid:网络名称(最长63字符) | :ssid:网络名称(最长63字符) | ||
第30行: | 第31行: | ||
配置AP | 配置AP | ||
+ | |||
参数 | 参数 | ||
:local_ip:ap ip(类型:IPAddress-例192,168,0,1) | :local_ip:ap ip(类型:IPAddress-例192,168,0,1) | ||
第43行: | 第45行: | ||
- <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> | ||
第62行: | 第64行: | ||
返回:String | 返回:String | ||
+ | |||
+ | <!---------------------------------------------------ESP8266 wifi sta---------------------------------------------------------------------> | ||
|width="50%" valign="top" align="left"| | |width="50%" valign="top" align="left"| | ||
第83行: | 第87行: | ||
- <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 | : local_ip Static ip configuration | ||
第90行: | 第95行: | ||
: dns1 Static DNS server 1 | : dns1 Static DNS server 1 | ||
: dns2 Static DNS server 2 | : dns2 Static DNS server 2 | ||
+ | |||
返回:bool | 返回:bool | ||
- <font color="forestgreen">WiFi.reconnect()</font> | - <font color="forestgreen">WiFi.reconnect()</font> | ||
− | + | 将强制断开连接,然后重新连接到AP | |
返回:bool | 返回:bool | ||
第101行: | 第107行: | ||
Disconnect from the network | Disconnect from the network | ||
+ | 断开网络 | ||
返回:bool | 返回:bool | ||
第116行: | 第123行: | ||
返回:bool | 返回:bool | ||
− | - <font color="forestgreen">WiFi. | + | - <font color="forestgreen">WiFi.getAutoConnect()</font> |
检查是否设置了复位自动连接 | 检查是否设置了复位自动连接 | ||
第160行: | 第167行: | ||
Get the interface subnet mask address. | Get the interface subnet mask address. | ||
+ | 获取接口子网掩码地址 | ||
返回:IPAddress | 返回:IPAddress | ||
第166行: | 第174行: | ||
Get the gateway ip address. | Get the gateway ip address. | ||
+ | 获取网关地址 | ||
返回:IPAddress | 返回:IPAddress | ||
第172行: | 第181行: | ||
Get the DNS ip address. | Get the DNS ip address. | ||
+ | 获取DNS ip 地址 | ||
返回:IPAddress | 返回:IPAddress | ||
第178行: | 第188行: | ||
Get ESP8266 station DHCP hostname | Get ESP8266 station DHCP hostname | ||
+ | |||
+ | 获取ESP8266 SAT DHCP主机名 | ||
返回:String | 返回:String | ||
第184行: | 第196行: | ||
Set ESP8266 station DHCP hostname | Set ESP8266 station DHCP hostname | ||
+ | 设置ESP8266 STA DHCP主机名 | ||
+ | |||
+ | 参数类型:char* | ||
返回:bool | 返回:bool | ||
第190行: | 第205行: | ||
Set ESP8266 station DHCP hostname | Set ESP8266 station DHCP hostname | ||
+ | |||
+ | 参数类型:const char* | ||
返回:bool | 返回:bool | ||
第196行: | 第213行: | ||
Set ESP8266 station DHCP hostname | Set ESP8266 station DHCP hostname | ||
+ | |||
+ | 参数类型:String | ||
返回:bool | 返回:bool | ||
第257行: | 第276行: | ||
<br> | <br> | ||
|} | |} | ||
+ | |||
+ | <!--------------------------------------------------------------ESP8266 wifi server---------------------------------------------------------------> | ||
{| border="0" cellpadding="10" width="100%" | {| border="0" cellpadding="10" width="100%" | ||
第264行: | 第285行: | ||
'''The Server class creates servers which can send data to and receive data from connected clients (programs running on other computers or devices).''' | '''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(IPAddress addr, uint16_t port)</font> | - <font color="forestgreen">WiFiServer(IPAddress addr, uint16_t port)</font> | ||
第280行: | 第299行: | ||
参数 | 参数 | ||
− | |||
:port:端口 | :port:端口 | ||
- <font color="forestgreen">WiFi.begin()</font> | - <font color="forestgreen">WiFi.begin()</font> | ||
− | + | - <font color="forestgreen">WiFi.setNoDelay(bool nodelay)</font> | |
+ | |||
+ | - <font color="forestgreen">WiFi.getNoDelay()</font> | ||
− | + | - <font color="forestgreen">WiFi.hasClient()</font> | |
− | |||
- <font color="forestgreen">WiFi.available()</font> | - <font color="forestgreen">WiFi.available()</font> | ||
− | + | - <font color="forestgreen">WiFi.status()</font> | |
− | + | - <font color="forestgreen">WiFi.close()</font> | |
+ | |||
+ | - <font color="forestgreen">WiFi.stop()</font> | ||
+ | |||
+ | - <font color="forestgreen">WiFi.write(uint8_t b)</font> | ||
+ | |||
+ | - <font color="forestgreen">WiFi.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> | ||
第305行: | 第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">WiFi.WiFiClient()</font> | |
− | + | - <font color="forestgreen">WiFi.WiFiClient(const WiFiClient& other)</font> | |
− | + | - <font color="forestgreen">WiFi.operator=(const WiFiClient& other)</font> | |
− | + | - <font color="forestgreen">WiFi.connect(const char* host, uint16_t port)</font> | |
− | + | - <font color="forestgreen">WiFi.connect(IPAddress ip, uint16_t port)</font> | |
− | + | - <font color="forestgreen">WiFi.setNoDelay(bool nodelay)</font> | |
− | + | - <font color="forestgreen">WiFi.getNoDelay()</font> | |
− | + | - <font color="forestgreen">WiFi.write(uint8_t b)</font> | |
− | + | - <font color="forestgreen">WiFi.write(const uint8_t *buf, size_t size)</font> | |
− | + | - <font color="forestgreen">WiFi.write_P(PGM_P buf, size_t size)</font> | |
+ | |||
+ | - <font color="forestgreen">WiFi.available()</font> | ||
+ | |||
+ | - <font color="forestgreen">WiFi.read()</font> | ||
+ | |||
+ | - <font color="forestgreen">WiFi.read(uint8_t* buf, size_t size)</font> | ||
+ | |||
+ | - <font color="forestgreen">WiFi.peekBytes(uint8_t *buffer, size_t length)</font> | ||
+ | |||
+ | - <font color="forestgreen">WiFi.flush()</font> | ||
+ | |||
+ | - <font color="forestgreen">WiFi.stop()</font> | ||
+ | |||
+ | - <font color="forestgreen">WiFi.connected()</font> | ||
+ | |||
+ | - <font color="forestgreen">WiFi.status()</font> | ||
+ | |||
+ | - <font color="forestgreen">WiFi.remoteIP()</font> | ||
+ | |||
+ | - <font color="forestgreen">WiFi.remotePort()</font> | ||
+ | |||
+ | - <font color="forestgreen">WiFi.localIP()</font> | ||
+ | |||
+ | - <font color="forestgreen">WiFi.localPort()</font> | ||
+ | |||
+ | - <font color="forestgreen">WiFi.stopAll()</font> | ||
+ | |||
+ | - <font color="forestgreen">WiFi.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">WiFi.WiFiUDP(const WiFiUDP& other)</font> | |
+ | |||
+ | - <font color="forestgreen">WiFi.begin(uint16_t port)</font> | ||
+ | |||
+ | - <font color="forestgreen">WiFi.beginMulticast(IPAddress interfaceAddr, IPAddress multicast, uint16_t port)</font> | ||
+ | |||
+ | - <font color="forestgreen">WiFi.available()</font> | ||
+ | |||
+ | - <font color="forestgreen">WiFi.stop()</font> | ||
+ | |||
+ | - <font color="forestgreen">WiFi.beginPacket(const char *host, uint16_t port)</font> | ||
+ | |||
+ | - <font color="forestgreen">WiFi.beginPacket(IPAddress ip, uint16_t port)</font> | ||
+ | |||
+ | - <font color="forestgreen">WiFi.beginPacketMulticast(IPAddress multicastAddress, uint16_t port,IPAddress interfaceAddress, int ttl)</font> | ||
+ | |||
+ | - <font color="forestgreen">WiFi.endPacket()</font> | ||
+ | |||
+ | - <font color="forestgreen">WiFi.write(uint8_t byte)</font> | ||
+ | |||
+ | - <font color="forestgreen">WiFi.write(const uint8_t *buffer, size_t size)</font> | ||
+ | |||
+ | - <font color="forestgreen">WiFi.parsePacket()</font> | ||
+ | |||
+ | - <font color="forestgreen">WiFi.read()</font> | ||
+ | |||
+ | - <font color="forestgreen">WiFi.stop()</font> | ||
+ | |||
+ | - <font color="forestgreen">WiFi.stop()</font> | ||
+ | |||
+ | - <font color="forestgreen">WiFi.stop()</font> | ||
+ | |||
+ | - <font color="forestgreen">WiFi.read(unsigned char* buffer, size_t len)</font> | ||
+ | |||
+ | - <font color="forestgreen">WiFi.peek()</font> | ||
− | + | - <font color="forestgreen">WiFi.flush()</font> | |
− | + | - <font color="forestgreen">WiFi.stop()</font> | |
− | + | - <font color="forestgreen">WiFi.remoteIP()</font> | |
− | + | - <font color="forestgreen">WiFi.remotePort()</font> | |
− | + | - <font color="forestgreen">WiFi.destinationIP()</font> | |
− | + | - <font color="forestgreen">WiFi.localPort()</font> | |
− | + | - <font color="forestgreen">WiFi.stopAll()</font> | |
− | + | - <font color="forestgreen">WiFi.stop()</font> | |
− | + | - <font color="forestgreen">WiFi.stopAllExcept(WiFiUDP * exC)</font> | |
− | |||
− | |||
|} | |} | ||
2016年4月20日 (三) 10:56的版本
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(IPAddress addr, uint16_t port) 开启服务 参数
- WiFiServer(uint16_t port) 开启服务 参数
- WiFi.begin() - WiFi.setNoDelay(bool nodelay) - WiFi.getNoDelay() - WiFi.hasClient() - WiFi.available() - WiFi.status() - WiFi.close() - WiFi.stop() - WiFi.write(uint8_t b) - WiFi.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. - WiFi.WiFiClient() - WiFi.WiFiClient(const WiFiClient& other) - WiFi.operator=(const WiFiClient& other) - WiFi.connect(const char* host, uint16_t port) - WiFi.connect(IPAddress ip, uint16_t port) - WiFi.setNoDelay(bool nodelay) - WiFi.getNoDelay() - WiFi.write(uint8_t b) - WiFi.write(const uint8_t *buf, size_t size) - WiFi.write_P(PGM_P buf, size_t size) - WiFi.available() - WiFi.read() - WiFi.read(uint8_t* buf, size_t size) - WiFi.peekBytes(uint8_t *buffer, size_t length) - WiFi.flush() - WiFi.stop() - WiFi.connected() - WiFi.status() - WiFi.remoteIP() - WiFi.remotePort() - WiFi.localIP() - WiFi.localPort() - WiFi.stopAll() - WiFi.stopAllExcept(WiFiClient * exC)
|
ESP8266WiFi Udp The UDP class enables UDP message to be sent and received. - WiFi.WiFiUDP(const WiFiUDP& other) - WiFi.begin(uint16_t port) - WiFi.beginMulticast(IPAddress interfaceAddr, IPAddress multicast, uint16_t port) - WiFi.available() - WiFi.stop() - WiFi.beginPacket(const char *host, uint16_t port) - WiFi.beginPacket(IPAddress ip, uint16_t port) - WiFi.beginPacketMulticast(IPAddress multicastAddress, uint16_t port,IPAddress interfaceAddress, int ttl) - WiFi.endPacket() - WiFi.write(uint8_t byte) - WiFi.write(const uint8_t *buffer, size_t size) - WiFi.parsePacket() - WiFi.read() - WiFi.stop() - WiFi.stop() - WiFi.stop() - WiFi.read(unsigned char* buffer, size_t len) - WiFi.peek() - WiFi.flush() - WiFi.stop() - WiFi.remoteIP() - WiFi.remotePort() - WiFi.destinationIP() - WiFi.localPort() - WiFi.stopAll() - WiFi.stop() - WiFi.stopAllExcept(WiFiUDP * exC)
|
更多建议和问题欢迎反馈至 YFRobot论坛