This commit is contained in:
VerstreuteSeele
2022-12-24 19:16:14 +01:00
20 changed files with 200 additions and 185 deletions
+1 -1
View File
@@ -9,6 +9,6 @@ Hit any button other than back repeatedly. Calculates based on the average of th
## Compiling
```
./fbt firmware_bpm_tapper
./fbt fap_bpm_tapper
```
@@ -7,7 +7,7 @@ App(
requires=["gui"],
stack_size=2 * 1024,
fap_icon="bpm_10px.png",
fap_category="Music",
fap_icon_assets="icons",
order=15,
fap_category="Music",
order=35,
)
+19 -20
View File
@@ -3,6 +3,7 @@
#include <dialogs/dialogs.h>
#include <gui/gui.h>
#include <input/input.h>
#include <m-string.h>
#include <stdlib.h>
#include "BPM_Tapper_icons.h"
@@ -126,7 +127,7 @@ static void input_callback(InputEvent* input_event, FuriMessageQueue* event_queu
}
static void render_callback(Canvas* const canvas, void* ctx) {
FuriString* tempStr;
string_t tempStr;
const BPMTapper* bpm_state = acquire_mutex((ValueMutex*)ctx, 25);
if(bpm_state == NULL) {
@@ -136,32 +137,30 @@ static void render_callback(Canvas* const canvas, void* ctx) {
//canvas_draw_frame(canvas, 0, 0, 128, 64);
canvas_set_font(canvas, FontPrimary);
tempStr = furi_string_alloc();
string_init(tempStr);
furi_string_printf(tempStr, "Taps: %d", bpm_state->taps);
canvas_draw_str_aligned(canvas, 5, 10, AlignLeft, AlignBottom, furi_string_get_cstr(tempStr));
furi_string_reset(tempStr);
string_printf(tempStr, "Taps: %d", bpm_state->taps);
canvas_draw_str_aligned(canvas, 5, 10, AlignLeft, AlignBottom, string_get_cstr(tempStr));
string_reset(tempStr);
furi_string_printf(tempStr, "Queue: %d", bpm_state->tap_queue->size);
canvas_draw_str_aligned(canvas, 70, 10, AlignLeft, AlignBottom, furi_string_get_cstr(tempStr));
furi_string_reset(tempStr);
string_printf(tempStr, "Queue: %d", bpm_state->tap_queue->size);
canvas_draw_str_aligned(canvas, 70, 10, AlignLeft, AlignBottom, string_get_cstr(tempStr));
string_reset(tempStr);
furi_string_printf(tempStr, "Interval: %ldms", bpm_state->interval);
canvas_draw_str_aligned(canvas, 5, 20, AlignLeft, AlignBottom, furi_string_get_cstr(tempStr));
furi_string_reset(tempStr);
string_printf(tempStr, "Interval: %dms", bpm_state->interval);
canvas_draw_str_aligned(canvas, 5, 20, AlignLeft, AlignBottom, string_get_cstr(tempStr));
string_reset(tempStr);
furi_string_printf(tempStr, "x2 %.2f /2 %.2f", bpm_state->bpm * 2, bpm_state->bpm / 2);
canvas_draw_str_aligned(
canvas, 64, 60, AlignCenter, AlignCenter, furi_string_get_cstr(tempStr));
furi_string_reset(tempStr);
string_printf(tempStr, "x2 %.2f /2 %.2f", bpm_state->bpm * 2, bpm_state->bpm / 2);
canvas_draw_str_aligned(canvas, 64, 60, AlignCenter, AlignCenter, string_get_cstr(tempStr));
string_reset(tempStr);
furi_string_printf(tempStr, "%.2f", bpm_state->bpm);
string_printf(tempStr, "%.2f", bpm_state->bpm);
canvas_set_font(canvas, FontBigNumbers);
canvas_draw_str_aligned(
canvas, 64, 40, AlignCenter, AlignCenter, furi_string_get_cstr(tempStr));
furi_string_reset(tempStr);
canvas_draw_str_aligned(canvas, 64, 40, AlignCenter, AlignCenter, string_get_cstr(tempStr));
string_reset(tempStr);
furi_string_free(tempStr);
string_clear(tempStr);
release_mutex((ValueMutex*)ctx, bpm_state);
}
+1 -3
View File
@@ -1,7 +1,5 @@
# Metronome
[Original link](https://github.com/panki27/Metronome)
A metronome for the [Flipper Zero](https://flipperzero.one/) device. Goes along perfectly with my [BPM tapper](https://github.com/panki27/bpm-tapper).
![screenshot](img/screenshot.png)
@@ -19,5 +17,5 @@ A metronome for the [Flipper Zero](https://flipperzero.one/) device. Goes along
## Compiling
```
./fbt firmware_metronome
./fbt fap_metronome
```
@@ -8,8 +8,8 @@ App(
"gui",
],
fap_icon="metronome_icon.png",
fap_icon_assets="icons",
fap_category="Music",
fap_icon_assets="images",
stack_size=2 * 1024,
order=20,
)
@@ -1,6 +1,6 @@
#include <gui/canvas.h>
#include <gui/icon_i.h>
#include <Metronome_icons.h>
#include "Metronome_icons.h"
//lib can only do bottom left/right
void elements_button_top_left(Canvas* canvas, const char* str) {
Binary file not shown.

Before

Width:  |  Height:  |  Size: 102 B

+14 -21
View File
@@ -1,6 +1,7 @@
#include <furi.h>
#include <furi_hal.h>
#include <input/input.h>
#include <m-string.h>
#include <stdlib.h>
#include <gui/gui.h>
@@ -57,26 +58,23 @@ static void render_callback(Canvas* const canvas, void* ctx) {
return;
}
FuriString* tempStr;
tempStr = furi_string_alloc();
string_t tempStr;
string_init(tempStr);
canvas_draw_frame(canvas, 0, 0, 128, 64);
canvas_set_font(canvas, FontPrimary);
// draw bars/beat
furi_string_printf(
tempStr, "%d/%d", metronome_state->beats_per_bar, metronome_state->note_length);
canvas_draw_str_aligned(
canvas, 64, 8, AlignCenter, AlignCenter, furi_string_get_cstr(tempStr));
furi_string_reset(tempStr);
string_printf(tempStr, "%d/%d", metronome_state->beats_per_bar, metronome_state->note_length);
canvas_draw_str_aligned(canvas, 64, 8, AlignCenter, AlignCenter, string_get_cstr(tempStr));
string_reset(tempStr);
// draw BPM value
furi_string_printf(tempStr, "%.2f", metronome_state->bpm);
string_printf(tempStr, "%.2f", metronome_state->bpm);
canvas_set_font(canvas, FontBigNumbers);
canvas_draw_str_aligned(
canvas, 64, 24, AlignCenter, AlignCenter, furi_string_get_cstr(tempStr));
furi_string_reset(tempStr);
canvas_draw_str_aligned(canvas, 64, 24, AlignCenter, AlignCenter, string_get_cstr(tempStr));
string_reset(tempStr);
// draw volume indicator
// always draw first waves
@@ -128,7 +126,7 @@ static void render_callback(Canvas* const canvas, void* ctx) {
canvas, 8, 36, 112, (float)metronome_state->current_beat / metronome_state->beats_per_bar);
// cleanup
furi_string_free(tempStr);
string_clear(tempStr);
release_mutex((ValueMutex*)ctx, metronome_state);
}
@@ -160,8 +158,6 @@ static void timer_callback(void* ctx) {
break;
case Silent:
break;
default:
break;
}
} else {
// unpronounced beat
@@ -177,8 +173,6 @@ static void timer_callback(void* ctx) {
break;
case Silent:
break;
default:
break;
}
};
@@ -203,8 +197,6 @@ static void timer_callback(void* ctx) {
break;
case Silent:
break;
default:
break;
}
notification_message(metronome_state->notifications, &sequence_reset_rgb);
@@ -295,6 +287,7 @@ int32_t metronome_app() {
metronome_state->timer = furi_timer_alloc(timer_callback, FuriTimerTypePeriodic, &state_mutex);
// Open GUI and register view_port
//
Gui* gui = furi_record_open("gui");
gui_add_view_port(gui, view_port, GuiLayerFullscreen);
@@ -333,7 +326,7 @@ int32_t metronome_app() {
case InputKeyBack:
processing = false;
break;
default:
case InputKeyMAX:
break;
}
} else if(event.input.type == InputTypeLong) {
@@ -355,7 +348,7 @@ int32_t metronome_app() {
case InputKeyBack:
processing = false;
break;
default:
case InputKeyMAX:
break;
}
} else if(event.input.type == InputTypeRepeat) {
@@ -376,7 +369,7 @@ int32_t metronome_app() {
case InputKeyBack:
processing = false;
break;
default:
case InputKeyMAX:
break;
}
}
@@ -1,7 +1,5 @@
# Minesweeper
[Original Link](https://github.com/panki27/minesweeper)
This is a Minesweeper implementation for the Flipper Zero device.
![screenshot](img/screenshot.png)
@@ -217,10 +217,6 @@ static bool game_lost(Minesweeper* minesweeper_state) {
dialog_message_set_icon(message, NULL, 0, 10);
// Set cursor to initial position
minesweeper_state->cursor_x = 0;
minesweeper_state->cursor_y = 0;
NotificationApp* notifications = furi_record_open(RECORD_NOTIFICATION);
notification_message(notifications, &sequence_set_vibro_on);
furi_record_close(RECORD_NOTIFICATION);
@@ -476,7 +472,7 @@ int32_t minesweeper_app(void* p) {
// Exit the plugin
processing = false;
break;
default:
case InputKeyMAX:
break;
}
} else if(event.input.type == InputTypeLong) {
@@ -495,7 +491,7 @@ int32_t minesweeper_app(void* p) {
case InputKeyBack:
processing = false;
break;
default:
case InputKeyMAX:
break;
}
}
+17 -10
View File
@@ -212,8 +212,11 @@ void write_to_log_file(Storage* storage, bool f_settings) {
if(fl) {
FURI_LOG_D(TAG, "Save to %s", furi_string_get_cstr(str));
if(save_to_new_log || f_settings) {
//if(what_to_do == 1) furi_string_printf(str, "%s\n", SettingsFld_Sniff); else furi_string_reset(str);
furi_string_printf(
if(what_to_do == 1)
furi_string_printf(str, "%s\n", SettingsFld_Sniff);
else
furi_string_reset(str);
furi_string_cat_printf(
str,
"%s %d\n%s %d\n%s %d\n",
SettingsFld_Rate,
@@ -231,9 +234,11 @@ void write_to_log_file(Storage* storage, bool f_settings) {
NRF_CRC,
SettingsFld_Payload,
what_to_do == 1 ? NRF_Payload_sniff_min : NRF_Payload);
furi_string_cat_printf(str, "P0: ");
add_to_furi_str_hex_bytes(str, (char*)addrs.addr_P0, addrs.addr_len);
furi_string_cat(str, "\n");
if(addrs.addr_count > 0) {
furi_string_cat_printf(str, "P0: ");
add_to_furi_str_hex_bytes(str, (char*)addrs.addr_P0, addrs.addr_len);
furi_string_cat(str, "\n");
}
if(addrs.addr_count > 1) {
furi_string_cat_printf(str, "P1: ");
add_to_furi_str_hex_bytes(str, (char*)addrs.addr_P1, addrs.addr_len);
@@ -428,13 +433,14 @@ static uint8_t load_settings_file(Stream* file_stream) {
if(err == 0 && a) adr->addr_count = a - '0' + 1;
} else if(line_len >= 3 * 2) { // data
if(!log_loaded) {
log_loaded = true;
clear_log();
what_to_do = 0;
log_loaded = true;
}
if(log_arr_idx < MAX_LOG_RECORDS - 1) {
ConvertHexToArray(
line_ptr, APP->log_arr + log_arr_idx * LOG_REC_SIZE, LOG_REC_SIZE);
if(ConvertHexToArray(
line_ptr, APP->log_arr + log_arr_idx * LOG_REC_SIZE, LOG_REC_SIZE) > 0)
err = 0;
log_arr_idx++;
}
}
@@ -511,13 +517,14 @@ static void prepare_nrf24(bool fsend_packet) {
}
if(what_to_do == 1) { // SNIFF
payload = 32;
nrf24_write_reg(nrf24_HANDLE, REG_CONFIG, 0x70); // Mask all interrupts
nrf24_write_reg(nrf24_HANDLE, REG_CONFIG, 0x70); // Mask all interrupts, NO CRC
nrf24_write_reg(nrf24_HANDLE, REG_SETUP_RETR, 0); // Automatic Retransmission
nrf24_write_reg(nrf24_HANDLE, REG_EN_AA, 0); // Auto acknowledgement
nrf24_write_reg(
nrf24_HANDLE,
REG_FEATURE,
0); // Enables the W_TX_PAYLOAD_NOACK command, Disable Payload with ACK, set Dynamic Payload
nrf24_write_reg(nrf24_HANDLE, REG_RF_CH, NRF_channel);
} else if(setup_from_log) { // Scan
nrf24_write_reg(
nrf24_HANDLE,
@@ -1013,7 +1020,7 @@ static void render_callback(Canvas* const canvas, void* ctx) {
if(log_arr_idx && (*p & 0x80)) { // +RAW
snprintf(screen_buf, sizeof(screen_buf), "Start read: ");
add_to_str_hex_bytes(screen_buf, (char*)p + 2, (*(p + 1) & 0b11) + 2);
if(what_to_do == 3) strcpy(screen_buf + strlen(screen_buf) - 2, "* ");
if(what_to_do == 2) strcpy(screen_buf + strlen(screen_buf) - 2, "* ");
} else
snprintf(
screen_buf,
@@ -34,7 +34,7 @@ void wifi_marauder_scene_console_output_on_enter(void* context) {
app->text_box_store_strlen = 0;
if(0 == strncmp("help", app->selected_tx_string, strlen("help"))) {
const char* help_msg =
"Marauder companion v0.2.2\nFor app support/feedback,\nreach out to me:\n@cococode#6011 (discord)\n0xchocolate (github)\n";
"Marauder companion v0.3.0\nFor app support/feedback,\nreach out to me:\n@cococode#6011 (discord)\n0xchocolate (github)\n";
furi_string_cat_str(app->text_box_store, help_msg);
app->text_box_store_strlen += strlen(help_msg);
}
@@ -26,7 +26,13 @@ typedef struct {
// NUM_MENU_ITEMS defined in wifi_marauder_app_i.h - if you add an entry here, increment it!
const WifiMarauderItem items[NUM_MENU_ITEMS] = {
{"View Log from", {"start", "end"}, 2, {"", ""}, NO_ARGS, FOCUS_CONSOLE_TOGGLE, NO_TIP},
{"Scan AP", {""}, 1, {"scanap"}, NO_ARGS, FOCUS_CONSOLE_END, SHOW_STOPSCAN_TIP},
{"Scan",
{"ap", "station"},
2,
{"scanap", "scansta"},
NO_ARGS,
FOCUS_CONSOLE_END,
SHOW_STOPSCAN_TIP},
{"SSID",
{"add rand", "add name", "remove"},
3,
@@ -34,12 +40,24 @@ const WifiMarauderItem items[NUM_MENU_ITEMS] = {
INPUT_ARGS,
FOCUS_CONSOLE_START,
NO_TIP},
{"List", {"ap", "ssid"}, 2, {"list -a", "list -s"}, NO_ARGS, FOCUS_CONSOLE_START, NO_TIP},
{"Select", {"ap", "ssid"}, 2, {"select -a", "select -s"}, INPUT_ARGS, FOCUS_CONSOLE_END, NO_TIP},
{"List",
{"ap", "ssid", "station"},
3,
{"list -a", "list -s", "list -c"},
NO_ARGS,
FOCUS_CONSOLE_START,
NO_TIP},
{"Select",
{"ap", "ssid", "station"},
3,
{"select -a", "select -s", "select -c"},
INPUT_ARGS,
FOCUS_CONSOLE_END,
NO_TIP},
{"Clear List",
{"ap", "ssid"},
2,
{"clearlist -a", "clearlist -s"},
{"ap", "ssid", "station"},
3,
{"clearlist -a", "clearlist -s", "clearlist -c"},
NO_ARGS,
FOCUS_CONSOLE_END,
NO_TIP},
@@ -50,6 +68,13 @@ const WifiMarauderItem items[NUM_MENU_ITEMS] = {
NO_ARGS,
FOCUS_CONSOLE_END,
SHOW_STOPSCAN_TIP},
{"Targeted Deauth",
{"station", "manual"},
2,
{"attack -t deauth -c", "attack -t deauth -s"},
TOGGLE_ARGS,
FOCUS_CONSOLE_END,
SHOW_STOPSCAN_TIP},
{"Beacon Spam",
{"ap list", "ssid list", "random"},
3,
@@ -87,18 +112,19 @@ const WifiMarauderItem items[NUM_MENU_ITEMS] = {
FOCUS_CONSOLE_END,
NO_TIP},
{"Settings",
{"display", "restore", "ForcePMKID", "ForceProbe", "SavePCAP", "other"},
6,
{"display", "restore", "ForcePMKID", "ForceProbe", "SavePCAP", "EnableLED", "other"},
7,
{"settings",
"settings -r",
"settings -s ForcePMKID enable",
"settings -s ForceProbe enable",
"settings -s SavePCAP enable",
"settings -s EnableLED enable",
"settings -s"},
TOGGLE_ARGS,
FOCUS_CONSOLE_START,
NO_TIP},
{"Update", {""}, 1, {"update -w"}, NO_ARGS, FOCUS_CONSOLE_END, NO_TIP},
{"Update", {"ota", "sd"}, 2, {"update -w", "update -s"}, NO_ARGS, FOCUS_CONSOLE_END, NO_TIP},
{"Reboot", {""}, 1, {"reboot"}, NO_ARGS, FOCUS_CONSOLE_END, NO_TIP},
{"Help", {""}, 1, {"help"}, NO_ARGS, FOCUS_CONSOLE_START, SHOW_STOPSCAN_TIP},
};
@@ -3,13 +3,34 @@
void wifi_marauder_scene_text_input_callback(void* context) {
WifiMarauderApp* app = context;
view_dispatcher_send_custom_event(app->view_dispatcher, WifiMarauderEventStartConsole);
switch(app->special_case_input_step) {
case 0: // most commands
view_dispatcher_send_custom_event(app->view_dispatcher, WifiMarauderEventStartConsole);
break;
case 1: // special case for deauth: save source MAC
view_dispatcher_send_custom_event(app->view_dispatcher, WifiMarauderEventSaveSourceMac);
break;
case 2: // special case for deauth: save destination MAC
view_dispatcher_send_custom_event(
app->view_dispatcher, WifiMarauderEventSaveDestinationMac);
break;
default:
break;
}
}
void wifi_marauder_scene_text_input_on_enter(void* context) {
WifiMarauderApp* app = context;
if(false == app->is_custom_tx_string) {
if(0 ==
strncmp("attack -t deauth -s", app->selected_tx_string, strlen("attack -t deauth -s"))) {
// Special case for manual deauth input
app->special_case_input_step = 1;
bzero(app->text_input_store, WIFI_MARAUDER_TEXT_INPUT_STORE_SIZE);
} else if(false == app->is_custom_tx_string) {
// Most commands
app->special_case_input_step = 0;
// Fill text input with selected string so that user can add to it
size_t length = strlen(app->selected_tx_string);
furi_assert(length < WIFI_MARAUDER_TEXT_INPUT_STORE_SIZE);
@@ -25,7 +46,9 @@ void wifi_marauder_scene_text_input_on_enter(void* context) {
// Setup view
TextInput* text_input = app->text_input;
// Add help message to header
if(0 == strncmp("ssid -a -g", app->selected_tx_string, strlen("ssid -a -g"))) {
if(app->special_case_input_step == 1) {
text_input_set_header_text(text_input, "Enter source MAC");
} else if(0 == strncmp("ssid -a -g", app->selected_tx_string, strlen("ssid -a -g"))) {
text_input_set_header_text(text_input, "Enter # SSIDs to generate");
} else if(0 == strncmp("ssid -a -n", app->selected_tx_string, strlen("ssid -a -n"))) {
text_input_set_header_text(text_input, "Enter SSID name to add");
@@ -59,6 +82,65 @@ bool wifi_marauder_scene_text_input_on_event(void* context, SceneManagerEvent ev
app->selected_tx_string = app->text_input_store;
scene_manager_next_scene(app->scene_manager, WifiMarauderAppViewConsoleOutput);
consumed = true;
} else if(event.event == WifiMarauderEventSaveSourceMac) {
if(12 != strlen(app->text_input_store)) {
text_input_set_header_text(app->text_input, "MAC must be 12 hex chars!");
} else {
snprintf(
app->special_case_input_src_addr,
sizeof(app->special_case_input_src_addr),
"%c%c:%c%c:%c%c:%c%c:%c%c:%c%c",
app->text_input_store[0],
app->text_input_store[1],
app->text_input_store[2],
app->text_input_store[3],
app->text_input_store[4],
app->text_input_store[5],
app->text_input_store[6],
app->text_input_store[7],
app->text_input_store[8],
app->text_input_store[9],
app->text_input_store[10],
app->text_input_store[11]);
// Advance scene to input destination MAC, clear text input
app->special_case_input_step = 2;
bzero(app->text_input_store, WIFI_MARAUDER_TEXT_INPUT_STORE_SIZE);
text_input_set_header_text(app->text_input, "Enter destination MAC");
}
consumed = true;
} else if(event.event == WifiMarauderEventSaveDestinationMac) {
if(12 != strlen(app->text_input_store)) {
text_input_set_header_text(app->text_input, "MAC must be 12 hex chars!");
} else {
snprintf(
app->special_case_input_dst_addr,
sizeof(app->special_case_input_dst_addr),
"%c%c:%c%c:%c%c:%c%c:%c%c:%c%c",
app->text_input_store[0],
app->text_input_store[1],
app->text_input_store[2],
app->text_input_store[3],
app->text_input_store[4],
app->text_input_store[5],
app->text_input_store[6],
app->text_input_store[7],
app->text_input_store[8],
app->text_input_store[9],
app->text_input_store[10],
app->text_input_store[11]);
// Construct command with source and destination MACs
snprintf(
app->text_input_store,
WIFI_MARAUDER_TEXT_INPUT_STORE_SIZE,
"attack -t deauth -s %18s -d %18s",
app->special_case_input_src_addr,
app->special_case_input_dst_addr);
app->selected_tx_string = app->text_input_store;
scene_manager_next_scene(app->scene_manager, WifiMarauderAppViewConsoleOutput);
}
consumed = true;
}
}
@@ -50,6 +50,8 @@ WifiMarauderApp* wifi_marauder_app_alloc() {
app->selected_option_index[i] = 0;
}
app->special_case_input_step = 0;
app->text_box = text_box_alloc();
view_dispatcher_add_view(
app->view_dispatcher, WifiMarauderAppViewConsoleOutput, text_box_get_view(app->text_box));
@@ -14,7 +14,7 @@
#include <gui/modules/text_input.h>
#include <gui/modules/variable_item_list.h>
#define NUM_MENU_ITEMS (15)
#define NUM_MENU_ITEMS (16)
#define WIFI_MARAUDER_TEXT_BOX_STORE_SIZE (4096)
#define WIFI_MARAUDER_TEXT_INPUT_STORE_SIZE (512)
@@ -41,6 +41,11 @@ struct WifiMarauderApp {
bool is_custom_tx_string;
bool focus_console_start;
bool show_stopscan_tip;
// For input source and destination MAC in targeted deauth attack
int special_case_input_step;
char special_case_input_src_addr[20];
char special_case_input_dst_addr[20];
};
// Supported commands:
@@ -4,4 +4,6 @@ typedef enum {
WifiMarauderEventRefreshConsoleOutput = 0,
WifiMarauderEventStartConsole,
WifiMarauderEventStartKeyboard,
WifiMarauderEventSaveSourceMac,
WifiMarauderEventSaveDestinationMac
} WifiMarauderCustomEvent;