From 4588f38ae97ac6302008c2ff72fbf4c30bc4e4d6 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Wed, 7 Sep 2022 17:48:24 +0300 Subject: [PATCH] some fixes --- applications/meta/application.fam | 1 + applications/subbrute/application.fam | 2 +- .../scene/subbrute_scene_run_attack.c | 39 ++++++++----------- applications/subbrute/subbrute.c | 14 ++++++- 4 files changed, 32 insertions(+), 24 deletions(-) diff --git a/applications/meta/application.fam b/applications/meta/application.fam index f12249642..df2286269 100644 --- a/applications/meta/application.fam +++ b/applications/meta/application.fam @@ -78,5 +78,6 @@ App( "wifi_scanner", "multi_converter", "flipfrid", + "subbrute", ], ) \ No newline at end of file diff --git a/applications/subbrute/application.fam b/applications/subbrute/application.fam index 4002421dd..ed39c6c0e 100644 --- a/applications/subbrute/application.fam +++ b/applications/subbrute/application.fam @@ -6,5 +6,5 @@ App( cdefines=["APP_SUB_BRUTE"], requires=["gui","dialogs"], stack_size=2 * 1024, - order=70, + order=11, ) diff --git a/applications/subbrute/scene/subbrute_scene_run_attack.c b/applications/subbrute/scene/subbrute_scene_run_attack.c index d865588a5..40a688c24 100644 --- a/applications/subbrute/scene/subbrute_scene_run_attack.c +++ b/applications/subbrute/scene/subbrute_scene_run_attack.c @@ -39,8 +39,7 @@ void subbrute_emit(SubBruteState* context) { } furi_hal_subghz_stop_async_tx(); - furi_hal_subghz_sleep(); - furi_hal_power_suppress_charge_exit(); + furi_hal_subghz_idle(); } void prepare_emit(SubBruteState* context) { @@ -58,22 +57,19 @@ void prepare_emit(SubBruteState* context) { furi_hal_subghz_load_preset(str_to_preset(context->preset)); context->frequency = furi_hal_subghz_set_frequency_and_path(context->frequency); - - furi_hal_power_suppress_charge_enter(); } void clear_emit(SubBruteState* context) { furi_hal_subghz_stop_async_tx(); furi_hal_subghz_sleep(); - furi_hal_power_suppress_charge_exit(); if(context->attack == SubBruteAttackLoadFile) { subghz_transmitter_free(context->transmitter); } subghz_transmitter_free(context->transmitter); is_running = false; } - +/* void subbrute_send_raw_packet(SubBruteState* context) { string_reset(context->candidate); @@ -117,11 +113,9 @@ void subbrute_send_raw_packet(SubBruteState* context) { string_get_cstr(context->preset), string_get_cstr(context->candidate)); - prepare_emit(context); subbrute_emit(context); - clear_emit(context); } - +*/ void subbrute_send_packet_parsed(SubBruteState* context) { if(context->attack == SubBruteAttackLoadFile) { snprintf(subbrute_payload_byte, 4, "%02X ", (uint8_t)context->payload); @@ -157,17 +151,15 @@ void subbrute_send_packet_parsed(SubBruteState* context) { string_get_cstr(context->candidate), context->te); - prepare_emit(context); subbrute_emit(context); - clear_emit(context); } void subbrute_send_packet(SubBruteState* context) { - if(string_cmp_str(context->protocol, "RAW") == 0) { - subbrute_send_raw_packet(context); - } else { - subbrute_send_packet_parsed(context); - } + ///if(string_cmp_str(context->protocol, "RAW") == 0) { + // subbrute_send_raw_packet(context); + //} else { + subbrute_send_packet_parsed(context); + //} string_clear(context->flipper_format_string); } @@ -190,13 +182,14 @@ void subbrute_scene_run_attack_on_enter(SubBruteState* context) { context->environment = subghz_environment_alloc(); context->transmitter = subghz_transmitter_alloc_init(context->environment, string_get_cstr(context->protocol)); + prepare_emit(context); } void subbrute_scene_run_attack_on_exit(SubBruteState* context) { if(is_running) { is_running = false; - clear_emit(context); } + clear_emit(context); } void subbrute_scene_run_attack_on_tick(SubBruteState* context) { @@ -230,21 +223,22 @@ void subbrute_scene_run_attack_on_event(SubBruteEvent event, SubBruteState* cont if(event.input_type == InputTypeShort) { switch(event.key) { case InputKeyDown: + case InputKeyUp: + break; + case InputKeyLeft: if(!context->is_attacking && context->payload > 0x00) { context->payload--; subbrute_send_packet(context); notification_message(context->notify, &sequence_blink_blue_10); } break; - case InputKeyUp: + case InputKeyRight: if(!context->is_attacking && context->payload < max_value) { context->payload++; subbrute_send_packet(context); notification_message(context->notify, &sequence_blink_blue_10); } break; - case InputKeyLeft: - case InputKeyRight: case InputKeyOk: if(!context->is_attacking) { context->is_attacking = true; @@ -282,8 +276,9 @@ void subbrute_scene_run_attack_on_draw(Canvas* canvas, SubBruteState* context) { canvas_set_font(canvas, FontPrimary); canvas_draw_str_aligned(canvas, 64, 8, AlignCenter, AlignTop, "Fire in the hole!"); - char msg_index[22]; - snprintf(msg_index, sizeof(msg_index), "%04d / %04d", (int)context->payload, (int)max_value); + char msg_index[26]; + snprintf( + msg_index, sizeof(msg_index), "< %04d / %04d >", (int)context->payload, (int)max_value); canvas_draw_str_aligned(canvas, 64, 24, AlignCenter, AlignTop, msg_index); diff --git a/applications/subbrute/subbrute.c b/applications/subbrute/subbrute.c index 26aededec..7da9bc009 100644 --- a/applications/subbrute/subbrute.c +++ b/applications/subbrute/subbrute.c @@ -79,8 +79,11 @@ SubBruteState* subbrute_alloc() { void subbrute_free(SubBruteState* subbrute) { //Dialog furi_record_close(RECORD_DIALOGS); + notification_message(subbrute->notify, &sequence_blink_stop); + furi_record_close(RECORD_NOTIFICATION); + string_clear(subbrute->preset); string_clear(subbrute->candidate); @@ -91,6 +94,10 @@ void subbrute_free(SubBruteState* subbrute) { string_clear(subbrute->candidate); string_clear(subbrute->flipper_format_string); + flipper_format_free(subbrute->flipper_format); + subghz_environment_free(subbrute->environment); + subghz_receiver_free(subbrute->receiver); + // The rest free(subbrute); } @@ -109,9 +116,12 @@ int32_t subbrute_start(void* p) { if(!init_mutex(&subbrute_state_mutex, subbrute_state, sizeof(SubBruteState))) { FURI_LOG_E(TAG, "cannot create mutex\r\n"); furi_message_queue_free(event_queue); - free(subbrute_state); + subbrute_free(subbrute_state); + return 255; } + furi_hal_power_suppress_charge_enter(); + // Configure view port FURI_LOG_I(TAG, "Initializing viewport"); ViewPort* view_port = view_port_alloc(); @@ -220,6 +230,8 @@ int32_t subbrute_start(void* p) { furi_timer_stop(timer); furi_timer_free(timer); + furi_hal_power_suppress_charge_exit(); + FURI_LOG_I(TAG, "Cleaning up"); gui_remove_view_port(gui, view_port); view_port_free(view_port);