mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-12 21:28:36 -07:00
BLE Spam add basic config page (parameters later)
This commit is contained in:
26
applications/external/ble_spam/ble_spam.c
vendored
26
applications/external/ble_spam/ble_spam.c
vendored
@@ -12,13 +12,6 @@
|
|||||||
// Research on behaviors and parameters by @Willy-JL, @ECTO-1A and @Spooks4576
|
// Research on behaviors and parameters by @Willy-JL, @ECTO-1A and @Spooks4576
|
||||||
// Controversy explained at https://willyjl.dev/blog/the-controversy-behind-apple-ble-spam
|
// Controversy explained at https://willyjl.dev/blog/the-controversy-behind-apple-ble-spam
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
const char* title;
|
|
||||||
const char* text;
|
|
||||||
const Protocol* protocol;
|
|
||||||
Payload payload;
|
|
||||||
} Attack;
|
|
||||||
|
|
||||||
static Attack attacks[] = {
|
static Attack attacks[] = {
|
||||||
{
|
{
|
||||||
.title = "+ Kitchen Sink",
|
.title = "+ Kitchen Sink",
|
||||||
@@ -323,7 +316,15 @@ static bool input_callback(InputEvent* input, void* ctx) {
|
|||||||
|
|
||||||
switch(input->key) {
|
switch(input->key) {
|
||||||
case InputKeyOk:
|
case InputKeyOk:
|
||||||
if(is_attack) toggle_adv(state);
|
if(is_attack) {
|
||||||
|
if(input->type == InputTypeLong) {
|
||||||
|
if(advertising) toggle_adv(state);
|
||||||
|
state->ctx.attack = &attacks[state->index];
|
||||||
|
scene_manager_next_scene(state->ctx.scene_manager, SceneConfig);
|
||||||
|
} else if(input->type == InputTypeShort) {
|
||||||
|
toggle_adv(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case InputKeyUp:
|
case InputKeyUp:
|
||||||
if(is_attack && state->delay < COUNT_OF(delays) - 1) {
|
if(is_attack && state->delay < COUNT_OF(delays) - 1) {
|
||||||
@@ -389,10 +390,19 @@ int32_t ble_spam(void* p) {
|
|||||||
view_set_input_callback(view_main, input_callback);
|
view_set_input_callback(view_main, input_callback);
|
||||||
view_dispatcher_add_view(state->ctx.view_dispatcher, ViewMain, view_main);
|
view_dispatcher_add_view(state->ctx.view_dispatcher, ViewMain, view_main);
|
||||||
|
|
||||||
|
state->ctx.variable_item_list = variable_item_list_alloc();
|
||||||
|
view_dispatcher_add_view(
|
||||||
|
state->ctx.view_dispatcher,
|
||||||
|
ViewVariableItemList,
|
||||||
|
variable_item_list_get_view(state->ctx.variable_item_list));
|
||||||
|
|
||||||
view_dispatcher_attach_to_gui(state->ctx.view_dispatcher, gui, ViewDispatcherTypeFullscreen);
|
view_dispatcher_attach_to_gui(state->ctx.view_dispatcher, gui, ViewDispatcherTypeFullscreen);
|
||||||
scene_manager_next_scene(state->ctx.scene_manager, SceneMain);
|
scene_manager_next_scene(state->ctx.scene_manager, SceneMain);
|
||||||
view_dispatcher_run(state->ctx.view_dispatcher);
|
view_dispatcher_run(state->ctx.view_dispatcher);
|
||||||
|
|
||||||
|
view_dispatcher_remove_view(state->ctx.view_dispatcher, ViewVariableItemList);
|
||||||
|
variable_item_list_free(state->ctx.variable_item_list);
|
||||||
|
|
||||||
view_dispatcher_remove_view(state->ctx.view_dispatcher, ViewMain);
|
view_dispatcher_remove_view(state->ctx.view_dispatcher, ViewMain);
|
||||||
view_free(view_main);
|
view_free(view_main);
|
||||||
|
|
||||||
|
|||||||
8
applications/external/ble_spam/ble_spam.h
vendored
8
applications/external/ble_spam/ble_spam.h
vendored
@@ -1,14 +1,22 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <gui/view_dispatcher.h>
|
#include <gui/view_dispatcher.h>
|
||||||
|
#include <gui/modules/variable_item_list.h>
|
||||||
|
|
||||||
#include "scenes/_setup.h"
|
#include "scenes/_setup.h"
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
ViewMain,
|
ViewMain,
|
||||||
|
ViewVariableItemList,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef struct Attack Attack;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
Attack* attack;
|
||||||
|
|
||||||
ViewDispatcher* view_dispatcher;
|
ViewDispatcher* view_dispatcher;
|
||||||
SceneManager* scene_manager;
|
SceneManager* scene_manager;
|
||||||
|
|
||||||
|
VariableItemList* variable_item_list;
|
||||||
} Ctx;
|
} Ctx;
|
||||||
|
|||||||
@@ -18,3 +18,10 @@ typedef struct {
|
|||||||
bool random_mac;
|
bool random_mac;
|
||||||
ProtocolCfg cfg;
|
ProtocolCfg cfg;
|
||||||
} Payload;
|
} Payload;
|
||||||
|
|
||||||
|
struct Attack {
|
||||||
|
const char* title;
|
||||||
|
const char* text;
|
||||||
|
const Protocol* protocol;
|
||||||
|
Payload payload;
|
||||||
|
};
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
#include "continuity_scenes.h"
|
||||||
|
#include "fastpair_scenes.h"
|
||||||
|
#include "swiftpair_scenes.h"
|
||||||
|
|||||||
0
applications/external/ble_spam/protocols/continuity_scenes.h
vendored
Normal file
0
applications/external/ble_spam/protocols/continuity_scenes.h
vendored
Normal file
0
applications/external/ble_spam/protocols/fastpair_scenes.h
vendored
Normal file
0
applications/external/ble_spam/protocols/fastpair_scenes.h
vendored
Normal file
0
applications/external/ble_spam/protocols/swiftpair_scenes.h
vendored
Normal file
0
applications/external/ble_spam/protocols/swiftpair_scenes.h
vendored
Normal file
@@ -1,2 +1,3 @@
|
|||||||
ADD_SCENE(main, Main)
|
ADD_SCENE(main, Main)
|
||||||
|
ADD_SCENE(config, Config)
|
||||||
#include "../protocols/_scenes.h"
|
#include "../protocols/_scenes.h"
|
||||||
|
|||||||
34
applications/external/ble_spam/scenes/config.c
vendored
Normal file
34
applications/external/ble_spam/scenes/config.c
vendored
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
#include "../ble_spam.h"
|
||||||
|
|
||||||
|
#include "protocols/_registry.h"
|
||||||
|
|
||||||
|
static void random_mac_changed(VariableItem* item) {
|
||||||
|
Ctx* ctx = variable_item_get_context(item);
|
||||||
|
ctx->attack->payload.random_mac = variable_item_get_current_value_index(item);
|
||||||
|
variable_item_set_current_value_text(item, ctx->attack->payload.random_mac ? "ON" : "OFF");
|
||||||
|
}
|
||||||
|
|
||||||
|
void scene_config_on_enter(void* _ctx) {
|
||||||
|
Ctx* ctx = _ctx;
|
||||||
|
VariableItem* item;
|
||||||
|
VariableItemList* list = ctx->variable_item_list;
|
||||||
|
variable_item_list_reset(list);
|
||||||
|
|
||||||
|
variable_item_list_set_header(list, ctx->attack->title);
|
||||||
|
|
||||||
|
item = variable_item_list_add(list, "Random MAC", 2, random_mac_changed, ctx);
|
||||||
|
variable_item_set_current_value_index(item, ctx->attack->payload.random_mac);
|
||||||
|
variable_item_set_current_value_text(item, ctx->attack->payload.random_mac ? "ON" : "OFF");
|
||||||
|
|
||||||
|
view_dispatcher_switch_to_view(ctx->view_dispatcher, ViewVariableItemList);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool scene_config_on_event(void* _ctx, SceneManagerEvent event) {
|
||||||
|
UNUSED(_ctx);
|
||||||
|
UNUSED(event);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void scene_config_on_exit(void* _ctx) {
|
||||||
|
UNUSED(_ctx);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user