说明
返回连接状态。
用法
WiFi.status()
参数
- None
返回
- WL_CONNECTED:连接到WiFi网络时分配;
- WL_AP_CONNECTED:当设备以接入点模式连接时分配;
- WL_AP_LISTENING:在接入点模式下监听连接时分配;
- WL_NO_SHIELD:当没有WiFi屏蔽存在时分配;
- WL_NO_MODULE:与集成WiFi模块通讯失败时赋值;
- WL_IDLE_STATUS:它是WiFi时分配的临时状态。begin()被调用并保持活动状态,直到尝试次数到期(导致WL_CONNECT_FAILED)或建立连接(导致WL_CONNECTED);
- WL_NO_SSID_AVAIL:当没有SSID可用时分配;
- WL_SCAN_COMPLETED:扫描网络完成时分配;
- WL_CONNECT_FAILED:在所有尝试连接失败时分配;
- WL_CONNECTION_LOST:连接丢失时赋值;
- WL_DISCONNECTED:断开网络时分配;
示例
#include <SPI.h>
#include <WiFiNINA.h>
char ssid[] = "yourNetwork"; // your network SSID (name)
char key[] = "D0D0DEADF00DABBADEAFBEADED"; // your network key
int keyIndex = 0; // your network key Index number
int status = WL_IDLE_STATUS; // the Wifi radio's status
void setup() {
//Initialize serial and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
// attempt to connect to Wifi network:
while ( status != WL_CONNECTED) {
Serial.print("Attempting to connect to WEP network, SSID: ");
Serial.println(ssid);
status = WiFi.begin(ssid, keyIndex, key);
// wait 10 seconds for connection:
delay(10000);
}
// once you are connected :
Serial.print("You're connected to the network");
}
void loop() {
// check the network status connection once every 10 seconds:
delay(10000);
Serial.println(WiFi.status());
}
相关用法
- Arduino WiFiNINA - WiFi.setTimeout()用法及代码示例
- Arduino WiFiNINA - WiFi.scanNetworks()用法及代码示例
- Arduino WiFiNINA - WiFi.setHostname()用法及代码示例
- Arduino WiFiNINA - WiFi.setDNS()用法及代码示例
- Arduino WiFiNINA - WiFi.subnetMask()用法及代码示例
- Arduino WiFiNINA - WiFi.config()用法及代码示例
- Arduino WiFiNINA - WiFi.encryptionType()用法及代码示例
- Arduino WiFiNINA - WiFi.gatewayIP()用法及代码示例
- Arduino WiFiNINA - WiFi.BSSID()用法及代码示例
- Arduino WiFiNINA - WiFi.begin()用法及代码示例
- Arduino WiFiNINA - WiFi.RSSI()用法及代码示例
- Arduino WiFiNINA - WiFi.channel()用法及代码示例
- Arduino WiFiNINA - WiFi.localIP()用法及代码示例
- Arduino WiFiNINA - WiFi.beginAP()用法及代码示例
- Arduino WiFiNINA - WiFi.hostByName()用法及代码示例
- Arduino WiFiNINA - WiFi.firmwareVersion()用法及代码示例
- Arduino WiFiNINA - WiFi.reasonCode()用法及代码示例
- Arduino WiFiNINA - WiFi.ping()用法及代码示例
- Arduino WiFiNINA - WiFi.SSID()用法及代码示例
- Arduino WiFiNINA - WiFi.macAddress()用法及代码示例
- Arduino WiFiNINA - WiFi.beginEnterprise()用法及代码示例
- Arduino WiFiNINA - WiFiSSLClient用法及代码示例
- Arduino WiFiNINA - WiFiClient()用法及代码示例
- Arduino WiFiNINA - WiFiServer()用法及代码示例
- Arduino WiFiNINA - WiFiUDP.beginMulticast()用法及代码示例
注:本文由纯净天空筛选整理自arduino.cc大神的英文原创作品 WiFiNINA - WiFi.status()。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。