Skip to content

Commit

Permalink
Merge pull request #14 from jaylikesbunda/main
Browse files Browse the repository at this point in the history
v1.1.0 🕸️👻
  • Loading branch information
jaylikesbunda authored Nov 8, 2024
2 parents e7faebc + 638a1ac commit b6e16e0
Show file tree
Hide file tree
Showing 18 changed files with 1,090 additions and 953 deletions.
3 changes: 3 additions & 0 deletions app_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ struct AppState {
uint32_t current_index;
uint8_t current_view;
uint8_t previous_view;
uint32_t last_wifi_index;
uint32_t last_ble_index;
uint32_t last_gps_index;
char* input_buffer;
const char* uart_command;
char* textBoxBuffer;
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.0.9",
fap_version="1.1.0",
fap_icon="ghost_esp.png", # 10x10 1-bit PNG
fap_icon_assets="images", # Image assets to compile for this application
)
2 changes: 1 addition & 1 deletion confirmation_view.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ static void confirmation_view_draw_callback(Canvas* canvas, void* _model) {

if(model->text) {
// Create a temporary buffer for visible text
const size_t max_visible_chars = 128; // Reduced size
const size_t max_visible_chars = 128;
char visible_text[max_visible_chars];
uint8_t current_line = 0;
uint8_t visible_lines = 0;
Expand Down
153 changes: 82 additions & 71 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,90 +1,101 @@
# Changelog

## v1.0.1
- Revamped menu structure with logical grouping (scanning, beacon spam, attacks, etc.)
- Simplified command addition and cleaned up documentation in `menu.c`
- Centralized and enum-based settings metadata for improved validation and extensibility
- Enhanced settings with Stop-on-Back feature and ESP reboot command
- Added ESP connection verification and clearer error messaging
- Enabled automatic connectivity check and error recovery for ESP issues
- Unified UI with metadata-driven consistency and better type safety
- Simplified UI view switching and improved error display
- Refined code organization, separating concerns, removing redundancy, and standardizing error handling
## TODO
- Added Easter Egg (Probably on App Info, shows like anim or image or simple game?)
- Improve directory organisation!!!!!!!!!!!!!!!!!!!!!!!!!!!!

## v1.0.2
- Added confirmation dialogs for WebUI-dependent features in the UI
- Improved settings menu with actions submenu, NVS clearing, and log clearing
- Enhanced memory management and improved settings storage/loading robustness
- Added contextual help for WebUI configuration and confirmation dialogs for command safety
- Improved view navigation, state management, and memory cleanup processes
- Added safeguards against `furi_check` failures with NULL checks and memory initialization

## v1.0.3
- Enhanced confirmation view structure and readability with better text alignment
- Added confirmation for "Clear Log Files" with a permanent action warning
- Enabled back press exit on confirmation views with callback context handling
- Improved memory management with context cleanup, view state tracking, and transition fixes
- Added NULL checks, fixed memory leaks, and added state tracking for dialogs
## v1.1.0 🕸️👻
- Ring buffer implementation for text handling
- New view buffer management
- Added proper locking mechanisms
- **Remove Filtering due to Firmware updates!**
- Made exiting views more consistent for UE
- **Replaced select a utility text with prompt to show NEW Help Menu**
- Refactored and simplified uart_utils
- Made PCAP file handling more robust
- **Add GPS Menu and commands with saving to .csv**
- Miscellaneous bug fixes

## v1.0.4
- Refined confirmation view line breaks for readability
- Improved ESP Connectity check to decrease false negatives
- Added optional filtering to UART output to improve readability (BETA)
- Added 'App Info' Button in Settings
- Misc Changes (mostly to UI)
## v1.0.9
- Fixed log file corruption when stopping captures
- Added proper bounds checking for oversized messages
- Improved text display buffer management
- **Added automatic prefix tagging for WiFi, BLE and system messages**
- Improved storage init speed

## v1.0.5
- Commands will silently fail if UART isn't working rather than crashing
- Fixed double-free memory issue by removing stream buffer cleanup from the worker thread
- Reorganized initialization order
- UART initialization happens in background
- Serial operations don't block app startup
- Optimized storage initialization by deferring file operations until needed
- Improved directory creation efficiency in storage handling
## v1.0.8

## v1.0.6
- Replaced 'Info' command in ESP Check with 'Stop'
- Slightly improved optional UART filtering
- Memory safety improvements.
- Improved Clear Logs to be faster and more efficient
- Added details view to each command accessable with hold of center button. (Like BLE Spam)
- Made ESP Not Connected screen more helpful with prompts to reboot/reflash if issues persist.
- Renamed CONF menu option to SET to better align with actual Settings menu since it's header is "Settings" and there is a configuration submenu
- Replaced textbox for ESP Connection Check with scrollable Confirmation View
### 🔴 CRITICAL FIX - PCAP capture
- **Fixed PCAP file handling and storage system**
- Resolved PCAP file stream corruption issues
- Added proper storage system initialization
- Removed the line buffering logic for PCAP data

### Improvements
- Added error checking for storage operations
- Filtering majorly improved
- Improved stop on back to be much more reliable by added type-specific stop commands with delays between operations

## v1.0.7a
- Disable the expansion interface before trying to use UART

## v1.0.7
- Increased buffers and stacks: MAX_BUFFER_SIZE to 8KB, INITIAL_BUFFER_SIZE to 4KB, BUFFER_CLEAR_SIZE to 128B, uart/app stacks to 4KB/6KB
- **Increased buffers and stacks: MAX_BUFFER_SIZE to 8KB, INITIAL_BUFFER_SIZE to 4KB, BUFFER_CLEAR_SIZE to 128B, uart/app stacks to 4KB/6KB**
- Added buffer_mutex with proper timeout handling
- Added Marauder-style data handling
- **Added Marauder-style data handling**
- Improved ESP connection reliability
- Added view log from start/end configuration setting
- Added line buffering with overflow detection, boundary protection and pre-flush on mode switches
- **Added line buffering with overflow detection, boundary protection and pre-flush on mode switches**

## v1.0.7a
- Disable the expansion interface before trying to use UART
## v1.0.6
- Replaced 'Info' command in ESP Check with 'Stop'
- Slightly improved optional UART filtering
- Memory safety improvements.
- Improved Clear Logs to be faster and more efficient
- **Added details view to each command accessible with hold of center button. (Like BLE Spam)**
- **Made ESP Not Connected screen more helpful with prompts to reboot/reflash if issues persist.**
- Renamed CONF menu option to SET to better align with actual Settings menu since its header is "Settings" and there is a configuration submenu
- Replaced textbox for ESP Connection Check with scrollable Confirmation View

## v1.0.8
## v1.0.5
- **Commands will silently fail if UART isn't working rather than crashing**
- **Fixed double-free memory issue by removing stream buffer cleanup from the worker thread**
- Reorganized initialization order
- **UART initialization happens in background**
- **Serial operations don't block app startup**
- Optimized storage initialization by deferring file operations until needed
- Improved directory creation efficiency in storage handling

### 🔴 CRITICAL FIX - PCAP capture
- Fixed PCAP file handling and storage system
- Resolved PCAP file stream corruption issues
- Added proper storage system initialization
- Removed the line buffering logic for PCAP data
## v1.0.4
- Refined confirmation view line breaks for readability
- Improved ESP Connectivity check to decrease false negatives
- **Added optional filtering to UART output to improve readability (BETA)**
- **Added 'App Info' Button in Settings**
- Misc Changes (mostly to UI)

### Improvements
- Added error checking for storage operations
- Filtering majorly improved
- Improved stop on back to be much more reliable by added type-specific stop commands with delays between operations
## v1.0.3
- Enhanced confirmation view structure and readability with better text alignment
- **Added confirmation for "Clear Log Files" with a permanent action warning**
- **Enabled back press exit on confirmation views with callback context handling**
- Improved memory management with context cleanup, view state tracking, and transition fixes
- Added NULL checks, fixed memory leaks, and added state tracking for dialogs

## v1.0.2
- **Added confirmation dialogs for WebUI-dependent features in the UI**
- Improved settings menu with actions submenu, NVS clearing, and log clearing
- Enhanced memory management and improved settings storage/loading robustness
- **Added contextual help for WebUI configuration and confirmation dialogs for command safety**
- Improved view navigation, state management, and memory cleanup processes
- **Added safeguards against `furi_check` failures with NULL checks and memory initialization**

## v1.0.9
- Fixed log file corruption when stopping captures
- Added proper bounds checking for oversized messages
- Improved text display buffer management
- Added automatic prefix tagging for WiFi, BLE and system messages
- Improved storage init speed
## v1.0.1
- **Revamped menu structure with logical grouping (scanning, beacon spam, attacks, etc.)**
- Simplified command addition and cleaned up documentation in `menu.c`
- **Centralized and enum-based settings metadata for improved validation and extensibility**
- **Enhanced settings with Stop-on-Back feature and ESP reboot command**
- **Enabled automatic connectivity check and error recovery for ESP issues**
- **Unified UI with metadata-driven consistency and better type safety**
- Simplified UI view switching and improved error display
- Refined code organization, separating concerns, removing redundancy, and standardizing error handling

## TODO
- Replaced select a utility text with prompt to show NEW Help Menu
- FINALISE optional filtering to UART output
- Improve directory organisation!!!!!!!!!!!!!!!!!!!!!!!!!!!!
8 changes: 8 additions & 0 deletions ghost_esp_icons.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#pragma once
#include <gui/icon.h>

extern const Icon I_Wifi_icon;
extern const Icon I_BLE_icon;
extern const Icon I_GPS_icon;
extern const Icon I_Cog;
extern const Icon I_ButtonDown_7x4;
69 changes: 44 additions & 25 deletions gui_modules/mainmenu.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ typedef struct {
struct MainMenu {
View* view;
FuriTimer* locked_timer;
MainMenuItemCallback help_callback;
void* help_context;
};

typedef struct {
Expand Down Expand Up @@ -96,26 +98,17 @@ static size_t main_menu_items_on_screen(MainMenuModel* model) {
}

static bool is_valid_icon_index(size_t position) {
return position <= 3;
return position <= 4;
}

static void draw_header(Canvas* canvas, const FuriString* header, uint8_t y_position) {
if(!furi_string_empty(header)) {
canvas_set_font(canvas, FontSecondary);

const char* header_text = furi_string_get_cstr(header);
int width = canvas_string_width(canvas, header_text);
int x_pos = (canvas_width(canvas) - width) / 2;

// Draw shadow
canvas_set_color(canvas, ColorWhite);
canvas_draw_str(canvas, x_pos + 1, y_position + 1, header_text);

// Draw main text
canvas_set_color(canvas, ColorBlack);
canvas_draw_str(canvas, x_pos, y_position, header_text);
}
// Add the new helper function:
void main_menu_set_help_callback(MainMenu* main_menu, MainMenuItemCallback callback, void* context) {
furi_assert(main_menu);
main_menu->help_callback = callback;
main_menu->help_context = context;
}


static CardLayout calculate_card_layout(
Canvas* canvas,
size_t total_cards,
Expand Down Expand Up @@ -212,18 +205,14 @@ static void draw_card_label(
layout->y + layout->height - TEXT_BOTTOM_MARGIN,
furi_string_get_cstr(label));
}

static void main_menu_view_draw_callback(Canvas* canvas, void* _model) {
MainMenuModel* model = _model;
const size_t total_cards = MainMenuItemArray_size(model->items);
const size_t visible_cards = total_cards;

canvas_clear(canvas);

if(!furi_string_empty(model->header)) {
draw_header(canvas, model->header, BASE_Y_POSITION + CARD_HEIGHT + 10);
}

// Draw all menu items first
size_t position = 0;
MainMenuItemArray_it_t it;
for(MainMenuItemArray_it(it, model->items); !MainMenuItemArray_end_p(it);
Expand All @@ -245,8 +234,8 @@ static void main_menu_view_draw_callback(Canvas* canvas, void* _model) {
switch(position) {
case 0: icon = &I_Wifi_icon; break;
case 1: icon = &I_BLE_icon; break;
// case 2: icon = &I_GPS; break;
case 2: icon = &I_Cog; break;
case 2: icon = &I_GPS; break; // Use GPS icon for position 2
case 3: icon = &I_Cog; break; // Use Settings icon for position 3
}
}

Expand All @@ -260,8 +249,30 @@ static void main_menu_view_draw_callback(Canvas* canvas, void* _model) {

position++;
}
}

// Draw help button last, so it's on top of everything
canvas_set_font(canvas, FontSecondary);
canvas_set_color(canvas, ColorBlack);

const size_t vertical_offset = 3;
const size_t horizontal_offset = 3;
const size_t string_width = canvas_string_width(canvas, "Help");
const Icon* icon = &I_ButtonDown_7x4;
const int32_t icon_h_offset = 3;
const int32_t icon_width_with_offset = icon_get_width(icon) + icon_h_offset;
const int32_t icon_v_offset = icon_get_height(icon) + vertical_offset + 1;
const size_t button_width = string_width + horizontal_offset * 2 + icon_width_with_offset;

const int32_t x = (canvas_width(canvas) - button_width) / 2;
const int32_t y = canvas_height(canvas);

// Position at bottom with proper margins
canvas_draw_str(canvas, x + horizontal_offset, y - vertical_offset, "Help");
canvas_draw_icon(
canvas, x + horizontal_offset + string_width + icon_h_offset, y - icon_v_offset, icon);
// Reset color
canvas_set_color(canvas, ColorBlack);
}
static bool main_menu_view_input_callback(InputEvent* event, void* context) {
MainMenu* main_menu = context;
furi_assert(main_menu);
Expand Down Expand Up @@ -296,6 +307,13 @@ static bool main_menu_view_input_callback(InputEvent* event, void* context) {
consumed = true;
main_menu_process_ok(main_menu);
break;
case InputKeyDown:
// Handle help button press
if(main_menu->help_callback) {
main_menu->help_callback(main_menu->help_context, 0);
consumed = true;
}
break;
default:
break;
}
Expand All @@ -312,6 +330,7 @@ static bool main_menu_view_input_callback(InputEvent* event, void* context) {
return consumed;
}


void main_menu_timer_callback(void* context) {
furi_assert(context);
MainMenu* main_menu = context;
Expand Down
3 changes: 3 additions & 0 deletions gui_modules/mainmenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ void main_menu_set_header(MainMenu* main_menu, const char* header);
*/
void main_menu_set_orientation(MainMenu* main_menu, ViewOrientation orientation);

void main_menu_set_help_callback(MainMenu* main_menu, MainMenuItemCallback callback, void* context);


#ifdef __cplusplus
}
#endif
8 changes: 8 additions & 0 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ int32_t ghost_esp_app(void* p) {
if (!state) return -1;
memset(state, 0, sizeof(AppState)); // Zero all memory first

// Initialize menu selection indices
state->last_wifi_index = 0;
state->last_ble_index = 0;
state->last_gps_index = 0;
state->current_index = 0;
state->current_view = 0;
state->previous_view = 0;

// Initialize essential text buffers with minimal size
state->textBoxBuffer = malloc(1);
if (state->textBoxBuffer) {
Expand Down
Loading

0 comments on commit b6e16e0

Please sign in to comment.