|
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(bool autoReconnect)
- Wait for WiFi connection to reach a resultreturns 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模式
- WiFi.softAP(ssid,password)
- 設置一個WPA2-PSK的網絡(密碼至少8個字符)
- WiFi.softAP(ssid,password)
- 設置一個WPA2-PSK的網絡(密碼至少8個字符)
- WiFi.softAP(ssid,password)
- 設置一個WPA2-PSK的網絡(密碼至少8個字符)
- - 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()
|