wifi扫描
Posted kekeoutlook
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了wifi扫描相关的知识,希望对你有一定的参考价值。
获取当前位置的wifi,信道,强度,mac
#include "ESP8266WiFi.h" IPAddress apIP(192, 168, 4, 1); void setup() { Serial.begin(115200); WiFi.mode(WIFI_STA); // WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0)); // WiFi.softAP("215-wifi","1234567890"); WiFi.disconnect(); delay(100); Serial.println("Setup done"); } void loop() { Serial.println("scan start"); // WiFi.scanNetworks will return the number of networks found int n = WiFi.scanNetworks(); Serial.println("scan done"); String maxwifi=""; int wifiq=-100; if (n == 0) { Serial.println("no networks found"); } else { Serial.print(n); Serial.println(" networks found"); for (int i = 0; i < n; ++i) { // Print SSID and RSSI for each network found Serial.print(i + 1); Serial.print(": "); Serial.print(WiFi.SSID(i)); Serial.print(" ("); Serial.print(WiFi.RSSI(i)); Serial.print(")"); /* byte:value表示加密类型 TKIP(WPA)= 2 WEP = 5 WEP 加密由于是一种静态加密方式,收发的包中就含有密码信息,因此可以非常容易地就直接破解密码,目前已经很少被使用 CCMP(WPA)= 4 动态加密 无= 7 AUTO = 8 */ Serial.print((WiFi.encryptionType(i) == ENC_TYPE_NONE) ? " " : "*");//获取当前网络的加密类型 Serial.print(" channel:"); Serial.print(WiFi.channel(i)); /* byte:value表示加密类型 TKIP(WPA)= 2 WEP = 5 CCMP(WPA)= 4 无= 7 AUTO = 8 */ Serial.print(" encryptionType:"); Serial.println(WiFi.encryptionType(i)); /* using ESP8266WiFiScanClass::SSID; using ESP8266WiFiScanClass::encryptionType; using ESP8266WiFiScanClass::RSSI; using ESP8266WiFiScanClass::BSSID; using ESP8266WiFiScanClass::BSSIDstr; using ESP8266WiFiScanClass::channel; using ESP8266WiFiScanClass::isHidden; */ if(WiFi.RSSI(i)>wifiq){ wifiq= WiFi.RSSI(i); maxwifi=String(WiFi.SSID(i)) ; } delay(10); } } Serial.println(""); Serial.print("maxwifi:"); Serial.println(maxwifi); //WiFi.softAP(maxwifi,"xixi",11); delay(5000); }
以上是关于wifi扫描的主要内容,如果未能解决你的问题,请参考以下文章
《安富莱嵌入式周报》第279期:强劲的代码片段搜索工具,卡内基梅隆大学安全可靠C编码标准,Nordic发布双频WiFi6 nRF7002芯片