diff --git a/applications/plugins/subbrute/helpers/subbrute_worker.c b/applications/plugins/subbrute/helpers/subbrute_worker.c index 22e0e7ec4..c821506a2 100644 --- a/applications/plugins/subbrute/helpers/subbrute_worker.c +++ b/applications/plugins/subbrute/helpers/subbrute_worker.c @@ -31,7 +31,7 @@ struct SubBruteWorker { #define SUBBRUTE_TXRX_WORKER_BUF_SIZE 2048 #define SUBBRUTE_TXRX_WORKER_MAX_TXRX_SIZE 60 #define SUBBRUTE_TXRX_WORKER_TIMEOUT_READ_WRITE_BUF 40 -#define SUBBRUTE_TX_TIMEOUT 50 +#define SUBBRUTE_TX_TIMEOUT 1 #define SUBBRUTE_SEND_DELAY 260 /** @@ -52,7 +52,7 @@ int32_t subbrute_worker_thread(void* context) { FURI_LOG_I(TAG, "Worker start"); #endif - instance->environment = subghz_environment_alloc(); + //instance->environment = subghz_environment_alloc(); instance->transmitter = subghz_transmitter_alloc_init( instance->environment, string_get_cstr(instance->protocol_name)); @@ -64,7 +64,7 @@ int32_t subbrute_worker_thread(void* context) { furi_hal_gpio_write(&gpio_cc1101_g0, true); // Set ready to transmit value - instance->last_time_tx_data = furi_get_tick() - SUBBRUTE_SEND_DELAY; + //instance->last_time_tx_data = furi_get_tick() - SUBBRUTE_SEND_DELAY; while(instance->worker_running) { // Transmit @@ -80,8 +80,8 @@ int32_t subbrute_worker_thread(void* context) { subghz_transmitter_free(instance->transmitter); instance->transmitter = NULL; - subghz_environment_free(instance->environment); - instance->environment = NULL; + /*subghz_environment_free(instance->environment); + instance->environment = NULL;*/ #ifdef FURI_DEBUG FURI_LOG_I(TAG, "Worker stop"); @@ -117,10 +117,10 @@ void subbrute_worker_free(SubBruteWorker* instance) { instance->transmitter = NULL; } - if(instance->environment != NULL) { + /*if(instance->environment != NULL) { subghz_environment_free(instance->environment); instance->environment = NULL; - } + }*/ furi_thread_free(instance->thread); flipper_format_free(instance->flipper_format); @@ -190,9 +190,10 @@ bool subbrute_worker_is_running(SubBruteWorker* instance) { } bool subbrute_worker_can_transmit(SubBruteWorker* instance) { - furi_assert(instance); - - return (furi_get_tick() - instance->last_time_tx_data) > SUBBRUTE_SEND_DELAY; + UNUSED(instance); + return true; + //furi_assert(instance); + //return (furi_get_tick() - instance->last_time_tx_data) > SUBBRUTE_SEND_DELAY; } bool subbrute_worker_transmit(SubBruteWorker* instance, const char* payload) { @@ -276,7 +277,7 @@ bool subbrute_worker_init_manual_transmit( FURI_LOG_I(TAG, "Frequency: %d", frequency); #endif - instance->environment = subghz_environment_alloc(); + //instance->environment = subghz_environment_alloc(); instance->transmitter = subghz_transmitter_alloc_init( instance->environment, string_get_cstr(instance->protocol_name)); @@ -310,8 +311,8 @@ void subbrute_worker_manual_transmit_stop(SubBruteWorker* instance) { subghz_transmitter_free(instance->transmitter); instance->transmitter = NULL; } - subghz_environment_free(instance->environment); - instance->environment = NULL; + /*subghz_environment_free(instance->environment); + instance->environment = NULL;*/ instance->is_manual_init = false; } diff --git a/applications/plugins/subbrute/scenes/subbrute_scene_run_attack.c b/applications/plugins/subbrute/scenes/subbrute_scene_run_attack.c index 36a9e86f9..209eb9df8 100644 --- a/applications/plugins/subbrute/scenes/subbrute_scene_run_attack.c +++ b/applications/plugins/subbrute/scenes/subbrute_scene_run_attack.c @@ -39,6 +39,8 @@ void subbrute_scene_run_attack_on_enter(void* context) { instance->device->frequency, instance->device->preset, string_get_cstr(instance->device->protocol_name)); + + notification_message(instance->notifications, &sequence_blink_start_magenta); } bool subbrute_scene_run_attack_on_event(void* context, SceneManagerEvent event) { @@ -57,12 +59,13 @@ bool subbrute_scene_run_attack_on_event(void* context, SceneManagerEvent event) } else if(event.type == SceneManagerEventTypeTick) { if(subbrute_worker_can_transmit(instance->worker)) { // Blink - notification_message(instance->notifications, &sequence_blink_yellow_100); if(subbrute_worker_manual_transmit(instance->worker, instance->device->payload)) { // Make payload for new iteration or exit if(instance->device->key_index + 1 > instance->device->max_value) { // End of list + notification_message(instance->notifications, &sequence_single_vibro); + notification_message(instance->notifications, &sequence_blink_stop); scene_manager_next_scene(instance->scene_manager, SubBruteSceneSetupAttack); } else { instance->device->key_index++; @@ -73,7 +76,6 @@ bool subbrute_scene_run_attack_on_event(void* context, SceneManagerEvent event) } // Stop - notification_message(instance->notifications, &sequence_blink_stop); } consumed = true; diff --git a/applications/plugins/subbrute/scenes/subbrute_scene_setup_attack.c b/applications/plugins/subbrute/scenes/subbrute_scene_setup_attack.c index 22d0a3a5f..7929b5d73 100644 --- a/applications/plugins/subbrute/scenes/subbrute_scene_setup_attack.c +++ b/applications/plugins/subbrute/scenes/subbrute_scene_setup_attack.c @@ -94,8 +94,8 @@ bool subbrute_scene_setup_attack_on_event(void* context, SceneManagerEvent event } subbrute_attack_view_set_current_step(view, instance->device->key_index); } else if(event.event == SubBruteCustomEventTypeChangeStepUpMore) { - // +100 - uint64_t value = instance->device->key_index + 100; + // +50 + uint64_t value = instance->device->key_index + 50; if(value == instance->device->max_value) { instance->device->key_index += value; } else { @@ -118,8 +118,8 @@ bool subbrute_scene_setup_attack_on_event(void* context, SceneManagerEvent event } subbrute_attack_view_set_current_step(view, instance->device->key_index); } else if(event.event == SubBruteCustomEventTypeChangeStepDownMore) { - // -100 - uint64_t value = ((instance->device->key_index - 100) + instance->device->max_value); + // -50 + uint64_t value = ((instance->device->key_index - 50) + instance->device->max_value); if(value == instance->device->max_value) { instance->device->key_index = value; } else { @@ -129,7 +129,7 @@ bool subbrute_scene_setup_attack_on_event(void* context, SceneManagerEvent event } else if(event.event == SubBruteCustomEventTypeTransmitCustom) { if(subbrute_worker_can_transmit(instance->worker)) { // Blink - notification_message(instance->notifications, &sequence_blink_green_100); + notification_message(instance->notifications, &sequence_blink_magenta_10); // if(!subbrute_attack_view_is_worker_running(view)) { // subbrute_attack_view_start_worker( diff --git a/applications/plugins/subbrute/subbrute.c b/applications/plugins/subbrute/subbrute.c index fb6e15882..b3cc25caf 100644 --- a/applications/plugins/subbrute/subbrute.c +++ b/applications/plugins/subbrute/subbrute.c @@ -142,12 +142,6 @@ SubBruteState* subbrute_alloc() { void subbrute_free(SubBruteState* instance) { furi_assert(instance); - // SubBruteDevice -#ifdef FURI_DEBUG - FURI_LOG_D(TAG, "free SubBruteDevice"); -#endif - subbrute_device_free(instance->device); - // SubBruteWorker #ifdef FURI_DEBUG FURI_LOG_D(TAG, "free SubBruteDevice"); @@ -155,6 +149,12 @@ void subbrute_free(SubBruteState* instance) { subbrute_worker_stop(instance->worker); subbrute_worker_free(instance->worker); + // SubBruteDevice +#ifdef FURI_DEBUG + FURI_LOG_D(TAG, "free SubBruteDevice"); +#endif + subbrute_device_free(instance->device); + // Notifications #ifdef FURI_DEBUG FURI_LOG_D(TAG, "free Notifications"); diff --git a/applications/plugins/subbrute/subbrute_device.c b/applications/plugins/subbrute/subbrute_device.c index 28b47562b..e8b33a9ec 100644 --- a/applications/plugins/subbrute/subbrute_device.c +++ b/applications/plugins/subbrute/subbrute_device.c @@ -60,6 +60,8 @@ SubBruteDevice* subbrute_device_alloc() { instance->receiver = NULL; instance->environment = NULL; + instance->environment = subghz_environment_alloc(); + subbrute_device_attack_set_default_values(instance, SubBruteAttackCAME12bit307); return instance; @@ -337,7 +339,7 @@ SubBruteFileResult subbrute_device_attack_set(SubBruteDevice* instance, SubBrute } // For non-file types we didn't set SubGhzProtocolDecoderBase - instance->environment = subghz_environment_alloc(); + //instance->environment = subghz_environment_alloc(); instance->receiver = subghz_receiver_alloc_init(instance->environment); subghz_receiver_set_filter(instance->receiver, SubGhzProtocolFlag_Decodable); furi_hal_subghz_reset(); @@ -359,10 +361,10 @@ SubBruteFileResult subbrute_device_attack_set(SubBruteDevice* instance, SubBrute protocol_check_result = SubBruteFileResultOk; } - subghz_environment_free(instance->environment); + //subghz_environment_free(instance->environment); subghz_receiver_free(instance->receiver); instance->receiver = NULL; - instance->environment = NULL; + //instance->environment = NULL; if(protocol_check_result != SubBruteFileResultOk) { return SubBruteFileResultProtocolNotFound; @@ -426,7 +428,7 @@ uint8_t subbrute_device_load_from_file(SubBruteDevice* instance, string_t file_p string_init(temp_str); uint32_t temp_data32; - instance->environment = subghz_environment_alloc(); + //instance->environment = subghz_environment_alloc(); instance->receiver = subghz_receiver_alloc_init(instance->environment); subghz_receiver_set_filter(instance->receiver, SubGhzProtocolFlag_Decodable); furi_hal_subghz_reset(); @@ -561,12 +563,12 @@ uint8_t subbrute_device_load_from_file(SubBruteDevice* instance, string_t file_p flipper_format_free(fff_data_file); furi_record_close(RECORD_STORAGE); - subghz_environment_free(instance->environment); + //subghz_environment_free(instance->environment); subghz_receiver_free(instance->receiver); instance->decoder_result = NULL; instance->receiver = NULL; - instance->environment = NULL; + //instance->environment = NULL; if(result == SubBruteFileResultOk) { #ifdef FURI_DEBUG diff --git a/applications/plugins/subbrute/views/subbrute_main_view.c b/applications/plugins/subbrute/views/subbrute_main_view.c index 141e3ce27..8d8bf477e 100644 --- a/applications/plugins/subbrute/views/subbrute_main_view.c +++ b/applications/plugins/subbrute/views/subbrute_main_view.c @@ -127,9 +127,9 @@ void subbrute_main_view_draw(Canvas* canvas, SubBruteMainViewModel* model) { if(m->index == position) { canvas_draw_str_aligned( canvas, - 64, + 4, 9 + (item_position * item_height) + STATUS_BAR_Y_SHIFT, - AlignCenter, + AlignLeft, AlignCenter, str); elements_frame( @@ -137,9 +137,9 @@ void subbrute_main_view_draw(Canvas* canvas, SubBruteMainViewModel* model) { } else { canvas_draw_str_aligned( canvas, - 64, + 4, 9 + (item_position * item_height) + STATUS_BAR_Y_SHIFT, - AlignCenter, + AlignLeft, AlignCenter, str); }