From acd6445d3bbb7a6fe1816f542118b53f6a6b8a9c Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Sat, 27 Jan 2024 03:20:53 +0300 Subject: [PATCH 1/6] fix NFC V dumps v3 crashing at info page --- lib/nfc/protocols/iso15693_3/iso15693_3.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/nfc/protocols/iso15693_3/iso15693_3.c b/lib/nfc/protocols/iso15693_3/iso15693_3.c index 3203cbad0..472edfa95 100644 --- a/lib/nfc/protocols/iso15693_3/iso15693_3.c +++ b/lib/nfc/protocols/iso15693_3/iso15693_3.c @@ -328,7 +328,12 @@ bool iso15693_3_is_block_locked(const Iso15693_3Data* data, uint8_t block_index) furi_assert(data); furi_assert(block_index < data->system_info.block_count); - return *(const uint8_t*)simple_array_cget(data->block_security, block_index); + // TODO: make proper fix for this, old format had no Block Security Status in file + if(simple_array_get_count(data->block_security) != 0) { + return *(const uint8_t*)simple_array_cget(data->block_security, block_index); + } else { + return false; + } } uint8_t iso15693_3_get_manufacturer_id(const Iso15693_3Data* data) { From ae04fc70eb826980631f8f7a7a559337260efa53 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Sat, 27 Jan 2024 17:53:11 +0300 Subject: [PATCH 2/6] fix archive filebrowser bugs --- applications/main/archive/helpers/archive_browser.c | 7 +++++-- applications/main/archive/views/archive_browser_view.c | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/applications/main/archive/helpers/archive_browser.c b/applications/main/archive/helpers/archive_browser.c index facf00a3a..520741fe2 100644 --- a/applications/main/archive/helpers/archive_browser.c +++ b/applications/main/archive/helpers/archive_browser.c @@ -153,7 +153,9 @@ void archive_update_focus(ArchiveBrowserView* browser, const char* target) { archive_get_items(browser, furi_string_get_cstr(browser->path)); - if(!archive_file_get_array_size(browser) && archive_is_home(browser)) { + ArchiveTabEnum tab = archive_get_tab(browser); + if(!archive_file_get_array_size(browser) && archive_is_home(browser) && + (tab != ArchiveTabBrowser)) { archive_switch_tab(browser, TAB_LEFT); } else { with_view_model( @@ -220,7 +222,8 @@ void archive_file_array_rm_selected(ArchiveBrowserView* browser) { }, false); - if((items_cnt == 0) && (archive_is_home(browser))) { + ArchiveTabEnum tab = archive_get_tab(browser); + if((items_cnt == 0) && (archive_is_home(browser)) && (tab != ArchiveTabBrowser)) { archive_switch_tab(browser, TAB_LEFT); } diff --git a/applications/main/archive/views/archive_browser_view.c b/applications/main/archive/views/archive_browser_view.c index e298583ec..de3aa8887 100644 --- a/applications/main/archive/views/archive_browser_view.c +++ b/applications/main/archive/views/archive_browser_view.c @@ -585,6 +585,10 @@ static bool archive_view_input(InputEvent* event, void* context) { ((model->item_idx - scroll_speed) + model->item_cnt) % model->item_cnt; } + // Fix for empty folders, we can't select -1 item + if(model->item_idx < 0) { + model->item_idx = 0; + } if(is_file_list_load_required(model)) { model->list_loading = true; browser->callback(ArchiveBrowserEventLoadPrevItems, browser->context); From 1ceacc6555b8769869fe32791dda0c365e65e821 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Sat, 27 Jan 2024 18:55:50 +0300 Subject: [PATCH 3/6] subghz keeloq fix emulation for multiple systems and extend add manually support for 2 of them --- .../main/subghz/helpers/subghz_custom_event.h | 2 ++ .../subghz/scenes/subghz_scene_set_type.c | 30 +++++++++++++++++++ lib/subghz/protocols/keeloq.c | 19 +++++++----- 3 files changed, 44 insertions(+), 7 deletions(-) diff --git a/applications/main/subghz/helpers/subghz_custom_event.h b/applications/main/subghz/helpers/subghz_custom_event.h index 6838b345d..ad26123ea 100644 --- a/applications/main/subghz/helpers/subghz_custom_event.h +++ b/applications/main/subghz/helpers/subghz_custom_event.h @@ -24,12 +24,14 @@ typedef enum { SubmenuIndexSommer_FM_868, SubmenuIndexStilmatic, SubmenuIndexDTMNeo433, + SubmenuIndexDeaMio433, SubmenuIndexGibidi433, SubmenuIndexNiceMHouse_433_92, SubmenuIndexJCM_433_92, SubmenuIndexFAACRCXT_433_92, SubmenuIndexFAACRCXT_868, SubmenuIndexNormstahl_433_92, + SubmenuIndexGeniusBravo433, SubmenuIndexGSN, SubmenuIndexAprimatic, SubmenuIndexHCS101_433_92, diff --git a/applications/main/subghz/scenes/subghz_scene_set_type.c b/applications/main/subghz/scenes/subghz_scene_set_type.c index 2d6181851..cd07b30bb 100644 --- a/applications/main/subghz/scenes/subghz_scene_set_type.c +++ b/applications/main/subghz/scenes/subghz_scene_set_type.c @@ -139,6 +139,12 @@ void subghz_scene_set_type_on_enter(void* context) { SubmenuIndexIronLogic, subghz_scene_set_type_submenu_callback, subghz); + submenu_add_item( + subghz->submenu, + "KL: DEA Mio 433MHz", + SubmenuIndexDeaMio433, + subghz_scene_set_type_submenu_callback, + subghz); submenu_add_item( subghz->submenu, "KL: DTM Neo 433MHz", @@ -193,6 +199,12 @@ void subghz_scene_set_type_on_enter(void* context) { SubmenuIndexFAACRCXT_868, subghz_scene_set_type_submenu_callback, subghz); + submenu_add_item( + subghz->submenu, + "KL: Genius Bravo 433MHz", + SubmenuIndexGeniusBravo433, + subghz_scene_set_type_submenu_callback, + subghz); submenu_add_item( subghz->submenu, "KL: Nice Mhouse 433MHz", @@ -747,6 +759,24 @@ bool subghz_scene_set_type_on_event(void* context, SceneManagerEvent event) { scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError); } break; + case SubmenuIndexDeaMio433: + generated_protocol = subghz_txrx_gen_keeloq_protocol( + subghz->txrx, "AM650", 433920000, key & 0x00FFFFFF, 0x2, 0x0003, "Dea_Mio"); + if(!generated_protocol) { + furi_string_set( + subghz->error_str, "Function requires\nan SD card with\nfresh databases."); + scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError); + } + break; + case SubmenuIndexGeniusBravo433: + generated_protocol = subghz_txrx_gen_keeloq_protocol( + subghz->txrx, "AM650", 433920000, key & 0x00FFFFFF, 0x6, 0x0003, "Genius_Bravo"); + if(!generated_protocol) { + furi_string_set( + subghz->error_str, "Function requires\nan SD card with\nfresh databases."); + scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError); + } + break; case SubmenuIndexJCM_433_92: generated_protocol = subghz_txrx_gen_keeloq_protocol( subghz->txrx, "AM650", 433920000, key & 0x00FFFFFF, 0x2, 0x0003, "JCM_Tech"); diff --git a/lib/subghz/protocols/keeloq.c b/lib/subghz/protocols/keeloq.c index 2a92e9db5..281373527 100644 --- a/lib/subghz/protocols/keeloq.c +++ b/lib/subghz/protocols/keeloq.c @@ -223,17 +223,18 @@ static bool subghz_protocol_keeloq_gen_data( (strcmp(instance->manufacture_name, "DTM_Neo") == 0) || (strcmp(instance->manufacture_name, "FAAC_RC,XT") == 0) || (strcmp(instance->manufacture_name, "Mutanco_Mutancode") == 0) || - (strcmp(instance->manufacture_name, "Came_Space") == 0)) { + (strcmp(instance->manufacture_name, "Came_Space") == 0) || + (strcmp(instance->manufacture_name, "Genius_Bravo") == 0) || + (strcmp(instance->manufacture_name, "GSN") == 0)) { // DTM Neo, Came_Space uses 12bit serial -> simple learning - // FAAC_RC,XT , Mutanco_Mutancode 12bit serial -> normal learning + // FAAC_RC,XT , Mutanco_Mutancode, Genius_Bravo, GSN 12bit serial -> normal learning decrypt = btn << 28 | (instance->generic.serial & 0xFFF) << 16 | instance->generic.cnt; } else if( (strcmp(instance->manufacture_name, "NICE_Smilo") == 0) || (strcmp(instance->manufacture_name, "NICE_MHOUSE") == 0) || - (strcmp(instance->manufacture_name, "JCM_Tech") == 0) || - (strcmp(instance->manufacture_name, "Normstahl") == 0)) { - // Nice Smilo, MHouse, JCM, Normstahl -> 8bit serial - simple learning + (strcmp(instance->manufacture_name, "JCM_Tech") == 0)) { + // Nice Smilo, MHouse, JCM -> 8bit serial - simple learning decrypt = btn << 28 | (instance->generic.serial & 0xFF) << 16 | instance->generic.cnt; } else if(strcmp(instance->manufacture_name, "Beninca") == 0) { @@ -242,6 +243,10 @@ static bool subghz_protocol_keeloq_gen_data( } else if(strcmp(instance->manufacture_name, "Centurion") == 0) { decrypt = btn << 28 | (0x1CE) << 16 | instance->generic.cnt; // Centurion -> no serial in hop, uses fixed value 0x1CE - normal learning + } else if(strcmp(instance->manufacture_name, "Dea_Mio") == 0) { + uint32_t dea_serial = (instance->generic.serial & 0xFFF) + 0x800; + decrypt = btn << 28 | (dea_serial & 0xFFF) << 16 | instance->generic.cnt; + // Dea_Mio -> modified serial in hop, uses last 3 digits adding +8 to first one (example - 419 -> C19) - simple learning } // Old type selector fixage for compatibilitiy with old signal files uint8_t kl_type_en = instance->keystore->kl_type; @@ -709,13 +714,13 @@ static inline bool subghz_protocol_keeloq_check_decrypt( if((decrypt >> 28 == btn) && (((((uint16_t)(decrypt >> 16)) & 0xFF) == end_serial) || ((((uint16_t)(decrypt >> 16)) & 0xFF) == 0))) { instance->cnt = decrypt & 0x0000FFFF; - /*FURI_LOG_I( + FURI_LOG_I( "KL", "decrypt: 0x%08lX, btn: %d, end_serial: 0x%03lX, cnt: %ld", decrypt, btn, end_serial, - instance->cnt);*/ + instance->cnt); return true; } return false; From cbc023146161e2bdde58080a8534fdcb53922484 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Sat, 27 Jan 2024 19:05:52 +0300 Subject: [PATCH 4/6] disable expansion and reset some flags for release builds there is no expansion modules yet, so we can disable uart listen for them being enabled 24/7 p.s. some parts of code was taken from Willy-JL's solution todo: revert force reset part if there are real use cases for expansion protocol appears --- applications/services/expansion/expansion.c | 5 ++--- .../services/expansion/expansion_settings.c | 16 ++++++++++------ .../expansion_settings_app.c | 4 +--- .../storage_move_to_sd/storage_move_to_sd.c | 4 ++++ .../updater/util/update_task_worker_flasher.c | 2 ++ 5 files changed, 19 insertions(+), 12 deletions(-) diff --git a/applications/services/expansion/expansion.c b/applications/services/expansion/expansion.c index ca3b71444..ae69db18a 100644 --- a/applications/services/expansion/expansion.c +++ b/applications/services/expansion/expansion.c @@ -395,9 +395,8 @@ void expansion_on_system_start(void* arg) { furi_record_create(RECORD_EXPANSION, instance); ExpansionSettings settings = {}; - if(!expansion_settings_load(&settings)) { - expansion_settings_save(&settings); - } else if(settings.uart_index < FuriHalSerialIdMax) { + expansion_settings_load(&settings); + if(settings.uart_index < FuriHalSerialIdMax) { expansion_enable(instance, settings.uart_index); } } diff --git a/applications/services/expansion/expansion_settings.c b/applications/services/expansion/expansion_settings.c index 586bf6e9c..f350e2c56 100644 --- a/applications/services/expansion/expansion_settings.c +++ b/applications/services/expansion/expansion_settings.c @@ -2,6 +2,7 @@ #include #include +#include #include "expansion_settings_filename.h" @@ -11,12 +12,15 @@ bool expansion_settings_load(ExpansionSettings* settings) { furi_assert(settings); - return saved_struct_load( - EXPANSION_SETTINGS_PATH, - settings, - sizeof(ExpansionSettings), - EXPANSION_SETTINGS_MAGIC, - EXPANSION_SETTINGS_VERSION); + if(!saved_struct_load( + EXPANSION_SETTINGS_PATH, + settings, + sizeof(ExpansionSettings), + EXPANSION_SETTINGS_MAGIC, + EXPANSION_SETTINGS_VERSION)) { + settings->uart_index = FuriHalSerialIdMax; + } + return true; } bool expansion_settings_save(ExpansionSettings* settings) { diff --git a/applications/settings/expansion_settings_app/expansion_settings_app.c b/applications/settings/expansion_settings_app/expansion_settings_app.c index 894015712..353fab611 100644 --- a/applications/settings/expansion_settings_app/expansion_settings_app.c +++ b/applications/settings/expansion_settings_app/expansion_settings_app.c @@ -27,9 +27,7 @@ static uint32_t expansion_settings_app_exit(void* context) { static ExpansionSettingsApp* expansion_settings_app_alloc() { ExpansionSettingsApp* app = malloc(sizeof(ExpansionSettingsApp)); - if(!expansion_settings_load(&app->settings)) { - expansion_settings_save(&app->settings); - } + expansion_settings_load(&app->settings); app->gui = furi_record_open(RECORD_GUI); app->expansion = furi_record_open(RECORD_EXPANSION); diff --git a/applications/system/storage_move_to_sd/storage_move_to_sd.c b/applications/system/storage_move_to_sd/storage_move_to_sd.c index 949f889b2..94d275878 100644 --- a/applications/system/storage_move_to_sd/storage_move_to_sd.c +++ b/applications/system/storage_move_to_sd/storage_move_to_sd.c @@ -28,6 +28,10 @@ static void storage_move_to_sd_remove_region() { if(storage_common_exists(storage, INT_PATH(".region_data"))) { storage_common_remove(storage, INT_PATH(".region_data")); } + // No expansion modules yet + if(storage_common_exists(storage, INT_PATH(".expansion.settings"))) { + storage_common_remove(storage, INT_PATH(".expansion.settings")); + } furi_record_close(RECORD_STORAGE); } diff --git a/applications/system/updater/util/update_task_worker_flasher.c b/applications/system/updater/util/update_task_worker_flasher.c index 40f58f462..0c7881e63 100644 --- a/applications/system/updater/util/update_task_worker_flasher.c +++ b/applications/system/updater/util/update_task_worker_flasher.c @@ -348,6 +348,8 @@ int32_t update_task_worker_flash_writer(void* context) { // Production furi_hal_rtc_set_log_level(FuriLogLevelDefault); furi_hal_rtc_reset_flag(FuriHalRtcFlagDebug); + furi_hal_rtc_reset_flag(FuriHalRtcFlagLegacySleep); + furi_hal_rtc_set_heap_track_mode(FuriHalRtcHeapTrackModeNone); #endif update_task_set_progress(update_task, UpdateTaskStageCompleted, 100); success = true; From 16b8fa471537e1f4938b30d08e3654726f9a9357 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Sun, 28 Jan 2024 06:45:33 +0300 Subject: [PATCH 5/6] Subghz save files with receive time [ci skip] + merge better scene_save_name code (removing kostily) some modifications to original code was made to keep previous formats original implementation by Willy-JL Source: https://github.com/Flipper-XFW/Xtreme-Firmware/commit/a1c7dc5eaa13905fa3282f7338408756b7af8cb0 https://github.com/Flipper-XFW/Xtreme-Firmware/commit/7e7509d48177b2593152d12d096206ae12a63ce6#diff-1708ba08196de5331f4b4c3d8e13162e78d5edb33e1308c1b4cc09975264151e --- .../scenes/subghz_scene_receiver_info.c | 3 + .../subghz/scenes/subghz_scene_save_name.c | 82 ++++++------------- applications/main/subghz/subghz_history.c | 10 +++ applications/main/subghz/subghz_history.h | 8 ++ applications/main/subghz/subghz_i.h | 3 + lib/subghz/protocols/keeloq.c | 4 +- lib/toolbox/name_generator.c | 52 +++++++++--- lib/toolbox/name_generator.h | 13 +++ targets/f7/api_symbols.csv | 3 + 9 files changed, 108 insertions(+), 70 deletions(-) diff --git a/applications/main/subghz/scenes/subghz_scene_receiver_info.c b/applications/main/subghz/scenes/subghz_scene_receiver_info.c index 807cc3ba2..5cf79eabc 100644 --- a/applications/main/subghz/scenes/subghz_scene_receiver_info.c +++ b/applications/main/subghz/scenes/subghz_scene_receiver_info.c @@ -165,6 +165,9 @@ bool subghz_scene_receiver_info_on_event(void* context, SceneManagerEvent event) if(subghz_txrx_protocol_is_serializable(subghz->txrx)) { subghz_file_name_clear(subghz); + subghz->save_datetime = + subghz_history_get_datetime(subghz->history, subghz->idx_menu_chosen); + subghz->save_datetime_set = true; scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSaveName); } return true; diff --git a/applications/main/subghz/scenes/subghz_scene_save_name.c b/applications/main/subghz/scenes/subghz_scene_save_name.c index e1bb6c33b..c0768de4b 100644 --- a/applications/main/subghz/scenes/subghz_scene_save_name.c +++ b/applications/main/subghz/scenes/subghz_scene_save_name.c @@ -6,44 +6,12 @@ #include #include -#define MAX_TEXT_INPUT_LEN 23 - void subghz_scene_save_name_text_input_callback(void* context) { furi_assert(context); SubGhz* subghz = context; view_dispatcher_send_custom_event(subghz->view_dispatcher, SubGhzCustomEventSceneSaveName); } -void subghz_scene_save_name_get_timefilename( - FuriString* name, - const char* proto_name, - bool fulldate) { - FuriHalRtcDateTime datetime = {0}; - furi_hal_rtc_get_datetime(&datetime); - if(fulldate) { - furi_string_printf( - name, - "%s_%.4d%.2d%.2d-%.2d%.2d%.2d", - proto_name, - datetime.year, - datetime.month, - datetime.day, - datetime.hour, - datetime.minute, - datetime.second); - } else { - furi_string_printf( - name, - "%s_%.2d%.2d-%.2d%.2d%.2d", - proto_name, - datetime.month, - datetime.day, - datetime.hour, - datetime.minute, - datetime.second); - } -} - void subghz_scene_save_name_on_enter(void* context) { SubGhz* subghz = context; @@ -54,35 +22,33 @@ void subghz_scene_save_name_on_enter(void* context) { FuriString* file_name = furi_string_alloc(); FuriString* dir_name = furi_string_alloc(); + char file_name_buf[SUBGHZ_MAX_LEN_NAME] = {0}; + FuriHalRtcDateTime* datetime = subghz->save_datetime_set ? &subghz->save_datetime : NULL; + subghz->save_datetime_set = false; if(!subghz_path_is_file(subghz->file_path)) { - char file_name_buf[SUBGHZ_MAX_LEN_NAME] = {0}; - if(subghz->last_settings->timestamp_file_names) { - SubGhzProtocolDecoderBase* decoder_result = subghz_txrx_get_decoder(subghz->txrx); - if(decoder_result != 0x0) { - if(decoder_result != NULL) { - if(strlen(decoder_result->protocol->name) != 0) { - if(scene_manager_has_previous_scene( - subghz->scene_manager, SubGhzSceneSetType)) { - subghz_scene_save_name_get_timefilename(file_name, "S", true); - } else { - subghz_scene_save_name_get_timefilename( - file_name, decoder_result->protocol->name, false); - } + SubGhzProtocolDecoderBase* decoder_result = subghz_txrx_get_decoder(subghz->txrx); - } else { - subghz_scene_save_name_get_timefilename(file_name, "S", true); + bool skip_dec_is_present = false; + if(decoder_result != 0x0) { + if(decoder_result != NULL) { + if(strlen(decoder_result->protocol->name) != 0 && + subghz->last_settings->timestamp_file_names) { + if(!scene_manager_has_previous_scene( + subghz->scene_manager, SubGhzSceneSetType)) { + name_generator_make_auto_datetime( + file_name_buf, + SUBGHZ_MAX_LEN_NAME, + decoder_result->protocol->name, + datetime); + skip_dec_is_present = true; } - } else { - subghz_scene_save_name_get_timefilename(file_name, "S", true); } - } else { - subghz_scene_save_name_get_timefilename(file_name, "S", true); } - } else { - name_generator_make_auto( - file_name_buf, SUBGHZ_MAX_LEN_NAME, SUBGHZ_APP_FILENAME_PREFIX); - furi_string_set(file_name, file_name_buf); } + if(!skip_dec_is_present) { + name_generator_make_auto_datetime(file_name_buf, SUBGHZ_MAX_LEN_NAME, NULL, datetime); + } + furi_string_set(file_name, file_name_buf); furi_string_set(subghz->file_path, SUBGHZ_APP_FOLDER); //highlighting the entire filename by default dev_name_empty = true; @@ -96,7 +62,9 @@ void subghz_scene_save_name_on_enter(void* context) { if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneReadRAW) == SubGhzCustomEventManagerSetRAW) { dev_name_empty = true; - subghz_scene_save_name_get_timefilename(file_name, "RAW", true); + name_generator_make_auto_datetime( + file_name_buf, SUBGHZ_MAX_LEN_NAME, "RAW", datetime); + furi_string_set(file_name, file_name_buf); } } furi_string_set(subghz->file_path, dir_name); @@ -109,7 +77,7 @@ void subghz_scene_save_name_on_enter(void* context) { subghz_scene_save_name_text_input_callback, subghz, subghz->file_name_tmp, - MAX_TEXT_INPUT_LEN, + SUBGHZ_MAX_LEN_NAME, dev_name_empty); ValidatorIsFile* validator_is_file = validator_is_file_alloc_init( diff --git a/applications/main/subghz/subghz_history.c b/applications/main/subghz/subghz_history.c index 048104f35..2f0371985 100644 --- a/applications/main/subghz/subghz_history.c +++ b/applications/main/subghz/subghz_history.c @@ -131,6 +131,16 @@ const char* subghz_history_get_protocol_name(SubGhzHistory* instance, uint16_t i return furi_string_get_cstr(instance->tmp_string); } +FuriHalRtcDateTime subghz_history_get_datetime(SubGhzHistory* instance, uint16_t idx) { + furi_assert(instance); + SubGhzHistoryItem* item = SubGhzHistoryItemArray_get(instance->history->data, idx); + if(item) { + return item->datetime; + } else { + return (FuriHalRtcDateTime){}; + } +} + FlipperFormat* subghz_history_get_raw_data(SubGhzHistory* instance, uint16_t idx) { furi_assert(instance); SubGhzHistoryItem* item = SubGhzHistoryItemArray_get(instance->history->data, idx); diff --git a/applications/main/subghz/subghz_history.h b/applications/main/subghz/subghz_history.h index cc63c0259..2e940a8d8 100644 --- a/applications/main/subghz/subghz_history.h +++ b/applications/main/subghz/subghz_history.h @@ -70,6 +70,14 @@ uint8_t subghz_history_get_type_protocol(SubGhzHistory* instance, uint16_t idx); */ const char* subghz_history_get_protocol_name(SubGhzHistory* instance, uint16_t idx); +/** Get datetime from history[idx] + * + * @param instance - SubGhzHistory instance + * @param idx - record index + * @return datetime - FuriHalRtcDateTime received timestamp + */ +FuriHalRtcDateTime subghz_history_get_datetime(SubGhzHistory* instance, uint16_t idx); + /** Get string item menu to history[idx] * * @param instance - SubGhzHistory instance diff --git a/applications/main/subghz/subghz_i.h b/applications/main/subghz/subghz_i.h index 4297699db..09caed7a9 100644 --- a/applications/main/subghz/subghz_i.h +++ b/applications/main/subghz/subghz_i.h @@ -79,6 +79,9 @@ struct SubGhz { SubGhzReadRAW* subghz_read_raw; bool raw_send_only; + bool save_datetime_set; + FuriHalRtcDateTime save_datetime; + SubGhzLastSettings* last_settings; SubGhzProtocolFlag filter; diff --git a/lib/subghz/protocols/keeloq.c b/lib/subghz/protocols/keeloq.c index 281373527..3a6ee5796 100644 --- a/lib/subghz/protocols/keeloq.c +++ b/lib/subghz/protocols/keeloq.c @@ -714,13 +714,13 @@ static inline bool subghz_protocol_keeloq_check_decrypt( if((decrypt >> 28 == btn) && (((((uint16_t)(decrypt >> 16)) & 0xFF) == end_serial) || ((((uint16_t)(decrypt >> 16)) & 0xFF) == 0))) { instance->cnt = decrypt & 0x0000FFFF; - FURI_LOG_I( + /*FURI_LOG_I( "KL", "decrypt: 0x%08lX, btn: %d, end_serial: 0x%03lX, cnt: %ld", decrypt, btn, end_serial, - instance->cnt); + instance->cnt);*/ return true; } return false; diff --git a/lib/toolbox/name_generator.c b/lib/toolbox/name_generator.c index 732fdfedf..541622b88 100644 --- a/lib/toolbox/name_generator.c +++ b/lib/toolbox/name_generator.c @@ -44,15 +44,23 @@ const char* const name_generator_right[] = { "stuff", }; -void name_generator_make_auto(char* name, size_t max_name_size, const char* prefix) { +void name_generator_make_auto_datetime( + char* name, + size_t max_name_size, + const char* prefix, + FuriHalRtcDateTime* custom_time) { if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDetailedFilename)) { - name_generator_make_detailed(name, max_name_size, prefix); + name_generator_make_detailed_datetime(name, max_name_size, prefix, custom_time); } else { - name_generator_make_random(name, max_name_size); + name_generator_make_random_prefixed(name, max_name_size, prefix); } } -void name_generator_make_random(char* name, size_t max_name_size) { +void name_generator_make_auto(char* name, size_t max_name_size, const char* prefix) { + name_generator_make_auto_datetime(name, max_name_size, prefix, NULL); +} + +void name_generator_make_random_prefixed(char* name, size_t max_name_size, const char* prefix) { furi_assert(name); furi_assert(max_name_size); @@ -62,30 +70,52 @@ void name_generator_make_random(char* name, size_t max_name_size) { snprintf( name, max_name_size, - "%s_%s", + "%s%s%s_%s", + prefix ? prefix : "", + prefix ? "_" : "", 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; + if(islower((int)name[0])) name[0] = name[0] - 0x20; } -void name_generator_make_detailed(char* name, size_t max_name_size, const char* prefix) { +void name_generator_make_random(char* name, size_t max_name_size) { + name_generator_make_random_prefixed(name, max_name_size, NULL); +} + +void name_generator_make_detailed_datetime( + char* name, + size_t max_name_size, + const char* prefix, + FuriHalRtcDateTime* custom_time) { furi_assert(name); furi_assert(max_name_size); furi_assert(prefix); FuriHalRtcDateTime dateTime; - furi_hal_rtc_get_datetime(&dateTime); + if(custom_time) { + dateTime = *custom_time; + } else { + furi_hal_rtc_get_datetime(&dateTime); + } snprintf( name, max_name_size, - "%s-%.4d_%.2d_%.2d-%.2d_%.2d", - prefix, + "%s-%.4d_%.2d_%.2d-%.2d_%.2d_%.2d", + prefix ? prefix : "S", dateTime.year, dateTime.month, dateTime.day, dateTime.hour, - dateTime.minute); + dateTime.minute, + dateTime.second); + + // Set first symbol to upper case + if(islower((int)name[0])) name[0] = name[0] - 0x20; +} + +void name_generator_make_detailed(char* name, size_t max_name_size, const char* prefix) { + name_generator_make_detailed_datetime(name, max_name_size, prefix, NULL); } diff --git a/lib/toolbox/name_generator.h b/lib/toolbox/name_generator.h index bc17d54cd..ac9cdf6f5 100644 --- a/lib/toolbox/name_generator.h +++ b/lib/toolbox/name_generator.h @@ -2,6 +2,7 @@ #include #include +#include #ifdef __cplusplus extern "C" { @@ -14,13 +15,20 @@ extern "C" { * @param[in] prefix The prefix of the name */ void name_generator_make_auto(char* name, size_t max_name_size, const char* prefix); +void name_generator_make_auto_datetime( + char* name, + size_t max_name_size, + const char* prefix, + FuriHalRtcDateTime* custom_time); /** Generates random 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_random(char* name, size_t max_name_size); +void name_generator_make_random_prefixed(char* name, size_t max_name_size, const char* prefix); /** Generates detailed name * @@ -29,6 +37,11 @@ void name_generator_make_random(char* name, size_t max_name_size); * @param[in] prefix The prefix of the name */ void name_generator_make_detailed(char* name, size_t max_name_size, const char* prefix); +void name_generator_make_detailed_datetime( + char* name, + size_t max_name_size, + const char* prefix, + FuriHalRtcDateTime* custom_time); #ifdef __cplusplus } diff --git a/targets/f7/api_symbols.csv b/targets/f7/api_symbols.csv index 11d4918cc..5b317bc16 100644 --- a/targets/f7/api_symbols.csv +++ b/targets/f7/api_symbols.csv @@ -2478,8 +2478,11 @@ 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_auto_datetime,void,"char*, size_t, const char*, FuriHalRtcDateTime*" Function,+,name_generator_make_detailed,void,"char*, size_t, const char*" +Function,+,name_generator_make_detailed_datetime,void,"char*, size_t, const char*, FuriHalRtcDateTime*" Function,+,name_generator_make_random,void,"char*, size_t" +Function,+,name_generator_make_random_prefixed,void,"char*, size_t, const char*" Function,-,nan,double,const char* Function,-,nanf,float,const char* Function,-,nanl,long double,const char* From 686c05d20ceae6f65ecbe78a4e7c84700fd6450e Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Sun, 28 Jan 2024 08:53:41 +0300 Subject: [PATCH 6/6] change ci node --- .drone.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index 0a225e722..6a25fb5ca 100644 --- a/.drone.yml +++ b/.drone.yml @@ -375,7 +375,7 @@ trigger: - tag node: - typ: haupt + typ: dev1 --- kind: pipeline @@ -678,4 +678,4 @@ trigger: - push node: - typ: haupt + typ: dev1