Skip to content

Commit 406d624

Browse files
author
Stefan Kremser
committed
Fixing APScan Display Bug
When you scan for a second time and find less APs then before, there was the possibility that the last of the old APs was still shown on the display.
1 parent 3bb2a80 commit 406d624

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

esp8266_deauther/APScan.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,17 @@ bool APScan::start() {
1010
Serial.println("MAC - Ch - RSSI - Encrypt. - SSID - Hidden");// - Vendor");
1111
}
1212
aps._clear();
13-
for (int i = 0; i < maxAPScanResults; i++) selected[i] = false;
13+
results = 0;
14+
for (int i = 0; i < maxAPScanResults; i++){
15+
selected[i] = false;
16+
String("").toCharArray(names[i], 33);
17+
}
1418
results = WiFi.scanNetworks(false, settings.apScanHidden); // lets scanNetworks return hidden APs. (async = false & show_hidden = true)
19+
if(results > maxAPScanResults) results = maxAPScanResults;
1520

16-
for (int i = 0; i < results && i < maxAPScanResults; i++) {
21+
if (debug) Serial.println("Scan results: "+(String)results);
22+
23+
for (int i = 0; i < results; i++) {
1724
Mac _ap;
1825
_ap.set(WiFi.BSSID(i)[0], WiFi.BSSID(i)[1], WiFi.BSSID(i)[2], WiFi.BSSID(i)[3], WiFi.BSSID(i)[4], WiFi.BSSID(i)[5]);
1926
aps.add(_ap);

esp8266_deauther/esp8266_deauther.ino

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include <FS.h>
1313

1414
#define resetPin 4 /* <-- comment out or change if you need GPIO 4 for other purposes */
15-
//#define USE_DISPLAY /* <-- uncomment that if you want to use the display */
15+
#define USE_DISPLAY /* <-- uncomment that if you want to use the display */
1616
//#define USE_LED16 /* <-- for the Pocket ESP8266 which has a LED on GPIO 16 to indicate if it's running */
1717

1818
#ifdef USE_DISPLAY
@@ -94,7 +94,7 @@ void drawInterface() {
9494
if (i == 0) display.drawString(3, i * fontSize, " --> WiFi " + wifiMode);
9595
else if (i == 1) display.drawString(3, i * fontSize, " --> " + scanMode);
9696
else if (i == 2) display.drawString(3, i * fontSize, " --> " + attackMode + " attack");
97-
else if (i - 3 <= apScan.results) {
97+
else if (i - 3 < apScan.results) {
9898
display.drawString(3, _lrow * fontSize, apScan.getAPName(i - 3));
9999
if (apScan.getAPSelected(i - 3)) {
100100
display.drawVerticalLine(1, _lrow * fontSize, fontSize);
@@ -603,7 +603,8 @@ void loop() {
603603

604604
// ===== SELECT =====
605605
} else if (buttonPressed == 2) {
606-
//WiFi on/off
606+
607+
// ===== WiFi on/off =====
607608
if (curRow == 0) {
608609
if (wifiMode == "ON") stopWifi();
609610
else startWifi();

0 commit comments

Comments
 (0)