Skip to content

Commit

Permalink
v1.1.4
Browse files Browse the repository at this point in the history
- Added confirmation dialog for Cast Video command 
- Fixed view locking issues with confirmation dialog
  • Loading branch information
jaylikesbunda authored Nov 17, 2024
1 parent 936ded6 commit 23b78f2
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 79 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# Changelog

## v1.1.4
- Added confirmation dialog for Cast Video command
- Fixed view locking issues with confirmation dialog

## v1.1.3
- **Added specific buttondown icon for help menu button to not be dependent on firmware icons**
**Added specific buttondown icon for help menu button to not be dependent on firmware icons**

## v1.1.2
- improved ESP connection check reliability by trying AT command first with shorter timeouts, while keeping original 'stop' command as fallback
Expand Down
2 changes: 1 addition & 1 deletion application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ App(
fap_category="GPIO/ESP",
# Optional values
icon="A_GhostESP_14",
fap_version="1.1.3",
fap_version="1.1.4",
fap_icon="ghost_esp.png", # 10x10 1-bit PNG
fap_icon_assets="images", # Image assets to compile for this application
)
69 changes: 18 additions & 51 deletions src/confirmation_view.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,57 +108,16 @@ static bool confirmation_view_input_callback(InputEvent* event, void* context) {
model->scroll_position < model->total_lines - 4) {
model->scroll_position++;
consumed = true;
}
}

// Easter egg sequence check - only on press events
if(model->header && strcmp(model->header, "App Info") == 0 && event->type == 0) {
// Expected sequence: Up,Up,Down,Down,Left,Right,Left,Right
const uint8_t sequence[] = {0,0,1,1,3,2,3,2};

if(event->key == sequence[model->sequence_position]) {
model->sequence_position++;
FURI_LOG_D("EasterEgg", "Correct button %d, pos %d", event->key, model->sequence_position);

// Check if sequence is complete
if(model->sequence_position == 8) {
model->easter_egg_active = true;
model->text = "Easter Egg Found!\n\n"
"Ghost in the Shell\n"
"ESP32 Edition v1.0\n\n"
"Made by: BigBrainAI\n"
"Licensed: MIT\n\n"
"A pentesting tool\n"
"for research only.\n\n"
"Up Up Down Down\n"
"Left Right Left Right";
consumed = true;
FURI_LOG_I("EasterEgg", "Easter egg activated!");
} else if(event->key == InputKeyOk) {
if(instance->ok_callback) {
instance->ok_callback(instance->ok_callback_context);
}
} else {
// Wrong button, reset sequence
model->sequence_position = 0;
// If this button is the start of sequence, count it
if(event->key == sequence[0]) {
model->sequence_position = 1;
}
}
}

if(!consumed) {
// Handle regular confirmation actions
if(event->type == InputTypeShort || event->type == InputTypeLong) {
if(event->key == InputKeyOk) {
if(instance->ok_callback) {
instance->ok_callback(instance->ok_callback_context);
}
consumed = true;
} else if(event->key == InputKeyBack) {
if(instance->cancel_callback) {
instance->cancel_callback(instance->cancel_callback_context);
}
consumed = true;
consumed = true;
} else if(event->key == InputKeyBack) {
if(instance->cancel_callback) {
instance->cancel_callback(instance->cancel_callback_context);
}
consumed = true;
}
}

Expand Down Expand Up @@ -250,7 +209,11 @@ __attribute__((used)) void confirmation_view_set_ok_callback(
ConfirmationView* instance,
ConfirmationViewCallback callback,
void* context) {
if(!instance) return;
if(!instance) {
FURI_LOG_E("ConfView", "Null instance in set_ok_callback");
return;
}
FURI_LOG_D("ConfView", "Setting OK callback: %p with context: %p", callback, context);
instance->ok_callback = callback;
instance->ok_callback_context = context;
}
Expand All @@ -259,7 +222,11 @@ __attribute__((used)) void confirmation_view_set_cancel_callback(
ConfirmationView* instance,
ConfirmationViewCallback callback,
void* context) {
if(!instance) return;
if(!instance) {
FURI_LOG_E("ConfView", "Null instance in set_cancel_callback");
return;
}
FURI_LOG_D("ConfView", "Setting Cancel callback: %p with context: %p", callback, context);
instance->cancel_callback = callback;
instance->cancel_callback_context = context;
}
42 changes: 25 additions & 17 deletions src/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -467,14 +467,14 @@ static const MenuCommand wifi_commands[] = {
.folder = NULL,
.needs_input = false,
.input_text = NULL,
.needs_confirmation = false,
.confirm_header = NULL,
.confirm_text = NULL,
.needs_confirmation = true, // Add confirmation
.confirm_header = "Cast Video",
.confirm_text = "Make sure you've connected\nto WiFi first via the\n'Connect to WiFi' option.\n",
.details_header = "Video Cast",
.details_text = "Casts random videos\n"
"to nearby Cast/DIAL\n"
"enabled devices.\n"
"Range: ~50m\n",
"to nearby Cast/DIAL\n"
"enabled devices.\n"
"Range: ~50m\n",
},
{
.label = "Printer Power",
Expand Down Expand Up @@ -633,7 +633,7 @@ static void confirmation_ok_callback(void* context) {
if(cmd_ctx && cmd_ctx->state && cmd_ctx->command) {
bool file_opened = false;

// **Step 1: Open the PCAP File First**
// Handle capture commands
if(cmd_ctx->command->capture_prefix || cmd_ctx->command->file_ext || cmd_ctx->command->folder) {
FURI_LOG_I("Capture", "Attempting to open PCAP file before sending capture command.");
file_opened = uart_receive_data(
Expand All @@ -649,11 +649,19 @@ static void confirmation_ok_callback(void* context) {
free(cmd_ctx);
return;
}

// Send capture command
send_uart_command(cmd_ctx->command->command, cmd_ctx->state);
FURI_LOG_I("Capture", "Capture command sent to firmware.");
} else {
// For non-capture confirmation commands, send command and switch to text view
send_uart_command(cmd_ctx->command->command, cmd_ctx->state);
uart_receive_data(
cmd_ctx->state->uart_context,
cmd_ctx->state->view_dispatcher,
cmd_ctx->state,
"", "", ""); // No capture files needed
}

// **Step 2: Send the Capture Command After File is Opened**
send_uart_command(cmd_ctx->command->command, cmd_ctx->state);
FURI_LOG_I("Capture", "Capture command sent to firmware.");
}
free(cmd_ctx);
}
Expand Down Expand Up @@ -784,19 +792,19 @@ static void execute_menu_command(AppState* state, const MenuCommand* command) {
send_uart_command(command->command, state);
return; // Important: Return here
}

// For regular commands:
// 1. First send the command
send_uart_command(command->command, state);

// 2. Then switch to text view
uart_receive_data(
state->uart_context,
state->view_dispatcher,
state,
"", // No capture prefix
"", // No file extension
""); // No folder

furi_delay_ms(5);

send_uart_command(command->command, state);


}
// Menu display functions
void show_wifi_menu(AppState* state) {
Expand Down
2 changes: 1 addition & 1 deletion src/settings_ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ bool settings_custom_event_callback(void* context, uint32_t event_id) {
"Updated by: Jay Candel\n"
"Built with <3";

confirmation_view_set_header(app_state->confirmation_view, "Ghost ESP v1.1.3");
confirmation_view_set_header(app_state->confirmation_view, "Ghost ESP v1.1.4");
confirmation_view_set_text(app_state->confirmation_view, info_text);

// Save current view before switching
Expand Down
27 changes: 19 additions & 8 deletions src/uart_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -470,10 +470,15 @@ void uart_stop_thread(UartContext *uart)

// Send data over UART
void uart_send(UartContext *uart, const uint8_t *data, size_t len) {
// Only try to send if serial is active
if (uart && uart->serial_handle && uart->is_serial_active) {
furi_hal_serial_tx(uart->serial_handle, data, len);
if(!uart || !uart->serial_handle || !uart->is_serial_active || !data || len == 0) {
return;
}

// Send data directly without mutex lock for basic commands
furi_hal_serial_tx(uart->serial_handle, data, len);

// Small delay to ensure transmission
furi_delay_ms(5);
}


Expand Down Expand Up @@ -565,7 +570,7 @@ bool uart_receive_data(
uart->pcap = false; // Reset capture state
furi_stream_buffer_reset(uart->pcap_stream);

// Clear display
// Clear display before switching view
text_box_set_text(state->text_box, "");
text_box_set_focus(state->text_box, TextBoxFocusEnd);

Expand All @@ -579,13 +584,19 @@ bool uart_receive_data(
extension);

if(!uart->storageContext->HasOpenedFile) {
FURI_LOG_E("UART", "Failed to open file: Prefix=%s, Ext=%s, Folder=%s", prefix, extension, TargetFolder);
FURI_LOG_E("UART", "Failed to open file");
return false;
}
}

view_dispatcher_switch_to_view(view_dispatcher, 5);
// Set the view state before switching
state->previous_view = state->current_view;
state->current_view = 5;

return true; // Indicate success
}
// Process any pending events before view switch
furi_delay_ms(5);

view_dispatcher_switch_to_view(view_dispatcher, 5);

return true;
}

0 comments on commit 23b78f2

Please sign in to comment.