mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-14 12:58:36 -07:00
Init work on rev3, but this is not working code
This commit is contained in:
@@ -1,346 +0,0 @@
|
|||||||
#include "subbrute_worker.h"
|
|
||||||
|
|
||||||
#include <subghz/environment.h>
|
|
||||||
#include <subghz/transmitter.h>
|
|
||||||
#include <flipper_format_i.h>
|
|
||||||
#include <lib/subghz/subghz_tx_rx_worker.h>
|
|
||||||
|
|
||||||
#define TAG "SubBruteWorker"
|
|
||||||
|
|
||||||
struct SubBruteWorker {
|
|
||||||
SubGhzTxRxWorker* subghz_txrx;
|
|
||||||
volatile bool worker_running;
|
|
||||||
volatile bool worker_manual_mode;
|
|
||||||
bool is_manual_init;
|
|
||||||
bool is_continuous_worker;
|
|
||||||
|
|
||||||
SubGhzEnvironment* environment;
|
|
||||||
SubGhzTransmitter* transmitter;
|
|
||||||
FlipperFormat* flipper_format;
|
|
||||||
|
|
||||||
uint32_t last_time_tx_data;
|
|
||||||
|
|
||||||
// Preset and frequency needed
|
|
||||||
FuriHalSubGhzPreset preset;
|
|
||||||
uint32_t frequency;
|
|
||||||
string_t protocol_name;
|
|
||||||
|
|
||||||
//SubBruteWorkerCallback callback;
|
|
||||||
//void* context;
|
|
||||||
};
|
|
||||||
|
|
||||||
/** Taken from subghz_tx_rx_worker.c */
|
|
||||||
#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 5
|
|
||||||
#define SUBBRUTE_SEND_DELAY 20
|
|
||||||
|
|
||||||
SubBruteWorker* subbrute_worker_alloc() {
|
|
||||||
SubBruteWorker* instance = malloc(sizeof(SubBruteWorker));
|
|
||||||
|
|
||||||
//instance->status = SubBruteWorkerStatusIDLE;
|
|
||||||
instance->worker_running = false;
|
|
||||||
instance->worker_manual_mode = false;
|
|
||||||
|
|
||||||
//instance->environment = subghz_environment_alloc();
|
|
||||||
instance->transmitter = NULL;
|
|
||||||
|
|
||||||
instance->flipper_format = flipper_format_string_alloc();
|
|
||||||
string_init(instance->protocol_name);
|
|
||||||
|
|
||||||
// SubGhzTxRxWorker
|
|
||||||
instance->subghz_txrx = subghz_tx_rx_worker_alloc();
|
|
||||||
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
void subbrute_worker_free(SubBruteWorker* instance) {
|
|
||||||
furi_assert(instance);
|
|
||||||
furi_assert(!instance->worker_running);
|
|
||||||
|
|
||||||
if(instance->transmitter != NULL) {
|
|
||||||
subghz_transmitter_free(instance->transmitter);
|
|
||||||
instance->transmitter = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*if(instance->environment != NULL) {
|
|
||||||
subghz_environment_free(instance->environment);
|
|
||||||
instance->environment = NULL;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
flipper_format_free(instance->flipper_format);
|
|
||||||
|
|
||||||
string_clear(instance->protocol_name);
|
|
||||||
|
|
||||||
// SubGhzTxRxWorker
|
|
||||||
subghz_tx_rx_worker_free(instance->subghz_txrx);
|
|
||||||
|
|
||||||
free(instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool subbrute_worker_start(
|
|
||||||
SubBruteWorker* instance,
|
|
||||||
uint32_t frequency,
|
|
||||||
FuriHalSubGhzPreset preset,
|
|
||||||
const char* protocol_name) {
|
|
||||||
furi_assert(instance);
|
|
||||||
|
|
||||||
if(instance->worker_manual_mode) {
|
|
||||||
FURI_LOG_W(TAG, "Invalid mode for starting worker!");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
instance->frequency = frequency;
|
|
||||||
instance->preset = preset;
|
|
||||||
|
|
||||||
string_clear(instance->protocol_name);
|
|
||||||
string_init_printf(instance->protocol_name, "%s", protocol_name);
|
|
||||||
|
|
||||||
bool res = false;
|
|
||||||
|
|
||||||
furi_hal_subghz_reset();
|
|
||||||
furi_hal_subghz_idle();
|
|
||||||
furi_hal_subghz_load_preset(instance->preset);
|
|
||||||
|
|
||||||
furi_hal_subghz_set_frequency_and_path(instance->frequency);
|
|
||||||
furi_hal_subghz_flush_rx();
|
|
||||||
|
|
||||||
//if(furi_hal_subghz_is_tx_allowed(frequency)) {
|
|
||||||
instance->frequency = frequency;
|
|
||||||
res = true;
|
|
||||||
//}
|
|
||||||
instance->worker_running = res;
|
|
||||||
|
|
||||||
#ifdef FURI_DEBUG
|
|
||||||
FURI_LOG_I(TAG, "Frequency: %d", frequency);
|
|
||||||
#endif
|
|
||||||
instance->preset = preset;
|
|
||||||
if(res) {
|
|
||||||
instance->worker_running = res =
|
|
||||||
subghz_tx_rx_worker_start(instance->subghz_txrx, frequency);
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
void subbrute_worker_stop(SubBruteWorker* instance) {
|
|
||||||
furi_assert(instance);
|
|
||||||
|
|
||||||
instance->worker_running = false;
|
|
||||||
|
|
||||||
if(subghz_tx_rx_worker_is_running(instance->subghz_txrx)) {
|
|
||||||
subghz_tx_rx_worker_stop(instance->subghz_txrx);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void subbrute_worker_set_continuous_worker(SubBruteWorker* instance, bool is_continuous_worker) {
|
|
||||||
furi_assert(instance);
|
|
||||||
|
|
||||||
instance->is_continuous_worker = is_continuous_worker;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool subbrute_worker_get_continuous_worker(SubBruteWorker* instance) {
|
|
||||||
furi_assert(instance);
|
|
||||||
|
|
||||||
return instance->is_continuous_worker;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool subbrute_worker_is_running(SubBruteWorker* instance) {
|
|
||||||
furi_assert(instance);
|
|
||||||
|
|
||||||
return instance->worker_running;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool subbrute_worker_can_transmit(SubBruteWorker* instance) {
|
|
||||||
furi_assert(instance);
|
|
||||||
|
|
||||||
return (furi_get_tick() - instance->last_time_tx_data) > SUBBRUTE_SEND_DELAY;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool subbrute_worker_can_manual_transmit(SubBruteWorker* instance, bool is_button_pressed) {
|
|
||||||
furi_assert(instance);
|
|
||||||
|
|
||||||
if(is_button_pressed) {
|
|
||||||
// It's human pressed, trying to reset twice pressing
|
|
||||||
return !instance->worker_manual_mode &&
|
|
||||||
(furi_get_tick() - instance->last_time_tx_data) > 500;
|
|
||||||
} else {
|
|
||||||
return !instance->worker_manual_mode;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool subbrute_worker_transmit(SubBruteWorker* instance, const char* payload) {
|
|
||||||
furi_assert(instance);
|
|
||||||
furi_assert(instance->worker_running);
|
|
||||||
|
|
||||||
if(!subbrute_worker_can_transmit(instance)) {
|
|
||||||
FURI_LOG_E(TAG, "Too early to transmit");
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
instance->last_time_tx_data = furi_get_tick();
|
|
||||||
|
|
||||||
#ifdef FURI_DEBUG
|
|
||||||
//FURI_LOG_D(TAG, "payload: %s", payload);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
while(!subghz_tx_rx_worker_write(instance->subghz_txrx, (uint8_t*)payload, strlen(payload))) {
|
|
||||||
furi_delay_ms(10);
|
|
||||||
}
|
|
||||||
|
|
||||||
furi_hal_subghz_flush_tx();
|
|
||||||
// Stream* stream = flipper_format_get_raw_stream(instance->flipper_format);
|
|
||||||
// stream_clean(stream);
|
|
||||||
// stream_write_cstring(stream, payload);
|
|
||||||
// subghz_transmitter_deserialize(instance->transmitter, instance->flipper_format);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Init MANUAL
|
|
||||||
bool subbrute_worker_init_manual_transmit(
|
|
||||||
SubBruteWorker* instance,
|
|
||||||
uint32_t frequency,
|
|
||||||
FuriHalSubGhzPreset preset,
|
|
||||||
const char* protocol_name) {
|
|
||||||
#ifdef FURI_DEBUG
|
|
||||||
FURI_LOG_D(
|
|
||||||
TAG,
|
|
||||||
"subbrute_worker_init_manual_transmit. frequency: %d, protocol: %s",
|
|
||||||
frequency,
|
|
||||||
protocol_name);
|
|
||||||
#endif
|
|
||||||
if(instance->worker_manual_mode || !subbrute_worker_can_manual_transmit(instance, false) ||
|
|
||||||
instance->worker_running) {
|
|
||||||
#ifdef FURI_DEBUG
|
|
||||||
FURI_LOG_D(TAG, "cannot transmit");
|
|
||||||
#endif
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if(instance->worker_running) {
|
|
||||||
#ifdef FURI_DEBUG
|
|
||||||
FURI_LOG_D(TAG, "subbrute_worker_stop");
|
|
||||||
#endif
|
|
||||||
subbrute_worker_stop(instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Not transmit at this period
|
|
||||||
instance->worker_manual_mode = true;
|
|
||||||
|
|
||||||
if(instance->is_manual_init) {
|
|
||||||
FURI_LOG_E(TAG, "Trying to setup without normally shutdown prev transmit session!");
|
|
||||||
subbrute_worker_manual_transmit_stop(instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
instance->preset = preset;
|
|
||||||
instance->frequency = frequency;
|
|
||||||
|
|
||||||
string_clear(instance->protocol_name);
|
|
||||||
string_init_printf(instance->protocol_name, "%s", protocol_name);
|
|
||||||
|
|
||||||
furi_hal_subghz_reset();
|
|
||||||
furi_hal_subghz_idle();
|
|
||||||
furi_hal_subghz_load_preset(instance->preset);
|
|
||||||
|
|
||||||
furi_hal_subghz_set_frequency_and_path(instance->frequency);
|
|
||||||
furi_hal_subghz_flush_rx();
|
|
||||||
|
|
||||||
/*if(!furi_hal_subghz_is_tx_allowed(frequency)) {
|
|
||||||
FURI_LOG_E(TAG, "Frequency: %d invalid!", frequency);
|
|
||||||
|
|
||||||
instance->frequency = frequency;
|
|
||||||
instance->worker_manual_mode = false;
|
|
||||||
return false;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
#ifdef FURI_DEBUG
|
|
||||||
FURI_LOG_I(TAG, "Frequency: %d", frequency);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
instance->transmitter = subghz_transmitter_alloc_init(
|
|
||||||
instance->environment, string_get_cstr(instance->protocol_name));
|
|
||||||
|
|
||||||
furi_hal_subghz_reset();
|
|
||||||
furi_hal_subghz_load_preset(instance->preset);
|
|
||||||
instance->frequency = furi_hal_subghz_set_frequency_and_path(frequency);
|
|
||||||
|
|
||||||
furi_hal_subghz_set_path(FuriHalSubGhzPathIsolate);
|
|
||||||
furi_hal_subghz_sleep();
|
|
||||||
subghz_transmitter_free(instance->transmitter);
|
|
||||||
instance->transmitter = NULL;
|
|
||||||
|
|
||||||
instance->worker_manual_mode = false;
|
|
||||||
instance->is_manual_init = true;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void subbrute_worker_manual_transmit_stop(SubBruteWorker* instance) {
|
|
||||||
#ifdef FURI_DEBUG
|
|
||||||
FURI_LOG_D(TAG, "subbrute_worker_manual_transmit_stop");
|
|
||||||
#endif
|
|
||||||
if(!instance->is_manual_init) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
furi_hal_subghz_idle();
|
|
||||||
furi_hal_subghz_sleep();
|
|
||||||
|
|
||||||
if(instance->transmitter != NULL) {
|
|
||||||
subghz_transmitter_free(instance->transmitter);
|
|
||||||
instance->transmitter = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
instance->is_manual_init = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool subbrute_worker_manual_transmit(SubBruteWorker* instance, const char* payload) {
|
|
||||||
furi_assert(instance);
|
|
||||||
|
|
||||||
if(instance->worker_manual_mode || !subbrute_worker_can_transmit(instance)) {
|
|
||||||
#ifdef FURI_DEBUG
|
|
||||||
FURI_LOG_D(TAG, "cannot transmit");
|
|
||||||
#endif
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if(instance->worker_running) {
|
|
||||||
FURI_LOG_W(TAG, "Worker was working for manual mode. Shutdown thread");
|
|
||||||
subbrute_worker_stop(instance);
|
|
||||||
}
|
|
||||||
if(!instance->is_manual_init) {
|
|
||||||
FURI_LOG_E(TAG, "Manually transmit doesn't set!");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
instance->last_time_tx_data = furi_get_tick();
|
|
||||||
instance->worker_manual_mode = true;
|
|
||||||
|
|
||||||
Stream* stream = flipper_format_get_raw_stream(instance->flipper_format);
|
|
||||||
stream_clean(stream);
|
|
||||||
stream_write_cstring(stream, payload);
|
|
||||||
|
|
||||||
instance->transmitter = subghz_transmitter_alloc_init(
|
|
||||||
instance->environment, string_get_cstr(instance->protocol_name));
|
|
||||||
subghz_transmitter_deserialize(instance->transmitter, instance->flipper_format);
|
|
||||||
furi_hal_subghz_reset();
|
|
||||||
furi_hal_subghz_load_preset(instance->preset);
|
|
||||||
instance->frequency = furi_hal_subghz_set_frequency_and_path(instance->frequency);
|
|
||||||
|
|
||||||
furi_hal_subghz_start_async_tx(subghz_transmitter_yield, instance->transmitter);
|
|
||||||
|
|
||||||
while(!furi_hal_subghz_is_async_tx_complete()) {
|
|
||||||
furi_delay_ms(SUBBRUTE_TX_TIMEOUT);
|
|
||||||
}
|
|
||||||
furi_hal_subghz_stop_async_tx();
|
|
||||||
|
|
||||||
furi_hal_subghz_set_path(FuriHalSubGhzPathIsolate);
|
|
||||||
furi_hal_subghz_sleep();
|
|
||||||
subghz_transmitter_free(instance->transmitter);
|
|
||||||
instance->transmitter = NULL;
|
|
||||||
|
|
||||||
stream_clean(stream);
|
|
||||||
|
|
||||||
instance->worker_manual_mode = false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <furi_hal_subghz.h>
|
|
||||||
|
|
||||||
typedef struct SubBruteWorker SubBruteWorker;
|
|
||||||
/**
|
|
||||||
* Same like SubGhzTxRxWorkerStatus in subghz_tx_rx_worker.h
|
|
||||||
* using just to not include that file
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
SubBruteWorkerStatusIDLE,
|
|
||||||
SubBruteWorkerStatusTx,
|
|
||||||
// SubBruteWorkerStatusRx,
|
|
||||||
} SubBruteWorkerStatus;
|
|
||||||
|
|
||||||
//typedef void (*SubBruteWorkerCallback)(SubBruteWorkerStatus event, void* context);
|
|
||||||
*/
|
|
||||||
SubBruteWorker* subbrute_worker_alloc();
|
|
||||||
void subbrute_worker_free(SubBruteWorker* instance);
|
|
||||||
bool subbrute_worker_start(
|
|
||||||
SubBruteWorker* instance,
|
|
||||||
uint32_t frequency,
|
|
||||||
FuriHalSubGhzPreset preset,
|
|
||||||
const char* protocol_name);
|
|
||||||
void subbrute_worker_stop(SubBruteWorker* instance);
|
|
||||||
bool subbrute_worker_get_continuous_worker(SubBruteWorker* instance);
|
|
||||||
void subbrute_worker_set_continuous_worker(SubBruteWorker* instance, bool is_continuous_worker);
|
|
||||||
//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 is_button_pressed);
|
|
||||||
bool subbrute_worker_transmit(SubBruteWorker* instance, const char* payload);
|
|
||||||
bool subbrute_worker_init_manual_transmit(
|
|
||||||
SubBruteWorker* instance,
|
|
||||||
uint32_t frequency,
|
|
||||||
FuriHalSubGhzPreset preset,
|
|
||||||
const char* protocol_name);
|
|
||||||
bool subbrute_worker_manual_transmit(SubBruteWorker* instance, const char* payload);
|
|
||||||
void subbrute_worker_manual_transmit_stop(SubBruteWorker* instance);
|
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
#include "../subbrute_i.h"
|
#include "../subbrute_i.h"
|
||||||
#include "../subbrute_custom_event.h"
|
#include "subbrute_scene.h"
|
||||||
#include <lib/subghz/protocols/registry.h>
|
|
||||||
|
|
||||||
#define TAG "SubBruteSceneLoadFile"
|
#define TAG "SubBruteSceneLoadFile"
|
||||||
|
|
||||||
@@ -40,7 +39,6 @@ void subbrute_scene_load_file_on_enter(void* context) {
|
|||||||
load_result = subbrute_device_attack_set(instance->device, SubBruteAttackLoadFile);
|
load_result = subbrute_device_attack_set(instance->device, SubBruteAttackLoadFile);
|
||||||
if(load_result == SubBruteFileResultOk) {
|
if(load_result == SubBruteFileResultOk) {
|
||||||
// Ready to run!
|
// Ready to run!
|
||||||
instance->device->state = SubBruteDeviceStateReady;
|
|
||||||
FURI_LOG_I(TAG, "Ready to run");
|
FURI_LOG_I(TAG, "Ready to run");
|
||||||
res = true;
|
res = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
#include "../subbrute_i.h"
|
#include "../subbrute_i.h"
|
||||||
#include "../subbrute_custom_event.h"
|
#include "subbrute_scene.h"
|
||||||
#include "../views/subbrute_main_view.h"
|
|
||||||
|
|
||||||
#define TAG "SubBruteSceneStart"
|
#define TAG "SubBruteSceneStart"
|
||||||
|
|
||||||
@@ -24,7 +23,7 @@ void subbrute_scene_load_select_on_enter(void* context) {
|
|||||||
|
|
||||||
instance->current_view = SubBruteViewMain;
|
instance->current_view = SubBruteViewMain;
|
||||||
subbrute_main_view_set_callback(view, subbrute_scene_load_select_callback, instance);
|
subbrute_main_view_set_callback(view, subbrute_scene_load_select_callback, instance);
|
||||||
subbrute_main_view_set_index(view, 7, true, instance->device->file_key);
|
subbrute_main_view_set_index(view, 7, true, subbrute_device_get_file_key(instance->device));
|
||||||
|
|
||||||
view_dispatcher_switch_to_view(instance->view_dispatcher, instance->current_view);
|
view_dispatcher_switch_to_view(instance->view_dispatcher, instance->current_view);
|
||||||
}
|
}
|
||||||
@@ -42,10 +41,8 @@ bool subbrute_scene_load_select_on_event(void* context, SceneManagerEvent event)
|
|||||||
|
|
||||||
if(event.type == SceneManagerEventTypeCustom) {
|
if(event.type == SceneManagerEventTypeCustom) {
|
||||||
if(event.event == SubBruteCustomEventTypeIndexSelected) {
|
if(event.event == SubBruteCustomEventTypeIndexSelected) {
|
||||||
instance->device->load_index = subbrute_main_view_get_index(instance->view_main);
|
subbrute_device_set_load_index(
|
||||||
#ifdef FURI_DEBUG
|
instance->device, subbrute_main_view_get_index(instance->view_main));
|
||||||
FURI_LOG_D(TAG, "load_index: %d", instance->device->load_index);
|
|
||||||
#endif
|
|
||||||
scene_manager_next_scene(instance->scene_manager, SubBruteSceneSetupAttack);
|
scene_manager_next_scene(instance->scene_manager, SubBruteSceneSetupAttack);
|
||||||
consumed = true;
|
consumed = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "../subbrute_i.h"
|
#include "../subbrute_i.h"
|
||||||
|
#include "subbrute_scene.h"
|
||||||
#include "../subbrute_custom_event.h"
|
#include "../subbrute_custom_event.h"
|
||||||
#include "../views/subbrute_attack_view.h"
|
#include "../views/subbrute_attack_view.h"
|
||||||
#include "../helpers/subbrute_worker.h"
|
|
||||||
|
|
||||||
#define TAG "SubBruteSceneRunAttack"
|
#define TAG "SubBruteSceneRunAttack"
|
||||||
|
|
||||||
@@ -12,56 +12,25 @@ static void subbrute_scene_run_attack_callback(SubBruteCustomEvent event, void*
|
|||||||
view_dispatcher_send_custom_event(instance->view_dispatcher, event);
|
view_dispatcher_send_custom_event(instance->view_dispatcher, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
//static void subbrute_scene_run_attack_worker_callback(void* context) {
|
static void
|
||||||
// SubBruteState* instance = (SubBruteState*)context;
|
subbrute_scene_run_attack_device_state_changed(void* context, SubBruteDeviceState state) {
|
||||||
//
|
furi_assert(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);
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
SubBruteState* instance = (SubBruteState*)context;
|
||||||
|
|
||||||
|
if(state == SubBruteDeviceStateIDLE) {
|
||||||
|
// Can't be IDLE on this step!
|
||||||
|
view_dispatcher_send_custom_event(instance->view_dispatcher, SubBruteCustomEventTypeError);
|
||||||
|
} else if(state == SubBruteDeviceStateFinished) {
|
||||||
|
view_dispatcher_send_custom_event(
|
||||||
|
instance->view_dispatcher, SubBruteCustomEventTypeTransmitFinished);
|
||||||
|
}
|
||||||
|
}
|
||||||
void subbrute_scene_run_attack_on_exit(void* context) {
|
void subbrute_scene_run_attack_on_exit(void* context) {
|
||||||
furi_assert(context);
|
furi_assert(context);
|
||||||
SubBruteState* instance = (SubBruteState*)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);
|
|
||||||
|
|
||||||
if(subbrute_worker_get_continuous_worker(instance->worker)) {
|
subbrute_worker_stop(instance->device);
|
||||||
subbrute_worker_stop(instance->worker);
|
|
||||||
}
|
|
||||||
|
|
||||||
notification_message(instance->notifications, &sequence_blink_stop);
|
notification_message(instance->notifications, &sequence_blink_stop);
|
||||||
}
|
}
|
||||||
@@ -70,124 +39,47 @@ void subbrute_scene_run_attack_on_enter(void* context) {
|
|||||||
furi_assert(context);
|
furi_assert(context);
|
||||||
SubBruteState* instance = (SubBruteState*)context;
|
SubBruteState* instance = (SubBruteState*)context;
|
||||||
SubBruteAttackView* view = instance->view_attack;
|
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;
|
instance->current_view = SubBruteViewAttack;
|
||||||
subbrute_attack_view_set_callback(view, subbrute_scene_run_attack_callback, instance);
|
subbrute_attack_view_set_callback(view, subbrute_scene_run_attack_callback, instance);
|
||||||
view_dispatcher_switch_to_view(instance->view_dispatcher, instance->current_view);
|
view_dispatcher_switch_to_view(instance->view_dispatcher, instance->current_view);
|
||||||
|
|
||||||
subbrute_attack_view_init_values(
|
subbrute_device_set_callback(
|
||||||
view,
|
instance->device, subbrute_scene_run_attack_device_state_changed, instance);
|
||||||
(uint8_t)instance->device->attack,
|
|
||||||
instance->device->max_value,
|
|
||||||
instance->device->key_index,
|
|
||||||
true);
|
|
||||||
|
|
||||||
if(subbrute_worker_get_continuous_worker(instance->worker)) {
|
if(!subbrute_device_is_worker_running(instance->device)) {
|
||||||
// Init Continuous worker with values!
|
subbrute_worker_start(instance->device);
|
||||||
if(!subbrute_worker_start(
|
|
||||||
instance->worker,
|
|
||||||
instance->device->frequency,
|
|
||||||
instance->device->preset,
|
|
||||||
string_get_cstr(instance->device->protocol_name))) {
|
|
||||||
FURI_LOG_W(TAG, "Worker Continuous init failed!");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// 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))) {
|
|
||||||
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) {
|
bool subbrute_scene_run_attack_on_event(void* context, SceneManagerEvent event) {
|
||||||
SubBruteState* instance = (SubBruteState*)context;
|
SubBruteState* instance = (SubBruteState*)context;
|
||||||
// SubBruteAttackState* state = (SubBruteAttackState*)scene_manager_get_scene_state(
|
SubBruteAttackView* view = instance->view_attack;
|
||||||
// instance->scene_manager, SubBruteSceneRunAttack);
|
|
||||||
// furi_assert(state);
|
|
||||||
|
|
||||||
bool consumed = false;
|
bool consumed = false;
|
||||||
|
|
||||||
if(event.type == SceneManagerEventTypeCustom) {
|
if(event.type == SceneManagerEventTypeCustom) {
|
||||||
SubBruteAttackView* view = instance->view_attack;
|
subbrute_attack_view_set_current_step(view, subbrute_device_get_step(instance->device));
|
||||||
|
|
||||||
if(event.event == SubBruteCustomEventTypeTransmitNotStarted ||
|
if(event.event == SubBruteCustomEventTypeTransmitFinished) {
|
||||||
event.event == SubBruteCustomEventTypeTransmitFinished ||
|
|
||||||
event.event == SubBruteCustomEventTypeBackPressed) {
|
|
||||||
// furi_timer_stop(state->timer);
|
|
||||||
// Stop transmit
|
|
||||||
notification_message(instance->notifications, &sequence_display_backlight_on);
|
notification_message(instance->notifications, &sequence_display_backlight_on);
|
||||||
notification_message(instance->notifications, &sequence_single_vibro);
|
notification_message(instance->notifications, &sequence_single_vibro);
|
||||||
subbrute_attack_view_set_current_step(view, instance->device->key_index);
|
|
||||||
|
scene_manager_next_scene(instance->scene_manager, SubBruteSceneSetupAttack);
|
||||||
|
} else if(
|
||||||
|
event.event == SubBruteCustomEventTypeTransmitNotStarted ||
|
||||||
|
event.event == SubBruteCustomEventTypeBackPressed) {
|
||||||
|
// Stop transmit
|
||||||
scene_manager_search_and_switch_to_previous_scene(
|
scene_manager_search_and_switch_to_previous_scene(
|
||||||
instance->scene_manager, SubBruteSceneSetupAttack);
|
instance->scene_manager, SubBruteSceneSetupAttack);
|
||||||
consumed = true;
|
} else if(event.event == SubBruteCustomEventTypeError) {
|
||||||
|
notification_message(instance->notifications, &sequence_error);
|
||||||
} else if(event.event == SubBruteCustomEventTypeUpdateView) {
|
} else if(event.event == SubBruteCustomEventTypeUpdateView) {
|
||||||
subbrute_attack_view_set_current_step(view, instance->device->key_index);
|
//subbrute_attack_view_set_current_step(view, instance->device->key_index);
|
||||||
}
|
}
|
||||||
|
consumed = true;
|
||||||
} else if(event.type == SceneManagerEventTypeTick) {
|
} else if(event.type == SceneManagerEventTypeTick) {
|
||||||
if(subbrute_worker_get_continuous_worker(instance->worker)) {
|
subbrute_attack_view_set_current_step(view, subbrute_device_get_step(instance->device));
|
||||||
if(subbrute_worker_can_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_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
|
|
||||||
view_dispatcher_send_custom_event(
|
|
||||||
instance->view_dispatcher, SubBruteCustomEventTypeTransmitFinished);
|
|
||||||
} else {
|
|
||||||
instance->device->key_index++;
|
|
||||||
view_dispatcher_send_custom_event(
|
|
||||||
instance->view_dispatcher, SubBruteCustomEventTypeUpdateView);
|
|
||||||
//subbrute_attack_view_set_current_step(view, instance->device->key_index);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Stop
|
|
||||||
notification_message(instance->notifications, &sequence_blink_stop);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if(subbrute_worker_can_manual_transmit(instance->worker, false)) {
|
|
||||||
// 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
|
|
||||||
view_dispatcher_send_custom_event(
|
|
||||||
instance->view_dispatcher, SubBruteCustomEventTypeTransmitFinished);
|
|
||||||
} else {
|
|
||||||
instance->device->key_index++;
|
|
||||||
view_dispatcher_send_custom_event(
|
|
||||||
instance->view_dispatcher, SubBruteCustomEventTypeUpdateView);
|
|
||||||
//subbrute_attack_view_set_current_step(view, instance->device->key_index);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Stop
|
|
||||||
notification_message(instance->notifications, &sequence_blink_stop);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
consumed = true;
|
consumed = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,35 +1,29 @@
|
|||||||
#include <m-string.h>
|
|
||||||
#include <subghz/types.h>
|
|
||||||
#include <lib/toolbox/random_name.h>
|
|
||||||
#include <gui/modules/validators.h>
|
|
||||||
#include <lib/toolbox/path.h>
|
|
||||||
|
|
||||||
#include "../subbrute_i.h"
|
#include "../subbrute_i.h"
|
||||||
#include "../subbrute_custom_event.h"
|
#include "subbrute_scene.h"
|
||||||
|
#include <lib/toolbox/random_name.h>
|
||||||
|
|
||||||
#define TAG "SubBruteSceneSaveFile"
|
#define TAG "SubBruteSceneSaveFile"
|
||||||
|
|
||||||
void subbrute_scene_save_name_on_enter(void* context) {
|
void subbrute_scene_save_name_on_enter(void* context) {
|
||||||
SubBruteState* instance = (SubBruteState*)context;
|
SubBruteState* instance = (SubBruteState*)context;
|
||||||
SubBruteDevice* device = instance->device;
|
|
||||||
|
|
||||||
// Setup view
|
// Setup view
|
||||||
TextInput* text_input = instance->text_input;
|
TextInput* text_input = instance->text_input;
|
||||||
set_random_name(device->text_store, sizeof(device->text_store));
|
set_random_name(instance->text_store, sizeof(instance->text_store));
|
||||||
|
|
||||||
text_input_set_header_text(text_input, "Name of file");
|
text_input_set_header_text(text_input, "Name of file");
|
||||||
text_input_set_result_callback(
|
text_input_set_result_callback(
|
||||||
text_input,
|
text_input,
|
||||||
subbrute_text_input_callback,
|
subbrute_text_input_callback,
|
||||||
instance,
|
instance,
|
||||||
device->text_store,
|
instance->text_store,
|
||||||
SUBBRUTE_MAX_LEN_NAME,
|
SUBBRUTE_MAX_LEN_NAME,
|
||||||
true);
|
true);
|
||||||
|
|
||||||
string_set_str(device->load_path, SUBBRUTE_PATH);
|
string_set_str(instance->file_path, SUBBRUTE_PATH);
|
||||||
|
|
||||||
ValidatorIsFile* validator_is_file =
|
ValidatorIsFile* validator_is_file =
|
||||||
validator_is_file_alloc_init(string_get_cstr(device->load_path), SUBBRUTE_FILE_EXT, "");
|
validator_is_file_alloc_init(string_get_cstr(instance->file_path), SUBBRUTE_FILE_EXT, "");
|
||||||
text_input_set_validator(text_input, validator_is_file_callback, validator_is_file);
|
text_input_set_validator(text_input, validator_is_file_callback, validator_is_file);
|
||||||
|
|
||||||
view_dispatcher_switch_to_view(instance->view_dispatcher, SubBruteViewTextInput);
|
view_dispatcher_switch_to_view(instance->view_dispatcher, SubBruteViewTextInput);
|
||||||
@@ -46,18 +40,14 @@ bool subbrute_scene_save_name_on_event(void* context, SceneManagerEvent event) {
|
|||||||
event.type == SceneManagerEventTypeCustom &&
|
event.type == SceneManagerEventTypeCustom &&
|
||||||
event.event == SubBruteCustomEventTypeTextEditDone) {
|
event.event == SubBruteCustomEventTypeTextEditDone) {
|
||||||
#ifdef FURI_DEBUG
|
#ifdef FURI_DEBUG
|
||||||
FURI_LOG_D(TAG, "Saving: %s", instance->device->text_store);
|
FURI_LOG_D(TAG, "Saving: %s", instance->text_store);
|
||||||
#endif
|
#endif
|
||||||
bool success = false;
|
bool success = false;
|
||||||
if(strcmp(instance->device->text_store, "")) {
|
if(strcmp(instance->text_store, "")) {
|
||||||
string_cat_printf(
|
string_cat_printf(
|
||||||
instance->device->load_path,
|
instance->file_path, "/%s%s", instance->text_store, SUBBRUTE_FILE_EXT);
|
||||||
"/%s%s",
|
|
||||||
instance->device->text_store,
|
|
||||||
SUBBRUTE_FILE_EXT);
|
|
||||||
|
|
||||||
if(subbrute_device_save_file(
|
if(subbrute_device_save_file(instance->device, string_get_cstr(instance->file_path))) {
|
||||||
instance->device, string_get_cstr(instance->device->load_path))) {
|
|
||||||
scene_manager_next_scene(instance->scene_manager, SubBruteSceneSaveSuccess);
|
scene_manager_next_scene(instance->scene_manager, SubBruteSceneSaveSuccess);
|
||||||
success = true;
|
success = true;
|
||||||
consumed = true;
|
consumed = true;
|
||||||
@@ -83,5 +73,5 @@ void subbrute_scene_save_name_on_exit(void* context) {
|
|||||||
|
|
||||||
text_input_reset(instance->text_input);
|
text_input_reset(instance->text_input);
|
||||||
|
|
||||||
string_reset(instance->device->load_path);
|
string_reset(instance->file_path);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#include "../subbrute_i.h"
|
#include "../subbrute_i.h"
|
||||||
#include "../subbrute_custom_event.h"
|
#include "subbrute_scene.h"
|
||||||
|
|
||||||
void subbrute_scene_save_success_on_enter(void* context) {
|
void subbrute_scene_save_success_on_enter(void* context) {
|
||||||
furi_assert(context);
|
furi_assert(context);
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
#include "../subbrute_i.h"
|
#include "../subbrute_i.h"
|
||||||
#include "../subbrute_custom_event.h"
|
#include "subbrute_scene.h"
|
||||||
#include "../views/subbrute_attack_view.h"
|
|
||||||
|
|
||||||
#define TAG "SubBruteSceneSetupAttack"
|
#define TAG "SubBruteSceneSetupAttack"
|
||||||
|
|
||||||
@@ -11,28 +10,32 @@ static void subbrute_scene_setup_attack_callback(SubBruteCustomEvent event, void
|
|||||||
view_dispatcher_send_custom_event(instance->view_dispatcher, event);
|
view_dispatcher_send_custom_event(instance->view_dispatcher, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
subbrute_scene_setup_attack_device_state_changed(void* context, SubBruteDeviceState state) {
|
||||||
|
furi_assert(context);
|
||||||
|
|
||||||
|
SubBruteState* instance = (SubBruteState*)context;
|
||||||
|
|
||||||
|
if(state == SubBruteDeviceStateIDLE) {
|
||||||
|
// Can't be IDLE on this step!
|
||||||
|
view_dispatcher_send_custom_event(instance->view_dispatcher, SubBruteCustomEventTypeError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void subbrute_scene_setup_attack_on_enter(void* context) {
|
void subbrute_scene_setup_attack_on_enter(void* context) {
|
||||||
furi_assert(context);
|
furi_assert(context);
|
||||||
SubBruteState* instance = (SubBruteState*)context;
|
SubBruteState* instance = (SubBruteState*)context;
|
||||||
SubBruteAttackView* view = instance->view_attack;
|
SubBruteAttackView* view = instance->view_attack;
|
||||||
|
|
||||||
#ifdef FURI_DEBUG
|
#ifdef FURI_DEBUG
|
||||||
FURI_LOG_D(TAG, "Enter Attack: %d", instance->device->attack);
|
FURI_LOG_D(TAG, "Enter Attack: %d", subbrute_device_get_attack(instance->device));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
subbrute_attack_view_init_values(
|
subbrute_device_set_callback(
|
||||||
view,
|
instance->device, subbrute_scene_setup_attack_device_state_changed, context);
|
||||||
instance->device->attack,
|
|
||||||
instance->device->max_value,
|
|
||||||
instance->device->key_index,
|
|
||||||
false);
|
|
||||||
|
|
||||||
if(!subbrute_worker_init_manual_transmit(
|
if(subbrute_device_is_worker_running(instance->device)) {
|
||||||
instance->worker,
|
subbrute_worker_stop(instance->device);
|
||||||
instance->device->frequency,
|
|
||||||
instance->device->preset,
|
|
||||||
string_get_cstr(instance->device->protocol_name))) {
|
|
||||||
FURI_LOG_W(TAG, "Worker init failed!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
instance->current_view = SubBruteViewAttack;
|
instance->current_view = SubBruteViewAttack;
|
||||||
@@ -46,7 +49,7 @@ void subbrute_scene_setup_attack_on_exit(void* context) {
|
|||||||
FURI_LOG_D(TAG, "subbrute_scene_setup_attack_on_exit");
|
FURI_LOG_D(TAG, "subbrute_scene_setup_attack_on_exit");
|
||||||
#endif
|
#endif
|
||||||
SubBruteState* instance = (SubBruteState*)context;
|
SubBruteState* instance = (SubBruteState*)context;
|
||||||
subbrute_worker_manual_transmit_stop(instance->worker);
|
subbrute_worker_stop(instance->device);
|
||||||
notification_message(instance->notifications, &sequence_blink_stop);
|
notification_message(instance->notifications, &sequence_blink_stop);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,129 +60,60 @@ bool subbrute_scene_setup_attack_on_event(void* context, SceneManagerEvent event
|
|||||||
|
|
||||||
if(event.type == SceneManagerEventTypeCustom) {
|
if(event.type == SceneManagerEventTypeCustom) {
|
||||||
if(event.event == SubBruteCustomEventTypeTransmitStarted) {
|
if(event.event == SubBruteCustomEventTypeTransmitStarted) {
|
||||||
subbrute_worker_set_continuous_worker(instance->worker, false);
|
|
||||||
subbrute_attack_view_set_worker_type(view, false);
|
subbrute_attack_view_set_worker_type(view, false);
|
||||||
scene_manager_next_scene(instance->scene_manager, SubBruteSceneRunAttack);
|
scene_manager_next_scene(instance->scene_manager, SubBruteSceneRunAttack);
|
||||||
} else if(event.event == SubBruteCustomEventTypeTransmitContinuousStarted) {
|
|
||||||
// Setting different type of worker
|
|
||||||
subbrute_worker_set_continuous_worker(instance->worker, true);
|
|
||||||
subbrute_attack_view_set_worker_type(view, true);
|
|
||||||
scene_manager_next_scene(instance->scene_manager, SubBruteSceneRunAttack);
|
|
||||||
} else if(event.event == SubBruteCustomEventTypeSaveFile) {
|
} else if(event.event == SubBruteCustomEventTypeSaveFile) {
|
||||||
subbrute_worker_manual_transmit_stop(instance->worker);
|
|
||||||
|
|
||||||
subbrute_attack_view_init_values(
|
subbrute_attack_view_init_values(
|
||||||
view,
|
view,
|
||||||
instance->device->attack,
|
subbrute_device_get_attack(instance->device),
|
||||||
instance->device->max_value,
|
subbrute_device_get_max_value(instance->device),
|
||||||
instance->device->key_index,
|
subbrute_device_get_step(instance->device),
|
||||||
false);
|
false);
|
||||||
scene_manager_next_scene(instance->scene_manager, SubBruteSceneSaveName);
|
scene_manager_next_scene(instance->scene_manager, SubBruteSceneSaveName);
|
||||||
} else if(event.event == SubBruteCustomEventTypeBackPressed) {
|
} else if(event.event == SubBruteCustomEventTypeBackPressed) {
|
||||||
#ifdef FURI_DEBUG
|
subbrute_device_reset_step(instance->device);
|
||||||
FURI_LOG_D(TAG, "SubBruteCustomEventTypeBackPressed");
|
|
||||||
#endif
|
|
||||||
instance->device->key_index = 0x00;
|
|
||||||
//subbrute_attack_view_stop_worker(view);
|
|
||||||
subbrute_attack_view_init_values(
|
subbrute_attack_view_init_values(
|
||||||
view,
|
view,
|
||||||
instance->device->attack,
|
subbrute_device_get_attack(instance->device),
|
||||||
instance->device->max_value,
|
subbrute_device_get_max_value(instance->device),
|
||||||
instance->device->key_index,
|
subbrute_device_get_step(instance->device),
|
||||||
false);
|
false);
|
||||||
scene_manager_next_scene(instance->scene_manager, SubBruteSceneStart);
|
scene_manager_next_scene(instance->scene_manager, SubBruteSceneStart);
|
||||||
} else if(event.event == SubBruteCustomEventTypeChangeStepUp) {
|
} else if(event.event == SubBruteCustomEventTypeError) {
|
||||||
// +1
|
notification_message(instance->notifications, &sequence_error);
|
||||||
if((instance->device->key_index + 1) - instance->device->max_value == 1) {
|
|
||||||
instance->device->key_index = 0x00;
|
|
||||||
} else {
|
|
||||||
uint64_t value = instance->device->key_index + 1;
|
|
||||||
if(value == instance->device->max_value) {
|
|
||||||
instance->device->key_index = value;
|
|
||||||
} else {
|
|
||||||
instance->device->key_index = value % instance->device->max_value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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;
|
|
||||||
if(value == instance->device->max_value) {
|
|
||||||
instance->device->key_index += value;
|
|
||||||
} else {
|
|
||||||
instance->device->key_index = value % instance->device->max_value;
|
|
||||||
}
|
|
||||||
subbrute_attack_view_set_current_step(view, instance->device->key_index);
|
|
||||||
} else if(event.event == SubBruteCustomEventTypeChangeStepDown) {
|
|
||||||
// -1
|
|
||||||
if(instance->device->key_index - 1 == 0) {
|
|
||||||
instance->device->key_index = 0x00;
|
|
||||||
} else if(instance->device->key_index == 0) {
|
|
||||||
instance->device->key_index = instance->device->max_value;
|
|
||||||
} else {
|
|
||||||
uint64_t value = ((instance->device->key_index - 1) + instance->device->max_value);
|
|
||||||
if(value == instance->device->max_value) {
|
|
||||||
instance->device->key_index = value;
|
|
||||||
} else {
|
|
||||||
instance->device->key_index = value % instance->device->max_value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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);
|
|
||||||
if(value == instance->device->max_value) {
|
|
||||||
instance->device->key_index = value;
|
|
||||||
} else {
|
|
||||||
instance->device->key_index = value % instance->device->max_value;
|
|
||||||
}
|
|
||||||
subbrute_attack_view_set_current_step(view, instance->device->key_index);
|
|
||||||
} else if(event.event == SubBruteCustomEventTypeTransmitCustom) {
|
} else if(event.event == SubBruteCustomEventTypeTransmitCustom) {
|
||||||
if(subbrute_worker_can_manual_transmit(instance->worker, true)) {
|
// We can transmit only in not working states
|
||||||
|
if(subbrute_device_can_manual_transmit(instance->device)) {
|
||||||
|
// MANUAL Transmit!
|
||||||
// Blink
|
// Blink
|
||||||
notification_message(instance->notifications, &sequence_blink_green_100);
|
notification_message(instance->notifications, &sequence_blink_green_100);
|
||||||
|
subbrute_device_transmit_current_key(instance->device);
|
||||||
// if(!subbrute_attack_view_is_worker_running(view)) {
|
|
||||||
// subbrute_attack_view_start_worker(
|
|
||||||
// view,
|
|
||||||
// instance->device->frequency,
|
|
||||||
// instance->device->preset,
|
|
||||||
// string_get_cstr(instance->device->protocol_name));
|
|
||||||
// }
|
|
||||||
subbrute_device_create_packet_parsed(
|
|
||||||
instance->device, instance->device->key_index, false);
|
|
||||||
subbrute_worker_manual_transmit(instance->worker, instance->device->payload);
|
|
||||||
|
|
||||||
// Stop
|
// Stop
|
||||||
notification_message(instance->notifications, &sequence_blink_stop);
|
notification_message(instance->notifications, &sequence_blink_stop);
|
||||||
}
|
}
|
||||||
|
} else if(event.event == SubBruteCustomEventTypeChangeStepUp) {
|
||||||
|
// +1
|
||||||
|
uint64_t step = subbrute_device_add_step(instance->device, 1);
|
||||||
|
subbrute_attack_view_set_current_step(view, step);
|
||||||
|
} else if(event.event == SubBruteCustomEventTypeChangeStepUpMore) {
|
||||||
|
// +50
|
||||||
|
uint64_t step = subbrute_device_add_step(instance->device, 50);
|
||||||
|
subbrute_attack_view_set_current_step(view, step);
|
||||||
|
} else if(event.event == SubBruteCustomEventTypeChangeStepDown) {
|
||||||
|
// -1
|
||||||
|
uint64_t step = subbrute_device_add_step(instance->device, -1);
|
||||||
|
subbrute_attack_view_set_current_step(view, step);
|
||||||
|
} else if(event.event == SubBruteCustomEventTypeChangeStepDownMore) {
|
||||||
|
// -50
|
||||||
|
uint64_t step = subbrute_device_add_step(instance->device, -50);
|
||||||
|
subbrute_attack_view_set_current_step(view, step);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
consumed = true;
|
||||||
|
} else if(event.type == SceneManagerEventTypeTick) {
|
||||||
|
subbrute_attack_view_set_current_step(view, subbrute_device_get_step(instance->device));
|
||||||
consumed = true;
|
consumed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if(event.type == SceneManagerEventTypeCustom) {
|
|
||||||
// switch(event.event) {
|
|
||||||
// case SubBruteCustomEventTypeMenuSelected:
|
|
||||||
// with_view_model(
|
|
||||||
// view, (SubBruteMainViewModel * model) {
|
|
||||||
// instance->menu_index = model->index;
|
|
||||||
// return false;
|
|
||||||
// });
|
|
||||||
// scene_manager_next_scene(instance->scene_manager, SubBruteSceneLoadFile);
|
|
||||||
// consumed = true;
|
|
||||||
// break;
|
|
||||||
// case SubBruteCustomEventTypeLoadFile:
|
|
||||||
// with_view_model(
|
|
||||||
// view, (SubBruteMainViewModel * model) {
|
|
||||||
// instance->menu_index = model->index;
|
|
||||||
// return false;
|
|
||||||
// });
|
|
||||||
// scene_manager_next_scene(instance->scene_manager, SubBruteSceneSetupAttack);
|
|
||||||
// consumed = true;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
return consumed;
|
return consumed;
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
#include "../subbrute_i.h"
|
#include "../subbrute_i.h"
|
||||||
#include "../subbrute_custom_event.h"
|
#include "subbrute_scene.h"
|
||||||
#include "../views/subbrute_main_view.h"
|
|
||||||
|
|
||||||
#define TAG "SubBruteSceneStart"
|
#define TAG "SubBruteSceneStart"
|
||||||
|
|
||||||
@@ -24,7 +23,7 @@ void subbrute_scene_start_on_enter(void* context) {
|
|||||||
|
|
||||||
instance->current_view = SubBruteViewMain;
|
instance->current_view = SubBruteViewMain;
|
||||||
subbrute_main_view_set_callback(view, subbrute_scene_start_callback, instance);
|
subbrute_main_view_set_callback(view, subbrute_scene_start_callback, instance);
|
||||||
subbrute_main_view_set_index(view, instance->device->attack, false, NULL);
|
subbrute_main_view_set_index(view, subbrute_device_get_attack(instance->device), false, NULL);
|
||||||
|
|
||||||
view_dispatcher_switch_to_view(instance->view_dispatcher, instance->current_view);
|
view_dispatcher_switch_to_view(instance->view_dispatcher, instance->current_view);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,55 +1,9 @@
|
|||||||
#include <furi.h>
|
|
||||||
#include <furi_hal.h>
|
|
||||||
#include <input/input.h>
|
|
||||||
#include <m-string.h>
|
|
||||||
|
|
||||||
#include <gui/gui.h>
|
|
||||||
#include <gui/view_dispatcher.h>
|
|
||||||
#include <gui/view_stack.h>
|
|
||||||
#include <gui/scene_manager.h>
|
|
||||||
#include <gui/modules/text_input.h>
|
|
||||||
#include <gui/modules/popup.h>
|
|
||||||
#include <gui/modules/widget.h>
|
|
||||||
#include <gui/modules/loading.h>
|
|
||||||
|
|
||||||
#include <dialogs/dialogs.h>
|
|
||||||
|
|
||||||
#include "subbrute.h"
|
|
||||||
#include "subbrute_i.h"
|
#include "subbrute_i.h"
|
||||||
#include "subbrute_custom_event.h"
|
#include "subbrute_custom_event.h"
|
||||||
|
#include "scenes/subbrute_scene.h"
|
||||||
|
|
||||||
#define TAG "SubBruteApp"
|
#define TAG "SubBruteApp"
|
||||||
|
|
||||||
static const char* subbrute_menu_names[] = {
|
|
||||||
[SubBruteAttackCAME12bit307] = "CAME 12bit 307MHz",
|
|
||||||
[SubBruteAttackCAME12bit433] = "CAME 12bit 433MHz",
|
|
||||||
[SubBruteAttackCAME12bit868] = "CAME 12bit 868MHz",
|
|
||||||
[SubBruteAttackNICE12bit433] = "NICE 12bit 433MHz",
|
|
||||||
[SubBruteAttackNICE12bit868] = "NICE 12bit 868MHz",
|
|
||||||
[SubBruteAttackChamberlain9bit300] = "Chamberlain 9bit 300MHz",
|
|
||||||
[SubBruteAttackChamberlain9bit315] = "Chamberlain 9bit 315MHz",
|
|
||||||
[SubBruteAttackChamberlain9bit390] = "Chamberlain 9bit 390MHz",
|
|
||||||
[SubBruteAttackLinear10bit300] = "Linear 10bit 300MHz",
|
|
||||||
[SubBruteAttackLinear10bit310] = "Linear 10bit 310MHz",
|
|
||||||
[SubBruteAttackLoadFile] = "BF existing dump",
|
|
||||||
[SubBruteAttackTotalCount] = "Total Count",
|
|
||||||
};
|
|
||||||
|
|
||||||
static const char* subbrute_menu_names_small[] = {
|
|
||||||
[SubBruteAttackCAME12bit307] = "CAME 307MHz",
|
|
||||||
[SubBruteAttackCAME12bit433] = "CAME 433MHz",
|
|
||||||
[SubBruteAttackCAME12bit868] = "CAME 868MHz",
|
|
||||||
[SubBruteAttackNICE12bit433] = "NICE 433MHz",
|
|
||||||
[SubBruteAttackNICE12bit868] = "NICE 868MHz",
|
|
||||||
[SubBruteAttackChamberlain9bit300] = "Cham 300MHz",
|
|
||||||
[SubBruteAttackChamberlain9bit315] = "Cham 315MHz",
|
|
||||||
[SubBruteAttackChamberlain9bit390] = "Cham 390MHz",
|
|
||||||
[SubBruteAttackLinear10bit300] = "Linear 300MHz",
|
|
||||||
[SubBruteAttackLinear10bit310] = "Linear 310MHz",
|
|
||||||
[SubBruteAttackLoadFile] = "Existing",
|
|
||||||
[SubBruteAttackTotalCount] = "Total Count",
|
|
||||||
};
|
|
||||||
|
|
||||||
static bool subbrute_custom_event_callback(void* context, uint32_t event) {
|
static bool subbrute_custom_event_callback(void* context, uint32_t event) {
|
||||||
furi_assert(context);
|
furi_assert(context);
|
||||||
SubBruteState* instance = context;
|
SubBruteState* instance = context;
|
||||||
@@ -71,6 +25,9 @@ static void subbrute_tick_event_callback(void* context) {
|
|||||||
SubBruteState* subbrute_alloc() {
|
SubBruteState* subbrute_alloc() {
|
||||||
SubBruteState* instance = malloc(sizeof(SubBruteState));
|
SubBruteState* instance = malloc(sizeof(SubBruteState));
|
||||||
|
|
||||||
|
memset(instance->text_store, 0, sizeof(instance->text_store));
|
||||||
|
string_init(instance->file_path);
|
||||||
|
|
||||||
instance->scene_manager = scene_manager_alloc(&subbrute_scene_handlers, instance);
|
instance->scene_manager = scene_manager_alloc(&subbrute_scene_handlers, instance);
|
||||||
instance->view_dispatcher = view_dispatcher_alloc();
|
instance->view_dispatcher = view_dispatcher_alloc();
|
||||||
|
|
||||||
@@ -94,9 +51,6 @@ SubBruteState* subbrute_alloc() {
|
|||||||
// Devices
|
// Devices
|
||||||
instance->device = subbrute_device_alloc();
|
instance->device = subbrute_device_alloc();
|
||||||
|
|
||||||
// Worker
|
|
||||||
instance->worker = subbrute_worker_alloc();
|
|
||||||
|
|
||||||
// TextInput
|
// TextInput
|
||||||
instance->text_input = text_input_alloc();
|
instance->text_input = text_input_alloc();
|
||||||
view_dispatcher_add_view(
|
view_dispatcher_add_view(
|
||||||
@@ -144,17 +98,11 @@ SubBruteState* subbrute_alloc() {
|
|||||||
void subbrute_free(SubBruteState* instance) {
|
void subbrute_free(SubBruteState* instance) {
|
||||||
furi_assert(instance);
|
furi_assert(instance);
|
||||||
|
|
||||||
// SubBruteWorker
|
|
||||||
#ifdef FURI_DEBUG
|
|
||||||
FURI_LOG_D(TAG, "free SubBruteDevice");
|
|
||||||
#endif
|
|
||||||
subbrute_worker_stop(instance->worker);
|
|
||||||
subbrute_worker_free(instance->worker);
|
|
||||||
|
|
||||||
// SubBruteDevice
|
// SubBruteDevice
|
||||||
#ifdef FURI_DEBUG
|
#ifdef FURI_DEBUG
|
||||||
FURI_LOG_D(TAG, "free SubBruteDevice");
|
FURI_LOG_D(TAG, "free SubBruteDevice");
|
||||||
#endif
|
#endif
|
||||||
|
subbrute_worker_stop(instance->device);
|
||||||
subbrute_device_free(instance->device);
|
subbrute_device_free(instance->device);
|
||||||
|
|
||||||
// Notifications
|
// Notifications
|
||||||
@@ -239,6 +187,9 @@ void subbrute_free(SubBruteState* instance) {
|
|||||||
furi_record_close(RECORD_GUI);
|
furi_record_close(RECORD_GUI);
|
||||||
instance->gui = NULL;
|
instance->gui = NULL;
|
||||||
|
|
||||||
|
string_clear(instance->file_path);
|
||||||
|
string_init(instance->file_path);
|
||||||
|
|
||||||
// The rest
|
// The rest
|
||||||
#ifdef FURI_DEBUG
|
#ifdef FURI_DEBUG
|
||||||
FURI_LOG_D(TAG, "free instance");
|
FURI_LOG_D(TAG, "free instance");
|
||||||
@@ -277,18 +228,6 @@ void subbrute_popup_closed_callback(void* context) {
|
|||||||
instance->view_dispatcher, SubBruteCustomEventTypePopupClosed);
|
instance->view_dispatcher, SubBruteCustomEventTypePopupClosed);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* subbrute_get_menu_name(SubBruteAttacks index) {
|
|
||||||
furi_assert(index < SubBruteAttackTotalCount);
|
|
||||||
|
|
||||||
return subbrute_menu_names[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* subbrute_get_small_menu_name(SubBruteAttacks index) {
|
|
||||||
furi_assert(index < SubBruteAttackTotalCount);
|
|
||||||
|
|
||||||
return subbrute_menu_names_small[index];
|
|
||||||
}
|
|
||||||
|
|
||||||
// ENTRYPOINT
|
// ENTRYPOINT
|
||||||
int32_t subbrute_app(void* p) {
|
int32_t subbrute_app(void* p) {
|
||||||
UNUSED(p);
|
UNUSED(p);
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ typedef enum {
|
|||||||
SubBruteCustomEventTypeBackPressed,
|
SubBruteCustomEventTypeBackPressed,
|
||||||
SubBruteCustomEventTypeIndexSelected,
|
SubBruteCustomEventTypeIndexSelected,
|
||||||
SubBruteCustomEventTypeTransmitStarted,
|
SubBruteCustomEventTypeTransmitStarted,
|
||||||
SubBruteCustomEventTypeTransmitContinuousStarted,
|
SubBruteCustomEventTypeError,
|
||||||
SubBruteCustomEventTypeTransmitFinished,
|
SubBruteCustomEventTypeTransmitFinished,
|
||||||
SubBruteCustomEventTypeTransmitNotStarted,
|
SubBruteCustomEventTypeTransmitNotStarted,
|
||||||
SubBruteCustomEventTypeTransmitCustom,
|
SubBruteCustomEventTypeTransmitCustom,
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,102 +1,58 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <lib/toolbox/stream/stream.h>
|
#include "subbrute_device_i.h"
|
||||||
#include <gui/gui.h>
|
|
||||||
#include <dialogs/dialogs.h>
|
|
||||||
#include <lib/subghz/protocols/base.h>
|
#include <lib/subghz/protocols/base.h>
|
||||||
#include <lib/subghz/transmitter.h>
|
#include <lib/subghz/transmitter.h>
|
||||||
#include <lib/subghz/receiver.h>
|
#include <lib/subghz/receiver.h>
|
||||||
#include <lib/subghz/environment.h>
|
#include <lib/subghz/environment.h>
|
||||||
|
|
||||||
#define SUBBRUTE_TEXT_STORE_SIZE 256
|
struct SubBruteDevice {
|
||||||
|
|
||||||
#define SUBBRUTE_MAX_LEN_NAME 64
|
|
||||||
#define SUBBRUTE_PATH EXT_PATH("subghz")
|
|
||||||
#define SUBBRUTE_FILE_EXT ".sub"
|
|
||||||
|
|
||||||
#define SUBBRUTE_PAYLOAD_SIZE 16
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
SubBruteAttackCAME12bit307,
|
|
||||||
SubBruteAttackCAME12bit433,
|
|
||||||
SubBruteAttackCAME12bit868,
|
|
||||||
SubBruteAttackNICE12bit433,
|
|
||||||
SubBruteAttackNICE12bit868,
|
|
||||||
SubBruteAttackChamberlain9bit300,
|
|
||||||
SubBruteAttackChamberlain9bit315,
|
|
||||||
SubBruteAttackChamberlain9bit390,
|
|
||||||
SubBruteAttackLinear10bit300,
|
|
||||||
SubBruteAttackLinear10bit310,
|
|
||||||
SubBruteAttackLoadFile,
|
|
||||||
SubBruteAttackTotalCount,
|
|
||||||
} SubBruteAttacks;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
SubBruteFileResultUnknown,
|
|
||||||
SubBruteFileResultOk,
|
|
||||||
SubBruteFileResultErrorOpenFile,
|
|
||||||
SubBruteFileResultMissingOrIncorrectHeader,
|
|
||||||
SubBruteFileResultFrequencyNotAllowed,
|
|
||||||
SubBruteFileResultMissingOrIncorrectFrequency,
|
|
||||||
SubBruteFileResultPresetInvalid,
|
|
||||||
SubBruteFileResultMissingProtocol,
|
|
||||||
SubBruteFileResultProtocolNotSupported,
|
|
||||||
SubBruteFileResultDynamicProtocolNotValid,
|
|
||||||
SubBruteFileResultProtocolNotFound,
|
|
||||||
SubBruteFileResultMissingOrIncorrectBit,
|
|
||||||
SubBruteFileResultMissingOrIncorrectKey,
|
|
||||||
SubBruteFileResultMissingOrIncorrectTe,
|
|
||||||
} SubBruteFileResult;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
SubBruteDeviceStateIDLE,
|
|
||||||
SubBruteDeviceStateReady,
|
|
||||||
SubBruteDeviceStateTx,
|
|
||||||
SubBruteDeviceStateFinished,
|
|
||||||
} SubBruteDeviceState;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
SubBruteDeviceState state;
|
SubBruteDeviceState state;
|
||||||
|
SubBruteProtocol* protocol_info;
|
||||||
|
volatile bool worker_running;
|
||||||
|
|
||||||
// Current step
|
// Current step
|
||||||
uint64_t key_index;
|
uint64_t key_index;
|
||||||
string_t load_path;
|
|
||||||
// Index of group to bruteforce in loaded file
|
// Index of group to bruteforce in loaded file
|
||||||
uint8_t load_index;
|
uint8_t load_index;
|
||||||
|
|
||||||
|
// SubGhz
|
||||||
|
FuriThread* thread;
|
||||||
SubGhzReceiver* receiver;
|
SubGhzReceiver* receiver;
|
||||||
SubGhzProtocolDecoderBase* decoder_result;
|
SubGhzProtocolDecoderBase* decoder_result;
|
||||||
SubGhzEnvironment* environment;
|
SubGhzEnvironment* environment;
|
||||||
|
SubGhzTransmitter* transmitter;
|
||||||
|
|
||||||
// Attack state
|
// Attack state
|
||||||
SubBruteAttacks attack;
|
SubBruteAttacks attack;
|
||||||
char file_template[SUBBRUTE_TEXT_STORE_SIZE];
|
char file_template[SUBBRUTE_TEXT_STORE_SIZE];
|
||||||
bool has_tail;
|
|
||||||
char payload[SUBBRUTE_TEXT_STORE_SIZE * 2];
|
|
||||||
uint64_t max_value;
|
uint64_t max_value;
|
||||||
|
|
||||||
// Loaded info for attack type
|
// Loaded info for attack type
|
||||||
FuriHalSubGhzPreset preset;
|
|
||||||
string_t preset_name;
|
|
||||||
string_t protocol_name;
|
|
||||||
uint32_t frequency;
|
|
||||||
uint32_t repeat;
|
|
||||||
uint32_t bit;
|
|
||||||
char current_key[SUBBRUTE_PAYLOAD_SIZE];
|
char current_key[SUBBRUTE_PAYLOAD_SIZE];
|
||||||
uint32_t te;
|
|
||||||
|
|
||||||
char file_key[SUBBRUTE_MAX_LEN_NAME];
|
char file_key[SUBBRUTE_MAX_LEN_NAME];
|
||||||
char text_store[SUBBRUTE_PAYLOAD_SIZE];
|
|
||||||
} SubBruteDevice;
|
|
||||||
|
|
||||||
SubBruteDevice* subbrute_device_alloc();
|
// Manual transmit
|
||||||
void subbrute_device_free(SubBruteDevice* instance);
|
uint32_t last_time_tx_data;
|
||||||
bool subbrute_device_save_file(SubBruteDevice* instance, const char* key_name);
|
|
||||||
const char* subbrute_device_error_get_desc(SubBruteFileResult error_id);
|
// Callback for changed states
|
||||||
bool subbrute_device_create_packet_parsed(SubBruteDevice* context, uint64_t step, bool small);
|
SubBruteDeviceWorkerCallback callback;
|
||||||
SubBruteFileResult subbrute_device_attack_set(SubBruteDevice* context, SubBruteAttacks type);
|
void* context;
|
||||||
uint8_t subbrute_device_load_from_file(SubBruteDevice* context, string_t file_path);
|
};
|
||||||
FuriHalSubGhzPreset subbrute_device_convert_preset(const char* preset);
|
|
||||||
|
/*
|
||||||
|
* PRIVATE METHODS
|
||||||
|
*/
|
||||||
|
void subbrute_device_free_protocol_info(SubBruteDevice* instance);
|
||||||
|
int32_t subbrute_worker_thread(void* context);
|
||||||
void subbrute_device_attack_set_default_values(
|
void subbrute_device_attack_set_default_values(
|
||||||
SubBruteDevice* context,
|
SubBruteDevice* context,
|
||||||
SubBruteAttacks default_attack);
|
SubBruteAttacks default_attack);
|
||||||
|
bool subbrute_device_create_packet_parsed(
|
||||||
|
SubBruteDevice* instance,
|
||||||
|
FlipperFormat* flipper_format,
|
||||||
|
uint64_t step,
|
||||||
|
bool small);
|
||||||
|
void subbrute_device_send_callback(SubBruteDevice* instance);
|
||||||
|
void subbrute_device_subghz_transmit(SubBruteDevice* instance, FlipperFormat* flipper_format);
|
||||||
64
applications/plugins/subbrute/subbrute_device_i.h
Normal file
64
applications/plugins/subbrute/subbrute_device_i.h
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "subbrute_protocols.h"
|
||||||
|
|
||||||
|
#define SUBBRUTE_TEXT_STORE_SIZE 256
|
||||||
|
|
||||||
|
#define SUBBRUTE_MAX_LEN_NAME 64
|
||||||
|
#define SUBBRUTE_PATH EXT_PATH("subghz")
|
||||||
|
#define SUBBRUTE_FILE_EXT ".sub"
|
||||||
|
|
||||||
|
#define SUBBRUTE_PAYLOAD_SIZE 16
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
SubBruteFileResultUnknown,
|
||||||
|
SubBruteFileResultOk,
|
||||||
|
SubBruteFileResultErrorOpenFile,
|
||||||
|
SubBruteFileResultMissingOrIncorrectHeader,
|
||||||
|
SubBruteFileResultFrequencyNotAllowed,
|
||||||
|
SubBruteFileResultMissingOrIncorrectFrequency,
|
||||||
|
SubBruteFileResultPresetInvalid,
|
||||||
|
SubBruteFileResultMissingProtocol,
|
||||||
|
SubBruteFileResultProtocolNotSupported,
|
||||||
|
SubBruteFileResultDynamicProtocolNotValid,
|
||||||
|
SubBruteFileResultProtocolNotFound,
|
||||||
|
SubBruteFileResultMissingOrIncorrectBit,
|
||||||
|
SubBruteFileResultMissingOrIncorrectKey,
|
||||||
|
SubBruteFileResultMissingOrIncorrectTe,
|
||||||
|
} SubBruteFileResult;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
SubBruteDeviceStateIDLE,
|
||||||
|
SubBruteDeviceStateReady,
|
||||||
|
SubBruteDeviceStateTx,
|
||||||
|
SubBruteDeviceStateFinished
|
||||||
|
} SubBruteDeviceState;
|
||||||
|
|
||||||
|
typedef void (*SubBruteDeviceWorkerCallback)(void* context, SubBruteDeviceState state);
|
||||||
|
typedef struct SubBruteDevice SubBruteDevice;
|
||||||
|
|
||||||
|
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);
|
||||||
|
SubBruteFileResult subbrute_device_attack_set(SubBruteDevice* context, SubBruteAttacks type);
|
||||||
|
uint8_t subbrute_device_load_from_file(SubBruteDevice* context, string_t file_path);
|
||||||
|
|
||||||
|
|
||||||
|
bool subbrute_device_is_worker_running(SubBruteDevice* instance);
|
||||||
|
SubBruteAttacks subbrute_device_get_attack(SubBruteDevice* instance);
|
||||||
|
uint64_t subbrute_device_get_max_value(SubBruteDevice* instance);
|
||||||
|
uint64_t subbrute_device_get_step(SubBruteDevice* instance);
|
||||||
|
uint64_t subbrute_device_add_step(SubBruteDevice* instance, int8_t step);
|
||||||
|
void subbrute_device_set_load_index(SubBruteDevice* instance, uint64_t load_index);
|
||||||
|
void subbrute_device_reset_step(SubBruteDevice* instance);
|
||||||
|
const char* subbrute_device_get_file_key(SubBruteDevice* instance);
|
||||||
|
|
||||||
|
bool subbrute_worker_start(SubBruteDevice* instance);
|
||||||
|
void subbrute_worker_stop(SubBruteDevice* instance);
|
||||||
|
bool subbrute_device_transmit_current_key(SubBruteDevice* instance);
|
||||||
|
bool subbrute_device_can_manual_transmit(SubBruteDevice* instance);
|
||||||
|
void subbrute_device_set_callback(
|
||||||
|
SubBruteDevice* instance,
|
||||||
|
SubBruteDeviceWorkerCallback callback,
|
||||||
|
void* context);
|
||||||
@@ -4,14 +4,10 @@
|
|||||||
#include <furi_hal.h>
|
#include <furi_hal.h>
|
||||||
#include <input/input.h>
|
#include <input/input.h>
|
||||||
|
|
||||||
#include "lib/toolbox/path.h"
|
|
||||||
#include <notification/notification.h>
|
#include <notification/notification.h>
|
||||||
#include <notification/notification_messages.h>
|
#include <notification/notification_messages.h>
|
||||||
#include <m-string.h>
|
#include <m-string.h>
|
||||||
|
|
||||||
#include <lib/toolbox/stream/stream.h>
|
|
||||||
#include <stream_buffer.h>
|
|
||||||
|
|
||||||
#include <gui/gui.h>
|
#include <gui/gui.h>
|
||||||
#include <gui/view_dispatcher.h>
|
#include <gui/view_dispatcher.h>
|
||||||
#include <gui/view_stack.h>
|
#include <gui/view_stack.h>
|
||||||
@@ -23,17 +19,11 @@
|
|||||||
|
|
||||||
#include <dialogs/dialogs.h>
|
#include <dialogs/dialogs.h>
|
||||||
|
|
||||||
#include <lib/subghz/protocols/base.h>
|
|
||||||
#include <lib/subghz/transmitter.h>
|
|
||||||
#include <lib/subghz/receiver.h>
|
|
||||||
#include <lib/subghz/environment.h>
|
|
||||||
#include <notification/notification.h>
|
#include <notification/notification.h>
|
||||||
#include <notification/notification_messages.h>
|
#include <notification/notification_messages.h>
|
||||||
|
|
||||||
#include "subbrute_device.h"
|
|
||||||
#include "helpers/subbrute_worker.h"
|
|
||||||
#include "subbrute.h"
|
#include "subbrute.h"
|
||||||
#include "scenes/subbrute_scene.h"
|
#include "subbrute_device_i.h"
|
||||||
#include "views/subbrute_attack_view.h"
|
#include "views/subbrute_attack_view.h"
|
||||||
#include "views/subbrute_main_view.h"
|
#include "views/subbrute_main_view.h"
|
||||||
|
|
||||||
@@ -60,6 +50,10 @@ struct SubBruteState {
|
|||||||
DialogsApp* dialogs;
|
DialogsApp* dialogs;
|
||||||
Loading* loading;
|
Loading* loading;
|
||||||
|
|
||||||
|
// Text store
|
||||||
|
char text_store[SUBBRUTE_MAX_LEN_NAME];
|
||||||
|
string_t file_path;
|
||||||
|
|
||||||
// Views
|
// Views
|
||||||
SubBruteMainView* view_main;
|
SubBruteMainView* view_main;
|
||||||
SubBruteAttackView* view_attack;
|
SubBruteAttackView* view_attack;
|
||||||
@@ -68,16 +62,10 @@ struct SubBruteState {
|
|||||||
// Scene
|
// Scene
|
||||||
SceneManager* scene_manager;
|
SceneManager* scene_manager;
|
||||||
|
|
||||||
|
// SubBruteDevice
|
||||||
SubBruteDevice* device;
|
SubBruteDevice* device;
|
||||||
SubBruteWorker* worker;
|
|
||||||
|
|
||||||
//Menu stuff
|
|
||||||
// TODO: Do we need it?
|
|
||||||
uint8_t menu_index;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
void subbrute_show_loading_popup(void* context, bool show);
|
void subbrute_show_loading_popup(void* context, bool show);
|
||||||
void subbrute_text_input_callback(void* context);
|
void subbrute_text_input_callback(void* context);
|
||||||
void subbrute_popup_closed_callback(void* context);
|
void subbrute_popup_closed_callback(void* context);
|
||||||
const char* subbrute_get_menu_name(uint8_t index);
|
|
||||||
const char* subbrute_get_small_menu_name(uint8_t index);
|
|
||||||
127
applications/plugins/subbrute/subbrute_protocols.c
Normal file
127
applications/plugins/subbrute/subbrute_protocols.c
Normal file
@@ -0,0 +1,127 @@
|
|||||||
|
#include "subbrute_protocols.h"
|
||||||
|
|
||||||
|
static const SubBruteProtocol subbrute_protocols[SubBruteAttackTotalCount] = {
|
||||||
|
[SubBruteAttackCAME12bit307] =
|
||||||
|
{307800000, 12, 0, 3, FuriHalSubGhzPresetOok650Async, CAMEFileProtocol},
|
||||||
|
[SubBruteAttackCAME12bit433] =
|
||||||
|
{433920000, 12, 0, 3, FuriHalSubGhzPresetOok650Async, CAMEFileProtocol},
|
||||||
|
[SubBruteAttackCAME12bit868] =
|
||||||
|
{868350000, 12, 0, 3, FuriHalSubGhzPresetOok650Async, CAMEFileProtocol},
|
||||||
|
[SubBruteAttackNICE12bit433] =
|
||||||
|
{433920000, 12, 0, 3, FuriHalSubGhzPresetOok650Async, NICEFileProtocol},
|
||||||
|
[SubBruteAttackNICE12bit868] =
|
||||||
|
{868350000, 12, 0, 3, FuriHalSubGhzPresetOok650Async, NICEFileProtocol},
|
||||||
|
[SubBruteAttackChamberlain9bit300] =
|
||||||
|
{300000000, 9, 0, 3, FuriHalSubGhzPresetOok650Async, ChamberlainFileProtocol},
|
||||||
|
[SubBruteAttackChamberlain9bit315] =
|
||||||
|
{315000000, 9, 0, 3, FuriHalSubGhzPresetOok650Async, ChamberlainFileProtocol},
|
||||||
|
[SubBruteAttackChamberlain9bit390] =
|
||||||
|
{390000000, 9, 0, 3, FuriHalSubGhzPresetOok650Async, ChamberlainFileProtocol},
|
||||||
|
[SubBruteAttackLinear10bit300] =
|
||||||
|
{300000000, 10, 0, 5, FuriHalSubGhzPresetOok650Async, LinearFileProtocol},
|
||||||
|
[SubBruteAttackLinear10bit310] =
|
||||||
|
{300000000, 10, 0, 5, FuriHalSubGhzPresetOok650Async, LinearFileProtocol},
|
||||||
|
[SubBruteAttackLoadFile] = {0, 0, 0, 3, FuriHalSubGhzPresetOok650Async, RAWFileProtocol},
|
||||||
|
};
|
||||||
|
//static const uint32_t subbrute_protocols[SubBruteAttackTotalCount][TotalProtocolFields] = {
|
||||||
|
// [SubBruteAttackCAME12bit307] = {307800000, 12, 0, 3, FuriHalSubGhzPresetOok650Async, CAMEFileProtocol},
|
||||||
|
// [SubBruteAttackCAME12bit433] = {433920000, 12, 0, 3, FuriHalSubGhzPresetOok650Async, CAMEFileProtocol},
|
||||||
|
// [SubBruteAttackCAME12bit868] = {868350000, 12, 0, 3, FuriHalSubGhzPresetOok650Async, CAMEFileProtocol},
|
||||||
|
// [SubBruteAttackNICE12bit433] = {433920000, 12, 0, 3, FuriHalSubGhzPresetOok650Async, NICEFileProtocol},
|
||||||
|
// [SubBruteAttackNICE12bit868] = {868350000, 12, 0, 3, FuriHalSubGhzPresetOok650Async, NICEFileProtocol},
|
||||||
|
// [SubBruteAttackChamberlain9bit300] = {300000000, 9, 0, 3, FuriHalSubGhzPresetOok650Async, ChamberlainFileProtocol},
|
||||||
|
// [SubBruteAttackChamberlain9bit315] = {315000000, 9, 0, 3, FuriHalSubGhzPresetOok650Async, ChamberlainFileProtocol},
|
||||||
|
// [SubBruteAttackChamberlain9bit390] = {390000000, 9, 0, 3, FuriHalSubGhzPresetOok650Async, ChamberlainFileProtocol},
|
||||||
|
// [SubBruteAttackLinear10bit300] = {300000000, 10, 0, 5, FuriHalSubGhzPresetOok650Async, LinearFileProtocol},
|
||||||
|
// [SubBruteAttackLinear10bit310] = {300000000, 10, 0, 5, FuriHalSubGhzPresetOok650Async, LinearFileProtocol},
|
||||||
|
// [SubBruteAttackLoadFile] = {0, 0, 0, 3, FuriHalSubGhzPresetOok650Async, RAWFileProtocol},
|
||||||
|
//};
|
||||||
|
|
||||||
|
static const char* subbrute_protocol_names[] = {
|
||||||
|
[SubBruteAttackCAME12bit307] = "CAME 12bit 307MHz",
|
||||||
|
[SubBruteAttackCAME12bit433] = "CAME 12bit 433MHz",
|
||||||
|
[SubBruteAttackCAME12bit868] = "CAME 12bit 868MHz",
|
||||||
|
[SubBruteAttackNICE12bit433] = "NICE 12bit 433MHz",
|
||||||
|
[SubBruteAttackNICE12bit868] = "NICE 12bit 868MHz",
|
||||||
|
[SubBruteAttackChamberlain9bit300] = "Chamberlain 9bit 300MHz",
|
||||||
|
[SubBruteAttackChamberlain9bit315] = "Chamberlain 9bit 315MHz",
|
||||||
|
[SubBruteAttackChamberlain9bit390] = "Chamberlain 9bit 390MHz",
|
||||||
|
[SubBruteAttackLinear10bit300] = "Linear 10bit 300MHz",
|
||||||
|
[SubBruteAttackLinear10bit310] = "Linear 10bit 310MHz",
|
||||||
|
[SubBruteAttackLoadFile] = "BF existing dump",
|
||||||
|
[SubBruteAttackTotalCount] = "Total Count",
|
||||||
|
};
|
||||||
|
|
||||||
|
static const char* subbrute_protocol_presets[] = {
|
||||||
|
[FuriHalSubGhzPresetIDLE] = "FuriHalSubGhzPresetIDLE",
|
||||||
|
[FuriHalSubGhzPresetOok270Async] = "FuriHalSubGhzPresetOok270Async",
|
||||||
|
[FuriHalSubGhzPresetOok650Async] = "FuriHalSubGhzPresetOok650Async",
|
||||||
|
[FuriHalSubGhzPreset2FSKDev238Async] = "FuriHalSubGhzPreset2FSKDev238Async",
|
||||||
|
[FuriHalSubGhzPreset2FSKDev476Async] = "FuriHalSubGhzPreset2FSKDev476Async",
|
||||||
|
[FuriHalSubGhzPresetMSK99_97KbAsync] = "FuriHalSubGhzPresetMSK99_97KbAsync",
|
||||||
|
[FuriHalSubGhzPresetGFSK9_99KbAsync] = "FuriHalSubGhzPresetGFSK9_99KbAsync",
|
||||||
|
};
|
||||||
|
|
||||||
|
static const char* subbrute_protocol_file_types[TotalFileProtocol] = {
|
||||||
|
[CAMEFileProtocol] = "CAME",
|
||||||
|
[NICEFileProtocol] = "Nice FLO",
|
||||||
|
[ChamberlainFileProtocol] = "Cham_Code",
|
||||||
|
[LinearFileProtocol] = "Linear",
|
||||||
|
[PrincetonFileProtocol] = "Princeton",
|
||||||
|
[RAWFileProtocol] = "RAW"};
|
||||||
|
|
||||||
|
SubBruteProtocol* subbrute_protocol_alloc(void) {
|
||||||
|
SubBruteProtocol* protocol = malloc(sizeof(SubBruteProtocol));
|
||||||
|
protocol->frequency = subbrute_protocols[SubBruteAttackLoadFile].frequency;
|
||||||
|
protocol->repeat = subbrute_protocols[SubBruteAttackLoadFile].repeat;
|
||||||
|
protocol->preset = subbrute_protocols[SubBruteAttackLoadFile].preset;
|
||||||
|
protocol->file = subbrute_protocols[SubBruteAttackLoadFile].file;
|
||||||
|
protocol->te = subbrute_protocols[SubBruteAttackLoadFile].te;
|
||||||
|
protocol->bits = subbrute_protocols[SubBruteAttackLoadFile].bits;
|
||||||
|
|
||||||
|
return protocol;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* subbrute_protocol_name(SubBruteAttacks index) {
|
||||||
|
return subbrute_protocol_names[index];
|
||||||
|
}
|
||||||
|
|
||||||
|
SubBruteProtocol* subbrute_protocol(SubBruteAttacks index) {
|
||||||
|
SubBruteProtocol* protocol = subbrute_protocol_alloc();
|
||||||
|
protocol->frequency = subbrute_protocols[index].frequency;
|
||||||
|
protocol->repeat = subbrute_protocols[index].repeat;
|
||||||
|
protocol->preset = subbrute_protocols[index].preset;
|
||||||
|
protocol->file = subbrute_protocols[index].file;
|
||||||
|
protocol->te = subbrute_protocols[index].te;
|
||||||
|
protocol->bits = subbrute_protocols[index].bits;
|
||||||
|
|
||||||
|
return protocol;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* subbrute_protocol_preset(FuriHalSubGhzPreset preset) {
|
||||||
|
return subbrute_protocol_presets[preset];
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* subbrute_protocol_file(SubBruteFileProtocol protocol) {
|
||||||
|
return subbrute_protocol_file_types[protocol];
|
||||||
|
}
|
||||||
|
|
||||||
|
FuriHalSubGhzPreset subbrute_protocol_convert_preset(string_t preset_name) {
|
||||||
|
for(size_t i = FuriHalSubGhzPresetIDLE; i<FuriHalSubGhzPresetCustom;i++) {
|
||||||
|
if(string_cmp_str(preset_name, subbrute_protocol_presets[i]) == 0) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return FuriHalSubGhzPresetIDLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
SubBruteFileProtocol subbrute_protocol_file_protocol_name(string_t name) {
|
||||||
|
for(size_t i = CAMEFileProtocol; i<TotalFileProtocol-1;i++) {
|
||||||
|
if(string_cmp_str(name, subbrute_protocol_file_types[i]) == 0) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return RAWFileProtocol;
|
||||||
|
}
|
||||||
42
applications/plugins/subbrute/subbrute_protocols.h
Normal file
42
applications/plugins/subbrute/subbrute_protocols.h
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "subbrute_protocols_i.h"
|
||||||
|
#include <furi.h>
|
||||||
|
#include <m-string.h>
|
||||||
|
#include <furi_hal_subghz.h>
|
||||||
|
|
||||||
|
//typedef enum {
|
||||||
|
// FrequencyProtocolField,
|
||||||
|
// BitsProtocolField,
|
||||||
|
// HasTeProtocolField,
|
||||||
|
// RepeatProtocolField,
|
||||||
|
// PresetProtocolField,
|
||||||
|
// FileProtocolField,
|
||||||
|
// TotalProtocolFields
|
||||||
|
//} ProtocolFields;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
CAMEFileProtocol,
|
||||||
|
NICEFileProtocol,
|
||||||
|
ChamberlainFileProtocol,
|
||||||
|
LinearFileProtocol,
|
||||||
|
PrincetonFileProtocol,
|
||||||
|
RAWFileProtocol,
|
||||||
|
TotalFileProtocol,
|
||||||
|
} SubBruteFileProtocol;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
uint32_t frequency;
|
||||||
|
uint8_t bits;
|
||||||
|
uint8_t te;
|
||||||
|
uint8_t repeat;
|
||||||
|
FuriHalSubGhzPreset preset;
|
||||||
|
SubBruteFileProtocol file;
|
||||||
|
} SubBruteProtocol;
|
||||||
|
|
||||||
|
SubBruteProtocol* subbrute_protocol_alloc(void);
|
||||||
|
SubBruteProtocol* subbrute_protocol(SubBruteAttacks index);
|
||||||
|
const char* subbrute_protocol_preset(FuriHalSubGhzPreset preset);
|
||||||
|
const char* subbrute_protocol_file(SubBruteFileProtocol protocol);
|
||||||
|
FuriHalSubGhzPreset subbrute_protocol_convert_preset(string_t preset_name);
|
||||||
|
SubBruteFileProtocol subbrute_protocol_file_protocol_name(string_t name);
|
||||||
18
applications/plugins/subbrute/subbrute_protocols_i.h
Normal file
18
applications/plugins/subbrute/subbrute_protocols_i.h
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
SubBruteAttackCAME12bit307,
|
||||||
|
SubBruteAttackCAME12bit433,
|
||||||
|
SubBruteAttackCAME12bit868,
|
||||||
|
SubBruteAttackNICE12bit433,
|
||||||
|
SubBruteAttackNICE12bit868,
|
||||||
|
SubBruteAttackChamberlain9bit300,
|
||||||
|
SubBruteAttackChamberlain9bit315,
|
||||||
|
SubBruteAttackChamberlain9bit390,
|
||||||
|
SubBruteAttackLinear10bit300,
|
||||||
|
SubBruteAttackLinear10bit310,
|
||||||
|
SubBruteAttackLoadFile,
|
||||||
|
SubBruteAttackTotalCount,
|
||||||
|
} SubBruteAttacks;
|
||||||
|
|
||||||
|
const char* subbrute_protocol_name(SubBruteAttacks index);
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "subbrute_attack_view.h"
|
#include "subbrute_attack_view.h"
|
||||||
#include "../subbrute_i.h"
|
#include "../subbrute_i.h"
|
||||||
|
#include "../subbrute_protocols_i.h"
|
||||||
|
|
||||||
#include "assets_icons.h"
|
#include "assets_icons.h"
|
||||||
#include <input/input.h>
|
#include <input/input.h>
|
||||||
@@ -350,7 +351,7 @@ void subbrute_attack_view_draw(Canvas* canvas, void* context) {
|
|||||||
char buffer[26];
|
char buffer[26];
|
||||||
|
|
||||||
const char* attack_name = NULL;
|
const char* attack_name = NULL;
|
||||||
attack_name = subbrute_get_menu_name(model->index);
|
attack_name = subbrute_protocol_name(model->index);
|
||||||
// Title
|
// Title
|
||||||
if(model->is_attacking) {
|
if(model->is_attacking) {
|
||||||
canvas_set_color(canvas, ColorBlack);
|
canvas_set_color(canvas, ColorBlack);
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "../subbrute_custom_event.h"
|
||||||
#include <gui/view.h>
|
#include <gui/view.h>
|
||||||
#include "assets_icons.h"
|
#include "assets_icons.h"
|
||||||
#include <input/input.h>
|
#include <input/input.h>
|
||||||
#include <gui/elements.h>
|
#include <gui/elements.h>
|
||||||
#include <gui/icon.h>
|
#include <gui/icon.h>
|
||||||
#include <subghz/types.h>
|
#include <subghz/types.h>
|
||||||
#include "../subbrute_custom_event.h"
|
|
||||||
|
|
||||||
typedef void (*SubBruteAttackViewCallback)(SubBruteCustomEvent event, void* context);
|
typedef void (*SubBruteAttackViewCallback)(SubBruteCustomEvent event, void* context);
|
||||||
typedef struct SubBruteAttackView SubBruteAttackView;
|
typedef struct SubBruteAttackView SubBruteAttackView;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "subbrute_main_view.h"
|
#include "subbrute_main_view.h"
|
||||||
#include "../subbrute_i.h"
|
#include "../subbrute_i.h"
|
||||||
|
#include "../subbrute_protocols_i.h"
|
||||||
|
|
||||||
#include <input/input.h>
|
#include <input/input.h>
|
||||||
#include <gui/elements.h>
|
#include <gui/elements.h>
|
||||||
@@ -123,7 +124,6 @@ void subbrute_main_view_draw(Canvas* canvas, SubBruteMainViewModel* model) {
|
|||||||
uint8_t item_position = position - model->window_position;
|
uint8_t item_position = position - model->window_position;
|
||||||
|
|
||||||
if(item_position < items_on_screen) {
|
if(item_position < items_on_screen) {
|
||||||
const char* str = subbrute_get_menu_name(position);
|
|
||||||
if(m->index == position) {
|
if(m->index == position) {
|
||||||
canvas_draw_str_aligned(
|
canvas_draw_str_aligned(
|
||||||
canvas,
|
canvas,
|
||||||
@@ -131,7 +131,7 @@ void subbrute_main_view_draw(Canvas* canvas, SubBruteMainViewModel* model) {
|
|||||||
9 + (item_position * item_height) + STATUS_BAR_Y_SHIFT,
|
9 + (item_position * item_height) + STATUS_BAR_Y_SHIFT,
|
||||||
AlignLeft,
|
AlignLeft,
|
||||||
AlignCenter,
|
AlignCenter,
|
||||||
str);
|
subbrute_protocol_name(position));
|
||||||
elements_frame(
|
elements_frame(
|
||||||
canvas, 1, 1 + (item_position * item_height) + STATUS_BAR_Y_SHIFT, 124, 15);
|
canvas, 1, 1 + (item_position * item_height) + STATUS_BAR_Y_SHIFT, 124, 15);
|
||||||
} else {
|
} else {
|
||||||
@@ -141,7 +141,7 @@ void subbrute_main_view_draw(Canvas* canvas, SubBruteMainViewModel* model) {
|
|||||||
9 + (item_position * item_height) + STATUS_BAR_Y_SHIFT,
|
9 + (item_position * item_height) + STATUS_BAR_Y_SHIFT,
|
||||||
AlignLeft,
|
AlignLeft,
|
||||||
AlignCenter,
|
AlignCenter,
|
||||||
str);
|
subbrute_protocol_name(position));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user