Skip to content

Instantly share code, notes, and snippets.

@zoutepopcorn
Last active June 10, 2019 19:38
Show Gist options
  • Save zoutepopcorn/b3aacfbe961ab9529bfa2a3a67b71951 to your computer and use it in GitHub Desktop.
Save zoutepopcorn/b3aacfbe961ab9529bfa2a3a67b71951 to your computer and use it in GitHub Desktop.
wifi test
#include "ESP8266WiFi.h"
#include "FS.h"
void setup() {
Serial.begin(115200);
SPIFFS.begin();
WiFi.mode(WIFI_STA);
WiFi.disconnect();
Serial.println("--->");
delay(100);
}
double findInFile(String fileName) {
Serial.println(fileName);
File file = SPIFFS.open(fileName, "r");
int countMacs = 0;
int lineNumber = 0;
int n = WiFi.scanNetworks();
if (!file) {
Serial.println("Oopsie geen file gevonden.");
} else {
while (file.available()) {
String line = file.readStringUntil('\n');
lineNumber++;
Serial.print("L: "); Serial.println(line);
for (int i = 0; i < n; ++i) {
if(WiFi.BSSIDstr(i) == line) {
Serial.print(" >> "); Serial.println(WiFi.BSSIDstr(i));
countMacs++;
}
}
}
}
Serial.print("found: "); Serial.print(countMacs); Serial.print(" / "); Serial.println(lineNumber);
file.close();
return countMacs / lineNumber;
}
void listAllFiles() {
int fileCount = 0;
Dir dirTmp = SPIFFS.openDir("/");
while (dirTmp.next()) {
fileCount++;
}
double rateZones[fileCount];
Dir dir = SPIFFS.openDir("/");
int zoneCount = 0;
while (dir.next()) {
rateZones[zoneCount++] = findInFile(dir.fileName());
Serial.println(rateZones[zoneCount]);
}
}
void loop() {
delay(5000);
listAllFiles();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment