Fixed light bulb config

This commit is contained in:
Stefan Kremser 2019-05-10 08:01:57 +02:00
parent 9faf40e41a
commit 1ee93f9f80
3 changed files with 232 additions and 197 deletions

View File

@ -29,17 +29,14 @@
// #define DEAUTHER_WRISTBAND
// #define DEAUTHER_WRISTBAND_V2
// #define DEAUTHER_MINI
// #define LYASI_7W_E27_LAMP
// #define AVATAR_5W_E14_LAMP
#define DEFAULT_ESP8266
// ========== CONFIGS ========== //
#if defined(DEFAULT_ESP8266) || defined(NODEMCU) || defined(WEMOS_D1_MINI) || defined(USB_DEAUTHER) || defined(NODEMCU_07) || defined(DEAUTHER) || defined(DEAUTHER_V1) || defined(DEAUTHER_V2) || defined(DEAUTHER_V3)
// ===== LED ===== //
#define LED_DIGITAL
#define LED_PIN_R 16 // NodeMCU on-board LED
#define LED_PIN_B 2 // ESP-12 LED
#elif defined(D_DUINO_B_V5_LED_RING)
// ========== CONFIGS ========== //
#if defined(D_DUINO_B_V5_LED_RING)
// ===== LED ===== //
#define LED_NEOPIXEL_GRB
@ -176,6 +173,45 @@
#define BUTTON_UP 12
#define BUTTON_DOWN 13
#define BUTTON_A 14
#elif defined(LYASI_7W_E27_LAMP)
// ===== LED ===== //
#define LED_MY92
#define LED_MODE_BRIGHTNESS 10
#define LED_MY92_NUM 1
#define LED_MY92_DATA 4
#define LED_MY92_CLK 5
#define LED_MY92_CH_R 0
#define LED_MY92_CH_G 1
#define LED_MY92_CH_B 2
#define LED_MY92_CH_BRIGHTNESS 3
#define LED_MY92_MODEL MY92XX_MODEL_MY9291
#elif defined(AVATAR_5W_E14_LAMP)
// ===== LED ===== //
#define LED_MY92
#define LED_MODE_BRIGHTNESS 10
#define LED_MY92_NUM 1
#define LED_MY92_DATA 13
#define LED_MY92_CLK 15
#define LED_MY92_CH_R 0
#define LED_MY92_CH_G 1
#define LED_MY92_CH_B 2
#define LED_MY92_CH_BRIGHTNESS 3
#define LED_MY92_MODEL MY92XX_MODEL_MY9291
#elif defined(DEFAULT_ESP8266) || defined(NODEMCU) || defined(WEMOS_D1_MINI) || defined(USB_DEAUTHER) || defined(NODEMCU_07) || defined(DEAUTHER) || defined(DEAUTHER_V1) || defined(DEAUTHER_V2) || defined(DEAUTHER_V3)
// ===== LED ===== //
#define LED_DIGITAL
#define LED_PIN_R 16 // NodeMCU on-board LED
#define LED_PIN_B 2 // ESP-12 LED
#endif /* if defined(DEFAULT_ESP8266) || defined(NODEMCU) || defined(WEMOS_D1_MINI) || defined(USB_DEAUTHER) || defined(NODEMCU_07) || defined(DEAUTHER) || defined(DEAUTHER_V1) || defined(DEAUTHER_V2) || defined(DEAUTHER_V3) */
// ============================== //
@ -301,7 +337,7 @@
#define LED_MY92_NUM 1
#define LED_MY92_DATA 4
#define LED_MY92_CLOCK 5
#define LED_MY92_CLK 5
#define LED_MY92_CH_R 0
#define LED_MY92_CH_G 1
#define LED_MY92_CH_B 2

View File

@ -31,7 +31,7 @@ class LED {
#elif defined(LED_NEOPIXEL_GRB)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(LED_NEOPIXEL_NUM, LED_NEOPIXEL_PIN, NEO_GRB + NEO_KHZ400);
#elif defined(LED_MY92)
my92xx myled = my92xx(LED_MY92_MODEL, LED_MY92_NUM, LED_MY92_DATA, LED_MY92_CLK, LED_MY92XX_COMMAND_DEFAULT);
my92xx myled = my92xx(LED_MY92_MODEL, LED_MY92_NUM, LED_MY92_DATA, LED_MY92_CLK, MY92XX_COMMAND_DEFAULT);
#endif // if defined(NEOPIXEL_LED)
public:
@ -52,8 +52,7 @@ class LED {
myled.setChannel(LED_MY92_CH_R, 0);
myled.setChannel(LED_MY92_CH_G, 0);
myled.setChannel(LED_MY92_CH_B, 0);
myled->setChannel(LED_MY92_CH_BRIGHTNESS, brightness);
myled->setChannel(3, 100);
myled.setChannel(LED_MY92_CH_BRIGHTNESS, brightness);
myled.setState(true);
myled.update();
#endif // if defined(LED_DIGITAL) || defined(LED_RGB)
@ -106,12 +105,12 @@ class LED {
strip.show();
#elif defined(LED_MY9291)
myled->setChannel(LED_MY92_CH_R, r);
myled->setChannel(LED_MY92_CH_G, g);
myled->setChannel(LED_MY92_CH_B, b);
myled->setChannel(LED_MY92_CH_BRIGHTNESS, brightness);
myled->setState(true);
myled->update();
myled.setChannel(LED_MY92_CH_R, r);
myled.setChannel(LED_MY92_CH_G, g);
myled.setChannel(LED_MY92_CH_B, b);
myled.setChannel(LED_MY92_CH_BRIGHTNESS, brightness);
myled.setState(true);
myled.update();
#endif // if defined(LED_DIGITAL)
}

View File

@ -1,180 +1,180 @@
/*
===========================================
Copyright (c) 2018 Stefan Kremser
github.com/spacehuhn
===========================================
*/
extern "C" {
// Please follow this tutorial:
// https://github.com/spacehuhn/esp8266_deauther/wiki/Installation#compiling-using-arduino-ide
// And be sure to have the right board selected
#include "user_interface.h"
}
#include <EEPROM.h>
#include <ArduinoJson.h>
#if ARDUINOJSON_VERSION_MAJOR != 5
// The software was build using ArduinoJson v5.x
// version 6 is still in beta at the time of writing
// go to tools -> manage libraries, search for ArduinoJSON and install the latest version 5
#error Please upgrade/downgrade ArduinoJSON library to version 5!
#endif
#include "oui.h"
#include "language.h"
#include "functions.h"
#include "Settings.h"
#include "Names.h"
#include "SSIDs.h"
#include "Scan.h"
#include "Attack.h"
#include "CLI.h"
#include "DisplayUI.h"
#include "A_config.h"
#include "webfiles.h"
#include "LED.h"
// Run-Time Variables //
LED led;
Settings settings;
Names names;
SSIDs ssids;
Accesspoints accesspoints;
Stations stations;
Scan scan;
Attack attack;
CLI cli;
DisplayUI displayUI;
#include "wifi.h"
uint32_t autosaveTime = 0;
uint32_t currentTime = 0;
bool booted = false;
void setup() {
// for random generator
randomSeed(os_random());
// start serial
Serial.begin(115200);
Serial.println();
// start SPIFFS
prnt(SETUP_MOUNT_SPIFFS);
prntln(SPIFFS.begin() ? SETUP_OK : SETUP_ERROR);
// Start EEPROM
EEPROM.begin(4096);
// auto repair when in boot-loop
uint8_t bootCounter = EEPROM.read(0);
if (bootCounter >= 3) {
prnt(SETUP_FORMAT_SPIFFS);
SPIFFS.format();
prntln(SETUP_OK);
} else {
EEPROM.write(0, bootCounter + 1); // add 1 to the boot counter
EEPROM.commit();
}
// get time
currentTime = millis();
// load settings
settings.load();
// set mac for access point
wifi_set_macaddr(SOFTAP_IF, settings.getMacAP());
// start WiFi
WiFi.mode(WIFI_OFF);
wifi_set_opmode(STATION_MODE);
wifi_set_promiscuous_rx_cb([](uint8_t* buf, uint16_t len) {
scan.sniffer(buf, len);
});
// set mac for station
wifi_set_macaddr(STATION_IF, settings.getMacSt());
// start display
if (settings.getDisplayInterface()) {
displayUI.setup();
displayUI.mode = displayUI.DISPLAY_MODE::INTRO;
}
// copy web files to SPIFFS
copyWebFiles(false);
// load everything else
names.load();
ssids.load();
cli.load();
// create scan.json
scan.setup();
// set channel
setWifiChannel(settings.getChannel());
// load Wifi settings: SSID, password,...
#ifdef DEFAULT_SSID
if (settings.getSSID() == "pwned") settings.setSSID(DEFAULT_SSID);
#endif // ifdef DEFAULT_SSID
loadWifiConfigDefaults();
// dis/enable serial command interface
if (settings.getCLI()) {
cli.enable();
} else {
prntln(SETUP_SERIAL_WARNING);
Serial.flush();
Serial.end();
}
// start access point/web interface
if (settings.getWebInterface()) startAP();
// STARTED
prntln(SETUP_STARTED);
// version
prntln(settings.getVersion());
// setup LED
led.setup();
}
void loop() {
currentTime = millis();
led.update(); // update LED color
wifiUpdate(); // manage access point
attack.update(); // run attacks
displayUI.update();
cli.update(); // read and run serial input
scan.update(); // run scan
ssids.update(); // run random mode, if enabled
// auto-save
if (settings.getAutosave() && (currentTime - autosaveTime > settings.getAutosaveTime())) {
autosaveTime = currentTime;
names.save(false);
ssids.save(false);
settings.save(false);
}
if (!booted) {
// reset boot counter
EEPROM.write(0, 0);
EEPROM.commit();
booted = true;
#ifdef HIGHLIGHT_LED
displayUI.setupLED();
#endif // ifdef HIGHLIGHT_LED
}
}
/*
===========================================
Copyright (c) 2018 Stefan Kremser
github.com/spacehuhn
===========================================
*/
extern "C" {
// Please follow this tutorial:
// https://github.com/spacehuhn/esp8266_deauther/wiki/Installation#compiling-using-arduino-ide
// And be sure to have the right board selected
#include "user_interface.h"
}
#include <EEPROM.h>
#include <ArduinoJson.h>
#if ARDUINOJSON_VERSION_MAJOR != 5
// The software was build using ArduinoJson v5.x
// version 6 is still in beta at the time of writing
// go to tools -> manage libraries, search for ArduinoJSON and install the latest version 5
#error Please upgrade/downgrade ArduinoJSON library to version 5!
#endif // if ARDUINOJSON_VERSION_MAJOR != 5
#include "oui.h"
#include "language.h"
#include "functions.h"
#include "Settings.h"
#include "Names.h"
#include "SSIDs.h"
#include "Scan.h"
#include "Attack.h"
#include "CLI.h"
#include "DisplayUI.h"
#include "A_config.h"
#include "webfiles.h"
#include "LED.h"
// Run-Time Variables //
LED led;
Settings settings;
Names names;
SSIDs ssids;
Accesspoints accesspoints;
Stations stations;
Scan scan;
Attack attack;
CLI cli;
DisplayUI displayUI;
#include "wifi.h"
uint32_t autosaveTime = 0;
uint32_t currentTime = 0;
bool booted = false;
void setup() {
// for random generator
randomSeed(os_random());
// start serial
Serial.begin(115200);
Serial.println();
// start SPIFFS
prnt(SETUP_MOUNT_SPIFFS);
prntln(SPIFFS.begin() ? SETUP_OK : SETUP_ERROR);
// Start EEPROM
EEPROM.begin(4096);
// auto repair when in boot-loop
uint8_t bootCounter = EEPROM.read(0);
if (bootCounter >= 3) {
prnt(SETUP_FORMAT_SPIFFS);
SPIFFS.format();
prntln(SETUP_OK);
} else {
EEPROM.write(0, bootCounter + 1); // add 1 to the boot counter
EEPROM.commit();
}
// get time
currentTime = millis();
// load settings
settings.load();
// set mac for access point
wifi_set_macaddr(SOFTAP_IF, settings.getMacAP());
// start WiFi
WiFi.mode(WIFI_OFF);
wifi_set_opmode(STATION_MODE);
wifi_set_promiscuous_rx_cb([](uint8_t* buf, uint16_t len) {
scan.sniffer(buf, len);
});
// set mac for station
wifi_set_macaddr(STATION_IF, settings.getMacSt());
// start display
if (settings.getDisplayInterface()) {
displayUI.setup();
displayUI.mode = displayUI.DISPLAY_MODE::INTRO;
}
// copy web files to SPIFFS
copyWebFiles(false);
// load everything else
names.load();
ssids.load();
cli.load();
// create scan.json
scan.setup();
// set channel
setWifiChannel(settings.getChannel());
// load Wifi settings: SSID, password,...
#ifdef DEFAULT_SSID
if (settings.getSSID() == "pwned") settings.setSSID(DEFAULT_SSID);
#endif // ifdef DEFAULT_SSID
loadWifiConfigDefaults();
// dis/enable serial command interface
if (settings.getCLI()) {
cli.enable();
} else {
prntln(SETUP_SERIAL_WARNING);
Serial.flush();
Serial.end();
}
// start access point/web interface
if (settings.getWebInterface()) startAP();
// STARTED
prntln(SETUP_STARTED);
// version
prntln(settings.getVersion());
// setup LED
led.setup();
}
void loop() {
currentTime = millis();
led.update(); // update LED color
wifiUpdate(); // manage access point
attack.update(); // run attacks
displayUI.update();
cli.update(); // read and run serial input
scan.update(); // run scan
ssids.update(); // run random mode, if enabled
// auto-save
if (settings.getAutosave() && (currentTime - autosaveTime > settings.getAutosaveTime())) {
autosaveTime = currentTime;
names.save(false);
ssids.save(false);
settings.save(false);
}
if (!booted) {
// reset boot counter
EEPROM.write(0, 0);
EEPROM.commit();
booted = true;
#ifdef HIGHLIGHT_LED
displayUI.setupLED();
#endif // ifdef HIGHLIGHT_LED
}
}