From 14a12b02efc595826114f78b75e5cb6559c9938e Mon Sep 17 00:00:00 2001 From: gid9798 <30450294+gid9798@users.noreply.github.com> Date: Fri, 26 May 2023 17:32:52 +0300 Subject: [PATCH] drop tx --- .../helpers/subrem_custom_event.h | 1 - .../scenes/subrem_scene_config.h | 3 +- .../scenes/subrem_scene_openmapfile.c | 1 - .../scenes/subrem_scene_remote.c | 130 ------------------ .../scenes/subrem_scene_start.c | 20 +-- .../subghz_remote_new/subghz_remote_app_i.c | 109 --------------- .../subghz_remote_new/subghz_remote_app_i.h | 7 - 7 files changed, 3 insertions(+), 268 deletions(-) delete mode 100644 applications/external/subghz_remote_new/scenes/subrem_scene_remote.c diff --git a/applications/external/subghz_remote_new/helpers/subrem_custom_event.h b/applications/external/subghz_remote_new/helpers/subrem_custom_event.h index 46ab8ad54..b6f752ba0 100644 --- a/applications/external/subghz_remote_new/helpers/subrem_custom_event.h +++ b/applications/external/subghz_remote_new/helpers/subrem_custom_event.h @@ -2,7 +2,6 @@ typedef enum { //SubmenuIndex - SubmenuIndexSubRemOpenMapFile, SubmenuIndexSubRemRemoteView, SubmenuIndexSubRemAbout, diff --git a/applications/external/subghz_remote_new/scenes/subrem_scene_config.h b/applications/external/subghz_remote_new/scenes/subrem_scene_config.h index 93d4de642..a07b93696 100644 --- a/applications/external/subghz_remote_new/scenes/subrem_scene_config.h +++ b/applications/external/subghz_remote_new/scenes/subrem_scene_config.h @@ -1,3 +1,2 @@ ADD_SCENE(subrem, start, Start) -ADD_SCENE(subrem, openmapfile, OpenMapFile) -ADD_SCENE(subrem, remote, Remote) \ No newline at end of file +ADD_SCENE(subrem, openmapfile, OpenMapFile) \ No newline at end of file diff --git a/applications/external/subghz_remote_new/scenes/subrem_scene_openmapfile.c b/applications/external/subghz_remote_new/scenes/subrem_scene_openmapfile.c index ea5c14a0a..8e6d9d0dd 100644 --- a/applications/external/subghz_remote_new/scenes/subrem_scene_openmapfile.c +++ b/applications/external/subghz_remote_new/scenes/subrem_scene_openmapfile.c @@ -19,7 +19,6 @@ void subrem_scene_openmapfile_on_enter(void* context) { #endif } if(load_state == SubRemLoadMapStateOK || load_state == SubRemLoadMapStateNotAllOK) { - scene_manager_next_scene(app->scene_manager, SubRemSceneRemote); } else { // TODO: Map Preset Reset if(!scene_manager_search_and_switch_to_previous_scene( diff --git a/applications/external/subghz_remote_new/scenes/subrem_scene_remote.c b/applications/external/subghz_remote_new/scenes/subrem_scene_remote.c deleted file mode 100644 index c24583233..000000000 --- a/applications/external/subghz_remote_new/scenes/subrem_scene_remote.c +++ /dev/null @@ -1,130 +0,0 @@ -#include "../subghz_remote_app_i.h" -#include "../views/remote.h" - -#include - -#define TAG "SubRemScenRemote" - -void subrem_scene_remote_callback(SubRemCustomEvent event, void* context) { - furi_assert(context); - SubGhzRemoteApp* app = context; - view_dispatcher_send_custom_event(app->view_dispatcher, event); -} - -void subrem_scene_remote_raw_callback_end_tx(void* context) { - furi_assert(context); - SubGhzRemoteApp* app = context; - view_dispatcher_send_custom_event(app->view_dispatcher, SubRemCustomEventViewRemoteForcedStop); -} - -static uint8_t subrem_scene_remote_event_to_index(SubRemCustomEvent event_id) { - uint8_t ret = 0; - - if(event_id == SubRemCustomEventViewRemoteStartUP) { - ret = SubRemSubKeyNameUp; - } else if(event_id == SubRemCustomEventViewRemoteStartDOWN) { - ret = SubRemSubKeyNameDown; - } else if(event_id == SubRemCustomEventViewRemoteStartLEFT) { - ret = SubRemSubKeyNameLeft; - } else if(event_id == SubRemCustomEventViewRemoteStartRIGHT) { - ret = SubRemSubKeyNameRight; - } else if(event_id == SubRemCustomEventViewRemoteStartOK) { - ret = SubRemSubKeyNameOk; - } - - return ret; -} - -static bool subrem_scene_remote_update_data_show(void* context) { - SubGhzRemoteApp* app = context; - bool ret = false; - - subrem_view_remote_add_data_to_show( - app->subrem_remote_view, - furi_string_get_cstr(app->subs_preset[0]->label), - furi_string_get_cstr(app->subs_preset[1]->label), - furi_string_get_cstr(app->subs_preset[2]->label), - furi_string_get_cstr(app->subs_preset[3]->label), - furi_string_get_cstr(app->subs_preset[4]->label)); - - return ret; -} - -void subrem_scene_remote_on_enter(void* context) { - SubGhzRemoteApp* app = context; - - subrem_scene_remote_update_data_show(app); - - subrem_view_remote_set_callback(app->subrem_remote_view, subrem_scene_remote_callback, app); - - view_dispatcher_switch_to_view(app->view_dispatcher, SubRemViewIDRemote); -} - -bool subrem_scene_remote_on_event(void* context, SceneManagerEvent event) { - SubGhzRemoteApp* app = context; - if(event.type == SceneManagerEventTypeCustom) { - if(event.event == SubRemCustomEventViewRemoteBack) { - if(!scene_manager_search_and_switch_to_previous_scene( - app->scene_manager, SubRemSceneOpenMapFile)) { - if(!scene_manager_search_and_switch_to_previous_scene( - app->scene_manager, SubRemSceneStart)) { - scene_manager_stop(app->scene_manager); - view_dispatcher_stop(app->view_dispatcher); - } - } - return true; - } else if( - event.event == SubRemCustomEventViewRemoteStartUP || - event.event == SubRemCustomEventViewRemoteStartDOWN || - event.event == SubRemCustomEventViewRemoteStartLEFT || - event.event == SubRemCustomEventViewRemoteStartRIGHT || - event.event == SubRemCustomEventViewRemoteStartOK) { - // Start sending sub - subrem_tx_stop_sub(app, true); - app->chusen_sub = subrem_scene_remote_event_to_index(event.event); - subrem_view_remote_set_state(app->subrem_remote_view, SubRemViewRemoteStateLoading); - if(subrem_tx_start_sub( - app, - app->subs_preset[app->chusen_sub], - subrem_scene_remote_raw_callback_end_tx)) { - subrem_view_remote_set_presed_btn(app->subrem_remote_view, app->chusen_sub); - subrem_view_remote_set_state( - app->subrem_remote_view, SubRemViewRemoteStateSending); - notification_message(app->notifications, &sequence_blink_start_magenta); - } else { - subrem_view_remote_set_state(app->subrem_remote_view, SubRemViewRemoteStateIdle); - notification_message(app->notifications, &sequence_blink_stop); - } - return true; - } else if(event.event == SubRemCustomEventViewRemoteForcedStop) { - subrem_tx_stop_sub(app, true); - subrem_view_remote_set_presed_btn(app->subrem_remote_view, 0); - subrem_view_remote_set_state(app->subrem_remote_view, SubRemViewRemoteStateIdle); - - notification_message(app->notifications, &sequence_blink_stop); - return true; - } else if(event.event == SubRemCustomEventViewRemoteStop) { - if(subrem_tx_stop_sub(app, false)) { - subrem_view_remote_set_presed_btn(app->subrem_remote_view, 0); - subrem_view_remote_set_state(app->subrem_remote_view, SubRemViewRemoteStateIdle); - - notification_message(app->notifications, &sequence_blink_stop); - } - return true; - } - } - // } else if(event.type == SceneManagerEventTypeTick) { - // } - return false; -} - -void subrem_scene_remote_on_exit(void* context) { - SubGhzRemoteApp* app = context; - - subrem_tx_stop_sub(app, true); - - subrem_view_remote_set_presed_btn(app->subrem_remote_view, 0); - subrem_view_remote_set_state(app->subrem_remote_view, SubRemViewRemoteStateIdle); - - notification_message(app->notifications, &sequence_blink_stop); -} diff --git a/applications/external/subghz_remote_new/scenes/subrem_scene_start.c b/applications/external/subghz_remote_new/scenes/subrem_scene_start.c index a4bfa5047..fd2d61c48 100644 --- a/applications/external/subghz_remote_new/scenes/subrem_scene_start.c +++ b/applications/external/subghz_remote_new/scenes/subrem_scene_start.c @@ -13,12 +13,6 @@ void subrem_scene_start_on_enter(void* context) { SubGhzRemoteApp* app = context; Submenu* submenu = app->submenu; - submenu_add_item( - submenu, - "Open Map File", - SubmenuIndexSubRemOpenMapFile, - subrem_scene_start_submenu_callback, - app); #if FURI_DEBUG submenu_add_item( submenu, @@ -37,7 +31,7 @@ void subrem_scene_start_on_enter(void* context) { // TODO: set scene state in subrem alloc // submenu_set_selected_item( // submenu, scene_manager_get_scene_state(app->scene_manager, SubRemSceneStart)); - submenu_set_selected_item(submenu, SubmenuIndexSubRemOpenMapFile); + submenu_set_selected_item(submenu, 0); view_dispatcher_switch_to_view(app->view_dispatcher, SubRemViewSubmenu); } @@ -47,22 +41,12 @@ bool subrem_scene_start_on_event(void* context, SceneManagerEvent event) { SubGhzRemoteApp* app = context; bool consumed = false; - + UNUSED(app); if(event.type == SceneManagerEventTypeCustom) { - if(event.event == SubmenuIndexSubRemOpenMapFile) { - scene_manager_next_scene(app->scene_manager, SubRemSceneOpenMapFile); - consumed = true; - } // } else if(event.event == SubmenuIndexSubRemAbout) { // scene_manager_next_scene(app->scene_manager, SubRemSceneAbout); // consumed = true; // } -#if FURI_DEBUG - else if(event.event == SubmenuIndexSubRemRemoteView) { - scene_manager_next_scene(app->scene_manager, SubRemSceneRemote); - consumed = true; - } -#endif } return consumed; diff --git a/applications/external/subghz_remote_new/subghz_remote_app_i.c b/applications/external/subghz_remote_new/subghz_remote_app_i.c index adc221941..aa8983951 100644 --- a/applications/external/subghz_remote_new/subghz_remote_app_i.c +++ b/applications/external/subghz_remote_new/subghz_remote_app_i.c @@ -163,115 +163,6 @@ bool subrem_save_protocol_to_file(FlipperFormat* flipper_format, const char* dev return saved; } -bool subrem_tx_start_sub( - SubGhzRemoteApp* app, - SubRemSubFilePreset* sub_preset, - SubGhzProtocolEncoderRAWCallbackEnd callback) { - furi_assert(app); - furi_assert(sub_preset); - bool ret = false; - - subrem_tx_stop_sub(app, true); - - if(sub_preset->type == SubGhzProtocolTypeUnknown) { - return false; - } - - FURI_LOG_I(TAG, "Send %s", furi_string_get_cstr(sub_preset->label)); - - // subghz_custom_btn_set(SUBGHZ_CUSTOM_BTN_OK); - // keeloq_reset_original_btn(); - // subghz_custom_btns_reset(); - - do { - flipper_format_rewind(sub_preset->fff_data); // - - app->transmitter = subghz_transmitter_alloc_init( - app->environment, furi_string_get_cstr(sub_preset->protocaol_name)); - - if(app->transmitter) { - if(subghz_transmitter_deserialize(app->transmitter, sub_preset->fff_data) != - SubGhzProtocolStatusOk) { - FURI_LOG_E(TAG, "Deserialize error!"); - break; - } - furi_hal_subghz_reset(); - furi_hal_subghz_idle(); - furi_hal_subghz_load_custom_preset(sub_preset->freq_preset.data); - furi_hal_gpio_init( - furi_hal_subghz.cc1101_g0_pin, GpioModeInput, GpioPullNo, GpioSpeedLow); - - furi_hal_subghz_idle(); - - furi_hal_subghz_set_frequency_and_path(sub_preset->freq_preset.frequency); - furi_hal_gpio_write(furi_hal_subghz.cc1101_g0_pin, false); - furi_hal_gpio_init( - furi_hal_subghz.cc1101_g0_pin, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow); - - if(!furi_hal_subghz_tx()) { - FURI_LOG_E(TAG, "Sending not allowed"); - break; - } - - if(sub_preset->type == SubGhzProtocolTypeRAW) { - subghz_protocol_raw_file_encoder_worker_set_callback_end( - (SubGhzProtocolEncoderRAW*)subghz_transmitter_get_protocol_instance( - app->transmitter), - callback, - app); - } - - furi_hal_subghz_start_async_tx(subghz_transmitter_yield, app->transmitter); - - ret = true; - } - } while(false); - - app->tx_running = ret; - - return ret; -} - -static void subghz_tx_stop(SubGhzRemoteApp* app) { - furi_assert(app); - - //Stop TX - furi_hal_subghz_stop_async_tx(); - - subghz_transmitter_stop(app->transmitter); - subghz_transmitter_free(app->transmitter); - furi_hal_subghz_idle(); -} - -bool subrem_tx_stop_sub(SubGhzRemoteApp* app, bool forced) { - furi_assert(app); - SubRemSubFilePreset* sub_preset = app->subs_preset[app->chusen_sub]; - - if(forced || (sub_preset->type != SubGhzProtocolTypeRAW)) { - // SubRemSubKeyTypeRawKey)) { - if(app->tx_running) { - subghz_tx_stop(app); - - if(sub_preset->type == SubGhzProtocolTypeDynamic) { - subrem_save_protocol_to_file( - sub_preset->fff_data, furi_string_get_cstr(sub_preset->file_path)); - - // keeloq_reset_mfname(); - // keeloq_reset_kl_type(); - // keeloq_reset_original_btn(); - // subghz_custom_btns_reset(); - // star_line_reset_mfname(); - // star_line_reset_kl_type(); - } - - app->tx_running = false; - return true; - } - } - - return false; -} - static SubRemLoadMapState subrem_map_preset_check(SubGhzRemoteApp* app, FlipperFormat* fff_data_file) { furi_assert(app); diff --git a/applications/external/subghz_remote_new/subghz_remote_app_i.h b/applications/external/subghz_remote_new/subghz_remote_app_i.h index 06abe659c..1bcb79d8f 100644 --- a/applications/external/subghz_remote_new/subghz_remote_app_i.h +++ b/applications/external/subghz_remote_new/subghz_remote_app_i.h @@ -76,10 +76,3 @@ typedef struct { } SubGhzRemoteApp; SubRemLoadMapState subrem_load_from_file(SubGhzRemoteApp* app); - -bool subrem_tx_start_sub( - SubGhzRemoteApp* app, - SubRemSubFilePreset* sub_preset, - SubGhzProtocolEncoderRAWCallbackEnd callback); - -bool subrem_tx_stop_sub(SubGhzRemoteApp* app, bool forced); \ No newline at end of file