Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ESP32CAM support #320

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 73 additions & 20 deletions esp32_marauder/SDInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,30 @@ bool SDInterface::initSD() {
}
#endif

pinMode(SD_CS, OUTPUT);

delay(10);

if (!SD.begin(SD_CS)) {
Serial.println(F("Failed to mount SD Card"));
this->supported = false;
return false;
}
#ifdef SD_IS_MMC
if (!SD_MMC.begin("/sdcard", true, false, SDMMC_FREQ_DEFAULT)) {
Serial.println(F("Failed to mount SD_MMC Card"));
this->supported = false;
return false;
}
#else
//pinMode(SD_CS, OUTPUT); // this was already done in esp32_marauder.ino
//delay(10);

if (!SD.begin(SD_CS)) {
Serial.println(F("Failed to mount SD Card"));
this->supported = false;
return false;
}
#endif
else {
this->supported = true;
this->cardType = SD.cardType();
#ifdef SD_IS_MMC
this->cardType = SD_MMC.cardType();
#else
this->cardType = SD.cardType();
#endif

//if (cardType == CARD_MMC)
// Serial.println(F("SD: MMC Mounted"));
//else if(cardType == CARD_SD)
Expand All @@ -38,7 +50,11 @@ bool SDInterface::initSD() {
//else
// Serial.println(F("SD: UNKNOWN Card Mounted"));

this->cardSizeMB = SD.cardSize() / (1024 * 1024);
#ifdef SD_IS_MMC
this->cardSizeMB = SD_MMC.cardSize() / (1024 * 1024);
#else
this->cardSizeMB = SD.cardSize() / (1024 * 1024);
#endif

//Serial.printf("SD Card Size: %lluMB\n", this->cardSizeMB);

Expand All @@ -59,10 +75,18 @@ bool SDInterface::initSD() {

buffer_obj = Buffer();

if (!SD.exists("/SCRIPTS")) {
#ifdef SD_IS_MMC
if (!SD_MMC.exists("/SCRIPTS")) {
#else
if (!SD.exists("/SCRIPTS")) {
#endif
Serial.println("/SCRIPTS does not exist. Creating...");

SD.mkdir("/SCRIPTS");
#ifdef SD_IS_MMC
SD_MMC.mkdir("/SCRIPTS");
#else
SD.mkdir("/SCRIPTS");
#endif
Serial.println("/SCRIPTS created");
}

Expand All @@ -77,7 +101,11 @@ bool SDInterface::initSD() {

File SDInterface::getFile(String path) {
if (this->supported) {
File file = SD.open(path, FILE_READ);
#ifdef SD_IS_MMC
File file = SD_MMC.open(path, FILE_READ);
#else
File file = SD.open(path, FILE_READ);
#endif

//if (file)
return file;
Expand All @@ -86,7 +114,12 @@ File SDInterface::getFile(String path) {

void SDInterface::listDir(String str_dir){
if (this->supported) {
File dir = SD.open(str_dir);
#ifdef SD_IS_MMC
File dir = SD_MMC.open(str_dir);
#else
File dir = SD.open(str_dir);
#endif

while (true)
{
File entry = dir.openNextFile();
Expand Down Expand Up @@ -115,15 +148,25 @@ void SDInterface::addPacket(uint8_t* buf, uint32_t len, bool log) {
void SDInterface::openCapture(String file_name) {
bool save_pcap = settings_obj.loadSetting<bool>("SavePCAP");
if ((this->supported) && (save_pcap)) {
buffer_obj.createPcapFile(&SD, file_name);
#ifdef SD_IS_MMC
buffer_obj.createPcapFile(&SD_MMC, file_name);
#else
buffer_obj.createPcapFile(&SD, file_name);
#endif

buffer_obj.open();
}
}

void SDInterface::openLog(String file_name) {
bool save_pcap = settings_obj.loadSetting<bool>("SavePCAP");
if ((this->supported) && (save_pcap)) {
buffer_obj.createPcapFile(&SD, file_name, true);
#ifdef SD_IS_MMC
buffer_obj.createPcapFile(&SD_MMC, file_name, true);
#else
buffer_obj.createPcapFile(&SD, file_name, true);
#endif

buffer_obj.open(true);
}
}
Expand All @@ -138,7 +181,13 @@ void SDInterface::runUpdate() {

display_obj.tft.println(F(text15));
#endif
File updateBin = SD.open("/update.bin");

#ifdef SD_IS_MMC
File updateBin = SD_MMC.open("/update.bin");
#else
File updateBin = SD.open("/update.bin");
#endif

if (updateBin) {
if(updateBin.isDirectory()){
#ifdef HAS_SCREEN
Expand Down Expand Up @@ -266,12 +315,16 @@ bool SDInterface::checkDetectPin() {
void SDInterface::main() {
if ((this->supported) && (this->do_save)) {
//Serial.println("Saving packet...");
buffer_obj.forceSave(&SD);
#ifdef SD_IS_MMC
buffer_obj.forceSave(&SD_MMC);
#else
buffer_obj.forceSave(&SD);
#endif
}
else if (!this->supported) {
if (checkDetectPin()) {
delay(100);
this->initSD();
}
}
}
}
8 changes: 7 additions & 1 deletion esp32_marauder/SDInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@
#include "configs.h"

#include "settings.h"
#include "SD.h"

#ifdef SD_IS_MMC
#include "SD_MMC.h"
#else
#include "SD.h"
#endif

#include "Buffer.h"
#ifdef HAS_SCREEN
#include "Display.h"
Expand Down
28 changes: 14 additions & 14 deletions esp32_marauder/WiFiScan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ void WiFiScan::startWiFiAttacks(uint8_t scan_mode, uint16_t color, String title_
flipper_led.attackLED();
#elif defined(XIAO_ESP32_S3)
xiao_led.attackLED();
#else
#elif defined(HAS_NEOPIXEL_LED)
led_obj.setMode(MODE_ATTACK);
#endif
initTime = millis();
Expand All @@ -439,7 +439,7 @@ bool WiFiScan::shutdownWiFi() {
flipper_led.offLED();
#elif defined(XIAO_ESP32_S3)
xiao_led.offLED();
#else
#elif defined(HAS_NEOPIXEL_LED)
led_obj.setMode(MODE_OFF);
#endif

Expand All @@ -463,7 +463,7 @@ bool WiFiScan::shutdownBLE() {
flipper_led.offLED();
#elif defined(XIAO_ESP32_S3)
xiao_led.offLED();
#else
#elif defined(HAS_NEOPIXEL_LED)
led_obj.setMode(MODE_OFF);
#endif

Expand Down Expand Up @@ -600,7 +600,7 @@ void WiFiScan::RunEvilPortal(uint8_t scan_mode, uint16_t color)
flipper_led.sniffLED();
#elif defined(XIAO_ESP32_S3)
xiao_led.sniffLED();
#else
#elif defined(HAS_NEOPIXEL_LED)
led_obj.setMode(MODE_SNIFF);
#endif

Expand Down Expand Up @@ -647,7 +647,7 @@ void WiFiScan::RunAPScan(uint8_t scan_mode, uint16_t color)
flipper_led.sniffLED();
#elif defined(XIAO_ESP32_S3)
xiao_led.sniffLED();
#else
#elif defined(HAS_NEOPIXEL_LED)
led_obj.setMode(MODE_SNIFF);
#endif

Expand Down Expand Up @@ -923,7 +923,7 @@ void WiFiScan::RunEspressifScan(uint8_t scan_mode, uint16_t color) {
flipper_led.sniffLED();
#elif defined(XIAO_ESP32_S3)
xiao_led.sniffLED();
#else
#elif defined(HAS_NEOPIXEL_LED)
led_obj.setMode(MODE_SNIFF);
#endif

Expand Down Expand Up @@ -962,7 +962,7 @@ void WiFiScan::RunPacketMonitor(uint8_t scan_mode, uint16_t color)
flipper_led.sniffLED();
#elif defined(XIAO_ESP32_S3)
xiao_led.sniffLED();
#else
#elif defined(HAS_NEOPIXEL_LED)
led_obj.setMode(MODE_SNIFF);
#endif

Expand Down Expand Up @@ -1045,7 +1045,7 @@ void WiFiScan::RunEapolScan(uint8_t scan_mode, uint16_t color)
flipper_led.sniffLED();
#elif defined(XIAO_ESP32_S3)
xiao_led.sniffLED();
#else
#elif defined(HAS_NEOPIXEL_LED)
led_obj.setMode(MODE_SNIFF);
#endif

Expand Down Expand Up @@ -1200,7 +1200,7 @@ void WiFiScan::RunPwnScan(uint8_t scan_mode, uint16_t color)
flipper_led.sniffLED();
#elif defined(XIAO_ESP32_S3)
xiao_led.sniffLED();
#else
#elif defined(HAS_NEOPIXEL_LED)
led_obj.setMode(MODE_SNIFF);
#endif

Expand Down Expand Up @@ -1248,7 +1248,7 @@ void WiFiScan::RunBeaconScan(uint8_t scan_mode, uint16_t color)
flipper_led.sniffLED();
#elif defined(XIAO_ESP32_S3)
xiao_led.sniffLED();
#else
#elif defined(HAS_NEOPIXEL_LED)
led_obj.setMode(MODE_SNIFF);
#endif

Expand Down Expand Up @@ -1295,7 +1295,7 @@ void WiFiScan::RunStationScan(uint8_t scan_mode, uint16_t color)
flipper_led.sniffLED();
#elif defined(XIAO_ESP32_S3)
xiao_led.sniffLED();
#else
#elif defined(HAS_NEOPIXEL_LED)
led_obj.setMode(MODE_SNIFF);
#endif

Expand Down Expand Up @@ -1343,7 +1343,7 @@ void WiFiScan::RunRawScan(uint8_t scan_mode, uint16_t color)
flipper_led.sniffLED();
#elif defined(XIAO_ESP32_S3)
xiao_led.sniffLED();
#else
#elif defined(HAS_NEOPIXEL_LED)
led_obj.setMode(MODE_SNIFF);
#endif

Expand Down Expand Up @@ -1393,7 +1393,7 @@ void WiFiScan::RunDeauthScan(uint8_t scan_mode, uint16_t color)
flipper_led.sniffLED();
#elif defined(XIAO_ESP32_S3)
xiao_led.sniffLED();
#else
#elif defined(HAS_NEOPIXEL_LED)
led_obj.setMode(MODE_SNIFF);
#endif

Expand Down Expand Up @@ -1442,7 +1442,7 @@ void WiFiScan::RunProbeScan(uint8_t scan_mode, uint16_t color)
flipper_led.sniffLED();
#elif defined(XIAO_ESP32_S3)
xiao_led.sniffLED();
#else
#elif defined(HAS_NEOPIXEL_LED)
led_obj.setMode(MODE_SNIFF);
#endif

Expand Down
4 changes: 2 additions & 2 deletions esp32_marauder/WiFiScan.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#include "flipperLED.h"
#elif defined(XIAO_ESP32_S3)
#include "xiaoLED.h"
#else
#elif defined(HAS_NEOPIXEL_LED)
#include "LedInterface.h"
#endif
//#include "MenuFunctions.h"
Expand Down Expand Up @@ -107,7 +107,7 @@ extern Settings settings_obj;
extern flipperLED flipper_led;
#elif defined(XIAO_ESP32_S3)
extern xiaoLED xiao_led;
#else
#elif defined(HAS_NEOPIXEL_LED)
extern LedInterface led_obj;
#endif

Expand Down
Loading
Loading