我最近正在开发一个流量监控项目,该项目基于计算存在的 Wi-Fi 设备数量。我想要获取可用 AP SSID 以及连接到该 AP 的所有客户端设备的列表。基本上,我想获得如下信息列表:
Network-Name BSSID RSSI
Client-Mac1 RSSI
Client-Mac2 RSSI
Client-Mac3 RSSI
Orphan Clients:
Client-Mac4 RSSI
我希望这可以通过使用带有 Wi-Fi 适配器和 python 的树莓派来完成。如果不可能,我有一个 ESP 8266,可以将其链接到 Linux 机器/Arduino。
请发表您的想法,了解如何使用哪种类型的平台/库来实现这一点。如果能附上一些代码示例就最好了!
最佳答案
从 esp8266 示例复制 - ESP8266Wifi - WifiScan: 然后您可以使用串行连接将其发送到您的主进程
/*
* This sketch demonstrates how to scan WiFi networks.
* The API is almost the same as with the WiFi Shield library,
* the most obvious difference being the different file you need to include:
*/
#include "ESP8266WiFi.h"
void setup() {
Serial.begin(115200);
// Set WiFi to station mode and disconnect from an AP if it was previously connected
WiFi.mode(WIFI_STA);
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");
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(")");
Serial.println((WiFi.encryptionType(i) == ENC_TYPE_NONE)?" ":"*");
delay(10);
}
}
Serial.println("");
// Wait a bit before scanning again
delay(5000);
}
关于python - 如何嗅探 Wi-Fi AP 名称和关联设备,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43017821/