mirror of
https://github.com/justcallmekoko/ESP32Marauder.git
synced 2025-12-23 07:29:14 -08:00
Clean up after BLE and OTA
This commit is contained in:
@@ -44,17 +44,17 @@ void Buffer::addPacket(uint8_t* buf, uint32_t len){
|
|||||||
|
|
||||||
// buffer is full -> drop packet
|
// buffer is full -> drop packet
|
||||||
if((useA && bufSizeA + len >= BUF_SIZE && bufSizeB > 0) || (!useA && bufSizeB + len >= BUF_SIZE && bufSizeA > 0)){
|
if((useA && bufSizeA + len >= BUF_SIZE && bufSizeB > 0) || (!useA && bufSizeB + len >= BUF_SIZE && bufSizeA > 0)){
|
||||||
Serial.print(";");
|
//Serial.print(";");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(useA && bufSizeA + len + 16 >= BUF_SIZE && bufSizeB == 0){
|
if(useA && bufSizeA + len + 16 >= BUF_SIZE && bufSizeB == 0){
|
||||||
useA = false;
|
useA = false;
|
||||||
Serial.println("\nswitched to buffer B");
|
//Serial.println("\nswitched to buffer B");
|
||||||
}
|
}
|
||||||
else if(!useA && bufSizeB + len + 16 >= BUF_SIZE && bufSizeA == 0){
|
else if(!useA && bufSizeB + len + 16 >= BUF_SIZE && bufSizeA == 0){
|
||||||
useA = true;
|
useA = true;
|
||||||
Serial.println("\nswitched to buffer A");
|
//Serial.println("\nswitched to buffer A");
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t microSeconds = micros(); // e.g. 45200400 => 45s 200ms 400us
|
uint32_t microSeconds = micros(); // e.g. 45200400 => 45s 200ms 400us
|
||||||
@@ -116,7 +116,7 @@ void Buffer::save(fs::FS* fs){
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Serial.println("saving file");
|
//Serial.println("saving file");
|
||||||
|
|
||||||
uint32_t startTime = millis();
|
uint32_t startTime = millis();
|
||||||
uint32_t finishTime;
|
uint32_t finishTime;
|
||||||
@@ -147,7 +147,7 @@ void Buffer::save(fs::FS* fs){
|
|||||||
|
|
||||||
finishTime = millis() - startTime;
|
finishTime = millis() - startTime;
|
||||||
|
|
||||||
Serial.printf("\n%u bytes written for %u ms\n", len, finishTime);
|
//Serial.printf("\n%u bytes written for %u ms\n", len, finishTime);
|
||||||
|
|
||||||
saving = false;
|
saving = false;
|
||||||
|
|
||||||
@@ -195,7 +195,7 @@ void Buffer::forceSave(fs::FS* fs){
|
|||||||
|
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
Serial.printf("saved %u bytes\n",len);
|
//Serial.printf("saved %u bytes\n",len);
|
||||||
|
|
||||||
saving = false;
|
saving = false;
|
||||||
writing = true;
|
writing = true;
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ void MenuFunctions::main()
|
|||||||
(wifi_scan_obj.currentScanMode != WIFI_ATTACK_BEACON_SPAM) &&
|
(wifi_scan_obj.currentScanMode != WIFI_ATTACK_BEACON_SPAM) &&
|
||||||
(wifi_scan_obj.currentScanMode != WIFI_ATTACK_RICK_ROLL))
|
(wifi_scan_obj.currentScanMode != WIFI_ATTACK_RICK_ROLL))
|
||||||
display_obj.displayBuffer();
|
display_obj.displayBuffer();
|
||||||
|
//Serial.println(wifi_scan_obj.freeRAM());
|
||||||
|
|
||||||
|
|
||||||
// Pressed will be set true is there is a valid touch on the screen
|
// Pressed will be set true is there is a valid touch on the screen
|
||||||
@@ -246,7 +247,7 @@ void MenuFunctions::RunSetup()
|
|||||||
addNodes(&deviceMenu, "Device Info", TFT_WHITE, NULL, DEVICE_INFO, [this](){wifi_scan_obj.currentScanMode = SHOW_INFO; changeMenu(&infoMenu); wifi_scan_obj.RunInfo();});
|
addNodes(&deviceMenu, "Device Info", TFT_WHITE, NULL, DEVICE_INFO, [this](){wifi_scan_obj.currentScanMode = SHOW_INFO; changeMenu(&infoMenu); wifi_scan_obj.RunInfo();});
|
||||||
|
|
||||||
updateMenu.parentMenu = &deviceMenu;
|
updateMenu.parentMenu = &deviceMenu;
|
||||||
addNodes(&updateMenu, "Back", TFT_LIGHTGREY, NULL, 0, [this](){wifi_scan_obj.currentScanMode = WIFI_SCAN_OFF; changeMenu(updateMenu.parentMenu); WiFi.softAPdisconnect(true);});
|
addNodes(&updateMenu, "Back", TFT_LIGHTGREY, NULL, 0, [this](){wifi_scan_obj.currentScanMode = WIFI_SCAN_OFF; changeMenu(updateMenu.parentMenu); WiFi.softAPdisconnect(true); web_obj.shutdownServer();});
|
||||||
|
|
||||||
infoMenu.parentMenu = &deviceMenu;
|
infoMenu.parentMenu = &deviceMenu;
|
||||||
addNodes(&infoMenu, "Back", TFT_LIGHTGREY, NULL, 0, [this](){wifi_scan_obj.currentScanMode = WIFI_SCAN_OFF; changeMenu(infoMenu.parentMenu);});
|
addNodes(&infoMenu, "Back", TFT_LIGHTGREY, NULL, 0, [this](){wifi_scan_obj.currentScanMode = WIFI_SCAN_OFF; changeMenu(infoMenu.parentMenu);});
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ void Web::main()
|
|||||||
{
|
{
|
||||||
//Serial.println("Running the shits");
|
//Serial.println("Running the shits");
|
||||||
// Notify if client has connected to the update server
|
// Notify if client has connected to the update server
|
||||||
|
|
||||||
|
|
||||||
int current_sta = WiFi.softAPgetStationNum();
|
int current_sta = WiFi.softAPgetStationNum();
|
||||||
|
|
||||||
if (current_sta < this->num_sta)
|
if (current_sta < this->num_sta)
|
||||||
@@ -26,6 +28,7 @@ void Web::main()
|
|||||||
Serial.println(this->num_sta);
|
Serial.println(this->num_sta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
server.handleClient();
|
server.handleClient();
|
||||||
delay(1);
|
delay(1);
|
||||||
}
|
}
|
||||||
@@ -46,15 +49,30 @@ void Web::setupOTAupdate()
|
|||||||
display_obj.tft.setTextSize(1);
|
display_obj.tft.setTextSize(1);
|
||||||
display_obj.tft.setTextColor(TFT_WHITE);
|
display_obj.tft.setTextColor(TFT_WHITE);
|
||||||
|
|
||||||
|
Serial.println(wifi_scan_obj.freeRAM());
|
||||||
display_obj.tft.print("Configuring update server...\n\n");
|
display_obj.tft.print("Configuring update server...\n\n");
|
||||||
Serial.println("Configuring update server...");
|
Serial.println("Configuring update server...");
|
||||||
|
|
||||||
display_obj.tft.setTextColor(TFT_YELLOW);
|
display_obj.tft.setTextColor(TFT_YELLOW);
|
||||||
|
|
||||||
// Start WiFi AP
|
// Start WiFi AP
|
||||||
|
Serial.println("Initializing WiFi...");
|
||||||
|
//wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
|
||||||
|
esp_wifi_init(&wifi_scan_obj.cfg);
|
||||||
|
//esp_wifi_set_storage(WIFI_STORAGE_RAM);
|
||||||
|
if (esp_wifi_set_storage(WIFI_STORAGE_FLASH) != ESP_OK)
|
||||||
|
Serial.println("Could not set WiFi Storage!");
|
||||||
|
esp_wifi_set_mode(WIFI_MODE_NULL);
|
||||||
|
esp_wifi_start();
|
||||||
|
Serial.println(wifi_scan_obj.freeRAM());
|
||||||
|
|
||||||
|
Serial.println("Starting softAP...");
|
||||||
WiFi.softAP(ssid, password);
|
WiFi.softAP(ssid, password);
|
||||||
Serial.println("");
|
Serial.println("");
|
||||||
|
|
||||||
|
Serial.println(wifi_scan_obj.freeRAM());
|
||||||
|
|
||||||
|
Serial.println("Displaying settings to TFT...");
|
||||||
display_obj.tft.print("SSID: ");
|
display_obj.tft.print("SSID: ");
|
||||||
display_obj.tft.println(ssid);
|
display_obj.tft.println(ssid);
|
||||||
display_obj.tft.print("IP address: ");
|
display_obj.tft.print("IP address: ");
|
||||||
@@ -75,6 +93,8 @@ void Web::setupOTAupdate()
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// return javascript jquery
|
// return javascript jquery
|
||||||
|
Serial.println("Setting server behavior...");
|
||||||
|
Serial.println(wifi_scan_obj.freeRAM());
|
||||||
server.on("/jquery.min.js", HTTP_GET, onJavaScript);
|
server.on("/jquery.min.js", HTTP_GET, onJavaScript);
|
||||||
/*return index page which is stored in serverIndex */
|
/*return index page which is stored in serverIndex */
|
||||||
server.on("/", HTTP_GET, [this]() {
|
server.on("/", HTTP_GET, [this]() {
|
||||||
@@ -138,9 +158,25 @@ void Web::setupOTAupdate()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
Serial.println("Finished setting server behavior");
|
||||||
|
Serial.println(wifi_scan_obj.freeRAM());
|
||||||
|
Serial.println("Starting server...");
|
||||||
server.begin();
|
server.begin();
|
||||||
|
|
||||||
display_obj.tft.setTextColor(TFT_GREEN);
|
display_obj.tft.setTextColor(TFT_GREEN);
|
||||||
display_obj.tft.println("\nCompleted update server setup");
|
display_obj.tft.println("\nCompleted update server setup");
|
||||||
Serial.println("Completed update server setup");
|
Serial.println("Completed update server setup");
|
||||||
|
Serial.println(wifi_scan_obj.freeRAM());
|
||||||
|
}
|
||||||
|
|
||||||
|
void Web::shutdownServer() {
|
||||||
|
Serial.println("Closing Update Server...");
|
||||||
|
server.stop();
|
||||||
|
WiFi.mode(WIFI_OFF);
|
||||||
|
esp_wifi_set_mode(WIFI_MODE_NULL);
|
||||||
|
esp_wifi_stop();
|
||||||
|
esp_wifi_deinit();
|
||||||
|
Serial.println(wifi_scan_obj.freeRAM());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,10 @@ Code taken from espressif ESP32 OTA Update example
|
|||||||
|
|
||||||
#include "Assets.h"
|
#include "Assets.h"
|
||||||
#include "Display.h"
|
#include "Display.h"
|
||||||
|
#include "WiFiScan.h"
|
||||||
|
|
||||||
extern Display display_obj;
|
extern Display display_obj;
|
||||||
|
extern WiFiScan wifi_scan_obj;
|
||||||
|
|
||||||
class Web
|
class Web
|
||||||
{
|
{
|
||||||
@@ -25,6 +27,7 @@ class Web
|
|||||||
PROGMEM const char* password = "justcallmekoko";
|
PROGMEM const char* password = "justcallmekoko";
|
||||||
|
|
||||||
bool serving = false;
|
bool serving = false;
|
||||||
|
|
||||||
int num_sta = 0;
|
int num_sta = 0;
|
||||||
|
|
||||||
PROGMEM const char* loginIndex =
|
PROGMEM const char* loginIndex =
|
||||||
@@ -121,8 +124,9 @@ class Web
|
|||||||
Web();
|
Web();
|
||||||
|
|
||||||
void main();
|
void main();
|
||||||
static void onJavaScript();
|
PROGMEM static void onJavaScript();
|
||||||
void setupOTAupdate();
|
void setupOTAupdate();
|
||||||
|
void shutdownServer();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -8,7 +8,11 @@ int num_deauth = 0;
|
|||||||
int num_probe = 0;
|
int num_probe = 0;
|
||||||
|
|
||||||
class bluetoothScanAllCallback: public BLEAdvertisedDeviceCallbacks {
|
class bluetoothScanAllCallback: public BLEAdvertisedDeviceCallbacks {
|
||||||
|
|
||||||
void onResult(BLEAdvertisedDevice advertisedDevice) {
|
void onResult(BLEAdvertisedDevice advertisedDevice) {
|
||||||
|
|
||||||
|
//advertisedDevice.getScan()->stop();
|
||||||
|
|
||||||
String display_string = "";
|
String display_string = "";
|
||||||
if (display_obj.display_buffer->size() >= 0)
|
if (display_obj.display_buffer->size() >= 0)
|
||||||
{
|
{
|
||||||
@@ -241,14 +245,14 @@ String WiFiScan::freeRAM()
|
|||||||
|
|
||||||
void WiFiScan::RunInfo()
|
void WiFiScan::RunInfo()
|
||||||
{
|
{
|
||||||
String sta_mac = this->getStaMAC();
|
//String sta_mac = this->getStaMAC();
|
||||||
String ap_mac = this->getApMAC();
|
//String ap_mac = this->getApMAC();
|
||||||
String free_ram = this->freeRAM();
|
String free_ram = this->freeRAM();
|
||||||
|
|
||||||
Serial.print("STA MAC: ");
|
//Serial.print("STA MAC: ");
|
||||||
Serial.println(sta_mac);
|
//Serial.println(sta_mac);
|
||||||
Serial.print("AP MAC: ");
|
//Serial.print("AP MAC: ");
|
||||||
Serial.println(ap_mac);
|
//Serial.println(ap_mac);
|
||||||
Serial.println(free_ram);
|
Serial.println(free_ram);
|
||||||
|
|
||||||
display_obj.tft.setTextWrap(false);
|
display_obj.tft.setTextWrap(false);
|
||||||
@@ -257,8 +261,8 @@ void WiFiScan::RunInfo()
|
|||||||
display_obj.tft.setTextSize(1);
|
display_obj.tft.setTextSize(1);
|
||||||
display_obj.tft.setTextColor(TFT_CYAN);
|
display_obj.tft.setTextColor(TFT_CYAN);
|
||||||
|
|
||||||
display_obj.tft.println(" Station MAC: " + sta_mac);
|
//display_obj.tft.println(" Station MAC: " + sta_mac);
|
||||||
display_obj.tft.println(" AP MAC: " + ap_mac);
|
//display_obj.tft.println(" AP MAC: " + ap_mac);
|
||||||
display_obj.tft.println(" " + free_ram);
|
display_obj.tft.println(" " + free_ram);
|
||||||
|
|
||||||
if (sd_obj.supported) {
|
if (sd_obj.supported) {
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ class WiFiScan
|
|||||||
|
|
||||||
bool orient_display = false;
|
bool orient_display = false;
|
||||||
|
|
||||||
|
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
|
||||||
|
|
||||||
String getStaMAC();
|
String getStaMAC();
|
||||||
String getApMAC();
|
String getApMAC();
|
||||||
|
|||||||
Reference in New Issue
Block a user