diff --git a/applications/plugins/subbrute/helpers/subbrute_worker.c b/applications/plugins/subbrute/helpers/subbrute_worker.c index c821506a2ea..22e0e7ec4fa 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 1 +#define SUBBRUTE_TX_TIMEOUT 50 #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,10 +190,9 @@ bool subbrute_worker_is_running(SubBruteWorker* instance) { } bool subbrute_worker_can_transmit(SubBruteWorker* instance) { - UNUSED(instance); - return true; - //furi_assert(instance); - //return (furi_get_tick() - instance->last_time_tx_data) > SUBBRUTE_SEND_DELAY; + furi_assert(instance); + + return (furi_get_tick() - instance->last_time_tx_data) > SUBBRUTE_SEND_DELAY; } bool subbrute_worker_transmit(SubBruteWorker* instance, const char* payload) { @@ -277,7 +276,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)); @@ -311,8 +310,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 209eb9df838..36a9e86f97a 100644 --- a/applications/plugins/subbrute/scenes/subbrute_scene_run_attack.c +++ b/applications/plugins/subbrute/scenes/subbrute_scene_run_attack.c @@ -39,8 +39,6 @@ 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) { @@ -59,13 +57,12 @@ 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++; @@ -76,6 +73,7 @@ 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 7929b5d7372..22d0a3a5f27 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) { - // +50 - uint64_t value = instance->device->key_index + 50; + // +100 + uint64_t value = instance->device->key_index + 100; 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) { - // -50 - uint64_t value = ((instance->device->key_index - 50) + instance->device->max_value); + // -100 + uint64_t value = ((instance->device->key_index - 100) + 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_magenta_10); + notification_message(instance->notifications, &sequence_blink_green_100); // 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 b3cc25caf7f..fb6e158824a 100644 --- a/applications/plugins/subbrute/subbrute.c +++ b/applications/plugins/subbrute/subbrute.c @@ -142,18 +142,18 @@ SubBruteState* subbrute_alloc() { void subbrute_free(SubBruteState* instance) { furi_assert(instance); - // SubBruteWorker + // SubBruteDevice #ifdef FURI_DEBUG FURI_LOG_D(TAG, "free SubBruteDevice"); #endif - subbrute_worker_stop(instance->worker); - subbrute_worker_free(instance->worker); + subbrute_device_free(instance->device); - // SubBruteDevice + // SubBruteWorker #ifdef FURI_DEBUG FURI_LOG_D(TAG, "free SubBruteDevice"); #endif - subbrute_device_free(instance->device); + subbrute_worker_stop(instance->worker); + subbrute_worker_free(instance->worker); // Notifications #ifdef FURI_DEBUG diff --git a/applications/plugins/subbrute/subbrute_device.c b/applications/plugins/subbrute/subbrute_device.c index e8b33a9ec01..28b47562b9f 100644 --- a/applications/plugins/subbrute/subbrute_device.c +++ b/applications/plugins/subbrute/subbrute_device.c @@ -60,8 +60,6 @@ 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; @@ -339,7 +337,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(); @@ -361,10 +359,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; @@ -428,7 +426,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(); @@ -563,12 +561,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 8d8bf477e2b..141e3ce2728 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, - 4, + 64, 9 + (item_position * item_height) + STATUS_BAR_Y_SHIFT, - AlignLeft, + AlignCenter, AlignCenter, str); elements_frame( @@ -137,9 +137,9 @@ void subbrute_main_view_draw(Canvas* canvas, SubBruteMainViewModel* model) { } else { canvas_draw_str_aligned( canvas, - 4, + 64, 9 + (item_position * item_height) + STATUS_BAR_Y_SHIFT, - AlignLeft, + AlignCenter, AlignCenter, str); }