mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2024-12-29 16:25:47 +03:00
speed-up linear to 07:10
This commit is contained in:
parent
be7e11e60f
commit
cdcf80ed05
@ -4,17 +4,17 @@ App(
|
||||
apptype=FlipperAppType.METAPACKAGE,
|
||||
provides=[
|
||||
"gpio",
|
||||
"ibutton",
|
||||
"infrared",
|
||||
"lfrfid",
|
||||
"nfc",
|
||||
#"ibutton",
|
||||
#"infrared",
|
||||
#"lfrfid",
|
||||
#"nfc",
|
||||
"subghz",
|
||||
"bad_usb",
|
||||
"u2f",
|
||||
#"bad_usb",
|
||||
#"u2f",
|
||||
"fap_loader",
|
||||
"archive",
|
||||
"clock",
|
||||
"unirfremix",
|
||||
#"unirfremix",
|
||||
],
|
||||
)
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
#define TAG "SubBruteWorker"
|
||||
|
||||
struct SubBruteWorker {
|
||||
FuriThread* thread;
|
||||
// FuriThread* thread;
|
||||
volatile bool worker_running;
|
||||
volatile bool worker_manual_mode;
|
||||
bool is_manual_init;
|
||||
@ -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 10
|
||||
#define SUBBRUTE_SEND_DELAY 260
|
||||
|
||||
/**
|
||||
@ -92,11 +92,11 @@ int32_t subbrute_worker_thread(void* context) {
|
||||
SubBruteWorker* subbrute_worker_alloc() {
|
||||
SubBruteWorker* instance = malloc(sizeof(SubBruteWorker));
|
||||
|
||||
instance->thread = furi_thread_alloc();
|
||||
furi_thread_set_name(instance->thread, "SubBruteAttackWorker");
|
||||
furi_thread_set_stack_size(instance->thread, 2048);
|
||||
furi_thread_set_context(instance->thread, instance);
|
||||
furi_thread_set_callback(instance->thread, subbrute_worker_thread);
|
||||
// instance->thread = furi_thread_alloc();
|
||||
// furi_thread_set_name(instance->thread, "SubBruteAttackWorker");
|
||||
// furi_thread_set_stack_size(instance->thread, 2048);
|
||||
// furi_thread_set_context(instance->thread, instance);
|
||||
// furi_thread_set_callback(instance->thread, subbrute_worker_thread);
|
||||
|
||||
//instance->status = SubBruteWorkerStatusIDLE;
|
||||
instance->worker_running = false;
|
||||
@ -122,7 +122,7 @@ void subbrute_worker_free(SubBruteWorker* instance) {
|
||||
instance->environment = NULL;
|
||||
}
|
||||
|
||||
furi_thread_free(instance->thread);
|
||||
// furi_thread_free(instance->thread);
|
||||
flipper_format_free(instance->flipper_format);
|
||||
|
||||
string_clear(instance->protocol_name);
|
||||
@ -167,7 +167,7 @@ bool subbrute_worker_start(
|
||||
#endif
|
||||
instance->preset = preset;
|
||||
|
||||
furi_thread_start(instance->thread);
|
||||
// furi_thread_start(instance->thread);
|
||||
|
||||
return res;
|
||||
}
|
||||
@ -177,7 +177,7 @@ void subbrute_worker_stop(SubBruteWorker* instance) {
|
||||
|
||||
instance->worker_running = false;
|
||||
|
||||
furi_thread_join(instance->thread);
|
||||
// furi_thread_join(instance->thread);
|
||||
|
||||
furi_hal_subghz_set_path(FuriHalSubGhzPathIsolate);
|
||||
furi_hal_subghz_sleep();
|
||||
@ -195,6 +195,12 @@ bool subbrute_worker_can_transmit(SubBruteWorker* instance) {
|
||||
return (furi_get_tick() - instance->last_time_tx_data) > SUBBRUTE_SEND_DELAY;
|
||||
}
|
||||
|
||||
bool subbrute_worker_can_manual_transmit(SubBruteWorker* instance) {
|
||||
furi_assert(instance);
|
||||
|
||||
return !instance->worker_manual_mode;
|
||||
}
|
||||
|
||||
bool subbrute_worker_transmit(SubBruteWorker* instance, const char* payload) {
|
||||
furi_assert(instance);
|
||||
furi_assert(instance->worker_running);
|
||||
|
@ -26,6 +26,7 @@ void subbrute_worker_stop(SubBruteWorker* instance);
|
||||
//bool subbrute_worker_write(SubBruteWorker* instance, uint8_t* data, size_t size);
|
||||
bool subbrute_worker_is_running(SubBruteWorker* instance);
|
||||
bool subbrute_worker_can_transmit(SubBruteWorker* instance);
|
||||
bool subbrute_worker_can_manual_transmit(SubBruteWorker* instance);
|
||||
bool subbrute_worker_transmit(SubBruteWorker* instance, const char* payload);
|
||||
bool subbrute_worker_init_manual_transmit(SubBruteWorker* instance,
|
||||
uint32_t frequency,
|
||||
|
@ -3,6 +3,8 @@
|
||||
#include "../views/subbrute_attack_view.h"
|
||||
#include "../helpers/subbrute_worker.h"
|
||||
|
||||
#define TAG "SubBruteSceneRunAttack"
|
||||
|
||||
static void subbrute_scene_run_attack_callback(SubBruteCustomEvent event, void* context) {
|
||||
furi_assert(context);
|
||||
|
||||
@ -10,10 +12,53 @@ static void subbrute_scene_run_attack_callback(SubBruteCustomEvent event, void*
|
||||
view_dispatcher_send_custom_event(instance->view_dispatcher, event);
|
||||
}
|
||||
|
||||
//static void subbrute_scene_run_attack_worker_callback(void* context) {
|
||||
// SubBruteState* instance = (SubBruteState*)context;
|
||||
//
|
||||
// if(instance->locked || instance->device->key_index + 1 > instance->device->max_value) {
|
||||
// return;
|
||||
// }
|
||||
// instance->locked = true;
|
||||
//
|
||||
// if(subbrute_worker_can_manual_transmit(instance->worker)) {
|
||||
// // Blink
|
||||
// notification_message(instance->notifications, &sequence_blink_yellow_100);
|
||||
// subbrute_device_create_packet_parsed(instance->device, instance->device->key_index, true);
|
||||
//
|
||||
//#ifdef FURI_DEBUG
|
||||
// FURI_LOG_I(TAG, "subbrute_worker_manual_transmit");
|
||||
//#endif
|
||||
// if(subbrute_worker_manual_transmit(instance->worker, instance->device->payload)) {
|
||||
//#ifdef FURI_DEBUG
|
||||
// FURI_LOG_I(TAG, "transmit ok");
|
||||
//#endif
|
||||
// // Make payload for new iteration or exit
|
||||
// if(instance->device->key_index + 1 <= instance->device->max_value) {
|
||||
// instance->device->key_index++;
|
||||
// } else {
|
||||
// view_dispatcher_send_custom_event(
|
||||
// instance->view_dispatcher, SubBruteCustomEventTypeTransmitFinished);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // Stop
|
||||
// notification_message(instance->notifications, &sequence_blink_stop);
|
||||
// }
|
||||
//
|
||||
// instance->locked = false;
|
||||
// subbrute_attack_view_set_current_step(instance->view_attack, instance->device->key_index);
|
||||
//}
|
||||
|
||||
void subbrute_scene_run_attack_on_exit(void* context) {
|
||||
furi_assert(context);
|
||||
|
||||
SubBruteState* instance = (SubBruteState*)context;
|
||||
// SubBruteAttackState* state = (SubBruteAttackState*)scene_manager_get_scene_state(
|
||||
// instance->scene_manager, SubBruteSceneRunAttack);
|
||||
// furi_assert(state);
|
||||
//
|
||||
// furi_timer_free(state->timer);
|
||||
// free(state);
|
||||
|
||||
notification_message(instance->notifications, &sequence_blink_stop);
|
||||
}
|
||||
|
||||
@ -21,6 +66,10 @@ void subbrute_scene_run_attack_on_enter(void* context) {
|
||||
furi_assert(context);
|
||||
SubBruteState* instance = (SubBruteState*)context;
|
||||
SubBruteAttackView* view = instance->view_attack;
|
||||
//
|
||||
// SubBruteAttackState* state = malloc(sizeof(SubBruteAttackState));
|
||||
// scene_manager_set_scene_state(
|
||||
// instance->scene_manager, SubBruteSceneRunAttack, (uint32_t)state);
|
||||
|
||||
instance->current_view = SubBruteViewAttack;
|
||||
subbrute_attack_view_set_callback(view, subbrute_scene_run_attack_callback, instance);
|
||||
@ -33,42 +82,62 @@ void subbrute_scene_run_attack_on_enter(void* context) {
|
||||
instance->device->key_index,
|
||||
true);
|
||||
|
||||
// Start worker if not started
|
||||
subbrute_worker_init_manual_transmit(
|
||||
// Init worker with values
|
||||
if(!subbrute_worker_init_manual_transmit(
|
||||
instance->worker,
|
||||
instance->device->frequency,
|
||||
instance->device->preset,
|
||||
string_get_cstr(instance->device->protocol_name));
|
||||
string_get_cstr(instance->device->protocol_name))) {
|
||||
FURI_LOG_W(TAG, "Worker init failed!");
|
||||
}
|
||||
|
||||
// state->timer = furi_timer_alloc(
|
||||
// subbrute_scene_run_attack_worker_callback, FuriTimerTypePeriodic, instance);
|
||||
// furi_timer_start(state->timer, pdMS_TO_TICKS(100)); // 20 ms
|
||||
}
|
||||
|
||||
bool subbrute_scene_run_attack_on_event(void* context, SceneManagerEvent event) {
|
||||
SubBruteState* instance = (SubBruteState*)context;
|
||||
SubBruteAttackView* view = instance->view_attack;
|
||||
// SubBruteAttackState* state = (SubBruteAttackState*)scene_manager_get_scene_state(
|
||||
// instance->scene_manager, SubBruteSceneRunAttack);
|
||||
// furi_assert(state);
|
||||
|
||||
bool consumed = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
SubBruteAttackView* view = instance->view_attack;
|
||||
|
||||
if(event.event == SubBruteCustomEventTypeTransmitNotStarted ||
|
||||
event.event == SubBruteCustomEventTypeTransmitFinished ||
|
||||
event.event == SubBruteCustomEventTypeBackPressed) {
|
||||
// furi_timer_stop(state->timer);
|
||||
// Stop transmit
|
||||
scene_manager_next_scene(instance->scene_manager, SubBruteSceneSetupAttack);
|
||||
subbrute_attack_view_set_current_step(view, instance->device->key_index);
|
||||
scene_manager_search_and_switch_to_previous_scene(
|
||||
instance->scene_manager, SubBruteSceneSetupAttack);
|
||||
consumed = true;
|
||||
} else if (event.event == SubBruteCustomEventTypeUpdateView) {
|
||||
subbrute_attack_view_set_current_step(view, instance->device->key_index);
|
||||
}
|
||||
} else if(event.type == SceneManagerEventTypeTick) {
|
||||
if(subbrute_worker_can_transmit(instance->worker)) {
|
||||
if(subbrute_worker_can_manual_transmit(instance->worker)) {
|
||||
// Blink
|
||||
notification_message(instance->notifications, &sequence_blink_yellow_100);
|
||||
|
||||
subbrute_device_create_packet_parsed(
|
||||
instance->device, instance->device->key_index, true);
|
||||
|
||||
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
|
||||
scene_manager_next_scene(instance->scene_manager, SubBruteSceneSetupAttack);
|
||||
view_dispatcher_send_custom_event(
|
||||
instance->view_dispatcher, SubBruteCustomEventTypeTransmitFinished);
|
||||
} else {
|
||||
instance->device->key_index++;
|
||||
subbrute_attack_view_set_current_step(view, instance->device->key_index);
|
||||
subbrute_device_create_packet_parsed(
|
||||
instance->device, instance->device->key_index);
|
||||
view_dispatcher_send_custom_event(
|
||||
instance->view_dispatcher, SubBruteCustomEventTypeUpdateView);
|
||||
//subbrute_attack_view_set_current_step(view, instance->device->key_index);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,11 +27,13 @@ void subbrute_scene_setup_attack_on_enter(void* context) {
|
||||
instance->device->key_index,
|
||||
false);
|
||||
|
||||
subbrute_worker_init_manual_transmit(
|
||||
if(!subbrute_worker_init_manual_transmit(
|
||||
instance->worker,
|
||||
instance->device->frequency,
|
||||
instance->device->preset,
|
||||
string_get_cstr(instance->device->protocol_name));
|
||||
string_get_cstr(instance->device->protocol_name))) {
|
||||
FURI_LOG_W(TAG, "Worker init failed!");
|
||||
}
|
||||
|
||||
instance->current_view = SubBruteViewAttack;
|
||||
subbrute_attack_view_set_callback(view, subbrute_scene_setup_attack_callback, instance);
|
||||
@ -55,7 +57,7 @@ bool subbrute_scene_setup_attack_on_event(void* context, SceneManagerEvent event
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubBruteCustomEventTypeTransmitStarted) {
|
||||
subbrute_device_create_packet_parsed(instance->device, instance->device->key_index);
|
||||
subbrute_device_create_packet_parsed(instance->device, instance->device->key_index, false);
|
||||
scene_manager_next_scene(instance->scene_manager, SubBruteSceneRunAttack);
|
||||
} else if(event.event == SubBruteCustomEventTypeSaveFile) {
|
||||
subbrute_worker_manual_transmit_stop(instance->worker);
|
||||
@ -127,7 +129,7 @@ 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 == SubBruteCustomEventTypeTransmitCustom) {
|
||||
if(subbrute_worker_can_transmit(instance->worker)) {
|
||||
if(subbrute_worker_can_manual_transmit(instance->worker)) {
|
||||
// Blink
|
||||
notification_message(instance->notifications, &sequence_blink_green_100);
|
||||
|
||||
@ -139,7 +141,7 @@ bool subbrute_scene_setup_attack_on_event(void* context, SceneManagerEvent event
|
||||
// string_get_cstr(instance->device->protocol_name));
|
||||
// }
|
||||
subbrute_device_create_packet_parsed(
|
||||
instance->device, instance->device->key_index);
|
||||
instance->device, instance->device->key_index, false);
|
||||
subbrute_worker_manual_transmit(instance->worker, instance->device->payload);
|
||||
|
||||
// Stop
|
||||
|
@ -81,7 +81,7 @@ SubBruteState* subbrute_alloc() {
|
||||
view_dispatcher_set_navigation_event_callback(
|
||||
instance->view_dispatcher, subbrute_back_event_callback);
|
||||
view_dispatcher_set_tick_event_callback(
|
||||
instance->view_dispatcher, subbrute_tick_event_callback, 100);
|
||||
instance->view_dispatcher, subbrute_tick_event_callback, 10);
|
||||
|
||||
//Dialog
|
||||
instance->dialogs = furi_record_open(RECORD_DIALOGS);
|
||||
@ -297,6 +297,7 @@ int32_t subbrute_app(void* p) {
|
||||
scene_manager_next_scene(instance->scene_manager, SubBruteSceneStart);
|
||||
|
||||
furi_hal_power_suppress_charge_enter();
|
||||
notification_message(instance->notifications, &sequence_display_backlight_on);
|
||||
view_dispatcher_run(instance->view_dispatcher);
|
||||
furi_hal_power_suppress_charge_exit();
|
||||
subbrute_free(instance);
|
||||
|
@ -14,7 +14,7 @@ typedef enum {
|
||||
SubBruteCustomEventTypeTransmitNotStarted,
|
||||
SubBruteCustomEventTypeTransmitCustom,
|
||||
SubBruteCustomEventTypeSaveFile,
|
||||
SubBruteCustomEventTypeSaveSuccess,
|
||||
SubBruteCustomEventTypeUpdateView,
|
||||
SubBruteCustomEventTypeChangeStepUp,
|
||||
SubBruteCustomEventTypeChangeStepDown,
|
||||
SubBruteCustomEventTypeChangeStepUpMore,
|
||||
|
@ -37,6 +37,8 @@ static const char* subbrute_key_file_start =
|
||||
"Filetype: Flipper SubGhz Key File\nVersion: 1\nFrequency: %u\nPreset: %s\nProtocol: %s\nBit: %d";
|
||||
static const char* subbrute_key_file_key = "%s\nKey: %s\n";
|
||||
static const char* subbrute_key_file_princeton_end = "%s\nKey: %s\nTE: %d\n";
|
||||
static const char* subbrute_key_small_no_tail = "Bit: %d\nKey: %s\n";
|
||||
static const char* subbrute_key_small_with_tail = "Bit: %d\nKey: %s\nTE: %d\n";
|
||||
|
||||
// Why nobody set in as const in all codebase?
|
||||
static const char* preset_ook270_async = "FuriHalSubGhzPresetOok270Async";
|
||||
@ -107,7 +109,7 @@ bool subbrute_device_save_file(SubBruteDevice* instance, const char* dev_file_na
|
||||
#ifdef FURI_DEBUG
|
||||
FURI_LOG_D(TAG, "subbrute_device_save_file: %s", dev_file_name);
|
||||
#endif
|
||||
bool result = subbrute_device_create_packet_parsed(instance, instance->key_index);
|
||||
bool result = subbrute_device_create_packet_parsed(instance, instance->key_index, false);
|
||||
|
||||
if(!result) {
|
||||
FURI_LOG_E(TAG, "subbrute_device_create_packet_parsed failed!");
|
||||
@ -191,7 +193,7 @@ const char* subbrute_device_error_get_desc(SubBruteFileResult error_id) {
|
||||
return result;
|
||||
}
|
||||
|
||||
bool subbrute_device_create_packet_parsed(SubBruteDevice* instance, uint64_t step) {
|
||||
bool subbrute_device_create_packet_parsed(SubBruteDevice* instance, uint64_t step, bool small) {
|
||||
furi_assert(instance);
|
||||
|
||||
//char step_payload[32];
|
||||
@ -234,6 +236,24 @@ bool subbrute_device_create_packet_parsed(SubBruteDevice* instance, uint64_t ste
|
||||
FURI_LOG_D(TAG, "candidate: %s, step: %d", string_get_cstr(candidate), step);
|
||||
#endif
|
||||
|
||||
if (small) {
|
||||
if(instance->has_tail) {
|
||||
snprintf(
|
||||
instance->payload,
|
||||
sizeof(instance->payload),
|
||||
subbrute_key_small_with_tail,
|
||||
instance->bit,
|
||||
string_get_cstr(candidate),
|
||||
instance->te);
|
||||
} else {
|
||||
snprintf(
|
||||
instance->payload,
|
||||
sizeof(instance->payload),
|
||||
subbrute_key_small_no_tail,
|
||||
instance->bit,
|
||||
string_get_cstr(candidate));
|
||||
}
|
||||
} else {
|
||||
if(instance->has_tail) {
|
||||
snprintf(
|
||||
instance->payload,
|
||||
@ -250,6 +270,7 @@ bool subbrute_device_create_packet_parsed(SubBruteDevice* instance, uint64_t ste
|
||||
instance->file_template,
|
||||
string_get_cstr(candidate));
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef FURI_DEBUG
|
||||
//FURI_LOG_D(TAG, "payload: %s", instance->payload);
|
||||
@ -407,7 +428,7 @@ SubBruteFileResult subbrute_device_attack_set(SubBruteDevice* instance, SubBrute
|
||||
#endif
|
||||
|
||||
// Init payload
|
||||
subbrute_device_create_packet_parsed(instance, instance->key_index);
|
||||
subbrute_device_create_packet_parsed(instance, instance->key_index, false);
|
||||
|
||||
return SubBruteFileResultOk;
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ SubBruteDevice* subbrute_device_alloc();
|
||||
void subbrute_device_free(SubBruteDevice* instance);
|
||||
bool subbrute_device_save_file(SubBruteDevice* instance, const char* key_name);
|
||||
const char* subbrute_device_error_get_desc(SubBruteFileResult error_id);
|
||||
bool subbrute_device_create_packet_parsed(SubBruteDevice* context, uint64_t step);
|
||||
bool subbrute_device_create_packet_parsed(SubBruteDevice* context, uint64_t step, bool small);
|
||||
SubBruteFileResult subbrute_device_attack_set(SubBruteDevice* context, SubBruteAttacks type);
|
||||
uint8_t subbrute_device_load_from_file(SubBruteDevice* context, string_t file_path);
|
||||
FuriHalSubGhzPreset subbrute_device_convert_preset(const char* preset);
|
||||
|
@ -198,7 +198,7 @@ View* subbrute_attack_view_get_view(SubBruteAttackView* instance) {
|
||||
void subbrute_attack_view_set_current_step(SubBruteAttackView* instance, uint64_t current_step) {
|
||||
furi_assert(instance);
|
||||
#ifdef FURI_DEBUG
|
||||
FURI_LOG_D(TAG, "Set step: %d", current_step);
|
||||
//FURI_LOG_D(TAG, "Set step: %d", current_step);
|
||||
#endif
|
||||
with_view_model(
|
||||
instance->view, (SubBruteAttackViewModel * model) {
|
||||
|
Loading…
Reference in New Issue
Block a user