ESP8266 WiFi
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論壇