Add File Naming setting for more detailed naming (#3002)
* added filename mode setting * added furi_flag checks for when filename_mode is set * changed naming for ibutton, lfrfid and subghz * requested changes from PR * Lib: gather all naming bits and pieces under name generator module. Properly bump api version. FuriHal: fix RTC flag enum. * PR requested changes * bug fix for arg type * added functionality for other application scenes * Lib: cleanup name generator API, simplify usage. Sync API symbols. * Lib: proper size type in name_generator. Cleanup. * FuriHal: cleanup rtc api usage across firmware Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
		
							parent
							
								
									e5fdb2e069
								
							
						
					
					
						commit
						52b5966262
					
				@ -195,7 +195,8 @@ bool ibutton_load_key(iButton* ibutton) {
 | 
			
		||||
 | 
			
		||||
bool ibutton_select_and_load_key(iButton* ibutton) {
 | 
			
		||||
    DialogsFileBrowserOptions browser_options;
 | 
			
		||||
    dialog_file_browser_set_basic_options(&browser_options, IBUTTON_APP_EXTENSION, &I_ibutt_10px);
 | 
			
		||||
    dialog_file_browser_set_basic_options(
 | 
			
		||||
        &browser_options, IBUTTON_APP_FILENAME_EXTENSION, &I_ibutt_10px);
 | 
			
		||||
    browser_options.base_path = IBUTTON_APP_FOLDER;
 | 
			
		||||
 | 
			
		||||
    if(furi_string_empty(ibutton->file_path)) {
 | 
			
		||||
 | 
			
		||||
@ -29,7 +29,8 @@
 | 
			
		||||
#include "scenes/ibutton_scene.h"
 | 
			
		||||
 | 
			
		||||
#define IBUTTON_APP_FOLDER ANY_PATH("ibutton")
 | 
			
		||||
#define IBUTTON_APP_EXTENSION ".ibtn"
 | 
			
		||||
#define IBUTTON_APP_FILENAME_PREFIX "iBtn"
 | 
			
		||||
#define IBUTTON_APP_FILENAME_EXTENSION ".ibtn"
 | 
			
		||||
 | 
			
		||||
#define IBUTTON_KEY_NAME_SIZE 22
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,6 @@
 | 
			
		||||
#include "../ibutton_i.h"
 | 
			
		||||
 | 
			
		||||
#include <toolbox/random_name.h>
 | 
			
		||||
#include <toolbox/name_generator.h>
 | 
			
		||||
#include <toolbox/path.h>
 | 
			
		||||
 | 
			
		||||
#include <dolphin/dolphin.h>
 | 
			
		||||
@ -17,7 +17,8 @@ void ibutton_scene_save_name_on_enter(void* context) {
 | 
			
		||||
    const bool is_new_file = furi_string_empty(ibutton->file_path);
 | 
			
		||||
 | 
			
		||||
    if(is_new_file) {
 | 
			
		||||
        set_random_name(ibutton->key_name, IBUTTON_KEY_NAME_SIZE);
 | 
			
		||||
        name_generator_make_auto(
 | 
			
		||||
            ibutton->key_name, IBUTTON_KEY_NAME_SIZE, IBUTTON_APP_FILENAME_PREFIX);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    text_input_set_header_text(text_input, "Name the key");
 | 
			
		||||
@ -29,8 +30,8 @@ void ibutton_scene_save_name_on_enter(void* context) {
 | 
			
		||||
        IBUTTON_KEY_NAME_SIZE,
 | 
			
		||||
        is_new_file);
 | 
			
		||||
 | 
			
		||||
    ValidatorIsFile* validator_is_file =
 | 
			
		||||
        validator_is_file_alloc_init(IBUTTON_APP_FOLDER, IBUTTON_APP_EXTENSION, ibutton->key_name);
 | 
			
		||||
    ValidatorIsFile* validator_is_file = validator_is_file_alloc_init(
 | 
			
		||||
        IBUTTON_APP_FOLDER, IBUTTON_APP_FILENAME_EXTENSION, ibutton->key_name);
 | 
			
		||||
    text_input_set_validator(text_input, validator_is_file_callback, validator_is_file);
 | 
			
		||||
 | 
			
		||||
    view_dispatcher_switch_to_view(ibutton->view_dispatcher, iButtonViewTextInput);
 | 
			
		||||
@ -48,7 +49,7 @@ bool ibutton_scene_save_name_on_event(void* context, SceneManagerEvent event) {
 | 
			
		||||
                "%s/%s%s",
 | 
			
		||||
                IBUTTON_APP_FOLDER,
 | 
			
		||||
                ibutton->key_name,
 | 
			
		||||
                IBUTTON_APP_EXTENSION);
 | 
			
		||||
                IBUTTON_APP_FILENAME_EXTENSION);
 | 
			
		||||
 | 
			
		||||
            if(ibutton_save_key(ibutton)) {
 | 
			
		||||
                scene_manager_next_scene(ibutton->scene_manager, iButtonSceneSaveSuccess);
 | 
			
		||||
 | 
			
		||||
@ -1,7 +1,6 @@
 | 
			
		||||
#include "../infrared_i.h"
 | 
			
		||||
 | 
			
		||||
#include "common/infrared_scene_universal_common.h"
 | 
			
		||||
#include <furi_hal_rtc.h>
 | 
			
		||||
 | 
			
		||||
void infrared_scene_universal_ac_on_enter(void* context) {
 | 
			
		||||
    infrared_scene_universal_common_on_enter(context);
 | 
			
		||||
 | 
			
		||||
@ -215,13 +215,16 @@ bool lfrfid_save_key(LfRfid* app) {
 | 
			
		||||
 | 
			
		||||
    lfrfid_make_app_folder(app);
 | 
			
		||||
 | 
			
		||||
    if(furi_string_end_with(app->file_path, LFRFID_APP_EXTENSION)) {
 | 
			
		||||
    if(furi_string_end_with(app->file_path, LFRFID_APP_FILENAME_EXTENSION)) {
 | 
			
		||||
        size_t filename_start = furi_string_search_rchar(app->file_path, '/');
 | 
			
		||||
        furi_string_left(app->file_path, filename_start);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    furi_string_cat_printf(
 | 
			
		||||
        app->file_path, "/%s%s", furi_string_get_cstr(app->file_name), LFRFID_APP_EXTENSION);
 | 
			
		||||
        app->file_path,
 | 
			
		||||
        "/%s%s",
 | 
			
		||||
        furi_string_get_cstr(app->file_name),
 | 
			
		||||
        LFRFID_APP_FILENAME_EXTENSION);
 | 
			
		||||
 | 
			
		||||
    result = lfrfid_save_key_data(app, app->file_path);
 | 
			
		||||
    return result;
 | 
			
		||||
@ -231,7 +234,8 @@ bool lfrfid_load_key_from_file_select(LfRfid* app) {
 | 
			
		||||
    furi_assert(app);
 | 
			
		||||
 | 
			
		||||
    DialogsFileBrowserOptions browser_options;
 | 
			
		||||
    dialog_file_browser_set_basic_options(&browser_options, LFRFID_APP_EXTENSION, &I_125_10px);
 | 
			
		||||
    dialog_file_browser_set_basic_options(
 | 
			
		||||
        &browser_options, LFRFID_APP_FILENAME_EXTENSION, &I_125_10px);
 | 
			
		||||
    browser_options.base_path = LFRFID_APP_FOLDER;
 | 
			
		||||
 | 
			
		||||
    // Input events and views are managed by file_browser
 | 
			
		||||
 | 
			
		||||
@ -40,8 +40,9 @@
 | 
			
		||||
 | 
			
		||||
#define LFRFID_APP_FOLDER ANY_PATH("lfrfid")
 | 
			
		||||
#define LFRFID_SD_FOLDER EXT_PATH("lfrfid")
 | 
			
		||||
#define LFRFID_APP_EXTENSION ".rfid"
 | 
			
		||||
#define LFRFID_APP_SHADOW_EXTENSION ".shd"
 | 
			
		||||
#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"
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,6 @@
 | 
			
		||||
#include <lib/toolbox/random_name.h>
 | 
			
		||||
#include "../lfrfid_i.h"
 | 
			
		||||
#include <dolphin/dolphin.h>
 | 
			
		||||
#include <toolbox/name_generator.h>
 | 
			
		||||
 | 
			
		||||
void lfrfid_scene_save_name_on_enter(void* context) {
 | 
			
		||||
    LfRfid* app = context;
 | 
			
		||||
@ -11,7 +11,10 @@ void lfrfid_scene_save_name_on_enter(void* context) {
 | 
			
		||||
    bool key_name_is_empty = furi_string_empty(app->file_name);
 | 
			
		||||
    if(key_name_is_empty) {
 | 
			
		||||
        furi_string_set(app->file_path, LFRFID_APP_FOLDER);
 | 
			
		||||
        set_random_name(app->text_store, LFRFID_TEXT_STORE_SIZE);
 | 
			
		||||
 | 
			
		||||
        name_generator_make_auto(
 | 
			
		||||
            app->text_store, LFRFID_TEXT_STORE_SIZE, LFRFID_APP_FILENAME_PREFIX);
 | 
			
		||||
 | 
			
		||||
        furi_string_set(folder_path, LFRFID_APP_FOLDER);
 | 
			
		||||
    } else {
 | 
			
		||||
        lfrfid_text_store_set(app, "%s", furi_string_get_cstr(app->file_name));
 | 
			
		||||
@ -31,7 +34,7 @@ void lfrfid_scene_save_name_on_enter(void* context) {
 | 
			
		||||
 | 
			
		||||
    ValidatorIsFile* validator_is_file = validator_is_file_alloc_init(
 | 
			
		||||
        furi_string_get_cstr(folder_path),
 | 
			
		||||
        LFRFID_APP_EXTENSION,
 | 
			
		||||
        LFRFID_APP_FILENAME_EXTENSION,
 | 
			
		||||
        furi_string_get_cstr(app->file_name));
 | 
			
		||||
    text_input_set_validator(text_input, validator_is_file_callback, validator_is_file);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -223,7 +223,11 @@ void nfc_blink_stop(Nfc* nfc) {
 | 
			
		||||
 | 
			
		||||
bool nfc_save_file(Nfc* nfc) {
 | 
			
		||||
    furi_string_printf(
 | 
			
		||||
        nfc->dev->load_path, "%s/%s%s", NFC_APP_FOLDER, nfc->dev->dev_name, NFC_APP_EXTENSION);
 | 
			
		||||
        nfc->dev->load_path,
 | 
			
		||||
        "%s/%s%s",
 | 
			
		||||
        NFC_APP_FOLDER,
 | 
			
		||||
        nfc->dev->dev_name,
 | 
			
		||||
        NFC_APP_FILENAME_EXTENSION);
 | 
			
		||||
    bool file_saved = nfc_device_save(nfc->dev, furi_string_get_cstr(nfc->dev->load_path));
 | 
			
		||||
    return file_saved;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,5 @@
 | 
			
		||||
#include "../nfc_i.h"
 | 
			
		||||
#include <lib/toolbox/random_name.h>
 | 
			
		||||
#include <lib/toolbox/name_generator.h>
 | 
			
		||||
#include <gui/modules/validators.h>
 | 
			
		||||
#include <toolbox/path.h>
 | 
			
		||||
#include <dolphin/dolphin.h>
 | 
			
		||||
@ -17,7 +17,7 @@ void nfc_scene_save_name_on_enter(void* context) {
 | 
			
		||||
    TextInput* text_input = nfc->text_input;
 | 
			
		||||
    bool dev_name_empty = false;
 | 
			
		||||
    if(!strcmp(nfc->dev->dev_name, "")) {
 | 
			
		||||
        set_random_name(nfc->text_store, sizeof(nfc->text_store));
 | 
			
		||||
        name_generator_make_auto(nfc->text_store, NFC_DEV_NAME_MAX_LEN, NFC_APP_FILENAME_PREFIX);
 | 
			
		||||
        dev_name_empty = true;
 | 
			
		||||
    } else {
 | 
			
		||||
        nfc_text_store_set(nfc, nfc->dev->dev_name);
 | 
			
		||||
@ -34,14 +34,14 @@ void nfc_scene_save_name_on_enter(void* context) {
 | 
			
		||||
    FuriString* folder_path;
 | 
			
		||||
    folder_path = furi_string_alloc();
 | 
			
		||||
 | 
			
		||||
    if(furi_string_end_with(nfc->dev->load_path, NFC_APP_EXTENSION)) {
 | 
			
		||||
    if(furi_string_end_with(nfc->dev->load_path, NFC_APP_FILENAME_EXTENSION)) {
 | 
			
		||||
        path_extract_dirname(furi_string_get_cstr(nfc->dev->load_path), folder_path);
 | 
			
		||||
    } else {
 | 
			
		||||
        furi_string_set(folder_path, NFC_APP_FOLDER);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    ValidatorIsFile* validator_is_file = validator_is_file_alloc_init(
 | 
			
		||||
        furi_string_get_cstr(folder_path), NFC_APP_EXTENSION, nfc->dev->dev_name);
 | 
			
		||||
        furi_string_get_cstr(folder_path), NFC_APP_FILENAME_EXTENSION, nfc->dev->dev_name);
 | 
			
		||||
    text_input_set_validator(text_input, validator_is_file_callback, validator_is_file);
 | 
			
		||||
 | 
			
		||||
    view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewTextInput);
 | 
			
		||||
 | 
			
		||||
@ -239,7 +239,11 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
 | 
			
		||||
 | 
			
		||||
            FuriString* temp_str = furi_string_alloc();
 | 
			
		||||
            furi_string_printf(
 | 
			
		||||
                temp_str, "%s/%s%s", SUBGHZ_RAW_FOLDER, RAW_FILE_NAME, SUBGHZ_APP_EXTENSION);
 | 
			
		||||
                temp_str,
 | 
			
		||||
                "%s/%s%s",
 | 
			
		||||
                SUBGHZ_RAW_FOLDER,
 | 
			
		||||
                RAW_FILE_NAME,
 | 
			
		||||
                SUBGHZ_APP_FILENAME_EXTENSION);
 | 
			
		||||
            subghz_protocol_raw_gen_fff_data(
 | 
			
		||||
                subghz_txrx_get_fff_data(subghz->txrx),
 | 
			
		||||
                furi_string_get_cstr(temp_str),
 | 
			
		||||
 | 
			
		||||
@ -1,10 +1,10 @@
 | 
			
		||||
#include "../subghz_i.h"
 | 
			
		||||
#include "subghz/types.h"
 | 
			
		||||
#include <lib/toolbox/random_name.h>
 | 
			
		||||
#include "../helpers/subghz_custom_event.h"
 | 
			
		||||
#include <lib/subghz/protocols/raw.h>
 | 
			
		||||
#include <gui/modules/validators.h>
 | 
			
		||||
#include <dolphin/dolphin.h>
 | 
			
		||||
#include <toolbox/name_generator.h>
 | 
			
		||||
 | 
			
		||||
#define MAX_TEXT_INPUT_LEN 22
 | 
			
		||||
 | 
			
		||||
@ -40,7 +40,9 @@ void subghz_scene_save_name_on_enter(void* context) {
 | 
			
		||||
 | 
			
		||||
    if(!subghz_path_is_file(subghz->file_path)) {
 | 
			
		||||
        char file_name_buf[SUBGHZ_MAX_LEN_NAME] = {0};
 | 
			
		||||
        set_random_name(file_name_buf, SUBGHZ_MAX_LEN_NAME);
 | 
			
		||||
 | 
			
		||||
        name_generator_make_auto(file_name_buf, SUBGHZ_MAX_LEN_NAME, SUBGHZ_APP_FILENAME_PREFIX);
 | 
			
		||||
 | 
			
		||||
        furi_string_set(file_name, file_name_buf);
 | 
			
		||||
        furi_string_set(subghz->file_path, SUBGHZ_APP_FOLDER);
 | 
			
		||||
        //highlighting the entire filename by default
 | 
			
		||||
@ -71,7 +73,7 @@ void subghz_scene_save_name_on_enter(void* context) {
 | 
			
		||||
        dev_name_empty);
 | 
			
		||||
 | 
			
		||||
    ValidatorIsFile* validator_is_file = validator_is_file_alloc_init(
 | 
			
		||||
        furi_string_get_cstr(subghz->file_path), SUBGHZ_APP_EXTENSION, "");
 | 
			
		||||
        furi_string_get_cstr(subghz->file_path), SUBGHZ_APP_FILENAME_EXTENSION, "");
 | 
			
		||||
    text_input_set_validator(text_input, validator_is_file_callback, validator_is_file);
 | 
			
		||||
 | 
			
		||||
    furi_string_free(file_name);
 | 
			
		||||
@ -94,7 +96,10 @@ bool subghz_scene_save_name_on_event(void* context, SceneManagerEvent event) {
 | 
			
		||||
        if(event.event == SubGhzCustomEventSceneSaveName) {
 | 
			
		||||
            if(strcmp(subghz->file_name_tmp, "") != 0) {
 | 
			
		||||
                furi_string_cat_printf(
 | 
			
		||||
                    subghz->file_path, "/%s%s", subghz->file_name_tmp, SUBGHZ_APP_EXTENSION);
 | 
			
		||||
                    subghz->file_path,
 | 
			
		||||
                    "/%s%s",
 | 
			
		||||
                    subghz->file_name_tmp,
 | 
			
		||||
                    SUBGHZ_APP_FILENAME_EXTENSION);
 | 
			
		||||
                if(subghz_path_is_file(subghz->file_path_tmp)) {
 | 
			
		||||
                    if(!subghz_rename_file(subghz)) {
 | 
			
		||||
                        return false;
 | 
			
		||||
 | 
			
		||||
@ -238,7 +238,7 @@ bool subghz_get_next_name_file(SubGhz* subghz, uint8_t max_len) {
 | 
			
		||||
            storage,
 | 
			
		||||
            furi_string_get_cstr(file_path),
 | 
			
		||||
            furi_string_get_cstr(file_name),
 | 
			
		||||
            SUBGHZ_APP_EXTENSION,
 | 
			
		||||
            SUBGHZ_APP_FILENAME_EXTENSION,
 | 
			
		||||
            file_name,
 | 
			
		||||
            max_len);
 | 
			
		||||
 | 
			
		||||
@ -247,7 +247,7 @@ bool subghz_get_next_name_file(SubGhz* subghz, uint8_t max_len) {
 | 
			
		||||
            "%s/%s%s",
 | 
			
		||||
            furi_string_get_cstr(file_path),
 | 
			
		||||
            furi_string_get_cstr(file_name),
 | 
			
		||||
            SUBGHZ_APP_EXTENSION);
 | 
			
		||||
            SUBGHZ_APP_FILENAME_EXTENSION);
 | 
			
		||||
        furi_string_set(subghz->file_path, temp_str);
 | 
			
		||||
        res = true;
 | 
			
		||||
    }
 | 
			
		||||
@ -320,7 +320,8 @@ bool subghz_load_protocol_from_file(SubGhz* subghz) {
 | 
			
		||||
    FuriString* file_path = furi_string_alloc();
 | 
			
		||||
 | 
			
		||||
    DialogsFileBrowserOptions browser_options;
 | 
			
		||||
    dialog_file_browser_set_basic_options(&browser_options, SUBGHZ_APP_EXTENSION, &I_sub1_10px);
 | 
			
		||||
    dialog_file_browser_set_basic_options(
 | 
			
		||||
        &browser_options, SUBGHZ_APP_FILENAME_EXTENSION, &I_sub1_10px);
 | 
			
		||||
    browser_options.base_path = SUBGHZ_APP_FOLDER;
 | 
			
		||||
 | 
			
		||||
    // Input events and views are managed by file_select
 | 
			
		||||
@ -394,7 +395,7 @@ void subghz_file_name_clear(SubGhz* subghz) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool subghz_path_is_file(FuriString* path) {
 | 
			
		||||
    return furi_string_end_with(path, SUBGHZ_APP_EXTENSION);
 | 
			
		||||
    return furi_string_end_with(path, SUBGHZ_APP_FILENAME_EXTENSION);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void subghz_lock(SubGhz* subghz) {
 | 
			
		||||
 | 
			
		||||
@ -4,7 +4,6 @@
 | 
			
		||||
 | 
			
		||||
#include <furi.h>
 | 
			
		||||
#include <furi_hal.h>
 | 
			
		||||
#include <furi_hal_rtc.h>
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
#include <u8g2_glue.h>
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -2,7 +2,6 @@
 | 
			
		||||
 | 
			
		||||
#include <furi.h>
 | 
			
		||||
#include <furi_hal.h>
 | 
			
		||||
#include <furi_hal_rtc.h>
 | 
			
		||||
 | 
			
		||||
#include "gui.h"
 | 
			
		||||
#include "gui_i.h"
 | 
			
		||||
 | 
			
		||||
@ -153,6 +153,21 @@ static void sleep_method_changed(VariableItem* item) {
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const char* const filename_scheme[] = {
 | 
			
		||||
    "Default",
 | 
			
		||||
    "Detailed",
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static void filename_scheme_changed(VariableItem* item) {
 | 
			
		||||
    uint8_t index = variable_item_get_current_value_index(item);
 | 
			
		||||
    variable_item_set_current_value_text(item, filename_scheme[index]);
 | 
			
		||||
    if(index) {
 | 
			
		||||
        furi_hal_rtc_set_flag(FuriHalRtcFlagDetailedFilename);
 | 
			
		||||
    } else {
 | 
			
		||||
        furi_hal_rtc_reset_flag(FuriHalRtcFlagDetailedFilename);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static uint32_t system_settings_exit(void* context) {
 | 
			
		||||
    UNUSED(context);
 | 
			
		||||
    return VIEW_NONE;
 | 
			
		||||
@ -236,6 +251,12 @@ SystemSettings* system_settings_alloc() {
 | 
			
		||||
    variable_item_set_current_value_index(item, value_index);
 | 
			
		||||
    variable_item_set_current_value_text(item, sleep_method[value_index]);
 | 
			
		||||
 | 
			
		||||
    item = variable_item_list_add(
 | 
			
		||||
        app->var_item_list, "File Naming", COUNT_OF(filename_scheme), filename_scheme_changed, app);
 | 
			
		||||
    value_index = furi_hal_rtc_is_flag_set(FuriHalRtcFlagDetailedFilename) ? 1 : 0;
 | 
			
		||||
    variable_item_set_current_value_index(item, value_index);
 | 
			
		||||
    variable_item_set_current_value_text(item, filename_scheme[value_index]);
 | 
			
		||||
 | 
			
		||||
    view_set_previous_callback(
 | 
			
		||||
        variable_item_list_get_view(app->var_item_list), system_settings_exit);
 | 
			
		||||
    view_dispatcher_add_view(
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,5 @@
 | 
			
		||||
entry,status,name,type,params
 | 
			
		||||
Version,+,35.1,,
 | 
			
		||||
Version,+,36.0,,
 | 
			
		||||
Header,+,applications/services/bt/bt_service/bt.h,,
 | 
			
		||||
Header,+,applications/services/cli/cli.h,,
 | 
			
		||||
Header,+,applications/services/cli/cli_vcp.h,,
 | 
			
		||||
@ -172,10 +172,10 @@ Header,+,lib/toolbox/hex.h,,
 | 
			
		||||
Header,+,lib/toolbox/manchester_decoder.h,,
 | 
			
		||||
Header,+,lib/toolbox/manchester_encoder.h,,
 | 
			
		||||
Header,+,lib/toolbox/md5.h,,
 | 
			
		||||
Header,+,lib/toolbox/name_generator.h,,
 | 
			
		||||
Header,+,lib/toolbox/path.h,,
 | 
			
		||||
Header,+,lib/toolbox/pretty_format.h,,
 | 
			
		||||
Header,+,lib/toolbox/protocols/protocol_dict.h,,
 | 
			
		||||
Header,+,lib/toolbox/random_name.h,,
 | 
			
		||||
Header,+,lib/toolbox/saved_struct.h,,
 | 
			
		||||
Header,+,lib/toolbox/sha256.h,,
 | 
			
		||||
Header,+,lib/toolbox/stream/buffered_file_stream.h,,
 | 
			
		||||
@ -1705,6 +1705,9 @@ Function,-,music_worker_set_callback,void,"MusicWorker*, MusicWorkerCallback, vo
 | 
			
		||||
Function,-,music_worker_set_volume,void,"MusicWorker*, float"
 | 
			
		||||
Function,-,music_worker_start,void,MusicWorker*
 | 
			
		||||
Function,-,music_worker_stop,void,MusicWorker*
 | 
			
		||||
Function,+,name_generator_make_auto,void,"char*, size_t, const char*"
 | 
			
		||||
Function,+,name_generator_make_detailed,void,"char*, size_t, const char*"
 | 
			
		||||
Function,+,name_generator_make_random,void,"char*, size_t"
 | 
			
		||||
Function,-,nan,double,const char*
 | 
			
		||||
Function,-,nanf,float,const char*
 | 
			
		||||
Function,-,nanl,long double,const char*
 | 
			
		||||
@ -1925,7 +1928,6 @@ Function,-,serial_svc_set_rpc_status,void,SerialServiceRpcStatus
 | 
			
		||||
Function,-,serial_svc_start,void,
 | 
			
		||||
Function,-,serial_svc_stop,void,
 | 
			
		||||
Function,-,serial_svc_update_tx,_Bool,"uint8_t*, uint16_t"
 | 
			
		||||
Function,+,set_random_name,void,"char*, uint8_t"
 | 
			
		||||
Function,-,setbuf,void,"FILE*, char*"
 | 
			
		||||
Function,-,setbuffer,void,"FILE*, char*, int"
 | 
			
		||||
Function,-,setenv,int,"const char*, const char*, int"
 | 
			
		||||
 | 
			
		||||
		
		
			
  | 
@ -1,5 +1,5 @@
 | 
			
		||||
entry,status,name,type,params
 | 
			
		||||
Version,+,35.1,,
 | 
			
		||||
Version,+,36.0,,
 | 
			
		||||
Header,+,applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.h,,
 | 
			
		||||
Header,+,applications/services/bt/bt_service/bt.h,,
 | 
			
		||||
Header,+,applications/services/cli/cli.h,,
 | 
			
		||||
@ -213,10 +213,10 @@ Header,+,lib/toolbox/hex.h,,
 | 
			
		||||
Header,+,lib/toolbox/manchester_decoder.h,,
 | 
			
		||||
Header,+,lib/toolbox/manchester_encoder.h,,
 | 
			
		||||
Header,+,lib/toolbox/md5.h,,
 | 
			
		||||
Header,+,lib/toolbox/name_generator.h,,
 | 
			
		||||
Header,+,lib/toolbox/path.h,,
 | 
			
		||||
Header,+,lib/toolbox/pretty_format.h,,
 | 
			
		||||
Header,+,lib/toolbox/protocols/protocol_dict.h,,
 | 
			
		||||
Header,+,lib/toolbox/random_name.h,,
 | 
			
		||||
Header,+,lib/toolbox/saved_struct.h,,
 | 
			
		||||
Header,+,lib/toolbox/sha256.h,,
 | 
			
		||||
Header,+,lib/toolbox/stream/buffered_file_stream.h,,
 | 
			
		||||
@ -2090,6 +2090,9 @@ Function,-,music_worker_set_callback,void,"MusicWorker*, MusicWorkerCallback, vo
 | 
			
		||||
Function,-,music_worker_set_volume,void,"MusicWorker*, float"
 | 
			
		||||
Function,-,music_worker_start,void,MusicWorker*
 | 
			
		||||
Function,-,music_worker_stop,void,MusicWorker*
 | 
			
		||||
Function,+,name_generator_make_auto,void,"char*, size_t, const char*"
 | 
			
		||||
Function,+,name_generator_make_detailed,void,"char*, size_t, const char*"
 | 
			
		||||
Function,+,name_generator_make_random,void,"char*, size_t"
 | 
			
		||||
Function,-,nan,double,const char*
 | 
			
		||||
Function,-,nanf,float,const char*
 | 
			
		||||
Function,-,nanl,long double,const char*
 | 
			
		||||
@ -2535,7 +2538,6 @@ Function,-,serial_svc_set_rpc_status,void,SerialServiceRpcStatus
 | 
			
		||||
Function,-,serial_svc_start,void,
 | 
			
		||||
Function,-,serial_svc_stop,void,
 | 
			
		||||
Function,-,serial_svc_update_tx,_Bool,"uint8_t*, uint16_t"
 | 
			
		||||
Function,+,set_random_name,void,"char*, uint8_t"
 | 
			
		||||
Function,-,setbuf,void,"FILE*, char*"
 | 
			
		||||
Function,-,setbuffer,void,"FILE*, char*, int"
 | 
			
		||||
Function,-,setenv,int,"const char*, const char*, int"
 | 
			
		||||
 | 
			
		||||
		
		
			
  | 
@ -32,6 +32,7 @@ typedef enum {
 | 
			
		||||
    FuriHalRtcFlagHandOrient = (1 << 4),
 | 
			
		||||
    FuriHalRtcFlagLegacySleep = (1 << 5),
 | 
			
		||||
    FuriHalRtcFlagStealthMode = (1 << 6),
 | 
			
		||||
    FuriHalRtcFlagDetailedFilename = (1 << 7),
 | 
			
		||||
} FuriHalRtcFlag;
 | 
			
		||||
 | 
			
		||||
typedef enum {
 | 
			
		||||
 | 
			
		||||
@ -1360,7 +1360,7 @@ void nfc_device_set_name(NfcDevice* dev, const char* name) {
 | 
			
		||||
static void nfc_device_get_path_without_ext(FuriString* orig_path, FuriString* shadow_path) {
 | 
			
		||||
    // TODO: this won't work if there is ".nfc" anywhere in the path other than
 | 
			
		||||
    // at the end
 | 
			
		||||
    size_t ext_start = furi_string_search(orig_path, NFC_APP_EXTENSION);
 | 
			
		||||
    size_t ext_start = furi_string_search(orig_path, NFC_APP_FILENAME_EXTENSION);
 | 
			
		||||
    furi_string_set_n(shadow_path, orig_path, 0, ext_start);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1587,7 +1587,7 @@ bool nfc_file_select(NfcDevice* dev) {
 | 
			
		||||
    // Input events and views are managed by file_browser
 | 
			
		||||
 | 
			
		||||
    const DialogsFileBrowserOptions browser_options = {
 | 
			
		||||
        .extension = NFC_APP_EXTENSION,
 | 
			
		||||
        .extension = NFC_APP_FILENAME_EXTENSION,
 | 
			
		||||
        .skip_assets = true,
 | 
			
		||||
        .hide_dot_files = true,
 | 
			
		||||
        .icon = &I_Nfc_10px,
 | 
			
		||||
@ -1659,7 +1659,7 @@ bool nfc_device_delete(NfcDevice* dev, bool use_load_path) {
 | 
			
		||||
                "%s/%s%s",
 | 
			
		||||
                furi_string_get_cstr(dev->folder),
 | 
			
		||||
                dev->dev_name,
 | 
			
		||||
                NFC_APP_EXTENSION);
 | 
			
		||||
                NFC_APP_FILENAME_EXTENSION);
 | 
			
		||||
        }
 | 
			
		||||
        if(!storage_simply_remove(dev->storage, furi_string_get_cstr(file_path))) break;
 | 
			
		||||
        // Delete shadow file if it exists
 | 
			
		||||
@ -1717,7 +1717,7 @@ bool nfc_device_restore(NfcDevice* dev, bool use_load_path) {
 | 
			
		||||
                "%s/%s%s",
 | 
			
		||||
                furi_string_get_cstr(dev->folder),
 | 
			
		||||
                dev->dev_name,
 | 
			
		||||
                NFC_APP_EXTENSION);
 | 
			
		||||
                NFC_APP_FILENAME_EXTENSION);
 | 
			
		||||
        }
 | 
			
		||||
        if(!nfc_device_load_data(dev, path, true)) break;
 | 
			
		||||
        restored = true;
 | 
			
		||||
 | 
			
		||||
@ -21,7 +21,8 @@ extern "C" {
 | 
			
		||||
#define NFC_READER_DATA_MAX_SIZE 64
 | 
			
		||||
#define NFC_DICT_KEY_BATCH_SIZE 10
 | 
			
		||||
 | 
			
		||||
#define NFC_APP_EXTENSION ".nfc"
 | 
			
		||||
#define NFC_APP_FILENAME_PREFIX "NFC"
 | 
			
		||||
#define NFC_APP_FILENAME_EXTENSION ".nfc"
 | 
			
		||||
#define NFC_APP_SHADOW_EXTENSION ".shd"
 | 
			
		||||
 | 
			
		||||
typedef void (*NfcLoadingCallback)(void* context, bool state);
 | 
			
		||||
 | 
			
		||||
@ -108,7 +108,8 @@ bool subghz_protocol_raw_save_to_file_init(
 | 
			
		||||
 | 
			
		||||
        furi_string_set(instance->file_name, dev_name);
 | 
			
		||||
        // First remove subghz device file if it was saved
 | 
			
		||||
        furi_string_printf(temp_str, "%s/%s%s", SUBGHZ_RAW_FOLDER, dev_name, SUBGHZ_APP_EXTENSION);
 | 
			
		||||
        furi_string_printf(
 | 
			
		||||
            temp_str, "%s/%s%s", SUBGHZ_RAW_FOLDER, dev_name, SUBGHZ_APP_FILENAME_EXTENSION);
 | 
			
		||||
 | 
			
		||||
        if(!storage_simply_remove(instance->storage, furi_string_get_cstr(temp_str))) {
 | 
			
		||||
            break;
 | 
			
		||||
 | 
			
		||||
@ -13,7 +13,8 @@
 | 
			
		||||
 | 
			
		||||
#define SUBGHZ_APP_FOLDER ANY_PATH("subghz")
 | 
			
		||||
#define SUBGHZ_RAW_FOLDER EXT_PATH("subghz")
 | 
			
		||||
#define SUBGHZ_APP_EXTENSION ".sub"
 | 
			
		||||
#define SUBGHZ_APP_FILENAME_PREFIX "SubGHz"
 | 
			
		||||
#define SUBGHZ_APP_FILENAME_EXTENSION ".sub"
 | 
			
		||||
 | 
			
		||||
#define SUBGHZ_KEY_FILE_VERSION 1
 | 
			
		||||
#define SUBGHZ_KEY_FILE_TYPE "Flipper SubGhz Key File"
 | 
			
		||||
 | 
			
		||||
@ -13,7 +13,7 @@ env.Append(
 | 
			
		||||
        File("manchester_decoder.h"),
 | 
			
		||||
        File("manchester_encoder.h"),
 | 
			
		||||
        File("path.h"),
 | 
			
		||||
        File("random_name.h"),
 | 
			
		||||
        File("name_generator.h"),
 | 
			
		||||
        File("sha256.h"),
 | 
			
		||||
        File("crc32_calc.h"),
 | 
			
		||||
        File("dir_walk.h"),
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										75
									
								
								lib/toolbox/name_generator.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										75
									
								
								lib/toolbox/name_generator.c
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,75 @@
 | 
			
		||||
#include "name_generator.h"
 | 
			
		||||
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
#include <furi_hal_rtc.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <stdbool.h>
 | 
			
		||||
#include <furi.h>
 | 
			
		||||
 | 
			
		||||
const char* const name_generator_left[] = {
 | 
			
		||||
    "ancient",  "hollow", "strange",   "disappeared", "unknown",    "unthinkable", "unnameable",
 | 
			
		||||
    "nameless", "my",     "concealed", "forgotten",   "hidden",     "mysterious",  "obscure",
 | 
			
		||||
    "random",   "remote", "uncharted", "undefined",   "untraveled", "untold",
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const char* const name_generator_right[] = {
 | 
			
		||||
    "door",
 | 
			
		||||
    "entrance",
 | 
			
		||||
    "doorway",
 | 
			
		||||
    "entry",
 | 
			
		||||
    "portal",
 | 
			
		||||
    "entree",
 | 
			
		||||
    "opening",
 | 
			
		||||
    "crack",
 | 
			
		||||
    "access",
 | 
			
		||||
    "corridor",
 | 
			
		||||
    "passage",
 | 
			
		||||
    "port",
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
void name_generator_make_auto(char* name, size_t max_name_size, const char* prefix) {
 | 
			
		||||
    if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDetailedFilename)) {
 | 
			
		||||
        name_generator_make_detailed(name, max_name_size, prefix);
 | 
			
		||||
    } else {
 | 
			
		||||
        name_generator_make_random(name, max_name_size);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void name_generator_make_random(char* name, size_t max_name_size) {
 | 
			
		||||
    furi_assert(name);
 | 
			
		||||
    furi_assert(max_name_size);
 | 
			
		||||
 | 
			
		||||
    uint8_t name_generator_left_i = rand() % COUNT_OF(name_generator_left);
 | 
			
		||||
    uint8_t name_generator_right_i = rand() % COUNT_OF(name_generator_right);
 | 
			
		||||
 | 
			
		||||
    snprintf(
 | 
			
		||||
        name,
 | 
			
		||||
        max_name_size,
 | 
			
		||||
        "%s_%s",
 | 
			
		||||
        name_generator_left[name_generator_left_i],
 | 
			
		||||
        name_generator_right[name_generator_right_i]);
 | 
			
		||||
 | 
			
		||||
    // Set first symbol to upper case
 | 
			
		||||
    name[0] = name[0] - 0x20;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void name_generator_make_detailed(char* name, size_t max_name_size, const char* prefix) {
 | 
			
		||||
    furi_assert(name);
 | 
			
		||||
    furi_assert(max_name_size);
 | 
			
		||||
    furi_assert(prefix);
 | 
			
		||||
 | 
			
		||||
    FuriHalRtcDateTime dateTime;
 | 
			
		||||
    furi_hal_rtc_get_datetime(&dateTime);
 | 
			
		||||
 | 
			
		||||
    snprintf(
 | 
			
		||||
        name,
 | 
			
		||||
        max_name_size,
 | 
			
		||||
        "%s-%.4d_%.2d_%.2d-%.2d_%.2d",
 | 
			
		||||
        prefix,
 | 
			
		||||
        dateTime.year,
 | 
			
		||||
        dateTime.month,
 | 
			
		||||
        dateTime.day,
 | 
			
		||||
        dateTime.hour,
 | 
			
		||||
        dateTime.minute);
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										35
									
								
								lib/toolbox/name_generator.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								lib/toolbox/name_generator.h
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,35 @@
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
#include <stddef.h>
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/** Generates detailed/random name based on furi_hal flags
 | 
			
		||||
 *
 | 
			
		||||
 * @param      name           buffer to write random name
 | 
			
		||||
 * @param      max_name_size  length of given buffer
 | 
			
		||||
 * @param[in]  prefix         The prefix of the name
 | 
			
		||||
 */
 | 
			
		||||
void name_generator_make_auto(char* name, size_t max_name_size, const char* prefix);
 | 
			
		||||
 | 
			
		||||
/** Generates random name
 | 
			
		||||
 *
 | 
			
		||||
 * @param      name           buffer to write random name
 | 
			
		||||
 * @param      max_name_size  length of given buffer
 | 
			
		||||
 */
 | 
			
		||||
void name_generator_make_random(char* name, size_t max_name_size);
 | 
			
		||||
 | 
			
		||||
/** Generates detailed name
 | 
			
		||||
 *
 | 
			
		||||
 * @param      name           buffer to write random name
 | 
			
		||||
 * @param      max_name_size  length of given buffer
 | 
			
		||||
 * @param[in]  prefix         The prefix of the name
 | 
			
		||||
 */
 | 
			
		||||
void name_generator_make_detailed(char* name, size_t max_name_size, const char* prefix);
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
@ -1,35 +0,0 @@
 | 
			
		||||
#include "random_name.h"
 | 
			
		||||
#include <stdio.h>
 | 
			
		||||
#include <stdlib.h>
 | 
			
		||||
#include <stdbool.h>
 | 
			
		||||
#include <furi.h>
 | 
			
		||||
 | 
			
		||||
void set_random_name(char* name, uint8_t max_name_size) {
 | 
			
		||||
    const char* prefix[] = {
 | 
			
		||||
        "ancient",     "hollow",    "strange",    "disappeared", "unknown",
 | 
			
		||||
        "unthinkable", "unnamable", "nameless",   "my",          "concealed",
 | 
			
		||||
        "forgotten",   "hidden",    "mysterious", "obscure",     "random",
 | 
			
		||||
        "remote",      "uncharted", "undefined",  "untravelled", "untold",
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    const char* suffix[] = {
 | 
			
		||||
        "door",
 | 
			
		||||
        "entrance",
 | 
			
		||||
        "doorway",
 | 
			
		||||
        "entry",
 | 
			
		||||
        "portal",
 | 
			
		||||
        "entree",
 | 
			
		||||
        "opening",
 | 
			
		||||
        "crack",
 | 
			
		||||
        "access",
 | 
			
		||||
        "corridor",
 | 
			
		||||
        "passage",
 | 
			
		||||
        "port",
 | 
			
		||||
    };
 | 
			
		||||
    uint8_t prefix_i = rand() % COUNT_OF(prefix);
 | 
			
		||||
    uint8_t suffix_i = rand() % COUNT_OF(suffix);
 | 
			
		||||
 | 
			
		||||
    snprintf(name, max_name_size, "%s_%s", prefix[prefix_i], suffix[suffix_i]);
 | 
			
		||||
    // Set first symbol to upper case
 | 
			
		||||
    name[0] = name[0] - 0x20;
 | 
			
		||||
}
 | 
			
		||||
@ -1,17 +0,0 @@
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
#include <stdint.h>
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/** Generates random name
 | 
			
		||||
 * @param name buffer to write random name
 | 
			
		||||
 * @param max_name_size length of given buffer
 | 
			
		||||
 */
 | 
			
		||||
void set_random_name(char* name, uint8_t max_name_size);
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user