Added a few comments

This commit is contained in:
Stefan Kremser
2017-07-17 20:03:21 +02:00
parent e9946d81ca
commit 6f2c99aa42

View File

@@ -5,22 +5,28 @@
=========================================== ===========================================
*/ */
// Including some libraries we need //
#include <Arduino.h> #include <Arduino.h>
#include <ESP8266WiFi.h> #include <ESP8266WiFi.h>
#include <ESP8266WebServer.h> #include <ESP8266WebServer.h>
#include <FS.h> #include <FS.h>
#define resetPin 4 /* <-- comment out or change if you need GPIO 4 for other purposes */
// Settings //
#define USE_DISPLAY /* <-- uncomment that if you want to use the display */ #define USE_DISPLAY /* <-- uncomment that if you want to use the display */
#define resetPin 4 /* <-- comment out or change if you need GPIO 4 for other purposes */
//#define USE_LED16 /* <-- for the Pocket ESP8266 which has a LED on GPIO 16 to indicate if it's running */ //#define USE_LED16 /* <-- for the Pocket ESP8266 which has a LED on GPIO 16 to indicate if it's running */
// Including everything for the OLED //
#ifdef USE_DISPLAY #ifdef USE_DISPLAY
#include <Wire.h> #include <Wire.h>
//include the library you need //include the library you need
#include "SSD1306.h" #include "SSD1306.h"
//#include "SH1106.h" #include "SH1106.h"
//create display(Adr, SDA-pin, SCL-pin) //create display(Adr, SDA-pin, SCL-pin)
SSD1306 display(0x3c, 5, 4); //GPIO 5 = D1, GPIO 4 = D2 SSD1306 display(0x3c, 5, 4); //GPIO 5 = D1, GPIO 4 = D2
@@ -42,17 +48,14 @@
int curSite = 1; int curSite = 1;
int lrow = 0; int lrow = 0;
int menu = 0; //0 = Main Menu, 1 = APs, 2 = Stations, 3 = Attacks, 4 = Monitor
bool canBtnPress = true; bool canBtnPress = true;
int buttonPressed = 0; //0 = UP, 1 = DOWN, 2 = SELECT, 3 = DISPLAY int buttonPressed = 0; //0 = UP, 1 = DOWN, 2 = SELECT, 3 = DISPLAY
bool displayOn = true; bool displayOn = true;
#endif #endif
String wifiMode = ""; // More Includes! //
String attackMode = "";
String scanMode = "SCAN";
bool warning = true;
extern "C" { extern "C" {
#include "user_interface.h" #include "user_interface.h"
} }
@@ -72,6 +75,13 @@ ESP8266WebServer server(80);
const bool debug = true; const bool debug = true;
/* ========== DEBUG ========== */ /* ========== DEBUG ========== */
// Run-Time Variables //
String wifiMode = "";
String attackMode = "";
String scanMode = "SCAN";
bool warning = true;
NameList nameList; NameList nameList;
APScan apScan; APScan apScan;
@@ -87,13 +97,14 @@ void sniffer(uint8_t *buf, uint16_t len) {
#ifdef USE_DISPLAY #ifdef USE_DISPLAY
void drawInterface() { void drawInterface() {
if(displayOn){ if(displayOn){
display.clear(); display.clear();
int _lrow = 0; int _lrow = 0;
for (int i = curSite * rowsPerSite - rowsPerSite; i < curSite * rowsPerSite; i++) { for (int i = curSite * rowsPerSite - rowsPerSite; i < curSite * rowsPerSite; i++) {
if (i == 0) display.drawString(3, i * fontSize, " --> WiFi " + wifiMode); if (i == 0) display.drawString(3, i * fontSize, "-> WiFi " + wifiMode);
else if (i == 1) display.drawString(3, i * fontSize, " --> " + scanMode); else if (i == 1) display.drawString(3, i * fontSize, "-> " + scanMode);
else if (i == 2) display.drawString(3, i * fontSize, " --> " + attackMode + " attack"); else if (i == 2) display.drawString(3, i * fontSize, "-> " + attackMode + " attack");
else if (i - 3 < apScan.results) { else if (i - 3 < apScan.results) {
display.drawString(3, _lrow * fontSize, apScan.getAPName(i - 3)); display.drawString(3, _lrow * fontSize, apScan.getAPName(i - 3));
if (apScan.getAPSelected(i - 3)) { if (apScan.getAPSelected(i - 3)) {
@@ -625,7 +636,7 @@ void loop() {
// ===== SELECT ===== // ===== SELECT =====
} else if (buttonPressed == 2) { } else if (buttonPressed == 2) {
// ===== WiFi on/off ===== // ===== WIFI on/off =====
if (curRow == 0) { if (curRow == 0) {
if (wifiMode == "ON") stopWifi(); if (wifiMode == "ON") stopWifi();
else startWifi(); else startWifi();