diff --git a/firmware/README.md b/firmware/README.md index 8ca20dc0..81218460 100644 --- a/firmware/README.md +++ b/firmware/README.md @@ -160,4 +160,25 @@ The build files will be in the `build_files.zip` file. Now you can create a rele | 0x20000 | minino.bin | ```bash python -m esptool --chip esp32c6 -b 460800 --before default_reset --after hard_reset write_flash --flash_mode dio --flash_size 8MB --flash_freq 80m 0x0 bootloader.bin 0x8000 partition-table.bin 0x20000 minino.bin +``` + + + +## BLE + +### ADV Filters +``` +BLE_SCAN_FILTER_ALLOW_ALL = 0x0, /*!< Accept all : + 1. advertisement packets except directed advertising packets not addressed to this device (default). */ + BLE_SCAN_FILTER_ALLOW_ONLY_WLST = 0x1, /*!< Accept only : + 1. advertisement packets from devices where the advertiser’s address is in the White list. + 2. Directed advertising packets which are not addressed for this device shall be ignored. */ + BLE_SCAN_FILTER_ALLOW_UND_RPA_DIR = 0x2, /*!< Accept all : + 1. undirected advertisement packets, and + 2. directed advertising packets where the initiator address is a resolvable private address, and + 3. directed advertising packets addressed to this device. */ + BLE_SCAN_FILTER_ALLOW_WLIST_RPA_DIR = 0x3, /*!< Accept all : + 1. advertisement packets from devices where the advertiser’s address is in the White list, and + 2. directed advertising packets where the initiator address is a resolvable private address, and + 3. directed advertising packets addressed to this device.*/ ``` \ No newline at end of file diff --git a/firmware/components/ble_scann/CMakeLists.txt b/firmware/components/ble_scann/CMakeLists.txt new file mode 100644 index 00000000..e0576fa8 --- /dev/null +++ b/firmware/components/ble_scann/CMakeLists.txt @@ -0,0 +1,3 @@ +idf_component_register(SRCS "ble_scann.c" +PRIV_REQUIRES bt bt_gattc uart_sender +INCLUDE_DIRS ".") diff --git a/firmware/components/ble_scann/ble_scann.c b/firmware/components/ble_scann/ble_scann.c new file mode 100644 index 00000000..35cac31a --- /dev/null +++ b/firmware/components/ble_scann/ble_scann.c @@ -0,0 +1,110 @@ +#include "ble_scann.h" +#include "bt_gattc.h" +#include "esp_bt.h" +#include "esp_log.h" +#include "inttypes.h" +#include "uart_sender.h" + +static TaskHandle_t ble_scan_timer_task = NULL; +static bluetooth_adv_scanner_cb_t display_records_cb = NULL; +static int ble_scan_duration = 0; +static bool ble_scanner_active = false; +static esp_ble_scan_filter_t ble_scan_filter = BLE_SCAN_FILTER_ALLOW_ALL; +static esp_ble_scan_type_t ble_scan_type = BLE_SCAN_TYPE_ACTIVE; +static void task_scanner_timer(); +static void handle_bt_gapc_events(esp_gap_ble_cb_event_t event_type, + esp_ble_gap_cb_param_t* param); + +void set_filter_type(uint8_t filter_type) { + ble_scan_filter = filter_type; +} + +void set_scan_type(uint8_t scan_type) { + ble_scan_type = scan_type; +} + +void ble_scanner_begin() { + // #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 = + bt_gattc_set_default_ble_filter_service_uuid(), + .remote_filter_char_uuid = bt_gattc_set_default_ble_filter_char_uuid(), + .notify_descr_uuid = bt_gattc_set_default_ble_notify_descr_uuid(), + .ble_scan_params = bt_gattc_set_default_ble_scan_params()}; + scan_params.ble_scan_params.scan_filter_policy = ble_scan_filter; + scan_params.ble_scan_params.scan_type = ble_scan_type; + bt_gattc_set_ble_scan_params(&scan_params); + bt_client_event_cb_t event_cb = {.handler_gattc_cb = NULL, + .handler_gapc_cb = handle_bt_gapc_events}; + bt_gattc_set_cb(event_cb); + bt_gattc_task_begin(); + ble_scanner_active = true; + xTaskCreate(task_scanner_timer, "ble_scanner", 4096, NULL, 5, + &ble_scan_timer_task); +} + +static void handle_bt_gapc_events(esp_gap_ble_cb_event_t event_type, + esp_ble_gap_cb_param_t* param) { + switch (event_type) { + case ESP_GAP_BLE_SCAN_RESULT_EVT: + esp_ble_gap_cb_param_t* scan_result = (esp_ble_gap_cb_param_t*) param; + switch (scan_result->scan_rst.search_evt) { + case ESP_GAP_SEARCH_INQ_RES_EVT: + if (!ble_scanner_active) { + break; + } + uart_sender_send_packet_ble(UART_SENDER_PACKET_TYPE_BLE, scan_result); + if (display_records_cb != NULL) { + display_records_cb(scan_result); + } + ESP_LOGI(TAG_BLE_CLIENT_MODULE, "New ADV found"); + break; + case ESP_GAP_SEARCH_INQ_CMPL_EVT: + break; + default: + break; + } + break; + default: + break; + } +} + +void ble_scanner_register_cb(bluetooth_adv_scanner_cb_t callback) { + display_records_cb = callback; +} + +static void task_scanner_timer() { + ESP_LOGI(TAG_BLE_CLIENT_MODULE, "Trackers task started"); + ble_scan_duration = 0; + while (ble_scanner_active) { + if (ble_scan_duration >= SCANNER_SCAN_DURATION) { + ESP_LOGI(TAG_BLE_CLIENT_MODULE, "Trackers task stopped"); + ble_scanner_stop(); + } + ble_scan_duration++; + vTaskDelay(1000 / portTICK_PERIOD_MS); + } +} + +void ble_scanner_stop() { + ble_scanner_active = false; + ESP_LOGI(TAG_BLE_CLIENT_MODULE, "Trackers task stopped"); + if (ble_scan_timer_task != NULL) { + ESP_LOGI(TAG_BLE_CLIENT_MODULE, "Trackers task stopped"); + vTaskSuspend(ble_scan_timer_task); + } + ESP_LOGI(TAG_BLE_CLIENT_MODULE, "Trackers task stopped"); + ble_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"); +} + +bool ble_scanner_is_active() { + return ble_scanner_active; +} diff --git a/firmware/components/ble_scann/ble_scann.h b/firmware/components/ble_scann/ble_scann.h new file mode 100644 index 00000000..e7457639 --- /dev/null +++ b/firmware/components/ble_scann/ble_scann.h @@ -0,0 +1,77 @@ +#include "esp_bt.h" +#include "esp_bt_defs.h" +#include "esp_bt_main.h" +#include "esp_gap_ble_api.h" +#include "esp_gatt_common_api.h" +#include "esp_gattc_api.h" +#include "esp_gatts_api.h" +#ifndef BLE_SCANNER_H + #define BLE_SCANNER_H + #define TAG_BLE_CLIENT_MODULE "scanner_module:main" + #define SCANNER_REMOTE_SERVICE_UUID 0x00FF + #define SCANNER_REMOTE_NOTIFY_CHAR_UUID 0xFF01 + #define SCANNER_PROFILE_NUM 1 + #define SCANNER_PROFILE_A_APP_ID 0 + #define SCANNER_INVALID_HANDLE 0 + #define SCANNER_SCAN_DURATION 60 + +/** + * @brief Structure to store the tracker profile + * + */ +typedef struct { + int rssi; + char* name; + char* vendor; + uint8_t mac_address[6]; + uint8_t adv_data[31]; + uint8_t adv_data_length; + bool is_tracker; +} device_profile; + +/** + * @brief Structure to store the tracker advertisement comparison + * + */ +typedef struct { + uint8_t adv_cmp[4]; + char* name; + char* vendor; +} scanner_adv_cmp_t; + +/** + * @brief Callback to handle the bluetooth scanner + * + * @param record The tracker profile record + */ +typedef void (*bluetooth_adv_scanner_cb_t)(esp_ble_gap_cb_param_t* record); + +/** + * @brief Register the callback to handle the bluetooth scanner + * + * @param cb The callback to handle the bluetooth scanner + */ +void ble_scanner_register_cb(bluetooth_adv_scanner_cb_t cb); + +/** + * @brief Start the bluetooth scanner + * + */ +void ble_scanner_begin(); + +/** + * @brief Stop the bluetooth scanner + * + */ +void ble_scanner_stop(); + +/** + * @brief Check if the bluetooth scanner is active + * + * @return true The bluetooth scanner is active + * @return false The bluetooth scanner is not active + */ +bool ble_scanner_is_active(); +void set_filter_type(uint8_t filter_type); +void set_scan_type(uint8_t scan_type); +#endif // BLE_SCANNER_H diff --git a/firmware/components/minino_config/Kconfig.projbuild b/firmware/components/minino_config/Kconfig.projbuild index 46ab71d6..181b9669 100644 --- a/firmware/components/minino_config/Kconfig.projbuild +++ b/firmware/components/minino_config/Kconfig.projbuild @@ -620,8 +620,12 @@ config BLUETOOTH_APP_HID default true help Enable or disable the Bluetooth HID application. +config BLUETOOTH_APP_ADV + bool "Enable ADV Scanner App" + default true + help + Enable or disable the Bluetooth ADV Scanner application. endif # BLUETOOTH_APPS_ENABLE - ################################# ZIGBEE ################################### config ZIGBEE_APPS_ENABLE diff --git a/firmware/components/uart_sender/CMakeLists.txt b/firmware/components/uart_sender/CMakeLists.txt index d208e3e0..a2a011bb 100644 --- a/firmware/components/uart_sender/CMakeLists.txt +++ b/firmware/components/uart_sender/CMakeLists.txt @@ -1,2 +1,3 @@ idf_component_register(SRCS "uart_sender.c" +PRIV_REQUIRES bt bt_gattc INCLUDE_DIRS ".") diff --git a/firmware/components/uart_sender/uart_sender.c b/firmware/components/uart_sender/uart_sender.c index 273c4454..bad38bf0 100644 --- a/firmware/components/uart_sender/uart_sender.c +++ b/firmware/components/uart_sender/uart_sender.c @@ -4,8 +4,24 @@ #include #include "esp_log.h" +#define BLE_ADDRESS_SIZE 6 +#define BLE_PDU_INFO_OFFSET 19 +#define BLE_ADDRESS_OFFSET 21 +#define BLE_PAYLOAD_OFFSET 27 + static bool is_uart_sender_initialized = false; +static unsigned char base_packet[] = { + 0x40, 0x53, // Start - TI packet + 0xc0, // Packet Info - TI Packet + 0x36, 0x00, // Packet Length - TI Packet + 0x8c, 0xc9, 0xaf, 0x01, 0x00, 0x00, // Timestamp - TI Packet + 0x25, // Channel - TI Packet + 0x00, 0x00, // Connection Event - TI Packet + 0x00, // Connection Info - TI Packet + 0xd6, 0xbe, 0x89, 0x8e, // Access Address - TI Packet +}; + /** * @brief Initialize the UART sender * @@ -55,3 +71,78 @@ void uart_sender_send_packet(uart_sender_packet_type type, printf("@E"); // End of packet printf("\n"); } + +// unsigned char array[] = { + +// // Header - BLE Packet +// 0x42, // PDU Info - BLE Packet +// 0x21, // AdvLen - BLE Packet +// 0x15, 0xc7, 0xbf, 0x84, 0x50, 0x4b, // AdvA - BLE Packet +// // Payload - BLE Packet +// 0x02, 0x01, 0x1a, 0x17, 0xff, +// 0x4c, 0x00, 0x09, 0x08, 0x13, 0x03, 0xc0, 0xa8, 0x00, 0xb2, 0x1b, 0x58, +// 0x16, 0x08, 0x00, 0xa6, 0x48, 0x4c, 0x4f, 0x71, 0xdf, 0xb7, 0xf1, 0x9b, +// 0xee, 0xc7, // RSSI - TI Packet 0x80, // Status - TI Packet 0x40, 0x45 // +// END - TI packet +// }; + +uint32_t calculate_ble_crc24(const uint8_t* data, size_t len) { + uint32_t crc = 0x555555; // Inicialización del CRC con 0x555555 + uint32_t poly = 0x65B; // Polinomio 0x65B + + for (size_t i = 0; i < len; i++) { + crc ^= ((uint32_t) data[i] << 16); // XOR el byte actual al CRC + + for (int j = 0; j < 8; j++) { // Procesar bit a bit + if (crc & 0x800000) { + crc = (crc << 1) ^ poly; + } else { + crc <<= 1; + } + } + } + + return (crc & 0xFFFFFF); // Retornar solo los 24 bits inferiores +} + +void uart_sender_send_packet_ble(uart_sender_packet_type type, + esp_ble_gap_cb_param_t* packet) { + uart_sender_init(); + uint8_t packet_length = + 1 + 1 + BLE_ADDRESS_SIZE + packet->scan_rst.adv_data_len; + for (int i = 0; i < sizeof(base_packet); i++) { + printf("%c", base_packet[i]); + } + unsigned char temp_packet[packet_length]; + uint8_t index = 0; + temp_packet[index] = packet->scan_rst.ble_evt_type; + index++; + temp_packet[index] = packet->scan_rst.adv_data_len; + index++; + for (int i = 0; i < BLE_ADDRESS_SIZE; i++) { + temp_packet[index] = packet->scan_rst.bda[i]; + index++; + } + for (int i = 0; i < packet->scan_rst.adv_data_len; i++) { + temp_packet[index] = packet->scan_rst.ble_adv[i]; + index++; + } + // printf("%c", packet->scan_rst.ble_evt_type); + // printf("%c", packet->scan_rst.adv_data_len); + // for (int i = 0; i < BLE_ADDRESS_SIZE; i++) { + // printf("%c", packet->scan_rst.bda[i]); + // } + // for (int i = 0; i < packet->scan_rst.adv_data_len; i++) { + // printf("%c", packet->scan_rst.ble_adv[i]); + // } + for (int i = 0; i < packet_length; i++) { + printf("%c", temp_packet[i]); + } + + uint16_t crc = calculate_ble_crc24(temp_packet, packet_length); + printf("%02x%02x", (crc >> 8) & 0xFF, crc & 0xFF); + printf("%c", packet->scan_rst.rssi); + printf("\x80"); // Status + printf("@E"); // End of packet + printf("\n"); +} diff --git a/firmware/components/uart_sender/uart_sender.h b/firmware/components/uart_sender/uart_sender.h index fbb91ece..b8c01ee1 100644 --- a/firmware/components/uart_sender/uart_sender.h +++ b/firmware/components/uart_sender/uart_sender.h @@ -1,11 +1,12 @@ #pragma once #include +#include "esp_gap_ble_api.h" #ifndef UART_SENDER #define UART_SENDER typedef enum { UART_SENDER_PACKET_TYPE_ZIGBEE = 0, - UART_SENDER_PACKET_TYPE_BT, + UART_SENDER_PACKET_TYPE_BLE, UART_SENDER_PACKET_TYPE_WIFI, UART_SENDER_PACKET_TYPE_THREAD, } uart_sender_packet_type; @@ -21,6 +22,8 @@ void uart_sender_send_packet(uart_sender_packet_type type, uint8_t* packet, uint8_t len); +void uart_sender_send_packet_ble(uart_sender_packet_type type, + esp_ble_gap_cb_param_t* packet); /** * @brief DeInitialize the UART sender * diff --git a/firmware/main/apps/ble/adv_scanner/adv_scan_module.c b/firmware/main/apps/ble/adv_scanner/adv_scan_module.c new file mode 100644 index 00000000..7d7e3319 --- /dev/null +++ b/firmware/main/apps/ble/adv_scanner/adv_scan_module.c @@ -0,0 +1,96 @@ +#include "adv_scan_screens.h" +#include "ble_scann.h" +#include "esp_log.h" +#include "esp_mac.h" +#include "general_submenu.h" +#include "menus_module.h" + +static uint16_t current_item = 0; + +static void adv_scanner_module_cb_event(uint8_t button_name, + uint8_t button_event); + +static void adv_scanner_module_reset_menu() { + current_item = 0; + adv_scanner_module_register_menu(GENERAL_TREE_APP_MENU); + adv_scanner_module_display_menu(current_item); + menus_module_set_app_state(true, adv_scanner_module_cb_event); +} + +static void adv_scanner_module_reset_start_menu() { + ble_scanner_register_cb(NULL); + menus_module_reset(); + adv_scanner_module_reset_menu(); +} + +static void adv_filter_selection(uint8_t selection) { + set_filter_type(selection); + adv_scanner_module_reset_menu(); +} + +static void adv_type_selection(uint8_t selection) { + set_scan_type(selection); + adv_scanner_module_reset_menu(); +} + +void adv_scanner_display_filter() { + general_submenu_menu_t adv_menu_filter; + adv_menu_filter.options = scan_filter_items; + adv_menu_filter.options_count = 4; + adv_menu_filter.select_cb = adv_filter_selection; + adv_menu_filter.exit_cb = adv_scanner_module_reset_menu; + general_submenu(adv_menu_filter); +} + +void adv_scanner_display_type() { + general_submenu_menu_t adv_menu_type; + adv_menu_type.options = scan_type_items; + adv_menu_type.options_count = 2; + adv_menu_type.select_cb = adv_type_selection; + adv_menu_type.exit_cb = adv_scanner_module_reset_menu; + general_submenu(adv_menu_type); +} + +static void adv_scanner_module_cb_event(uint8_t button_name, + uint8_t button_event) { + if (button_event != BUTTON_PRESS_DOWN) { + return; + } + switch (button_name) { + case BUTTON_UP: + current_item = current_item-- == 0 ? SCAN_MENU_COUNT - 1 : current_item; + adv_scanner_module_display_menu(current_item); + break; + case BUTTON_DOWN: + current_item = ++current_item > SCAN_MENU_COUNT - 1 ? 0 : current_item; + adv_scanner_module_display_menu(current_item); + break; + case BUTTON_RIGHT: + if (current_item == SCAN_TYPE) { + adv_scanner_display_type(); + } else if (current_item == SCAN_FILTER) { + adv_scanner_display_filter(); + } else if (current_item == SCAN_START) { + general_screen_display_card_information_handler( + "Scanning", "Scanning for devices", + adv_scanner_module_reset_start_menu, + adv_scanner_module_reset_start_menu); + ble_scanner_register_cb(adv_scanner_display_record); + ble_scanner_begin(); + } + current_item = 0; + + break; + case BUTTON_LEFT: + menus_module_restart(); + break; + default: + break; + } +} + +void adv_scanner_module_begin() { + adv_scanner_module_register_menu(GENERAL_TREE_APP_MENU); + adv_scanner_module_display_menu(current_item); + menus_module_set_app_state(true, adv_scanner_module_cb_event); +} diff --git a/firmware/main/apps/ble/adv_scanner/adv_scan_module.h b/firmware/main/apps/ble/adv_scanner/adv_scan_module.h new file mode 100644 index 00000000..9a694271 --- /dev/null +++ b/firmware/main/apps/ble/adv_scanner/adv_scan_module.h @@ -0,0 +1,5 @@ +#include +#ifndef ADV_SCAN_MODULE_H + #define ADV_SCAN_MODULE_H +void adv_scanner_module_begin(); +#endif // ADV_SCAN_MODULE_H diff --git a/firmware/main/apps/ble/adv_scanner/adv_scan_screens.c b/firmware/main/apps/ble/adv_scanner/adv_scan_screens.c new file mode 100644 index 00000000..965d96ac --- /dev/null +++ b/firmware/main/apps/ble/adv_scanner/adv_scan_screens.c @@ -0,0 +1,69 @@ +#include "adv_scan_screens.h" +#include +#include +#include "animations_task.h" +#include "freertos/FreeRTOS.h" +#include "general/general_screens.h" +#include "led_events.h" +#include "oled_screen.h" + +#define MAX_ITEMS_PER_SCREEN 5 + +static uint16_t hid_current_item = 0; +static esp_ble_gap_cb_param_t adv_list[MAX_ITEMS_PER_SCREEN]; +static uint8_t adv_list_count = 0; + +static const general_menu_t adv_menu_main = { + .menu_items = scan_menu_items, + .menu_count = SCAN_MENU_COUNT, + .menu_level = GENERAL_TREE_APP_MENU, +}; + +// static const general_menu_t adv_type = { +// .menu_items = scan_type_items, +// .menu_count = 2, +// .menu_level = GENERAL_TREE_APP_MENU, +// }; + +// static const general_menu_t adv_filter = { +// .menu_items = scan_filter_items, +// .menu_count = 4, +// .menu_level = GENERAL_TREE_APP_MENU, +// }; + +void adv_scanner_module_register_menu(menu_tree_t menu) { + switch (menu) { + case GENERAL_TREE_APP_MENU: + general_register_menu(&adv_menu_main); + break; + default: + general_register_menu(&adv_menu_main); + break; + } +} + +void adv_scanner_display_record(esp_ble_gap_cb_param_t* record) { + if (adv_list_count >= MAX_ITEMS_PER_SCREEN) { + adv_list_count = 0; + } + adv_list[adv_list_count] = *record; + + oled_screen_clear_buffer(); + oled_screen_display_text("< Back", 0, 0, OLED_DISPLAY_NORMAL); + oled_screen_display_text("ADV Type | RSSI", 0, 1, OLED_DISPLAY_NORMAL); + + char* row = (char*) malloc(17); + for (int i = 0; i < MAX_ITEMS_PER_SCREEN; i++) { + sprintf(row, "%s %d", evt_adv_type[adv_list[i].scan_rst.ble_evt_type], + adv_list[i].scan_rst.rssi); + oled_screen_display_text(row, 0, i + 2, OLED_DISPLAY_NORMAL); + } + oled_screen_display_show(); + adv_list_count++; +} + +void adv_scanner_module_display_menu(uint16_t current_item) { + led_control_run_effect(led_control_pulse_leds); + hid_current_item = current_item; + general_screen_display_menu(current_item); +} \ No newline at end of file diff --git a/firmware/main/apps/ble/adv_scanner/adv_scan_screens.h b/firmware/main/apps/ble/adv_scanner/adv_scan_screens.h new file mode 100644 index 00000000..eb4279e3 --- /dev/null +++ b/firmware/main/apps/ble/adv_scanner/adv_scan_screens.h @@ -0,0 +1,26 @@ +#include +#include +#include "esp_gap_ble_api.h" +#include "general/general_screens.h" +#ifndef ADV_SCAN_SCREENS_H + #define ADV_SCAN_SCREENS_H + +enum { + SCAN_TYPE, + SCAN_FILTER, + SCAN_START, + SCAN_MENU_COUNT +} scan_menu_item = SCAN_FILTER; +char* scan_menu_items[SCAN_MENU_COUNT] = {"Scan Type", "ADV Filter", "Start"}; + +char* scan_type_items[2] = {"Active", "Passive"}; +char* scan_filter_items[4] = {"Allow All", "Allow Only WLST", "Allow UND RPA", + "Allow WLST & RPA"}; +char* evt_adv_type[5] = {"IND", "DIRECT_IND", "SCAN_IND", "NONCONN_IND", + "SCAN_RSP"}; + +void adv_scanner_module_register_menu(menu_tree_t menu); +void adv_scanner_clear_screen(); +void adv_scanner_module_display_menu(uint16_t current_item); +void adv_scanner_display_record(esp_ble_gap_cb_param_t* record); +#endif // ADV_SCAN_SCREENS_H diff --git a/firmware/main/general/general_screens.c b/firmware/main/general/general_screens.c index 95b846bd..ac2ccae3 100644 --- a/firmware/main/general/general_screens.c +++ b/firmware/main/general/general_screens.c @@ -8,11 +8,13 @@ #define ARROWS_X_POS 118 #ifdef CONFIG_RESOLUTION_128X64 - #define ITEMOFFSET 2 - #define ITEM_PAGE_OFFSET 2 + #define ITEMOFFSET 2 + #define ITEM_PAGE_OFFSET 2 + #define MAX_ITEMS_PER_SCREEN 5 #else // CONFIG_RESOLUTION_128X32 - #define ITEMOFFSET 1 - #define ITEM_PAGE_OFFSET 1 + #define ITEMOFFSET 1 + #define ITEM_PAGE_OFFSET 1 + #define MAX_ITEMS_PER_SCREEN 3 #endif static uint8_t scrolling_option = 0; static const general_menu_t* current_menu_ctx = NULL; diff --git a/firmware/main/main.c b/firmware/main/main.c index effd4b71..15d71118 100644 --- a/firmware/main/main.c +++ b/firmware/main/main.c @@ -1,6 +1,7 @@ #include #include "apps/ble/hid_device/hid_module.h" #include "apps/ble/trackers/trackers_module.h" + #include "buzzer.h" #include "cat_console.h" #include "esp_log.h" diff --git a/firmware/main/modules/menus_module/menus_include/menus.h b/firmware/main/modules/menus_module/menus_include/menus.h index 6b513112..8fde279e 100644 --- a/firmware/main/modules/menus_module/menus_include/menus.h +++ b/firmware/main/modules/menus_module/menus_include/menus.h @@ -7,6 +7,7 @@ #include "trackers_module.h" #include "z_switch_module.h" +#include "adv_scan_module.h" #include "catdos_module.h" #include "deauth_module.h" #include "display_settings.h" @@ -55,6 +56,7 @@ typedef enum { MENU_BLUETOOTH_TRAKERS_SCAN, MENU_BLUETOOTH_SPAM, MENU_BLUETOOTH_HID, + MENU_BLUETOOTH_ADV, /* Zigbee applications */ MENU_ZIGBEE_SPOOFING, MENU_ZIGBEE_SWITCH, @@ -280,6 +282,15 @@ menu_t menus[] = { ////////////////////////////////// .on_exit_cb = NULL, .is_visible = true}, #endif + #ifdef CONFIG_BLUETOOTH_APP_ADV + {.display_name = "ADV Scanner", + .menu_idx = MENU_BLUETOOTH_ADV, + .parent_idx = MENU_BLUETOOTH_APPS, + .last_selected_submenu = 0, + .on_enter_cb = adv_scanner_module_begin, + .on_exit_cb = NULL, + .is_visible = true}, + #endif #endif #ifdef CONFIG_ZIGBEE_APPS_ENABLE {.display_name = "Zigbee", diff --git a/firmware/sdkconfig.defaults b/firmware/sdkconfig.defaults index 8dae4dfd..d57fa54d 100644 --- a/firmware/sdkconfig.defaults +++ b/firmware/sdkconfig.defaults @@ -99,6 +99,7 @@ CONFIG_BLUETOOTH_APPS_ENABLE=y CONFIG_BLUETOOTH_APP_TRAKERS=y CONFIG_BLUETOOTH_APP_SPAM=y CONFIG_BLUETOOTH_APP_HID=y +CONFIG_BLUETOOTH_APP_ADV=y ## ZIGBEE ## CONFIG_ZIGBEE_APPS_ENABLE=y CONFIG_ZIGBEE_APP_SPOOFING=y