mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-17 04:34:44 -07:00
Update wifi marauder
This commit is contained in:
@@ -13,3 +13,4 @@ ADD_SCENE(wifi_marauder, script_stage_edit, ScriptStageEdit)
|
||||
ADD_SCENE(wifi_marauder, script_stage_add, ScriptStageAdd)
|
||||
ADD_SCENE(wifi_marauder, script_stage_edit_list, ScriptStageEditList)
|
||||
ADD_SCENE(wifi_marauder, sniffpmkid_options, SniffPmkidOptions)
|
||||
ADD_SCENE(wifi_marauder, flasher, Flasher)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "../wifi_marauder_app_i.h"
|
||||
|
||||
#include "../wifi_marauder_flasher.h"
|
||||
|
||||
char* _wifi_marauder_get_prefix_from_cmd(const char* command) {
|
||||
int end = strcspn(command, " ");
|
||||
char* prefix = (char*)malloc(sizeof(char) * (end + 1));
|
||||
@@ -101,13 +103,24 @@ void wifi_marauder_scene_console_output_on_enter(void* context) {
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, WifiMarauderAppViewConsoleOutput);
|
||||
|
||||
// Register callbacks to receive data
|
||||
wifi_marauder_uart_set_handle_rx_data_cb(
|
||||
app->uart,
|
||||
wifi_marauder_console_output_handle_rx_data_cb); // setup callback for general log rx thread
|
||||
// setup callback for general log rx thread
|
||||
if(app->flash_mode) {
|
||||
wifi_marauder_uart_set_handle_rx_data_cb(
|
||||
app->uart,
|
||||
wifi_marauder_flash_handle_rx_data_cb); // setup callback for general log rx thread
|
||||
} else {
|
||||
wifi_marauder_uart_set_handle_rx_data_cb(
|
||||
app->uart,
|
||||
wifi_marauder_console_output_handle_rx_data_cb); // setup callback for general log rx thread
|
||||
}
|
||||
wifi_marauder_uart_set_handle_rx_data_cb(
|
||||
app->lp_uart,
|
||||
wifi_marauder_console_output_handle_rx_packets_cb); // setup callback for packets rx thread
|
||||
|
||||
if(app->flash_mode) {
|
||||
wifi_marauder_flash_start_thread(app);
|
||||
}
|
||||
|
||||
// Get ready to send command
|
||||
if((app->is_command && app->selected_tx_string) || app->script) {
|
||||
const char* prefix =
|
||||
@@ -183,6 +196,10 @@ void wifi_marauder_scene_console_output_on_exit(void* context) {
|
||||
furi_delay_ms(50);
|
||||
}
|
||||
|
||||
if(app->flash_mode) {
|
||||
wifi_marauder_flash_stop_thread(app);
|
||||
}
|
||||
|
||||
// Unregister rx callback
|
||||
wifi_marauder_uart_set_handle_rx_data_cb(app->uart, NULL);
|
||||
wifi_marauder_uart_set_handle_rx_data_cb(app->lp_uart, NULL);
|
||||
|
||||
92
applications/external/wifi_marauder_companion/scenes/wifi_marauder_scene_flasher.c
vendored
Normal file
92
applications/external/wifi_marauder_companion/scenes/wifi_marauder_scene_flasher.c
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
#include "../wifi_marauder_app_i.h"
|
||||
|
||||
enum SubmenuIndex {
|
||||
SubmenuIndexBoot,
|
||||
SubmenuIndexPart,
|
||||
SubmenuIndexApp,
|
||||
SubmenuIndexFlash,
|
||||
};
|
||||
|
||||
static void wifi_marauder_scene_flasher_callback(void* context, uint32_t index) {
|
||||
WifiMarauderApp* app = context;
|
||||
|
||||
scene_manager_set_scene_state(app->scene_manager, WifiMarauderSceneFlasher, index);
|
||||
|
||||
// browse for files
|
||||
FuriString* predefined_filepath = furi_string_alloc_set_str(MARAUDER_APP_FOLDER);
|
||||
FuriString* selected_filepath = furi_string_alloc();
|
||||
DialogsFileBrowserOptions browser_options;
|
||||
dialog_file_browser_set_basic_options(&browser_options, ".bin", &I_Text_10x10);
|
||||
|
||||
// TODO refactor
|
||||
switch(index) {
|
||||
case SubmenuIndexBoot:
|
||||
if(dialog_file_browser_show(
|
||||
app->dialogs, selected_filepath, predefined_filepath, &browser_options)) {
|
||||
strncpy(
|
||||
app->bin_file_path_boot,
|
||||
furi_string_get_cstr(selected_filepath),
|
||||
sizeof(app->bin_file_path_boot));
|
||||
}
|
||||
break;
|
||||
case SubmenuIndexPart:
|
||||
if(dialog_file_browser_show(
|
||||
app->dialogs, selected_filepath, predefined_filepath, &browser_options)) {
|
||||
strncpy(
|
||||
app->bin_file_path_part,
|
||||
furi_string_get_cstr(selected_filepath),
|
||||
sizeof(app->bin_file_path_part));
|
||||
}
|
||||
break;
|
||||
case SubmenuIndexApp:
|
||||
if(dialog_file_browser_show(
|
||||
app->dialogs, selected_filepath, predefined_filepath, &browser_options)) {
|
||||
strncpy(
|
||||
app->bin_file_path_app,
|
||||
furi_string_get_cstr(selected_filepath),
|
||||
sizeof(app->bin_file_path_app));
|
||||
}
|
||||
break;
|
||||
case SubmenuIndexFlash:
|
||||
// TODO error checking
|
||||
scene_manager_next_scene(app->scene_manager, WifiMarauderSceneConsoleOutput);
|
||||
break;
|
||||
}
|
||||
|
||||
furi_string_free(selected_filepath);
|
||||
furi_string_free(predefined_filepath);
|
||||
}
|
||||
|
||||
void wifi_marauder_scene_flasher_on_enter(void* context) {
|
||||
WifiMarauderApp* app = context;
|
||||
|
||||
Submenu* submenu = app->submenu;
|
||||
|
||||
submenu_set_header(submenu, "Browse for files to flash");
|
||||
submenu_add_item(
|
||||
submenu, "Bootloader", SubmenuIndexBoot, wifi_marauder_scene_flasher_callback, app);
|
||||
submenu_add_item(
|
||||
submenu, "Partition Table", SubmenuIndexPart, wifi_marauder_scene_flasher_callback, app);
|
||||
submenu_add_item(
|
||||
submenu, "Application", SubmenuIndexApp, wifi_marauder_scene_flasher_callback, app);
|
||||
submenu_add_item(
|
||||
submenu, "[>] FLASH", SubmenuIndexFlash, wifi_marauder_scene_flasher_callback, app);
|
||||
|
||||
submenu_set_selected_item(
|
||||
submenu, scene_manager_get_scene_state(app->scene_manager, WifiMarauderSceneFlasher));
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, WifiMarauderAppViewSubmenu);
|
||||
}
|
||||
|
||||
bool wifi_marauder_scene_flasher_on_event(void* context, SceneManagerEvent event) {
|
||||
//WifiMarauderApp* app = context;
|
||||
UNUSED(context);
|
||||
UNUSED(event);
|
||||
bool consumed = false;
|
||||
|
||||
return consumed;
|
||||
}
|
||||
|
||||
void wifi_marauder_scene_flasher_on_exit(void* context) {
|
||||
WifiMarauderApp* app = context;
|
||||
submenu_reset(app->submenu);
|
||||
}
|
||||
@@ -121,6 +121,7 @@ const WifiMarauderItem items[NUM_MENU_ITEMS] = {
|
||||
{"Update", {"ota", "sd"}, 2, {"update -w", "update -s"}, NO_ARGS, FOCUS_CONSOLE_END, NO_TIP},
|
||||
{"Reboot", {""}, 1, {"reboot"}, NO_ARGS, FOCUS_CONSOLE_END, NO_TIP},
|
||||
{"Help", {""}, 1, {"help"}, NO_ARGS, FOCUS_CONSOLE_START, SHOW_STOPSCAN_TIP},
|
||||
{"Reflash ESP32 (WIP)", {""}, 1, {""}, NO_ARGS, FOCUS_CONSOLE_END, NO_TIP},
|
||||
{"Scripts", {""}, 1, {""}, NO_ARGS, FOCUS_CONSOLE_END, NO_TIP},
|
||||
{"Save to flipper sdcard", // keep as last entry or change logic in callback below
|
||||
{""},
|
||||
@@ -149,6 +150,17 @@ static void wifi_marauder_scene_start_var_list_enter_callback(void* context, uin
|
||||
item->focus_console;
|
||||
app->show_stopscan_tip = item->show_stopscan_tip;
|
||||
|
||||
// TODO cleanup
|
||||
if(index == NUM_MENU_ITEMS - 3) {
|
||||
// flasher
|
||||
app->is_command = false;
|
||||
app->flash_mode = true;
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, WifiMarauderEventStartFlasher);
|
||||
return;
|
||||
}
|
||||
|
||||
app->flash_mode = false;
|
||||
|
||||
if(!app->is_command && selected_option_index == 0) {
|
||||
// View Log from start
|
||||
view_dispatcher_send_custom_event(app->view_dispatcher, WifiMarauderEventStartLogViewer);
|
||||
@@ -260,6 +272,10 @@ bool wifi_marauder_scene_start_on_event(void* context, SceneManagerEvent event)
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager, WifiMarauderSceneStart, app->selected_menu_index);
|
||||
scene_manager_next_scene(app->scene_manager, WifiMarauderSceneSniffPmkidOptions);
|
||||
} else if(event.event == WifiMarauderEventStartFlasher) {
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager, WifiMarauderSceneStart, app->selected_menu_index);
|
||||
scene_manager_next_scene(app->scene_manager, WifiMarauderSceneFlasher);
|
||||
}
|
||||
consumed = true;
|
||||
} else if(event.type == SceneManagerEventTypeTick) {
|
||||
|
||||
@@ -46,7 +46,9 @@ void wifi_marauder_scene_text_input_on_enter(void* context) {
|
||||
// Setup view
|
||||
WIFI_TextInput* text_input = app->text_input;
|
||||
// Add help message to header
|
||||
if(app->special_case_input_step == 1) {
|
||||
if(app->flash_mode) {
|
||||
wifi_text_input_set_header_text(text_input, "Enter destination address");
|
||||
} else if(app->special_case_input_step == 1) {
|
||||
wifi_text_input_set_header_text(text_input, "Enter source MAC");
|
||||
} else if(0 == strncmp("ssid -a -g", app->selected_tx_string, strlen("ssid -a -g"))) {
|
||||
wifi_text_input_set_header_text(text_input, "Enter # SSIDs to generate");
|
||||
|
||||
Reference in New Issue
Block a user