Skip to content

Instantly share code, notes, and snippets.

@shige-ta
Last active June 14, 2018 05:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shige-ta/0cdcae7f1bf372eac887e17aba1ce2c3 to your computer and use it in GitHub Desktop.
Save shige-ta/0cdcae7f1bf372eac887e17aba1ce2c3 to your computer and use it in GitHub Desktop.
#include "WiFi.h"
#include "esp_wifi.h"
const char *ssid = "";
const char *password = "";
const String mac = "";
void PrintStations()
{
String s = "";
wifi_sta_list_t stationList;
esp_wifi_ap_get_sta_list(&stationList);
Serial.print("N of connected stations: ");
Serial.println(stationList.num);
for(int i = 0; i < stationList.num; i++) {
wifi_sta_info_t station = stationList.sta[i];
for(int j = 0; j< 6; j++){
char str[3];
sprintf(str, "%02x", (int)station.mac[j]);
s.concat(str);
if(j<5){
s.concat(":");
}
}
if(mac == s)
{
Serial.println("Hit " + s);
}
}
Serial.println("-----------------");
}
void setup() {
Serial.begin(115200);
WiFi.softAP(ssid, password);
Serial.println();
Serial.print("IP address: ");
Serial.println(WiFi.softAPIP());
}
void loop() {
PrintStations();
delay(20000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment