Skip to content

Commit

Permalink
Merge branch 'merge_refactor' into Stealth_Mode
Browse files Browse the repository at this point in the history
  • Loading branch information
JahazielLem committed Aug 19, 2024
2 parents 0f88023 + f691c50 commit 3fd00f3
Show file tree
Hide file tree
Showing 56 changed files with 1,822 additions and 508 deletions.
6 changes: 5 additions & 1 deletion firmware/components/ble_hid/ble_hidd_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
#include "ble_hidd_main.h"

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "esp_bt.h"
#include "esp_event.h"
#include "esp_log.h"
#include "esp_mac.h"
#include "esp_system.h"
#include "esp_wifi.h"
#include "freertos/FreeRTOS.h"
Expand Down Expand Up @@ -221,6 +221,10 @@ void ble_hid_get_device_name(char* device_name) {
strcpy(device_name, HIDD_DEVICE_NAME);
}

void ble_hid_get_device_mac(uint8_t* mac) {
esp_read_mac(mac, ESP_MAC_BT);
}

void ble_hid_begin() {
esp_err_t ret;

Expand Down
1 change: 1 addition & 0 deletions firmware/components/ble_hid/ble_hidd_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ void ble_hid_volume_up(bool press);
void ble_hid_play(bool press);
void ble_hid_pause(bool press);
void ble_hid_get_device_name(char* device_name);
void ble_hid_get_device_mac(uint8_t* mac);
void ble_hid_register_callback(hid_event_callback_f callback);
32 changes: 15 additions & 17 deletions firmware/components/trackers_scanner/trackers_scanner.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ static void handle_bt_gapc_events(esp_gap_ble_cb_event_t event_type,
esp_ble_gap_cb_param_t* param);

void trackers_scanner_start() {
#if !defined(CONFIG_TRACKERS_SCANNER_DEBUG)
esp_log_level_set(TAG_BLE_CLIENT_MODULE, ESP_LOG_NONE);
#endif
// #if !defined(CONFIG_TRACKERS_SCANNER_DEBUG)
// esp_log_level_set(TAG_BLE_CLIENT_MODULE, ESP_LOG_NONE);
// #endif

gattc_scan_params_t scan_params = {
.remote_filter_service_uuid =
Expand Down Expand Up @@ -90,7 +90,7 @@ void trackers_scanner_register_cb(bluetooth_traker_scanner_cb_t callback) {
static void task_tracker_timer() {
ESP_LOGI(TAG_BLE_CLIENT_MODULE, "Trackers task started");
trackers_scan_duration = 0;
while (1) {
while (trackers_scanner_active) {
if (trackers_scan_duration >= TRACKER_SCAN_DURATION) {
ESP_LOGI(TAG_BLE_CLIENT_MODULE, "Trackers task stopped");
trackers_scanner_stop();
Expand All @@ -100,14 +100,18 @@ static void task_tracker_timer() {
}

void trackers_scanner_stop() {
trackers_scanner_active = false;
ESP_LOGI(TAG_BLE_CLIENT_MODULE, "Trackers task stopped");
if (trackers_scan_timer_task != NULL) {
vTaskDelete(trackers_scan_timer_task);
trackers_scan_timer_task = NULL;
ESP_LOGI(TAG_BLE_CLIENT_MODULE, "Trackers task stopped");
vTaskSuspend(trackers_scan_timer_task);
}
ESP_LOGI(TAG_BLE_CLIENT_MODULE, "Trackers task stopped");
trackers_scan_duration = 0;
vTaskDelete(NULL);
// TODO: When this is called, the BLE stopping bricks the device
// bt_gattc_task_stop();
ESP_LOGI(TAG_BLE_CLIENT_MODULE, "Trackers task stopped");
}

static void tracker_dissector(esp_ble_gap_cb_param_t* scan_rst,
Expand All @@ -133,7 +137,7 @@ static void tracker_dissector(esp_ble_gap_cb_param_t* scan_rst,
scan_rst->scan_rst.bda[1], scan_rst->scan_rst.bda[0]);
ESP_LOGI(TAG_BLE_CLIENT_MODULE,
"ADV data %d:", scan_rst->scan_rst.adv_data_len);
esp_log_buffer_hex(TAG_BLE_CLIENT_MODULE, &scan_rst->scan_rst.ble_adv,
ESP_LOG_BUFFER_HEX(TAG_BLE_CLIENT_MODULE, &scan_rst->scan_rst.ble_adv,
scan_rst->scan_rst.adv_data_len);
ESP_LOGI(TAG_BLE_CLIENT_MODULE, " ");
break;
Expand All @@ -142,22 +146,16 @@ static void tracker_dissector(esp_ble_gap_cb_param_t* scan_rst,
}

void trackers_scanner_add_tracker_profile(tracker_profile_t** profiles,
int* num_profiles,
uint8_t mac_address[6],
int rssi,
char* name) {
uint16_t* num_profiles,
tracker_profile_t new_profile) {
*profiles =
realloc(*profiles, (*num_profiles + 1) * sizeof(tracker_profile_t));

(*profiles)[*num_profiles].rssi = rssi;
(*profiles)[*num_profiles].name = name;
memcpy((*profiles)[*num_profiles].mac_address, mac_address, 6);

(*profiles)[*num_profiles] = new_profile;
(*num_profiles)++;
}

int trackers_scanner_find_profile_by_mac(tracker_profile_t* profiles,
int num_profiles,
uint16_t num_profiles,
uint8_t mac_address[6]) {
for (int i = 0; i < num_profiles; i++) {
if (memcmp(profiles[i].mac_address, mac_address, 6) == 0) {
Expand Down
12 changes: 4 additions & 8 deletions firmware/components/trackers_scanner/trackers_scanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,11 @@ bool trackers_scanner_is_active();
*
* @param profiles The list of tracker profiles
* @param num_profiles The number of tracker profiles
* @param mac_address The mac address of the tracker
* @param rssi The rssi of the tracker
* @param name The name of the tracker
* @param new_profile The new tracker profile to add
*/
void trackers_scanner_add_tracker_profile(tracker_profile_t** profiles,
int* num_profiles,
uint8_t mac_address[6],
int rssi,
char* name);
uint16_t* num_profiles,
tracker_profile_t new_profile);

/**
* @brief Find a profile by the mac address
Expand All @@ -97,6 +93,6 @@ void trackers_scanner_add_tracker_profile(tracker_profile_t** profiles,
* @return int Index of the profile or -1 if not found
*/
int trackers_scanner_find_profile_by_mac(tracker_profile_t* profiles,
int num_profiles,
uint16_t num_profiles,
uint8_t mac_address[6]);
#endif // TRACKERS_SCANNER_H
155 changes: 155 additions & 0 deletions firmware/main/Kconfig.projbuild
Original file line number Diff line number Diff line change
Expand Up @@ -562,3 +562,158 @@ menu "Frequency Configuration"
default 13 if EXAMPLE_MIN_CPU_FREQ_13M
default 32 if EXAMPLE_MIN_CPU_FREQ_32M
endmenu

menu "Apps & Features"
################################# WIFI ###################################
config WIFI_APPS_ENABLE
bool "Enable WiFi Apps"
default true
help
Enable or disable all WiFi applications.

if WIFI_APPS_ENABLE

config WIFI_APP_ANALYZER
bool "Enable Analyzer App"
default true
help
Enable or disable the WiFi Analyzer application.

config WIFI_APP_DEAUTH
bool "Enable Deauth App"
default true
help
Enable or disable the WiFi Deauth application.

config WIFI_APP_DOS
bool "Enable DoS App"
default true
help
Enable or disable the WiFi DoS application.

endif # WIFI_APPS_ENABLE

############################### BLUETOOTH #################################

config BLUETOOTH_APPS_ENABLE
bool "Enable Bluetooth Apps"
default true
help
Enable or disable all Bluetooth applications.

if BLUETOOTH_APPS_ENABLE

config BLUETOOTH_APP_TRAKERS
bool "Enable Trakers App"
default true
help
Enable or disable the Bluetooth Trakers application.

config BLUETOOTH_APP_SPAM
bool "Enable Spam App"
default true
help
Enable or disable the Bluetooth Spam application.

config BLUETOOTH_APP_HID
bool "Enable HID App"
default true
help
Enable or disable the Bluetooth HID application.
endif # BLUETOOTH_APPS_ENABLE

################################# ZIGBEE ###################################

config ZIGBEE_APPS_ENABLE
bool "Enable Zigbee Apps"
default true
help
Enable or disable all Zigbee applications.

if ZIGBEE_APPS_ENABLE

config ZIGBEE_APP_SPOOFING
bool "Enable Spoofing App"
default true
help
Enable or disable the Zigbee Spoofing application.

config ZIGBEE_APP_SNIFFER
bool "Enable Sniffer App"
default true
help
Enable or disable the Zigbee Sniffer application.
endif # ZIGBEE_APPS_ENABLE

################################# THREAD ###################################

config THREAD_APPS_ENABLE
bool "Enable Thread Apps"
default true
help
Enable or disable all Thread applications.

if THREAD_APPS_ENABLE

config THREAD_APP_BROADCAST
bool "Enable Boradcast App"
default true
help
Enable or disable the Thread Broadcast application.

config THREAD_APP_SNIFFER
bool "Enable Sniffer App"
default true
help
Enable or disable the Thread Sniffer application.
endif # THREAD_APPS_ENABLE

################################# GPS ###################################

config GPS_APPS_ENABLE
bool "Enable GPS Apps"
default true
help
Enable or disable all GPS applications.

if GPS_APPS_ENABLE

config GPS_APP_WARDRIVING
bool "Enable Wardriving App"
default true
help
Enable or disable the GPS Wardriving application.
endif # GPS_APPS_ENABLE

################################# OTA ###################################

config OTA_ENABLE
bool "Enable OTA feature"
default true
help
Enable or disable OTA feature.

########################### FILE MANAGER #############################

config FILE_MANAGER_ENABLE
bool "Enable File Manager Features"
default true
help
Enable or disable all File Manager Features.

if FILE_MANAGER_ENABLE

config FILE_MANAGER_LOCAL
bool "Enable Local File Manager"
default true
help
Enable or disable the Local File Manager feature.

config FILE_MANAGER_WEB
bool "Enable Web File Manager"
default true
help
Enable or disable the Web File Manager Feature.
endif # FILE_MANAGER_ENABLE

endmenu
36 changes: 23 additions & 13 deletions firmware/main/apps/ble/hid_device/hid_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
#include "apps/ble/hid_device/hid_screens.h"
#include "ble_hidd_main.h"
#include "esp_log.h"
#include "menu_screens_modules.h"
#include "esp_mac.h"
#include "menus_module.h"

static uint16_t current_item = 0;

Expand All @@ -22,7 +23,7 @@ static void hid_module_decrement_item() {
static void hid_module_cb_connection_handler(bool connection) {
hid_module_display_device_connection(connection);
if (!connection) {
esp_restart();
// esp_restart();
}
}

Expand All @@ -48,9 +49,9 @@ static void hid_module_cb_event_volumen(uint8_t button_name,
break;
case BUTTON_LEFT:
current_item = 0;
hid_module_register_menu(HID_TREE_MENU);
hid_module_register_menu(GENERAL_TREE_APP_MENU);
hid_module_display_menu(current_item);
menu_screens_set_app_state(true, hid_module_cb_event);
menus_module_set_app_state(true, hid_module_cb_event);
break;
case BUTTON_RIGHT:
if (current_item == HID_DEVICE_VOL_UP) {
Expand Down Expand Up @@ -94,31 +95,40 @@ static void hid_module_cb_event(uint8_t button_name, uint8_t button_event) {
case BUTTON_RIGHT:
if (current_item == HID_CONFIG_NAME) {
current_item = 0;
hid_module_display_device_name();
char* hid_name[20];
ble_hid_get_device_name(&hid_name);
general_screen_display_card_information_handler(
"Device Name", &hid_name, hid_module_display_menu,
hid_module_cb_event);
} else if (current_item == HID_CONFIG_MAC) {
current_item = 0;
hid_module_display_device_mac();
uint8_t hid_mac[8] = {0};
esp_read_mac(hid_mac, ESP_MAC_BT);
char mac_address[20];
sprintf(mac_address, "%02X:%02X:%02X:%02X", hid_mac[2], hid_mac[3],
hid_mac[4], hid_mac[5]);
general_screen_display_card_information_handler(
"Device MAC", &mac_address, hid_module_display_menu,
hid_module_cb_event);
} else if (current_item == HID_CONFIG_START) {
current_item = 0;
hid_module_register_menu(HID_TREE_DEVICE);
hid_module_register_menu(GENERAL_TREE_APP_SUBMENU);
hid_module_display_device_pairing();
ble_hid_register_callback(hid_module_cb_connection_handler);
ble_hid_begin();
menu_screens_set_app_state(true, hid_module_cb_event_volumen);
menus_module_set_app_state(true, hid_module_cb_event_volumen);
}
break;
case BUTTON_LEFT:
current_item = 0;
hid_module_register_menu(HID_TREE_MENU);
hid_module_display_menu(current_item);
menus_module_exit_app();
break;
default:
break;
}
}

void hid_module_begin() {
hid_module_register_menu(HID_TREE_MENU);
hid_module_register_menu(GENERAL_TREE_APP_MENU);
hid_module_display_menu(current_item);
menu_screens_set_app_state(true, hid_module_cb_event);
menus_module_set_app_state(true, hid_module_cb_event);
}
Loading

0 comments on commit 3fd00f3

Please sign in to comment.