This commit is contained in:
MX 2022-07-29 19:34:41 +03:00
parent d6bf4819d2
commit 79e7636507
No known key found for this signature in database
GPG key ID: 6C4C311DFD4B4AB5
9 changed files with 136 additions and 143 deletions

View file

@ -36,7 +36,6 @@ typedef struct {
int y; int y;
bool ducky_err; bool ducky_err;
bool addr_err; bool addr_err;
bool ducky_running;
} PluginState; } PluginState;
uint8_t addrs_count = 0; uint8_t addrs_count = 0;
@ -55,7 +54,7 @@ static void render_callback(Canvas* const canvas, void* ctx) {
canvas_draw_frame(canvas, 0, 0, 128, 64); canvas_draw_frame(canvas, 0, 0, 128, 64);
canvas_set_font(canvas, FontSecondary); canvas_set_font(canvas, FontSecondary);
if(!plugin_state->addr_err && !plugin_state->ducky_err && !plugin_state->ducky_running) { if(!plugin_state->addr_err && !plugin_state->ducky_err) {
sprintf(target_text, target_fmt_text, target_address_str); sprintf(target_text, target_fmt_text, target_address_str);
canvas_draw_str_aligned(canvas, 7, 10, AlignLeft, AlignBottom, target_text); canvas_draw_str_aligned(canvas, 7, 10, AlignLeft, AlignBottom, target_text);
canvas_draw_str_aligned(canvas, 22, 20, AlignLeft, AlignBottom, "<- select address ->"); canvas_draw_str_aligned(canvas, 22, 20, AlignLeft, AlignBottom, "<- select address ->");
@ -74,10 +73,6 @@ static void render_callback(Canvas* const canvas, void* ctx) {
canvas, 10, 10, AlignLeft, AlignBottom, "Error: No mousejacker folder"); canvas, 10, 10, AlignLeft, AlignBottom, "Error: No mousejacker folder");
canvas_draw_str_aligned(canvas, 10, 20, AlignLeft, AlignBottom, "or duckyscript file"); canvas_draw_str_aligned(canvas, 10, 20, AlignLeft, AlignBottom, "or duckyscript file");
canvas_draw_str_aligned(canvas, 10, 30, AlignLeft, AlignBottom, "loading error"); canvas_draw_str_aligned(canvas, 10, 30, AlignLeft, AlignBottom, "loading error");
} else if(plugin_state->ducky_running) {
sprintf(target_text, target_fmt_text, target_address_str);
canvas_draw_str_aligned(canvas, 7, 10, AlignLeft, AlignBottom, target_text);
canvas_draw_str_aligned(canvas, 10, 30, AlignLeft, AlignBottom, "Running duckyscript...");
} }
release_mutex((ValueMutex*)ctx, plugin_state); release_mutex((ValueMutex*)ctx, plugin_state);
@ -142,13 +137,8 @@ static bool open_addrs_file(Stream* stream) {
return result; return result;
} }
static bool process_ducky_file( static bool
ViewPort* view_port, process_ducky_file(Stream* file_stream, uint8_t* addr, uint8_t addr_size, uint8_t rate) {
PluginState* plugin_state,
Stream* file_stream,
uint8_t* addr,
uint8_t addr_size,
uint8_t rate) {
size_t file_size = 0; size_t file_size = 0;
size_t bytes_read = 0; size_t bytes_read = 0;
uint8_t* file_buf; uint8_t* file_buf;
@ -164,13 +154,9 @@ static bool process_ducky_file(
memset(file_buf, 0, file_size); memset(file_buf, 0, file_size);
bytes_read = stream_read(file_stream, file_buf, file_size); bytes_read = stream_read(file_stream, file_buf, file_size);
if(bytes_read == file_size) { if(bytes_read == file_size) {
plugin_state->ducky_running = true;
view_port_update(view_port);
FURI_LOG_I(TAG, "executing ducky script"); FURI_LOG_I(TAG, "executing ducky script");
mj_process_ducky_script(nrf24_HANDLE, addr, addr_size, rate, (char*)file_buf); mj_process_ducky_script(nrf24_HANDLE, addr, addr_size, rate, (char*)file_buf);
FURI_LOG_I(TAG, "finished execution"); FURI_LOG_I(TAG, "finished execution");
furi_delay_ms(300);
plugin_state->ducky_running = false;
loaded = true; loaded = true;
} else { } else {
FURI_LOG_I(TAG, "load failed. file size: %d", file_size); FURI_LOG_I(TAG, "load failed. file size: %d", file_size);
@ -311,8 +297,6 @@ int32_t mousejacker_app(void* p) {
LOGITECH_MAX_CHANNEL, LOGITECH_MAX_CHANNEL,
true); true);
ducky_ok = process_ducky_file( ducky_ok = process_ducky_file(
view_port,
plugin_state,
file_stream, file_stream,
loaded_addrs[addr_idx] + 1, loaded_addrs[addr_idx] + 1,
5, 5,

View file

@ -1,12 +1,12 @@
#include "../wifi_marauder_app_i.h" #include "../wifi_marauder_app_i.h"
void wifi_marauder_console_output_handle_rx_data_cb(uint8_t *buf, size_t len, void* context) { void wifi_marauder_console_output_handle_rx_data_cb(uint8_t* buf, size_t len, void* context) {
furi_assert(context); furi_assert(context);
WifiMarauderApp* app = context; WifiMarauderApp* app = context;
// If text box store gets too big, then truncate it // If text box store gets too big, then truncate it
app->text_box_store_strlen += len; app->text_box_store_strlen += len;
if (app->text_box_store_strlen >= WIFI_MARAUDER_TEXT_BOX_STORE_SIZE - 1) { if(app->text_box_store_strlen >= WIFI_MARAUDER_TEXT_BOX_STORE_SIZE - 1) {
string_right(app->text_box_store, app->text_box_store_strlen / 2); string_right(app->text_box_store, app->text_box_store_strlen / 2);
app->text_box_store_strlen = string_size(app->text_box_store); app->text_box_store_strlen = string_size(app->text_box_store);
} }
@ -24,12 +24,12 @@ void wifi_marauder_scene_console_output_on_enter(void* context) {
TextBox* text_box = app->text_box; TextBox* text_box = app->text_box;
text_box_reset(app->text_box); text_box_reset(app->text_box);
text_box_set_font(text_box, TextBoxFontText); text_box_set_font(text_box, TextBoxFontText);
if (app->focus_console_start) { if(app->focus_console_start) {
text_box_set_focus(text_box, TextBoxFocusStart); text_box_set_focus(text_box, TextBoxFocusStart);
} else { } else {
text_box_set_focus(text_box, TextBoxFocusEnd); text_box_set_focus(text_box, TextBoxFocusEnd);
} }
if (app->is_command) { if(app->is_command) {
string_reset(app->text_box_store); string_reset(app->text_box_store);
app->text_box_store_strlen = 0; app->text_box_store_strlen = 0;
} else { // "View Log" menu action } else { // "View Log" menu action
@ -40,11 +40,13 @@ void wifi_marauder_scene_console_output_on_enter(void* context) {
view_dispatcher_switch_to_view(app->view_dispatcher, WifiMarauderAppViewConsoleOutput); view_dispatcher_switch_to_view(app->view_dispatcher, WifiMarauderAppViewConsoleOutput);
// Register callback to receive data // Register callback to receive data
wifi_marauder_uart_set_handle_rx_data_cb(app->uart, wifi_marauder_console_output_handle_rx_data_cb); // setup callback for rx thread wifi_marauder_uart_set_handle_rx_data_cb(
app->uart, wifi_marauder_console_output_handle_rx_data_cb); // setup callback for rx thread
// Send command with newline '\n' // Send command with newline '\n'
if (app->is_command && app->selected_tx_string) { if(app->is_command && app->selected_tx_string) {
wifi_marauder_uart_tx((uint8_t*)(app->selected_tx_string), strlen(app->selected_tx_string)); wifi_marauder_uart_tx(
(uint8_t*)(app->selected_tx_string), strlen(app->selected_tx_string));
wifi_marauder_uart_tx((uint8_t*)("\n"), 1); wifi_marauder_uart_tx((uint8_t*)("\n"), 1);
} }
} }
@ -71,7 +73,7 @@ void wifi_marauder_scene_console_output_on_exit(void* context) {
wifi_marauder_uart_set_handle_rx_data_cb(app->uart, NULL); wifi_marauder_uart_set_handle_rx_data_cb(app->uart, NULL);
// Automatically stop the scan when exiting view // Automatically stop the scan when exiting view
if (app->is_command) { if(app->is_command) {
wifi_marauder_uart_tx((uint8_t*)("stopscan\n"), strlen("stopscan\n")); wifi_marauder_uart_tx((uint8_t*)("stopscan\n"), strlen("stopscan\n"));
} }
} }

View file

@ -5,10 +5,10 @@
// For each command, define whether additional arguments are needed // For each command, define whether additional arguments are needed
// (enabling text input to fill them out), and whether the console // (enabling text input to fill them out), and whether the console
// text box should focus at the start of the output or the end // text box should focus at the start of the output or the end
#define INPUT_ARGS (true) #define INPUT_ARGS (true)
#define NO_ARGS (false) #define NO_ARGS (false)
#define FOCUS_CONSOLE_START (true) #define FOCUS_CONSOLE_START (true)
#define FOCUS_CONSOLE_END (false) #define FOCUS_CONSOLE_END (false)
struct WifiMarauderItem { struct WifiMarauderItem {
const char* item_string; const char* item_string;
bool needs_keyboard; bool needs_keyboard;
@ -16,35 +16,35 @@ struct WifiMarauderItem {
}; };
const struct WifiMarauderItem items[NUM_MENU_ITEMS] = { const struct WifiMarauderItem items[NUM_MENU_ITEMS] = {
{ "View Log (start)", NO_ARGS, FOCUS_CONSOLE_START }, {"View Log (start)", NO_ARGS, FOCUS_CONSOLE_START},
{ "View Log (end)", NO_ARGS, FOCUS_CONSOLE_END }, {"View Log (end)", NO_ARGS, FOCUS_CONSOLE_END},
{ "attack -t beacon -l", NO_ARGS, FOCUS_CONSOLE_END }, {"attack -t beacon -l", NO_ARGS, FOCUS_CONSOLE_END},
{ "attack -t beacon -r", NO_ARGS, FOCUS_CONSOLE_END }, {"attack -t beacon -r", NO_ARGS, FOCUS_CONSOLE_END},
{ "attack -t beacon -a", NO_ARGS, FOCUS_CONSOLE_END }, {"attack -t beacon -a", NO_ARGS, FOCUS_CONSOLE_END},
{ "attack -t deauth", NO_ARGS, FOCUS_CONSOLE_END }, {"attack -t deauth", NO_ARGS, FOCUS_CONSOLE_END},
{ "attack -t probe", NO_ARGS, FOCUS_CONSOLE_END }, {"attack -t probe", NO_ARGS, FOCUS_CONSOLE_END},
{ "attack -t rickroll", NO_ARGS, FOCUS_CONSOLE_END }, {"attack -t rickroll", NO_ARGS, FOCUS_CONSOLE_END},
{ "channel", NO_ARGS, FOCUS_CONSOLE_END }, {"channel", NO_ARGS, FOCUS_CONSOLE_END},
{ "channel -s", INPUT_ARGS, FOCUS_CONSOLE_END }, {"channel -s", INPUT_ARGS, FOCUS_CONSOLE_END},
{ "clearlist -a", NO_ARGS, FOCUS_CONSOLE_END }, {"clearlist -a", NO_ARGS, FOCUS_CONSOLE_END},
{ "clearlist -s", NO_ARGS, FOCUS_CONSOLE_END }, {"clearlist -s", NO_ARGS, FOCUS_CONSOLE_END},
{ "help", NO_ARGS, FOCUS_CONSOLE_START }, {"help", NO_ARGS, FOCUS_CONSOLE_START},
{ "list -a", NO_ARGS, FOCUS_CONSOLE_START }, {"list -a", NO_ARGS, FOCUS_CONSOLE_START},
{ "list -s", NO_ARGS, FOCUS_CONSOLE_START }, {"list -s", NO_ARGS, FOCUS_CONSOLE_START},
{ "reboot", NO_ARGS, FOCUS_CONSOLE_END }, {"reboot", NO_ARGS, FOCUS_CONSOLE_END},
{ "scanap", NO_ARGS, FOCUS_CONSOLE_END }, {"scanap", NO_ARGS, FOCUS_CONSOLE_END},
{ "select -a", INPUT_ARGS, FOCUS_CONSOLE_END }, {"select -a", INPUT_ARGS, FOCUS_CONSOLE_END},
{ "select -s", INPUT_ARGS, FOCUS_CONSOLE_END }, {"select -s", INPUT_ARGS, FOCUS_CONSOLE_END},
{ "sniffbeacon", NO_ARGS, FOCUS_CONSOLE_END }, {"sniffbeacon", NO_ARGS, FOCUS_CONSOLE_END},
{ "sniffdeauth", NO_ARGS, FOCUS_CONSOLE_END }, {"sniffdeauth", NO_ARGS, FOCUS_CONSOLE_END},
{ "sniffesp", NO_ARGS, FOCUS_CONSOLE_END }, {"sniffesp", NO_ARGS, FOCUS_CONSOLE_END},
{ "sniffpmkid", NO_ARGS, FOCUS_CONSOLE_END }, {"sniffpmkid", NO_ARGS, FOCUS_CONSOLE_END},
{ "sniffpmkid -c", INPUT_ARGS, FOCUS_CONSOLE_END }, {"sniffpmkid -c", INPUT_ARGS, FOCUS_CONSOLE_END},
{ "sniffpwn", NO_ARGS, FOCUS_CONSOLE_END }, {"sniffpwn", NO_ARGS, FOCUS_CONSOLE_END},
{ "ssid -a -g", INPUT_ARGS, FOCUS_CONSOLE_END }, {"ssid -a -g", INPUT_ARGS, FOCUS_CONSOLE_END},
{ "ssid -a -n", INPUT_ARGS, FOCUS_CONSOLE_END }, {"ssid -a -n", INPUT_ARGS, FOCUS_CONSOLE_END},
{ "ssid -r", INPUT_ARGS, FOCUS_CONSOLE_END }, {"ssid -r", INPUT_ARGS, FOCUS_CONSOLE_END},
{ "update -w", NO_ARGS, FOCUS_CONSOLE_END }, {"update -w", NO_ARGS, FOCUS_CONSOLE_END},
}; };
static void wifi_marauder_scene_start_var_list_enter_callback(void* context, uint32_t index) { static void wifi_marauder_scene_start_var_list_enter_callback(void* context, uint32_t index) {
@ -55,7 +55,7 @@ static void wifi_marauder_scene_start_var_list_enter_callback(void* context, uin
app->is_custom_tx_string = false; app->is_custom_tx_string = false;
app->selected_menu_index = index; app->selected_menu_index = index;
app->focus_console_start = items[index].focus_console_start; app->focus_console_start = items[index].focus_console_start;
if (items[index].needs_keyboard) { if(items[index].needs_keyboard) {
view_dispatcher_send_custom_event(app->view_dispatcher, WifiMarauderEventStartKeyboard); view_dispatcher_send_custom_event(app->view_dispatcher, WifiMarauderEventStartKeyboard);
} else { } else {
view_dispatcher_send_custom_event(app->view_dispatcher, WifiMarauderEventStartConsole); view_dispatcher_send_custom_event(app->view_dispatcher, WifiMarauderEventStartConsole);
@ -70,7 +70,7 @@ void wifi_marauder_scene_start_on_enter(void* context) {
var_item_list, wifi_marauder_scene_start_var_list_enter_callback, app); var_item_list, wifi_marauder_scene_start_var_list_enter_callback, app);
// TODO: organize menu // TODO: organize menu
for (int i = 0; i < NUM_MENU_ITEMS; ++i) { for(int i = 0; i < NUM_MENU_ITEMS; ++i) {
variable_item_list_add(var_item_list, items[i].item_string, 0, NULL, NULL); variable_item_list_add(var_item_list, items[i].item_string, 0, NULL, NULL);
} }
@ -86,11 +86,13 @@ bool wifi_marauder_scene_start_on_event(void* context, SceneManagerEvent event)
bool consumed = false; bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) { if(event.type == SceneManagerEventTypeCustom) {
if (event.event == WifiMarauderEventStartKeyboard) { if(event.event == WifiMarauderEventStartKeyboard) {
scene_manager_set_scene_state(app->scene_manager, WifiMarauderSceneStart, app->selected_menu_index); scene_manager_set_scene_state(
app->scene_manager, WifiMarauderSceneStart, app->selected_menu_index);
scene_manager_next_scene(app->scene_manager, WifiMarauderAppViewTextInput); scene_manager_next_scene(app->scene_manager, WifiMarauderAppViewTextInput);
} else if (event.event == WifiMarauderEventStartConsole) { } else if(event.event == WifiMarauderEventStartConsole) {
scene_manager_set_scene_state(app->scene_manager, WifiMarauderSceneStart, app->selected_menu_index); scene_manager_set_scene_state(
app->scene_manager, WifiMarauderSceneStart, app->selected_menu_index);
scene_manager_next_scene(app->scene_manager, WifiMarauderAppViewConsoleOutput); scene_manager_next_scene(app->scene_manager, WifiMarauderAppViewConsoleOutput);
} }
consumed = true; consumed = true;

View file

@ -1,6 +1,5 @@
#include "../wifi_marauder_app_i.h" #include "../wifi_marauder_app_i.h"
void wifi_marauder_scene_text_input_callback(void* context) { void wifi_marauder_scene_text_input_callback(void* context) {
WifiMarauderApp* app = context; WifiMarauderApp* app = context;
@ -10,7 +9,7 @@ void wifi_marauder_scene_text_input_callback(void* context) {
void wifi_marauder_scene_text_input_on_enter(void* context) { void wifi_marauder_scene_text_input_on_enter(void* context) {
WifiMarauderApp* app = context; WifiMarauderApp* app = context;
if (false == app->is_custom_tx_string) { if(false == app->is_custom_tx_string) {
// Fill text input with selected string so that user can add to it // Fill text input with selected string so that user can add to it
size_t length = strlen(app->selected_tx_string); size_t length = strlen(app->selected_tx_string);
furi_assert(length < WIFI_MARAUDER_TEXT_INPUT_STORE_SIZE); furi_assert(length < WIFI_MARAUDER_TEXT_INPUT_STORE_SIZE);
@ -19,14 +18,20 @@ void wifi_marauder_scene_text_input_on_enter(void* context) {
// Add space - because flipper keyboard currently doesn't have a space // Add space - because flipper keyboard currently doesn't have a space
app->text_input_store[length] = ' '; app->text_input_store[length] = ' ';
app->text_input_store[length+1] = '\0'; app->text_input_store[length + 1] = '\0';
app->is_custom_tx_string = true; app->is_custom_tx_string = true;
} }
// Setup view // Setup view
TextInput* text_input = app->text_input; TextInput* text_input = app->text_input;
text_input_set_header_text(text_input, "Add command arguments"); text_input_set_header_text(text_input, "Add command arguments");
text_input_set_result_callback(text_input, wifi_marauder_scene_text_input_callback, app, app->text_input_store, WIFI_MARAUDER_TEXT_INPUT_STORE_SIZE, false); text_input_set_result_callback(
text_input,
wifi_marauder_scene_text_input_callback,
app,
app->text_input_store,
WIFI_MARAUDER_TEXT_INPUT_STORE_SIZE,
false);
view_dispatcher_switch_to_view(app->view_dispatcher, WifiMarauderAppViewTextInput); view_dispatcher_switch_to_view(app->view_dispatcher, WifiMarauderAppViewTextInput);
} }
@ -35,8 +40,8 @@ bool wifi_marauder_scene_text_input_on_event(void* context, SceneManagerEvent ev
WifiMarauderApp* app = context; WifiMarauderApp* app = context;
bool consumed = false; bool consumed = false;
if (event.type == SceneManagerEventTypeCustom) { if(event.type == SceneManagerEventTypeCustom) {
if (event.event == WifiMarauderEventStartConsole) { if(event.event == WifiMarauderEventStartConsole) {
// Point to custom string to send // Point to custom string to send
app->selected_tx_string = app->text_input_store; app->selected_tx_string = app->text_input_store;
scene_manager_next_scene(app->scene_manager, WifiMarauderAppViewConsoleOutput); scene_manager_next_scene(app->scene_manager, WifiMarauderAppViewConsoleOutput);

View file

@ -47,12 +47,14 @@ WifiMarauderApp* wifi_marauder_app_alloc() {
variable_item_list_get_view(app->var_item_list)); variable_item_list_get_view(app->var_item_list));
app->text_box = text_box_alloc(); app->text_box = text_box_alloc();
view_dispatcher_add_view(app->view_dispatcher, WifiMarauderAppViewConsoleOutput, text_box_get_view(app->text_box)); view_dispatcher_add_view(
app->view_dispatcher, WifiMarauderAppViewConsoleOutput, text_box_get_view(app->text_box));
string_init(app->text_box_store); string_init(app->text_box_store);
string_reserve(app->text_box_store, WIFI_MARAUDER_TEXT_BOX_STORE_SIZE); string_reserve(app->text_box_store, WIFI_MARAUDER_TEXT_BOX_STORE_SIZE);
app->text_input = text_input_alloc(); app->text_input = text_input_alloc();
view_dispatcher_add_view(app->view_dispatcher, WifiMarauderAppViewTextInput, text_input_get_view(app->text_input)); view_dispatcher_add_view(
app->view_dispatcher, WifiMarauderAppViewTextInput, text_input_get_view(app->text_input));
scene_manager_next_scene(app->scene_manager, WifiMarauderSceneStart); scene_manager_next_scene(app->scene_manager, WifiMarauderSceneStart);

View file

@ -10,8 +10,8 @@ struct WifiMarauderUart {
WifiMarauderApp* app; WifiMarauderApp* app;
FuriThread* rx_thread; FuriThread* rx_thread;
StreamBufferHandle_t rx_stream; StreamBufferHandle_t rx_stream;
uint8_t rx_buf[RX_BUF_SIZE+1]; uint8_t rx_buf[RX_BUF_SIZE + 1];
void (*handle_rx_data_cb)(uint8_t *buf, size_t len, void* context); void (*handle_rx_data_cb)(uint8_t* buf, size_t len, void* context);
}; };
typedef enum { typedef enum {
@ -19,7 +19,9 @@ typedef enum {
WorkerEvtRxDone = (1 << 1), WorkerEvtRxDone = (1 << 1),
} WorkerEvtFlags; } WorkerEvtFlags;
void wifi_marauder_uart_set_handle_rx_data_cb(WifiMarauderUart* uart, void (*handle_rx_data_cb)(uint8_t *buf, size_t len, void* context)) { void wifi_marauder_uart_set_handle_rx_data_cb(
WifiMarauderUart* uart,
void (*handle_rx_data_cb)(uint8_t* buf, size_t len, void* context)) {
furi_assert(uart); furi_assert(uart);
uart->handle_rx_data_cb = handle_rx_data_cb; uart->handle_rx_data_cb = handle_rx_data_cb;
} }
@ -48,10 +50,9 @@ static int32_t uart_worker(void* context) {
furi_check((events & FuriFlagError) == 0); furi_check((events & FuriFlagError) == 0);
if(events & WorkerEvtStop) break; if(events & WorkerEvtStop) break;
if(events & WorkerEvtRxDone) { if(events & WorkerEvtRxDone) {
size_t len = size_t len = xStreamBufferReceive(uart->rx_stream, uart->rx_buf, RX_BUF_SIZE, 0);
xStreamBufferReceive(uart->rx_stream, uart->rx_buf, RX_BUF_SIZE, 0);
if(len > 0) { if(len > 0) {
if (uart->handle_rx_data_cb) uart->handle_rx_data_cb(uart->rx_buf, len, uart->app); if(uart->handle_rx_data_cb) uart->handle_rx_data_cb(uart->rx_buf, len, uart->app);
} }
} }
} }
@ -61,12 +62,12 @@ static int32_t uart_worker(void* context) {
return 0; return 0;
} }
void wifi_marauder_uart_tx(uint8_t *data, size_t len) { void wifi_marauder_uart_tx(uint8_t* data, size_t len) {
furi_hal_uart_tx(UART_CH, data, len); furi_hal_uart_tx(UART_CH, data, len);
} }
WifiMarauderUart* wifi_marauder_uart_init(WifiMarauderApp* app) { WifiMarauderUart* wifi_marauder_uart_init(WifiMarauderApp* app) {
WifiMarauderUart *uart = malloc(sizeof(WifiMarauderUart)); WifiMarauderUart* uart = malloc(sizeof(WifiMarauderUart));
furi_hal_console_disable(); furi_hal_console_disable();
furi_hal_uart_set_br(UART_CH, BAUDRATE); furi_hal_uart_set_br(UART_CH, BAUDRATE);

View file

@ -6,7 +6,9 @@
typedef struct WifiMarauderUart WifiMarauderUart; typedef struct WifiMarauderUart WifiMarauderUart;
void wifi_marauder_uart_set_handle_rx_data_cb(WifiMarauderUart* uart, void (*handle_rx_data_cb)(uint8_t *buf, size_t len, void* context)); void wifi_marauder_uart_set_handle_rx_data_cb(
void wifi_marauder_uart_tx(uint8_t *data, size_t len); WifiMarauderUart* uart,
void (*handle_rx_data_cb)(uint8_t* buf, size_t len, void* context));
void wifi_marauder_uart_tx(uint8_t* data, size_t len);
WifiMarauderUart* wifi_marauder_uart_init(WifiMarauderApp* app); WifiMarauderUart* wifi_marauder_uart_init(WifiMarauderApp* app);
void wifi_marauder_uart_free(WifiMarauderUart* uart); void wifi_marauder_uart_free(WifiMarauderUart* uart);

View file

@ -7,45 +7,43 @@
extern "C" { extern "C" {
#endif #endif
#define R_REGISTER 0x00 #define R_REGISTER 0x00
#define W_REGISTER 0x20 #define W_REGISTER 0x20
#define REGISTER_MASK 0x1F #define REGISTER_MASK 0x1F
#define ACTIVATE 0x50 #define ACTIVATE 0x50
#define R_RX_PL_WID 0x60 #define R_RX_PL_WID 0x60
#define R_RX_PAYLOAD 0x61 #define R_RX_PAYLOAD 0x61
#define W_TX_PAYLOAD 0xA0 #define W_TX_PAYLOAD 0xA0
#define W_TX_PAYLOAD_NOACK 0xB0 #define W_TX_PAYLOAD_NOACK 0xB0
#define W_ACK_PAYLOAD 0xA8 #define W_ACK_PAYLOAD 0xA8
#define FLUSH_TX 0xE1 #define FLUSH_TX 0xE1
#define FLUSH_RX 0xE2 #define FLUSH_RX 0xE2
#define REUSE_TX_PL 0xE3 #define REUSE_TX_PL 0xE3
#define RF24_NOP 0xFF #define RF24_NOP 0xFF
#define REG_CONFIG 0x00 #define REG_CONFIG 0x00
#define REG_EN_AA 0x01 #define REG_EN_AA 0x01
#define REG_EN_RXADDR 0x02 #define REG_EN_RXADDR 0x02
#define REG_SETUP_AW 0x03 #define REG_SETUP_AW 0x03
#define REG_SETUP_RETR 0x04 #define REG_SETUP_RETR 0x04
#define REG_DYNPD 0x1C #define REG_DYNPD 0x1C
#define REG_FEATURE 0x1D #define REG_FEATURE 0x1D
#define REG_RF_SETUP 0x06 #define REG_RF_SETUP 0x06
#define REG_STATUS 0x07 #define REG_STATUS 0x07
#define REG_RX_ADDR_P0 0x0A #define REG_RX_ADDR_P0 0x0A
#define REG_RF_CH 0x05 #define REG_RF_CH 0x05
#define REG_TX_ADDR 0x10 #define REG_TX_ADDR 0x10
#define RX_PW_P0 0x11 #define RX_PW_P0 0x11
#define TX_DS 0x20 #define TX_DS 0x20
#define MAX_RT 0x10 #define MAX_RT 0x10
#define nrf24_TIMEOUT 500 #define nrf24_TIMEOUT 500
#define nrf24_CE_PIN &gpio_ext_pb2 #define nrf24_CE_PIN &gpio_ext_pb2
#define nrf24_HANDLE &furi_hal_spi_bus_handle_external #define nrf24_HANDLE &furi_hal_spi_bus_handle_external
/* Low level API */ /* Low level API */
/** Write device register /** Write device register
* *
* @param handle - pointer to FuriHalSpiHandle * @param handle - pointer to FuriHalSpiHandle
@ -56,7 +54,6 @@ extern "C" {
*/ */
uint8_t nrf24_write_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t data); uint8_t nrf24_write_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t data);
/** Write buffer to device register /** Write buffer to device register
* *
* @param handle - pointer to FuriHalSpiHandle * @param handle - pointer to FuriHalSpiHandle
@ -68,7 +65,6 @@ uint8_t nrf24_write_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t data);
*/ */
uint8_t nrf24_write_buf_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t* data, uint8_t size); uint8_t nrf24_write_buf_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t* data, uint8_t size);
/** Read device register /** Read device register
* *
* @param handle - pointer to FuriHalSpiHandle * @param handle - pointer to FuriHalSpiHandle
@ -79,7 +75,6 @@ uint8_t nrf24_write_buf_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t* d
*/ */
uint8_t nrf24_read_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t* data, uint8_t size); uint8_t nrf24_read_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t* data, uint8_t size);
/** Power up the radio for operation /** Power up the radio for operation
* *
* @param handle - pointer to FuriHalSpiHandle * @param handle - pointer to FuriHalSpiHandle
@ -88,7 +83,6 @@ uint8_t nrf24_read_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t* data,
*/ */
uint8_t nrf24_power_up(FuriHalSpiBusHandle* handle); uint8_t nrf24_power_up(FuriHalSpiBusHandle* handle);
/** Power down the radio /** Power down the radio
* *
* @param handle - pointer to FuriHalSpiHandle * @param handle - pointer to FuriHalSpiHandle
@ -97,7 +91,6 @@ uint8_t nrf24_power_up(FuriHalSpiBusHandle* handle);
*/ */
uint8_t nrf24_set_idle(FuriHalSpiBusHandle* handle); uint8_t nrf24_set_idle(FuriHalSpiBusHandle* handle);
/** Sets the radio to RX mode /** Sets the radio to RX mode
* *
* @param handle - pointer to FuriHalSpiHandle * @param handle - pointer to FuriHalSpiHandle
@ -106,7 +99,6 @@ uint8_t nrf24_set_idle(FuriHalSpiBusHandle* handle);
*/ */
uint8_t nrf24_set_rx_mode(FuriHalSpiBusHandle* handle); uint8_t nrf24_set_rx_mode(FuriHalSpiBusHandle* handle);
/** Sets the radio to TX mode /** Sets the radio to TX mode
* *
* @param handle - pointer to FuriHalSpiHandle * @param handle - pointer to FuriHalSpiHandle
@ -121,10 +113,9 @@ uint8_t nrf24_set_tx_mode(FuriHalSpiBusHandle* handle);
/** Must call this before using any other nrf24 API /** Must call this before using any other nrf24 API
* *
*/ */
void nrf24_init(); void nrf24_init();
/** Send flush rx command /** Send flush rx command
* *
* @param handle - pointer to FuriHalSpiHandle * @param handle - pointer to FuriHalSpiHandle
@ -141,7 +132,6 @@ uint8_t nrf24_flush_rx(FuriHalSpiBusHandle* handle);
*/ */
uint8_t nrf24_flush_tx(FuriHalSpiBusHandle* handle); uint8_t nrf24_flush_tx(FuriHalSpiBusHandle* handle);
/** Gets the RX packet length in data pipe 0 /** Gets the RX packet length in data pipe 0
* *
* @param handle - pointer to FuriHalSpiHandle * @param handle - pointer to FuriHalSpiHandle
@ -150,7 +140,6 @@ uint8_t nrf24_flush_tx(FuriHalSpiBusHandle* handle);
*/ */
uint8_t nrf24_get_packetlen(FuriHalSpiBusHandle* handle); uint8_t nrf24_get_packetlen(FuriHalSpiBusHandle* handle);
/** Sets the RX packet length in data pipe 0 /** Sets the RX packet length in data pipe 0
* *
* @param handle - pointer to FuriHalSpiHandle * @param handle - pointer to FuriHalSpiHandle
@ -160,7 +149,6 @@ uint8_t nrf24_get_packetlen(FuriHalSpiBusHandle* handle);
*/ */
uint8_t nrf24_set_packetlen(FuriHalSpiBusHandle* handle, uint8_t len); uint8_t nrf24_set_packetlen(FuriHalSpiBusHandle* handle, uint8_t len);
/** Gets configured length of MAC address /** Gets configured length of MAC address
* *
* @param handle - pointer to FuriHalSpiHandle * @param handle - pointer to FuriHalSpiHandle
@ -212,7 +200,6 @@ uint8_t nrf24_set_rate(FuriHalSpiBusHandle* handle, uint32_t rate);
*/ */
uint8_t nrf24_get_chan(FuriHalSpiBusHandle* handle); uint8_t nrf24_get_chan(FuriHalSpiBusHandle* handle);
/** Sets the channel /** Sets the channel
* *
* @param handle - pointer to FuriHalSpiHandle * @param handle - pointer to FuriHalSpiHandle
@ -222,7 +209,6 @@ uint8_t nrf24_get_chan(FuriHalSpiBusHandle* handle);
*/ */
uint8_t nrf24_set_chan(FuriHalSpiBusHandle* handle, uint8_t chan); uint8_t nrf24_set_chan(FuriHalSpiBusHandle* handle, uint8_t chan);
/** Gets the source mac address /** Gets the source mac address
* *
* @param handle - pointer to FuriHalSpiHandle * @param handle - pointer to FuriHalSpiHandle
@ -230,8 +216,7 @@ uint8_t nrf24_set_chan(FuriHalSpiBusHandle* handle, uint8_t chan);
* *
* @return device status * @return device status
*/ */
uint8_t nrf24_get_src_mac(FuriHalSpiBusHandle* handle, uint8_t *mac); uint8_t nrf24_get_src_mac(FuriHalSpiBusHandle* handle, uint8_t* mac);
/** Sets the source mac address /** Sets the source mac address
* *
@ -243,7 +228,6 @@ uint8_t nrf24_get_src_mac(FuriHalSpiBusHandle* handle, uint8_t *mac);
*/ */
uint8_t nrf24_set_src_mac(FuriHalSpiBusHandle* handle, uint8_t* mac, uint8_t size); uint8_t nrf24_set_src_mac(FuriHalSpiBusHandle* handle, uint8_t* mac, uint8_t size);
/** Gets the dest mac address /** Gets the dest mac address
* *
* @param handle - pointer to FuriHalSpiHandle * @param handle - pointer to FuriHalSpiHandle
@ -251,8 +235,7 @@ uint8_t nrf24_set_src_mac(FuriHalSpiBusHandle* handle, uint8_t* mac, uint8_t siz
* *
* @return device status * @return device status
*/ */
uint8_t nrf24_get_dst_mac(FuriHalSpiBusHandle* handle, uint8_t *mac); uint8_t nrf24_get_dst_mac(FuriHalSpiBusHandle* handle, uint8_t* mac);
/** Sets the dest mac address /** Sets the dest mac address
* *
@ -264,7 +247,6 @@ uint8_t nrf24_get_dst_mac(FuriHalSpiBusHandle* handle, uint8_t *mac);
*/ */
uint8_t nrf24_set_dst_mac(FuriHalSpiBusHandle* handle, uint8_t* mac, uint8_t size); uint8_t nrf24_set_dst_mac(FuriHalSpiBusHandle* handle, uint8_t* mac, uint8_t size);
/** Reads RX packet /** Reads RX packet
* *
* @param handle - pointer to FuriHalSpiHandle * @param handle - pointer to FuriHalSpiHandle
@ -274,8 +256,8 @@ uint8_t nrf24_set_dst_mac(FuriHalSpiBusHandle* handle, uint8_t* mac, uint8_t siz
* *
* @return device status * @return device status
*/ */
uint8_t nrf24_rxpacket(FuriHalSpiBusHandle* handle, uint8_t* packet, uint8_t* packetsize, bool full); uint8_t
nrf24_rxpacket(FuriHalSpiBusHandle* handle, uint8_t* packet, uint8_t* packetsize, bool full);
/** Sends TX packet /** Sends TX packet
* *
@ -288,7 +270,6 @@ uint8_t nrf24_rxpacket(FuriHalSpiBusHandle* handle, uint8_t* packet, uint8_t* pa
*/ */
uint8_t nrf24_txpacket(FuriHalSpiBusHandle* handle, uint8_t* payload, uint8_t size, bool ack); uint8_t nrf24_txpacket(FuriHalSpiBusHandle* handle, uint8_t* payload, uint8_t size, bool ack);
/** Configure the radio /** Configure the radio
* This is not comprehensive, but covers a lot of the common configuration options that may be changed * This is not comprehensive, but covers a lot of the common configuration options that may be changed
* @param handle - pointer to FuriHalSpiHandle * @param handle - pointer to FuriHalSpiHandle
@ -301,7 +282,15 @@ uint8_t nrf24_txpacket(FuriHalSpiBusHandle* handle, uint8_t* payload, uint8_t si
* @param disable_aa - if true, disable ShockBurst * @param disable_aa - if true, disable ShockBurst
* *
*/ */
void nrf24_configure(FuriHalSpiBusHandle* handle, uint8_t rate, uint8_t* srcmac, uint8_t* dstmac, uint8_t maclen, uint8_t channel, bool noack, bool disable_aa); void nrf24_configure(
FuriHalSpiBusHandle* handle,
uint8_t rate,
uint8_t* srcmac,
uint8_t* dstmac,
uint8_t maclen,
uint8_t channel,
bool noack,
bool disable_aa);
/** Configures the radio for "promiscuous mode" and primes it for rx /** Configures the radio for "promiscuous mode" and primes it for rx
* This is not an actual mode of the nrf24, but this function exploits a few bugs in the chip that allows it to act as if it were. * This is not an actual mode of the nrf24, but this function exploits a few bugs in the chip that allows it to act as if it were.
@ -312,7 +301,6 @@ void nrf24_configure(FuriHalSpiBusHandle* handle, uint8_t rate, uint8_t* srcmac,
*/ */
void nrf24_init_promisc_mode(FuriHalSpiBusHandle* handle, uint8_t channel, uint8_t rate); void nrf24_init_promisc_mode(FuriHalSpiBusHandle* handle, uint8_t channel, uint8_t rate);
/** Listens for a packet and returns first possible address sniffed /** Listens for a packet and returns first possible address sniffed
* Call this only after calling nrf24_init_promisc_mode * Call this only after calling nrf24_init_promisc_mode
* @param handle - pointer to FuriHalSpiHandle * @param handle - pointer to FuriHalSpiHandle
@ -336,8 +324,15 @@ bool nrf24_sniff_address(FuriHalSpiBusHandle* handle, uint8_t maclen, uint8_t* a
* *
* @return channel that the address is listening on, if this value is above the max_channel param, it failed * @return channel that the address is listening on, if this value is above the max_channel param, it failed
*/ */
uint8_t nrf24_find_channel(FuriHalSpiBusHandle* handle, uint8_t* srcmac, uint8_t* dstmac, uint8_t maclen, uint8_t rate, uint8_t min_channel, uint8_t max_channel, bool autoinit); uint8_t nrf24_find_channel(
FuriHalSpiBusHandle* handle,
uint8_t* srcmac,
uint8_t* dstmac,
uint8_t maclen,
uint8_t rate,
uint8_t min_channel,
uint8_t max_channel,
bool autoinit);
/** Converts 64 bit value into uint8_t array /** Converts 64 bit value into uint8_t array
* @param val - 64-bit integer * @param val - 64-bit integer
@ -346,7 +341,6 @@ uint8_t nrf24_find_channel(FuriHalSpiBusHandle* handle, uint8_t* srcmac, uint8_t
*/ */
void int64_to_bytes(uint64_t val, uint8_t* out, bool bigendian); void int64_to_bytes(uint64_t val, uint8_t* out, bool bigendian);
/** Converts 32 bit value into uint8_t array /** Converts 32 bit value into uint8_t array
* @param val - 32-bit integer * @param val - 32-bit integer
* @param[out] out - bytes out * @param[out] out - bytes out
@ -354,7 +348,6 @@ void int64_to_bytes(uint64_t val, uint8_t* out, bool bigendian);
*/ */
void int32_to_bytes(uint32_t val, uint8_t* out, bool bigendian); void int32_to_bytes(uint32_t val, uint8_t* out, bool bigendian);
/** Converts uint8_t array into 32 bit value /** Converts uint8_t array into 32 bit value
* @param bytes - uint8_t array * @param bytes - uint8_t array
* @param bigendian - if true, convert as big endian, otherwise little endian * @param bigendian - if true, convert as big endian, otherwise little endian

View file

@ -31,8 +31,10 @@ typedef void* (*SubGhzAlloc)(SubGhzEnvironment* environment);
typedef void (*SubGhzFree)(void* context); typedef void (*SubGhzFree)(void* context);
// Serialize and Deserialize // Serialize and Deserialize
typedef bool ( typedef bool (*SubGhzSerialize)(
*SubGhzSerialize)(void* context, FlipperFormat* flipper_format, SubGhzPresetDefinition* preset); void* context,
FlipperFormat* flipper_format,
SubGhzPresetDefinition* preset);
typedef bool (*SubGhzDeserialize)(void* context, FlipperFormat* flipper_format); typedef bool (*SubGhzDeserialize)(void* context, FlipperFormat* flipper_format);
// Decoder specific // Decoder specific