mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-13 21:38:36 -07:00
Update multi fuzzer and subghz remote
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
#include "subghz_remote_app_i.h"
|
||||
#include <dolphin/dolphin.h>
|
||||
|
||||
static bool subghz_remote_app_custom_event_callback(void* context, uint32_t event) {
|
||||
furi_assert(context);
|
||||
@@ -19,26 +18,23 @@ static void subghz_remote_app_tick_event_callback(void* context) {
|
||||
scene_manager_handle_tick_event(app->scene_manager);
|
||||
}
|
||||
|
||||
SubGhzRemoteApp* subghz_remote_app_alloc(char* p) {
|
||||
SubGhzRemoteApp* app = malloc(sizeof(SubGhzRemoteApp));
|
||||
static void subghz_remote_make_app_folder(SubGhzRemoteApp* app) {
|
||||
furi_assert(app);
|
||||
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
|
||||
// Migrate old users data
|
||||
storage_common_migrate(storage, EXT_PATH("unirf"), SUBREM_APP_FOLDER);
|
||||
storage_common_migrate(storage, EXT_PATH("subghz/unirf"), SUBREM_APP_FOLDER);
|
||||
|
||||
if(!storage_simply_mkdir(storage, SUBREM_APP_FOLDER)) {
|
||||
//FURI_LOG_E(TAG, "Could not create folder %s", SUBREM_APP_FOLDER);
|
||||
// FURI_LOG_E(TAG, "Could not create folder %s", SUBREM_APP_FOLDER);
|
||||
dialog_message_show_storage_error(app->dialogs, "Cannot create\napp folder");
|
||||
}
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
}
|
||||
|
||||
// // Enable power for External CC1101 if it is connected
|
||||
// furi_hal_subghz_enable_ext_power();
|
||||
// // Auto switch to internal radio if external radio is not available
|
||||
// furi_delay_ms(15);
|
||||
// if(!furi_hal_subghz_check_radio()) {
|
||||
// furi_hal_subghz_select_radio_type(SubGhzRadioInternal);
|
||||
// furi_hal_subghz_init_radio_type(SubGhzRadioInternal);
|
||||
// }
|
||||
SubGhzRemoteApp* subghz_remote_app_alloc() {
|
||||
SubGhzRemoteApp* app = malloc(sizeof(SubGhzRemoteApp));
|
||||
|
||||
furi_hal_power_suppress_charge_enter();
|
||||
|
||||
@@ -75,6 +71,20 @@ SubGhzRemoteApp* subghz_remote_app_alloc(char* p) {
|
||||
// Dialog
|
||||
app->dialogs = furi_record_open(RECORD_DIALOGS);
|
||||
|
||||
// TextInput
|
||||
app->text_input = text_input_alloc();
|
||||
view_dispatcher_add_view(
|
||||
app->view_dispatcher, SubRemViewIDTextInput, text_input_get_view(app->text_input));
|
||||
|
||||
// Widget
|
||||
app->widget = widget_alloc();
|
||||
view_dispatcher_add_view(
|
||||
app->view_dispatcher, SubRemViewIDWidget, widget_get_view(app->widget));
|
||||
|
||||
// Popup
|
||||
app->popup = popup_alloc();
|
||||
view_dispatcher_add_view(app->view_dispatcher, SubRemViewIDPopup, popup_get_view(app->popup));
|
||||
|
||||
// Remote view
|
||||
app->subrem_remote_view = subrem_view_remote_alloc();
|
||||
view_dispatcher_add_view(
|
||||
@@ -82,6 +92,13 @@ SubGhzRemoteApp* subghz_remote_app_alloc(char* p) {
|
||||
SubRemViewIDRemote,
|
||||
subrem_view_remote_get_view(app->subrem_remote_view));
|
||||
|
||||
// Edit Menu view
|
||||
app->subrem_edit_menu = subrem_view_edit_menu_alloc();
|
||||
view_dispatcher_add_view(
|
||||
app->view_dispatcher,
|
||||
SubRemViewIDEditMenu,
|
||||
subrem_view_edit_menu_get_view(app->subrem_edit_menu));
|
||||
|
||||
app->map_preset = malloc(sizeof(SubRemMapPreset));
|
||||
for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) {
|
||||
app->map_preset->subs_preset[i] = subrem_sub_file_preset_alloc();
|
||||
@@ -91,19 +108,7 @@ SubGhzRemoteApp* subghz_remote_app_alloc(char* p) {
|
||||
|
||||
subghz_txrx_set_need_save_callback(app->txrx, subrem_save_active_sub, app);
|
||||
|
||||
if(p && strlen(p)) {
|
||||
furi_string_set(app->file_path, p);
|
||||
subrem_map_file_load(app, furi_string_get_cstr(app->file_path));
|
||||
scene_manager_next_scene(app->scene_manager, SubRemSceneRemote);
|
||||
} else {
|
||||
#ifdef SUBREM_LIGHT
|
||||
scene_manager_next_scene(app->scene_manager, SubRemSceneOpenMapFile);
|
||||
#else
|
||||
scene_manager_next_scene(app->scene_manager, SubRemSceneStart);
|
||||
scene_manager_set_scene_state(
|
||||
app->scene_manager, SubRemSceneStart, SubmenuIndexSubRemOpenMapFile);
|
||||
#endif
|
||||
}
|
||||
app->map_not_saved = false;
|
||||
|
||||
return app;
|
||||
}
|
||||
@@ -113,11 +118,6 @@ void subghz_remote_app_free(SubGhzRemoteApp* app) {
|
||||
|
||||
furi_hal_power_suppress_charge_exit();
|
||||
|
||||
// // Disable power for External CC1101 if it was enabled and module is connected
|
||||
// furi_hal_subghz_disable_ext_power();
|
||||
// // Reinit SPI handles for internal radio / nfc
|
||||
// furi_hal_subghz_init_radio_type(SubGhzRadioInternal);
|
||||
|
||||
// Submenu
|
||||
view_dispatcher_remove_view(app->view_dispatcher, SubRemViewIDSubmenu);
|
||||
submenu_free(app->submenu);
|
||||
@@ -125,10 +125,26 @@ void subghz_remote_app_free(SubGhzRemoteApp* app) {
|
||||
// Dialog
|
||||
furi_record_close(RECORD_DIALOGS);
|
||||
|
||||
// TextInput
|
||||
view_dispatcher_remove_view(app->view_dispatcher, SubRemViewIDTextInput);
|
||||
text_input_free(app->text_input);
|
||||
|
||||
// Widget
|
||||
view_dispatcher_remove_view(app->view_dispatcher, SubRemViewIDWidget);
|
||||
widget_free(app->widget);
|
||||
|
||||
// Popup
|
||||
view_dispatcher_remove_view(app->view_dispatcher, SubRemViewIDPopup);
|
||||
popup_free(app->popup);
|
||||
|
||||
// Remote view
|
||||
view_dispatcher_remove_view(app->view_dispatcher, SubRemViewIDRemote);
|
||||
subrem_view_remote_free(app->subrem_remote_view);
|
||||
|
||||
// Edit view
|
||||
view_dispatcher_remove_view(app->view_dispatcher, SubRemViewIDEditMenu);
|
||||
subrem_view_edit_menu_free(app->subrem_edit_menu);
|
||||
|
||||
scene_manager_free(app->scene_manager);
|
||||
view_dispatcher_free(app->view_dispatcher);
|
||||
|
||||
@@ -152,10 +168,33 @@ void subghz_remote_app_free(SubGhzRemoteApp* app) {
|
||||
free(app);
|
||||
}
|
||||
|
||||
int32_t subghz_remote_app(char* p) {
|
||||
UNUSED(p);
|
||||
dolphin_deed(DolphinDeedPluginStart);
|
||||
SubGhzRemoteApp* subghz_remote_app = subghz_remote_app_alloc(p);
|
||||
int32_t subghz_remote_app(void* arg) {
|
||||
SubGhzRemoteApp* subghz_remote_app = subghz_remote_app_alloc();
|
||||
|
||||
subghz_remote_make_app_folder(subghz_remote_app);
|
||||
|
||||
bool map_loaded = false;
|
||||
|
||||
if((arg != NULL) && (strlen(arg) != 0)) {
|
||||
furi_string_set(subghz_remote_app->file_path, (const char*)arg);
|
||||
SubRemLoadMapState load_state = subrem_map_file_load(
|
||||
subghz_remote_app, furi_string_get_cstr(subghz_remote_app->file_path));
|
||||
|
||||
if(load_state == SubRemLoadMapStateOK || load_state == SubRemLoadMapStateNotAllOK) {
|
||||
map_loaded = true;
|
||||
} else {
|
||||
// TODO Replace
|
||||
dialog_message_show_storage_error(subghz_remote_app->dialogs, "Cannot load\nmap file");
|
||||
}
|
||||
}
|
||||
|
||||
if(map_loaded) {
|
||||
scene_manager_next_scene(subghz_remote_app->scene_manager, SubRemSceneRemote);
|
||||
} else {
|
||||
furi_string_set(subghz_remote_app->file_path, SUBREM_APP_FOLDER);
|
||||
scene_manager_next_scene(subghz_remote_app->scene_manager, SubRemSceneStart);
|
||||
scene_manager_next_scene(subghz_remote_app->scene_manager, SubRemSceneOpenMapFile);
|
||||
}
|
||||
|
||||
view_dispatcher_run(subghz_remote_app->view_dispatcher);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user