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.