Skip to content

Commit 069dd29

Browse files
committed
Revert "some fixes, trying to speed up bruteforce(unsuccessful)"
This reverts commit 61fee8e.
1 parent 60242cd commit 069dd29

File tree

6 files changed

+35
-40
lines changed

6 files changed

+35
-40
lines changed

applications/plugins/subbrute/helpers/subbrute_worker.c

+13-14
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ struct SubBruteWorker {
3131
#define SUBBRUTE_TXRX_WORKER_BUF_SIZE 2048
3232
#define SUBBRUTE_TXRX_WORKER_MAX_TXRX_SIZE 60
3333
#define SUBBRUTE_TXRX_WORKER_TIMEOUT_READ_WRITE_BUF 40
34-
#define SUBBRUTE_TX_TIMEOUT 1
34+
#define SUBBRUTE_TX_TIMEOUT 50
3535
#define SUBBRUTE_SEND_DELAY 260
3636

3737
/**
@@ -52,7 +52,7 @@ int32_t subbrute_worker_thread(void* context) {
5252
FURI_LOG_I(TAG, "Worker start");
5353
#endif
5454

55-
//instance->environment = subghz_environment_alloc();
55+
instance->environment = subghz_environment_alloc();
5656
instance->transmitter = subghz_transmitter_alloc_init(
5757
instance->environment, string_get_cstr(instance->protocol_name));
5858

@@ -64,7 +64,7 @@ int32_t subbrute_worker_thread(void* context) {
6464
furi_hal_gpio_write(&gpio_cc1101_g0, true);
6565

6666
// Set ready to transmit value
67-
//instance->last_time_tx_data = furi_get_tick() - SUBBRUTE_SEND_DELAY;
67+
instance->last_time_tx_data = furi_get_tick() - SUBBRUTE_SEND_DELAY;
6868

6969
while(instance->worker_running) {
7070
// Transmit
@@ -80,8 +80,8 @@ int32_t subbrute_worker_thread(void* context) {
8080

8181
subghz_transmitter_free(instance->transmitter);
8282
instance->transmitter = NULL;
83-
/*subghz_environment_free(instance->environment);
84-
instance->environment = NULL;*/
83+
subghz_environment_free(instance->environment);
84+
instance->environment = NULL;
8585

8686
#ifdef FURI_DEBUG
8787
FURI_LOG_I(TAG, "Worker stop");
@@ -117,10 +117,10 @@ void subbrute_worker_free(SubBruteWorker* instance) {
117117
instance->transmitter = NULL;
118118
}
119119

120-
/*if(instance->environment != NULL) {
120+
if(instance->environment != NULL) {
121121
subghz_environment_free(instance->environment);
122122
instance->environment = NULL;
123-
}*/
123+
}
124124

125125
furi_thread_free(instance->thread);
126126
flipper_format_free(instance->flipper_format);
@@ -190,10 +190,9 @@ bool subbrute_worker_is_running(SubBruteWorker* instance) {
190190
}
191191

192192
bool subbrute_worker_can_transmit(SubBruteWorker* instance) {
193-
UNUSED(instance);
194-
return true;
195-
//furi_assert(instance);
196-
//return (furi_get_tick() - instance->last_time_tx_data) > SUBBRUTE_SEND_DELAY;
193+
furi_assert(instance);
194+
195+
return (furi_get_tick() - instance->last_time_tx_data) > SUBBRUTE_SEND_DELAY;
197196
}
198197

199198
bool subbrute_worker_transmit(SubBruteWorker* instance, const char* payload) {
@@ -277,7 +276,7 @@ bool subbrute_worker_init_manual_transmit(
277276
FURI_LOG_I(TAG, "Frequency: %d", frequency);
278277
#endif
279278

280-
//instance->environment = subghz_environment_alloc();
279+
instance->environment = subghz_environment_alloc();
281280
instance->transmitter = subghz_transmitter_alloc_init(
282281
instance->environment, string_get_cstr(instance->protocol_name));
283282

@@ -311,8 +310,8 @@ void subbrute_worker_manual_transmit_stop(SubBruteWorker* instance) {
311310
subghz_transmitter_free(instance->transmitter);
312311
instance->transmitter = NULL;
313312
}
314-
/*subghz_environment_free(instance->environment);
315-
instance->environment = NULL;*/
313+
subghz_environment_free(instance->environment);
314+
instance->environment = NULL;
316315

317316
instance->is_manual_init = false;
318317
}

applications/plugins/subbrute/scenes/subbrute_scene_run_attack.c

+2-4
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ void subbrute_scene_run_attack_on_enter(void* context) {
3939
instance->device->frequency,
4040
instance->device->preset,
4141
string_get_cstr(instance->device->protocol_name));
42-
43-
notification_message(instance->notifications, &sequence_blink_start_magenta);
4442
}
4543

4644
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)
5957
} else if(event.type == SceneManagerEventTypeTick) {
6058
if(subbrute_worker_can_transmit(instance->worker)) {
6159
// Blink
60+
notification_message(instance->notifications, &sequence_blink_yellow_100);
6261

6362
if(subbrute_worker_manual_transmit(instance->worker, instance->device->payload)) {
6463
// Make payload for new iteration or exit
6564
if(instance->device->key_index + 1 > instance->device->max_value) {
6665
// End of list
67-
notification_message(instance->notifications, &sequence_single_vibro);
68-
notification_message(instance->notifications, &sequence_blink_stop);
6966
scene_manager_next_scene(instance->scene_manager, SubBruteSceneSetupAttack);
7067
} else {
7168
instance->device->key_index++;
@@ -76,6 +73,7 @@ bool subbrute_scene_run_attack_on_event(void* context, SceneManagerEvent event)
7673
}
7774

7875
// Stop
76+
notification_message(instance->notifications, &sequence_blink_stop);
7977
}
8078

8179
consumed = true;

applications/plugins/subbrute/scenes/subbrute_scene_setup_attack.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ bool subbrute_scene_setup_attack_on_event(void* context, SceneManagerEvent event
9494
}
9595
subbrute_attack_view_set_current_step(view, instance->device->key_index);
9696
} else if(event.event == SubBruteCustomEventTypeChangeStepUpMore) {
97-
// +50
98-
uint64_t value = instance->device->key_index + 50;
97+
// +100
98+
uint64_t value = instance->device->key_index + 100;
9999
if(value == instance->device->max_value) {
100100
instance->device->key_index += value;
101101
} else {
@@ -118,8 +118,8 @@ bool subbrute_scene_setup_attack_on_event(void* context, SceneManagerEvent event
118118
}
119119
subbrute_attack_view_set_current_step(view, instance->device->key_index);
120120
} else if(event.event == SubBruteCustomEventTypeChangeStepDownMore) {
121-
// -50
122-
uint64_t value = ((instance->device->key_index - 50) + instance->device->max_value);
121+
// -100
122+
uint64_t value = ((instance->device->key_index - 100) + instance->device->max_value);
123123
if(value == instance->device->max_value) {
124124
instance->device->key_index = value;
125125
} else {
@@ -129,7 +129,7 @@ bool subbrute_scene_setup_attack_on_event(void* context, SceneManagerEvent event
129129
} else if(event.event == SubBruteCustomEventTypeTransmitCustom) {
130130
if(subbrute_worker_can_transmit(instance->worker)) {
131131
// Blink
132-
notification_message(instance->notifications, &sequence_blink_magenta_10);
132+
notification_message(instance->notifications, &sequence_blink_green_100);
133133

134134
// if(!subbrute_attack_view_is_worker_running(view)) {
135135
// subbrute_attack_view_start_worker(

applications/plugins/subbrute/subbrute.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -142,18 +142,18 @@ SubBruteState* subbrute_alloc() {
142142
void subbrute_free(SubBruteState* instance) {
143143
furi_assert(instance);
144144

145-
// SubBruteWorker
145+
// SubBruteDevice
146146
#ifdef FURI_DEBUG
147147
FURI_LOG_D(TAG, "free SubBruteDevice");
148148
#endif
149-
subbrute_worker_stop(instance->worker);
150-
subbrute_worker_free(instance->worker);
149+
subbrute_device_free(instance->device);
151150

152-
// SubBruteDevice
151+
// SubBruteWorker
153152
#ifdef FURI_DEBUG
154153
FURI_LOG_D(TAG, "free SubBruteDevice");
155154
#endif
156-
subbrute_device_free(instance->device);
155+
subbrute_worker_stop(instance->worker);
156+
subbrute_worker_free(instance->worker);
157157

158158
// Notifications
159159
#ifdef FURI_DEBUG

applications/plugins/subbrute/subbrute_device.c

+6-8
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ SubBruteDevice* subbrute_device_alloc() {
6060
instance->receiver = NULL;
6161
instance->environment = NULL;
6262

63-
instance->environment = subghz_environment_alloc();
64-
6563
subbrute_device_attack_set_default_values(instance, SubBruteAttackCAME12bit307);
6664

6765
return instance;
@@ -339,7 +337,7 @@ SubBruteFileResult subbrute_device_attack_set(SubBruteDevice* instance, SubBrute
339337
}
340338

341339
// For non-file types we didn't set SubGhzProtocolDecoderBase
342-
//instance->environment = subghz_environment_alloc();
340+
instance->environment = subghz_environment_alloc();
343341
instance->receiver = subghz_receiver_alloc_init(instance->environment);
344342
subghz_receiver_set_filter(instance->receiver, SubGhzProtocolFlag_Decodable);
345343
furi_hal_subghz_reset();
@@ -361,10 +359,10 @@ SubBruteFileResult subbrute_device_attack_set(SubBruteDevice* instance, SubBrute
361359
protocol_check_result = SubBruteFileResultOk;
362360
}
363361

364-
//subghz_environment_free(instance->environment);
362+
subghz_environment_free(instance->environment);
365363
subghz_receiver_free(instance->receiver);
366364
instance->receiver = NULL;
367-
//instance->environment = NULL;
365+
instance->environment = NULL;
368366

369367
if(protocol_check_result != SubBruteFileResultOk) {
370368
return SubBruteFileResultProtocolNotFound;
@@ -428,7 +426,7 @@ uint8_t subbrute_device_load_from_file(SubBruteDevice* instance, string_t file_p
428426
string_init(temp_str);
429427
uint32_t temp_data32;
430428

431-
//instance->environment = subghz_environment_alloc();
429+
instance->environment = subghz_environment_alloc();
432430
instance->receiver = subghz_receiver_alloc_init(instance->environment);
433431
subghz_receiver_set_filter(instance->receiver, SubGhzProtocolFlag_Decodable);
434432
furi_hal_subghz_reset();
@@ -563,12 +561,12 @@ uint8_t subbrute_device_load_from_file(SubBruteDevice* instance, string_t file_p
563561
flipper_format_free(fff_data_file);
564562
furi_record_close(RECORD_STORAGE);
565563

566-
//subghz_environment_free(instance->environment);
564+
subghz_environment_free(instance->environment);
567565
subghz_receiver_free(instance->receiver);
568566

569567
instance->decoder_result = NULL;
570568
instance->receiver = NULL;
571-
//instance->environment = NULL;
569+
instance->environment = NULL;
572570

573571
if(result == SubBruteFileResultOk) {
574572
#ifdef FURI_DEBUG

applications/plugins/subbrute/views/subbrute_main_view.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -127,19 +127,19 @@ void subbrute_main_view_draw(Canvas* canvas, SubBruteMainViewModel* model) {
127127
if(m->index == position) {
128128
canvas_draw_str_aligned(
129129
canvas,
130-
4,
130+
64,
131131
9 + (item_position * item_height) + STATUS_BAR_Y_SHIFT,
132-
AlignLeft,
132+
AlignCenter,
133133
AlignCenter,
134134
str);
135135
elements_frame(
136136
canvas, 1, 1 + (item_position * item_height) + STATUS_BAR_Y_SHIFT, 124, 15);
137137
} else {
138138
canvas_draw_str_aligned(
139139
canvas,
140-
4,
140+
64,
141141
9 + (item_position * item_height) + STATUS_BAR_Y_SHIFT,
142-
AlignLeft,
142+
AlignCenter,
143143
AlignCenter,
144144
str);
145145
}

0 commit comments

Comments
 (0)