Compare commits
5 Commits
main
...
fix-compil
Author | SHA1 | Date | |
---|---|---|---|
6ac0c11c29 | |||
eaed8eded0 | |||
bdba7c0752 | |||
8e7a24be29 | |||
6045430b54 |
@@ -3,8 +3,12 @@ App(
|
||||
name="Rogue_AP_Detector",
|
||||
apptype=FlipperAppType.EXTERNAL,
|
||||
entry_point="rogue_ap_detector",
|
||||
stack_size=2 * 1024,
|
||||
stack_size=4 * 1024,
|
||||
fap_description="Rogue AP detector",
|
||||
fap_author="charlesreid1",
|
||||
fap_version="1.0",
|
||||
requires=[
|
||||
"gui",
|
||||
"wifi"
|
||||
],
|
||||
)
|
||||
|
@@ -2,6 +2,7 @@
|
||||
#include <furi_hal_rtc.h>
|
||||
#include <flipper_format/flipper_format.h> // For file operations
|
||||
#include <toolbox/dir_walk.h> // To ensure directory exists
|
||||
#include <toolbox/path.h> // For path_extract_dirname
|
||||
|
||||
// Header for our binary save file
|
||||
typedef struct {
|
||||
@@ -95,7 +96,10 @@ bool baseline_manager_save(BaselineManager* manager) {
|
||||
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
// Ensure the directory exists
|
||||
storage_simply_mkdir(storage, furi_string_get_dirname(BASELINE_FILE_PATH));
|
||||
FuriString* dir_path = furi_string_alloc();
|
||||
path_extract_dirname(BASELINE_FILE_PATH, dir_path);
|
||||
storage_simply_mkdir(storage, furi_string_get_cstr(dir_path));
|
||||
furi_string_free(dir_path);
|
||||
|
||||
File* file = storage_file_alloc(storage);
|
||||
bool success = false;
|
||||
@@ -105,7 +109,7 @@ bool baseline_manager_save(BaselineManager* manager) {
|
||||
}
|
||||
|
||||
BaselineFileHeader header = {.version = 1, .count = manager->count};
|
||||
strncpy(header.magic, "RGFAP_B", 7);
|
||||
memcpy(header.magic, "RGFAP_B", 7);
|
||||
|
||||
if(storage_file_write(file, &header, sizeof(header)) != sizeof(header)) {
|
||||
goto cleanup;
|
||||
|
@@ -63,7 +63,7 @@ typedef struct {
|
||||
// --- Forward Declarations for Callbacks and Functions ---
|
||||
|
||||
// Main menu callback
|
||||
uint32_t rogue_ap_navigation_exit_callback(void* context);
|
||||
bool rogue_ap_navigation_exit_callback(void* context);
|
||||
void rogue_ap_main_menu_callback(void* context, uint32_t index);
|
||||
|
||||
// Dashboard view
|
||||
@@ -94,7 +94,7 @@ RogueApApp* rogue_ap_app_alloc() {
|
||||
app->gui = furi_record_open(RECORD_GUI);
|
||||
app->notifications = furi_record_open(RECORD_NOTIFICATION);
|
||||
app->view_dispatcher = view_dispatcher_alloc();
|
||||
view_dispatcher_enable_queue(app->view_dispatcher);
|
||||
// // // view_dispatcher_enable_queue(app->view_dispatcher);
|
||||
view_dispatcher_attach_to_gui(app->view_dispatcher, app->gui, ViewDispatcherTypeFullscreen);
|
||||
view_dispatcher_set_navigation_event_callback(app->view_dispatcher, rogue_ap_navigation_exit_callback);
|
||||
|
||||
@@ -110,7 +110,8 @@ RogueApApp* rogue_ap_app_alloc() {
|
||||
|
||||
// Dashboard Widget
|
||||
app->dashboard_widget = widget_alloc();
|
||||
widget_set_draw_callback(app->dashboard_widget, rogue_ap_dashboard_render_callback, app);
|
||||
view_set_context(widget_get_view(app->dashboard_widget), app);
|
||||
view_set_draw_callback(widget_get_view(app->dashboard_widget), rogue_ap_dashboard_render_callback);
|
||||
view_dispatcher_add_view(app->view_dispatcher, AppViewDashboard, widget_get_view(app->dashboard_widget));
|
||||
|
||||
// Alert Popup
|
||||
@@ -173,15 +174,15 @@ void rogue_ap_main_menu_callback(void* context, uint32_t index) {
|
||||
/**
|
||||
* @brief Handles the 'back' button press to exit views.
|
||||
*/
|
||||
uint32_t rogue_ap_navigation_exit_callback(void* context) {
|
||||
bool rogue_ap_navigation_exit_callback(void* context) {
|
||||
RogueApApp* app = context;
|
||||
// Stop scanning when backing out of the dashboard
|
||||
if(app->mode != AppModeIdle) {
|
||||
rogue_ap_stop_worker(app);
|
||||
view_dispatcher_switch_to_view(app->view_dispatcher, AppViewMainMenu);
|
||||
return VIEW_NONE; // Prevent exit
|
||||
return true; // Prevent exit
|
||||
}
|
||||
return VIEW_IGNORE; // Allow exit
|
||||
return false; // Allow exit
|
||||
}
|
||||
|
||||
|
||||
@@ -201,7 +202,7 @@ void rogue_ap_dashboard_render_callback(Canvas* canvas, void* context) {
|
||||
canvas_draw_str(canvas, 4, 12, "Mode: Learning");
|
||||
}
|
||||
|
||||
char buffer[64];
|
||||
char buffer[128];
|
||||
canvas_set_font(canvas, FontSecondary);
|
||||
snprintf(buffer, sizeof(buffer), "Status: %s", app->status_text);
|
||||
canvas_draw_str(canvas, 4, 26, buffer);
|
||||
@@ -244,16 +245,16 @@ int32_t rogue_ap_worker_thread(void* context) {
|
||||
furi_mutex_acquire(app->ui_mutex, FuriWaitForever);
|
||||
snprintf(app->status_text, sizeof(app->status_text), "Scanning...");
|
||||
furi_mutex_release(app->ui_mutex);
|
||||
widget_update(app->dashboard_widget); // Force a repaint
|
||||
view_dispatcher_run(app->view_dispatcher); // Force a repaint
|
||||
|
||||
wifi_scanner_full_scan(app->scanner);
|
||||
uint16_t result_count = wifi_scanner_get_results(app->scanner, scan_results, MAX_APS_TO_STORE);
|
||||
|
||||
// --- 2. Process Phase ---
|
||||
furi_mutex_acquire(app->ui_mutex, FuriWaitForever);
|
||||
snprintf(app->status_text, sizeof(app->status_text), "Analyzing %u APs...", result_count);
|
||||
snprintf(app->status_text, sizeof(app->status_text), "Analyzing %u APs...", (unsigned int)result_count);
|
||||
furi_mutex_release(app->ui_mutex);
|
||||
widget_update(app->dashboard_widget);
|
||||
view_dispatcher_run(app->view_dispatcher);
|
||||
|
||||
detector_clear_new_detections(app->detector);
|
||||
|
||||
|
@@ -1,5 +1,6 @@
|
||||
#include "scanner.h"
|
||||
#include <furi_hal.h>
|
||||
#include <furi_hal_wifi.h>
|
||||
#include <string.h>
|
||||
|
||||
// A global pointer to the scanner instance is needed for the static callback function.
|
||||
|
Reference in New Issue
Block a user