unleashed-firmware/applications/main/lfrfid/lfrfid_i.h
あく 4d985ba8f8
Storage: remove LFS (#3577)
* Storage: drop internal storage

* Storage: rollback some unnecessary changes

* Storage: rollback some unnecessary changes part 2

* Storage: cleanup various defines and int handling. Ble: allow short connection interval if internal flash is not used.

* Storage: do not return storage if it is not ready

* Save PIN code to RTC, update settings

* Simplify the code, clean up includes

* Rearrange some code

* apps: storage_move_to_sd: conditionally enable with --extra-define=STORAGE_INT_ON_LFS

* Load Desktop settings automatically

* Redirect /any to /ext

* Abolish storage_move_to_sd app

* Remove as many mentions of ANY_PATH as possible

* Fix desktop settings wrongly not loading

* Improve desktop settings handling and strings

* Load BLE settings and keys automatically

* Improve BLE configuration procedure

* Do not load bluetooth keys twice if they were already loaded

* Load dolphin state automatically

* Fix merge artifact

* Load notification settings automatically

* Update desktop settings strings

* Load expansion settings automatically

* Do not use thread signals to reload desktop settings

* Load region data automatically, separate to its own hook

* Improve ble behaviour with no keys

* Fix Dolphin state not resetting correctly

* Add a status check

* Make Desktop save its own settings

* Check result when taking and releasing mutex

* Improve default thread signal handling in FuriEventLoop

* Make bt service in charge of saving settings, add settings api

* Fix a deadlock due to timer thread not receiving time

* Lock core2 when reinitialising bt

* Update clang-format

* Revert "Update clang-format"

This reverts commit d61295ac063c6ec879375ceeab54d6ff2c90a9a1.

* Format sources with clang-format

* Revert old stack size for desktop settings

* Allocate big struct dynamically

* Simplify PIN comparison

* Save pointer to storage in Desktop object

* Fix region provisioning for hardware regions

* Remove stale TODO + siimplify code

* Clean up region.c

* Use sizeof instead of macro define

* Limit PIN length to 10 for consistency

* Emit a warning upon usage of /any

* Add delay after finding flipper

* Remove unnecessary delay

* Remove all mentions of STORAGE_INT_ON_LFS

* Remove littlefs and internal storage

* Remove all possible LittleFS mentions

* Fix browser tab in Archive

* Ble: fix connection interval explanation

* Bump API Symbols

* BLE: Update comments interval connection comments

* Storage: clear FuriHalRtcFlagStorageFormatInternal if set

---------

Co-authored-by: Georgii Surkov <georgii.surkov@outlook.com>
Co-authored-by: hedger <hedger@nanode.su>
Co-authored-by: Georgii Surkov <37121527+gsurkov@users.noreply.github.com>
2024-08-04 10:54:02 +01:00

153 lines
3.7 KiB
C

#pragma once
#include <furi.h>
#include <furi_hal.h>
#include <gui/gui.h>
#include <gui/view.h>
#include <assets_icons.h>
#include <gui/view_dispatcher.h>
#include <gui/scene_manager.h>
#include <cli/cli.h>
#include <notification/notification_messages.h>
#include <gui/modules/submenu.h>
#include <gui/modules/dialog_ex.h>
#include <gui/modules/popup.h>
#include <gui/modules/text_input.h>
#include <gui/modules/byte_input.h>
#include <gui/modules/widget.h>
#include <lfrfid/views/lfrfid_view_read.h>
#include <notification/notification_messages.h>
#include <dialogs/dialogs.h>
#include <storage/storage.h>
#include <flipper_format/flipper_format.h>
#include <rpc/rpc_app.h>
#include <toolbox/protocols/protocol_dict.h>
#include <toolbox/path.h>
#include <lfrfid/lfrfid_dict_file.h>
#include <lfrfid/protocols/lfrfid_protocols.h>
#include <lfrfid/lfrfid_worker.h>
#include <lfrfid/scenes/lfrfid_scene.h>
#define LFRFID_KEY_NAME_SIZE 22
#define LFRFID_TEXT_STORE_SIZE 40
#define LFRFID_APP_FOLDER EXT_PATH("lfrfid")
#define LFRFID_SD_FOLDER EXT_PATH("lfrfid")
#define LFRFID_APP_FILENAME_PREFIX "RFID"
#define LFRFID_APP_FILENAME_EXTENSION ".rfid"
#define LFRFID_APP_SHADOW_FILENAME_EXTENSION ".shd"
#define LFRFID_APP_RAW_ASK_EXTENSION ".ask.raw"
#define LFRFID_APP_RAW_PSK_EXTENSION ".psk.raw"
enum LfRfidCustomEvent {
LfRfidEventNext = 100,
LfRfidEventExit,
LfRfidEventPopupClosed,
LfRfidEventReadSenseStart,
LfRfidEventReadSenseEnd,
LfRfidEventReadSenseCardStart,
LfRfidEventReadSenseCardEnd,
LfRfidEventReadStartASK,
LfRfidEventReadStartPSK,
LfRfidEventReadDone,
LfRfidEventReadOverrun,
LfRfidEventReadError,
LfRfidEventWriteOK,
LfRfidEventWriteProtocolCannotBeWritten,
LfRfidEventWriteFobCannotBeWritten,
LfRfidEventWriteTooLongToWrite,
LfRfidEventRpcLoadFile,
LfRfidEventRpcSessionClose,
};
typedef enum {
LfRfidRpcStateIdle,
LfRfidRpcStateEmulating,
} LfRfidRpcState;
typedef struct LfRfid LfRfid;
struct LfRfid {
LFRFIDWorker* lfworker;
ViewDispatcher* view_dispatcher;
Gui* gui;
NotificationApp* notifications;
SceneManager* scene_manager;
Storage* storage;
DialogsApp* dialogs;
Widget* widget;
char text_store[LFRFID_TEXT_STORE_SIZE + 1];
FuriString* file_path;
FuriString* file_name;
FuriString* raw_file_name;
ProtocolDict* dict;
ProtocolId protocol_id;
ProtocolId protocol_id_next;
LFRFIDWorkerReadType read_type;
uint8_t* old_key_data;
uint8_t* new_key_data;
RpcAppSystem* rpc_ctx;
LfRfidRpcState rpc_state;
// Common Views
Submenu* submenu;
DialogEx* dialog_ex;
Popup* popup;
TextInput* text_input;
ByteInput* byte_input;
// Custom views
LfRfidReadView* read_view;
};
typedef enum {
LfRfidViewSubmenu,
LfRfidViewDialogEx,
LfRfidViewPopup,
LfRfidViewWidget,
LfRfidViewTextInput,
LfRfidViewByteInput,
LfRfidViewRead,
} LfRfidView;
typedef enum {
LfRfidMenuIndexRead,
LfRfidMenuIndexSaved,
LfRfidMenuIndexAddManually,
LfRfidMenuIndexExtraActions,
} LfRfidMenuIndex;
bool lfrfid_save_key(LfRfid* app);
bool lfrfid_load_key_from_file_select(LfRfid* app);
bool lfrfid_delete_key(LfRfid* app);
bool lfrfid_load_key_data(LfRfid* app, FuriString* path, bool show_dialog);
bool lfrfid_save_key_data(LfRfid* app, FuriString* path);
void lfrfid_make_app_folder(LfRfid* app);
void lfrfid_text_store_set(LfRfid* app, const char* text, ...);
void lfrfid_text_store_clear(LfRfid* app);
void lfrfid_popup_timeout_callback(void* context);
void lfrfid_widget_callback(GuiButtonType result, InputType type, void* context);
void lfrfid_text_input_callback(void* context);