WiFi.gatewayIP()
描述
取得 WiFi Shield 闸道(gateway)的 IP 位址。
语法
WiFi.gatewayIP();
参数
无参数
回传
IPAddress:WiFi Shield 闸道的 IP 位址
范例
#include <WiFi.h>
int status = WL_IDLE_STATUS; // 无线网路的状态
// 无线网路的 SSID
char ssid[] = "yourNetwork";
// WPA 的密码
char pass[] = "secretPassword";
IPAddress gateway;
void setup() {
Serial.begin(9600);
WiFi.begin(ssid, pass);
if ( status != WL_CONNECTED) {
Serial.println("Couldn't get a wifi connection");
while(true);
}
// 如果成功连上无线网路,印出相关资讯
else {
// 印出 WiFi Shield 闸道的 IP 位址
gateway = WiFi.gatewayIP();
Serial.print("GATEWAY: ");
Serial.println(gateway);
}
}
void loop () {}
The text of the 86Duino reference is a modification of the Arduino reference, and is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.
