mirror of
https://github.com/SpacehuhnTech/esp8266_deauther.git
synced 2025-12-22 23:26:49 -08:00
Dynamic ledPin switching
This commit is contained in:
@@ -461,11 +461,11 @@ void Attack::refreshLed() {
|
||||
}
|
||||
if (numberRunning >= 1 && settings.useLed) {
|
||||
if (debug) Serial.println("Attack LED : ON");
|
||||
digitalWrite(settings.ledPin, LOW);
|
||||
digitalWrite(settings.ledPin, !settings.pinStateOff);
|
||||
}
|
||||
else if (numberRunning == 0 || !settings.useLed) {
|
||||
if (debug) Serial.println("Attack LED : OFF");
|
||||
digitalWrite(settings.ledPin, HIGH);
|
||||
digitalWrite(settings.ledPin, settings.pinStateOff);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@ extern "C" {
|
||||
|
||||
#define attacksNum 3
|
||||
#define macListLen 64
|
||||
#define PIN_STATE_OFF false
|
||||
#define PIN_STATE_ON true
|
||||
|
||||
extern void PrintHex8(uint8_t *data, uint8_t length);
|
||||
extern void getRandomVendorMac(uint8_t *buf);
|
||||
|
||||
@@ -26,6 +26,21 @@ void Settings::syncMacInterface(){
|
||||
}
|
||||
}
|
||||
|
||||
void Settings::setLedPin(int newLedPin){
|
||||
prevLedPin = ledPin;
|
||||
if(newLedPin > 0 && newLedPin != prevLedPin){
|
||||
ledPin = newLedPin;
|
||||
pinMode(ledPin, OUTPUT);
|
||||
if(!prevLedPin == 0){
|
||||
digitalWrite(ledPin, digitalRead(prevLedPin));
|
||||
digitalWrite(prevLedPin, pinStateOff);
|
||||
pinMode(prevLedPin, INPUT);
|
||||
}else{
|
||||
digitalWrite(ledPin, pinStateOff);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Settings::load() {
|
||||
|
||||
if (EEPROM.read(checkNumAdr) != checkNum) {
|
||||
@@ -72,7 +87,7 @@ void Settings::load() {
|
||||
multiAttacks = (bool)EEPROM.read(multiAttacksAdr);
|
||||
macInterval = eepromReadInt(macIntervalAdr);
|
||||
beaconInterval = (bool)EEPROM.read(beaconIntervalAdr);
|
||||
ledPin = (int)EEPROM.read(ledPinAdr);
|
||||
setLedPin((int)EEPROM.read(ledPinAdr));
|
||||
isSettingsLoaded = 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,6 @@ class Settings
|
||||
void save();
|
||||
void send();
|
||||
void info();
|
||||
void syncMacInterface();
|
||||
|
||||
int ssidLen;
|
||||
String ssid = "";
|
||||
@@ -76,11 +75,15 @@ class Settings
|
||||
bool multiAttacks;
|
||||
int macInterval;
|
||||
bool beaconInterval;
|
||||
int ledPin;
|
||||
int ledPin = 0;
|
||||
int prevLedPin = 0;
|
||||
Mac defaultMacAP;
|
||||
Mac macAP;
|
||||
bool isMacAPRand;
|
||||
bool isSettingsLoaded = 0;
|
||||
void syncMacInterface();
|
||||
void setLedPin(int newLedPin);
|
||||
bool pinStateOff = true; // When attack is off, pin state is HIGH
|
||||
|
||||
private:
|
||||
size_t getSize();
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -445,7 +445,7 @@ void saveSettings() {
|
||||
else settings.multiAttacks = true;
|
||||
}
|
||||
|
||||
if (server.hasArg("ledPin")) settings.ledPin = server.arg("ledPin").toInt();
|
||||
if (server.hasArg("ledPin")) settings.setLedPin(server.arg("ledPin").toInt());
|
||||
if(server.hasArg("macInterval")) settings.macInterval = server.arg("macInterval").toInt();
|
||||
|
||||
settings.save();
|
||||
@@ -479,6 +479,8 @@ void setup() {
|
||||
nameList.load();
|
||||
ssidList.load();
|
||||
|
||||
attack.refreshLed();
|
||||
|
||||
delay(500); // Prevent bssid leak
|
||||
|
||||
startWifi();
|
||||
@@ -568,9 +570,6 @@ void setup() {
|
||||
if(digitalRead(resetPin) == LOW) settings.reset();
|
||||
#endif
|
||||
|
||||
pinMode(settings.ledPin, OUTPUT);
|
||||
digitalWrite(settings.ledPin, HIGH);
|
||||
|
||||
if(debug){
|
||||
Serial.println("\nStarting...\n");
|
||||
#ifndef USE_DISPLAY
|
||||
|
||||
@@ -137,7 +137,7 @@
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<label for="ledPin">LED Pin (restart needed)</label>
|
||||
<label for="ledPin">LED Pin</label>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<input type="number" id="ledPin" min="0" max="18">
|
||||
|
||||
Reference in New Issue
Block a user