-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
52da943
commit 07e14ef
Showing
10 changed files
with
209 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#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_filter_selection(uint8_t selection) { | ||
set_filter_type(selection); | ||
} | ||
|
||
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); | ||
} | ||
|
||
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_filter(); | ||
} else if (current_item == SCAN_START) { | ||
ESP_LOGI(TAG_BLE_CLIENT_MODULE, "Scan start"); | ||
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#include <stdint.h> | ||
#ifndef ADV_SCAN_MODULE_H | ||
#define ADV_SCAN_MODULE_H | ||
void adv_scanner_module_begin(); | ||
#endif // ADV_SCAN_MODULE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#include "adv_scan_screens.h" | ||
#include <stdint.h> | ||
#include <string.h> | ||
#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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include <stdbool.h> | ||
#include <stdint.h> | ||
#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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters