Skip to content

Commit

Permalink
feat: Add screen callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
JahazielLem committed Dec 19, 2024
1 parent 9cc7a97 commit 59b64a2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
18 changes: 16 additions & 2 deletions firmware/main/apps/wifi/deauth_detector/detector.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#define WIFI_CHANNEL_SWITCH_INTERVAL 1000

static const char* TAG = "DEAUTH_DETECTOR";
static uint8_t current_channel = 1;
static uint8_t current_channel = 99;
static uint16_t total_deauth_packets_count = 0;
static uint16_t deauth_packets_count_list[14];
static bool running = false;
Expand All @@ -36,7 +36,7 @@ static void packet_handler(uint8_t* buf, wifi_promiscuous_pkt_type_t type) {
if (channel_hopping) {
detector_scenes_show_table(deauth_packets_count_list);
} else {
detector_scenes_show_count(total_deauth_packets_count, rx_ctrl.channel)
detector_scenes_show_count(total_deauth_packets_count, rx_ctrl.channel);
}
}

Expand Down Expand Up @@ -85,10 +85,24 @@ void deauth_detector_begin() {
ESP_LOGE(TAG, "Error starting wifi: %s", esp_err_to_name(err));
return;
}
uint8_t get_saved_channel =
preferences_get_int("det_channel", current_channel);
if (get_saved_channel == 99) {
channel_hopping = true;
current_channel = 1;
} else {
current_channel = get_saved_channel;
}
esp_wifi_set_channel(current_channel, WIFI_SECOND_CHAN_NONE);
running = true;

if (channel_hopping) {
xTaskCreate(channel_hopper, "channel_hopper", 2048, NULL, 10, NULL);
}
}

void deauth_detector_stop() {
esp_wifi_set_promiscuous(false);
esp_wifi_stop();
running = false;
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "general_submenu.h"
#include "menus_module.h"
#include "oled_screen.h"
#include "preferences.h"

void detector_scenes_main_menu();
void detector_scenes_settings();
Expand All @@ -17,7 +18,7 @@ static void detector_scenes_scanning() {
}

void detector_scenes_show_count(uint16_t count, uint8_t channel) {
oled_screen_clear();
oled_screen_clear_buffer();
oled_screen_display_text_center("Scanning", 0, OLED_DISPLAY_NORMAL);
char* str = malloc(40);
sprintf(str, "Total packets: %d", count);
Expand All @@ -27,6 +28,7 @@ void detector_scenes_show_count(uint16_t count, uint8_t channel) {
oled_screen_display_text_center(str2, 2, OLED_DISPLAY_NORMAL);
free(str);
free(str2);
oled_screen_display_show();
}

void detector_scenes_show_table(uint16_t* deauth_packets_count_list) {
Expand Down Expand Up @@ -90,6 +92,7 @@ static void settings_handler(uint8_t scan_mode) {
// TODO: SET SCAN MODE TO "scan_mode"
switch (scan_mode) {
case CHANNEL_HOP_OPTION:
preferences_put_int("det_channel", 99);
break;
case CHANNEL_OPTION:
detector_scenes_channel();
Expand Down Expand Up @@ -122,6 +125,7 @@ static const char* channel_options[] = {
static void channel_handler(uint8_t channel) {
// TODO: Set Deauth Detector Channel to "channel"
// TODO: SAVE "channel" TO FLASH
preferences_put_int("det_channel", channel);
}

static void channel_exit() {
Expand Down

0 comments on commit 59b64a2

Please sign in to comment.