WiFi.scanNetworks()

描述

搜寻邻近的无线网路。

语法


WiFi.scanNetworks();

参数

无参数

回传

byte:搜寻到的无线网路数量

范例

#include <WiFi.h>

char ssid[] = "yourNetwork";     // 无线网路的 SSID
int status = WL_IDLE_STATUS;     // 无线网路的状态

void setup()
{
 Serial.begin(9600);

 status = WiFi.begin(ssid);

 if ( status != WL_CONNECTED) {
    Serial.println("Couldn't get a wifi connection");
    while(true);
  }
  // 如果连线成功,搜寻邻近的无线网路并且印出搜寻到的数量
  else {
    Serial.println("** Scan Networks **");
    byte numSsid = WiFi.scanNetworks();

    Serial.print("SSID List:");
    Serial.println(numSsid);
  }
}

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.