Skorp subghz signal archive (#667)
* SubGhz: Add millis() furi, add subghz history struct
* SubGhz: Fix subghz history
* Gubghz: Fix code repeat history, add clean history
* SubGhz: reading and adding keys to history
* Gui: Renaming Sub 1-Ghz -> SubGhz
* Archive: Renaming Sub 1-Ghz -> SubGhz
* SubGhz: Add menu history, modified button for sending a signal, changed output of data about accepted protocol
* Archive: Fix name subghz
* SubGhz: Menu navigation
* Assets: Add assets/SubGHz/icon.png
* Assets: add new icons for subghz
* SubGhz: Fix name Add manually scene
* SubGhz: Fix load icon Read scene. rename encoder struct, rename protocol function load from file, add load raw data protocol, add info pleasant signals all protocol
* SubGhz: fix memory leak
* SubGhz: change of receiving frequency for read scene
* SubGhz: Add save/load frequency and preset, add automatic configuration of transmit/receive to the desired frequency and modulation, add button "save" config scene
* SubGhz: Fix frequency and preset, fix frequency add manualli scene, fix re-executing the parser
* Furi-hal-subghz: add 2-FSK config, fix ook config 650KHz BW Tx filter
* Fix formatting and release build
* SubGhz: Delete read scene
* SubGhz: Fix frequency add manualli scene, refactoring code
* SubGhz: 2 profiles for OOK, fix broken build.
* SubGhz: Add passing static codes from read scene, add notification read scene, refactoring code
* SubGhz: fix assert on worker double stop.
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-08-28 16:51:48 +03:00
|
|
|
#include "subghz_history.h"
|
2022-03-03 12:48:56 +03:00
|
|
|
#include <lib/subghz/receiver.h>
|
2022-10-01 07:39:51 +03:00
|
|
|
#include <flipper_format/flipper_format_i.h>
|
Skorp subghz signal archive (#667)
* SubGhz: Add millis() furi, add subghz history struct
* SubGhz: Fix subghz history
* Gubghz: Fix code repeat history, add clean history
* SubGhz: reading and adding keys to history
* Gui: Renaming Sub 1-Ghz -> SubGhz
* Archive: Renaming Sub 1-Ghz -> SubGhz
* SubGhz: Add menu history, modified button for sending a signal, changed output of data about accepted protocol
* Archive: Fix name subghz
* SubGhz: Menu navigation
* Assets: Add assets/SubGHz/icon.png
* Assets: add new icons for subghz
* SubGhz: Fix name Add manually scene
* SubGhz: Fix load icon Read scene. rename encoder struct, rename protocol function load from file, add load raw data protocol, add info pleasant signals all protocol
* SubGhz: fix memory leak
* SubGhz: change of receiving frequency for read scene
* SubGhz: Add save/load frequency and preset, add automatic configuration of transmit/receive to the desired frequency and modulation, add button "save" config scene
* SubGhz: Fix frequency and preset, fix frequency add manualli scene, fix re-executing the parser
* Furi-hal-subghz: add 2-FSK config, fix ook config 650KHz BW Tx filter
* Fix formatting and release build
* SubGhz: Delete read scene
* SubGhz: Fix frequency add manualli scene, refactoring code
* SubGhz: 2 profiles for OOK, fix broken build.
* SubGhz: Add passing static codes from read scene, add notification read scene, refactoring code
* SubGhz: fix assert on worker double stop.
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-08-28 16:51:48 +03:00
|
|
|
|
2022-09-16 21:30:53 +03:00
|
|
|
#define SUBGHZ_HISTORY_MAX 65
|
2022-10-02 02:18:30 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Settings for temporary files
|
|
|
|
*
|
|
|
|
*/
|
2022-10-01 07:39:51 +03:00
|
|
|
#define SUBGHZ_HISTORY_TMP_DIR EXT_PATH("subghz/tmp_history")
|
|
|
|
#define SUBGHZ_HISTORY_TMP_EXTENSION ".tmp"
|
|
|
|
#define SUBGHZ_HISTORY_TMP_FILE_KEY "Filename"
|
2022-10-02 02:18:30 +03:00
|
|
|
|
2022-03-03 12:48:56 +03:00
|
|
|
#define TAG "SubGhzHistory"
|
Skorp subghz signal archive (#667)
* SubGhz: Add millis() furi, add subghz history struct
* SubGhz: Fix subghz history
* Gubghz: Fix code repeat history, add clean history
* SubGhz: reading and adding keys to history
* Gui: Renaming Sub 1-Ghz -> SubGhz
* Archive: Renaming Sub 1-Ghz -> SubGhz
* SubGhz: Add menu history, modified button for sending a signal, changed output of data about accepted protocol
* Archive: Fix name subghz
* SubGhz: Menu navigation
* Assets: Add assets/SubGHz/icon.png
* Assets: add new icons for subghz
* SubGhz: Fix name Add manually scene
* SubGhz: Fix load icon Read scene. rename encoder struct, rename protocol function load from file, add load raw data protocol, add info pleasant signals all protocol
* SubGhz: fix memory leak
* SubGhz: change of receiving frequency for read scene
* SubGhz: Add save/load frequency and preset, add automatic configuration of transmit/receive to the desired frequency and modulation, add button "save" config scene
* SubGhz: Fix frequency and preset, fix frequency add manualli scene, fix re-executing the parser
* Furi-hal-subghz: add 2-FSK config, fix ook config 650KHz BW Tx filter
* Fix formatting and release build
* SubGhz: Delete read scene
* SubGhz: Fix frequency add manualli scene, refactoring code
* SubGhz: 2 profiles for OOK, fix broken build.
* SubGhz: Add passing static codes from read scene, add notification read scene, refactoring code
* SubGhz: fix assert on worker double stop.
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-08-28 16:51:48 +03:00
|
|
|
|
2022-03-03 12:48:56 +03:00
|
|
|
typedef struct {
|
|
|
|
string_t item_str;
|
|
|
|
FlipperFormat* flipper_string;
|
2022-10-01 07:39:51 +03:00
|
|
|
string_t protocol_name;
|
|
|
|
bool is_file;
|
2022-03-03 12:48:56 +03:00
|
|
|
uint8_t type;
|
2022-07-27 15:58:32 +03:00
|
|
|
SubGhzPresetDefinition* preset;
|
2022-03-03 12:48:56 +03:00
|
|
|
} SubGhzHistoryItem;
|
|
|
|
|
|
|
|
ARRAY_DEF(SubGhzHistoryItemArray, SubGhzHistoryItem, M_POD_OPLIST)
|
|
|
|
|
|
|
|
#define M_OPL_SubGhzHistoryItemArray_t() ARRAY_OPLIST(SubGhzHistoryItemArray, M_POD_OPLIST)
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
SubGhzHistoryItemArray_t data;
|
|
|
|
} SubGhzHistoryStruct;
|
Skorp subghz signal archive (#667)
* SubGhz: Add millis() furi, add subghz history struct
* SubGhz: Fix subghz history
* Gubghz: Fix code repeat history, add clean history
* SubGhz: reading and adding keys to history
* Gui: Renaming Sub 1-Ghz -> SubGhz
* Archive: Renaming Sub 1-Ghz -> SubGhz
* SubGhz: Add menu history, modified button for sending a signal, changed output of data about accepted protocol
* Archive: Fix name subghz
* SubGhz: Menu navigation
* Assets: Add assets/SubGHz/icon.png
* Assets: add new icons for subghz
* SubGhz: Fix name Add manually scene
* SubGhz: Fix load icon Read scene. rename encoder struct, rename protocol function load from file, add load raw data protocol, add info pleasant signals all protocol
* SubGhz: fix memory leak
* SubGhz: change of receiving frequency for read scene
* SubGhz: Add save/load frequency and preset, add automatic configuration of transmit/receive to the desired frequency and modulation, add button "save" config scene
* SubGhz: Fix frequency and preset, fix frequency add manualli scene, fix re-executing the parser
* Furi-hal-subghz: add 2-FSK config, fix ook config 650KHz BW Tx filter
* Fix formatting and release build
* SubGhz: Delete read scene
* SubGhz: Fix frequency add manualli scene, refactoring code
* SubGhz: 2 profiles for OOK, fix broken build.
* SubGhz: Add passing static codes from read scene, add notification read scene, refactoring code
* SubGhz: fix assert on worker double stop.
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-08-28 16:51:48 +03:00
|
|
|
|
|
|
|
struct SubGhzHistory {
|
|
|
|
uint32_t last_update_timestamp;
|
|
|
|
uint16_t last_index_write;
|
2022-03-03 12:48:56 +03:00
|
|
|
uint8_t code_last_hash_data;
|
|
|
|
string_t tmp_string;
|
2022-10-01 07:39:51 +03:00
|
|
|
bool write_tmp_files;
|
|
|
|
Storage* storage;
|
2022-03-03 12:48:56 +03:00
|
|
|
SubGhzHistoryStruct* history;
|
Skorp subghz signal archive (#667)
* SubGhz: Add millis() furi, add subghz history struct
* SubGhz: Fix subghz history
* Gubghz: Fix code repeat history, add clean history
* SubGhz: reading and adding keys to history
* Gui: Renaming Sub 1-Ghz -> SubGhz
* Archive: Renaming Sub 1-Ghz -> SubGhz
* SubGhz: Add menu history, modified button for sending a signal, changed output of data about accepted protocol
* Archive: Fix name subghz
* SubGhz: Menu navigation
* Assets: Add assets/SubGHz/icon.png
* Assets: add new icons for subghz
* SubGhz: Fix name Add manually scene
* SubGhz: Fix load icon Read scene. rename encoder struct, rename protocol function load from file, add load raw data protocol, add info pleasant signals all protocol
* SubGhz: fix memory leak
* SubGhz: change of receiving frequency for read scene
* SubGhz: Add save/load frequency and preset, add automatic configuration of transmit/receive to the desired frequency and modulation, add button "save" config scene
* SubGhz: Fix frequency and preset, fix frequency add manualli scene, fix re-executing the parser
* Furi-hal-subghz: add 2-FSK config, fix ook config 650KHz BW Tx filter
* Fix formatting and release build
* SubGhz: Delete read scene
* SubGhz: Fix frequency add manualli scene, refactoring code
* SubGhz: 2 profiles for OOK, fix broken build.
* SubGhz: Add passing static codes from read scene, add notification read scene, refactoring code
* SubGhz: fix assert on worker double stop.
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-08-28 16:51:48 +03:00
|
|
|
};
|
|
|
|
|
2022-10-02 02:18:30 +03:00
|
|
|
#ifdef FURI_DEBUG
|
|
|
|
#define LOG_DELAY 0
|
2022-10-01 07:39:51 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Generate filename like 000.tmp
|
|
|
|
*
|
2022-10-02 02:18:30 +03:00
|
|
|
* @param filename - input parameter
|
2022-10-01 07:39:51 +03:00
|
|
|
* @param index - index of file, timestamp doesn't accepted!
|
|
|
|
*/
|
|
|
|
void subghz_history_generate_temp_filename(string_t filename, uint32_t index) {
|
|
|
|
FuriHalRtcDateTime datetime = {0};
|
|
|
|
furi_hal_rtc_get_datetime(&datetime);
|
|
|
|
string_init_printf(filename, "%03d%s", index, SUBGHZ_HISTORY_TMP_EXTENSION);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2022-10-02 02:18:30 +03:00
|
|
|
* @brief Check if directory for temporary files is exists
|
2022-10-01 07:39:51 +03:00
|
|
|
*
|
2022-10-02 02:18:30 +03:00
|
|
|
* @param instance SubGhzHistory*
|
|
|
|
* @return true
|
|
|
|
* @return false
|
|
|
|
*/
|
|
|
|
bool subghz_history_is_tmp_dir_exists(SubGhzHistory* instance) {
|
|
|
|
FileInfo file_info;
|
|
|
|
storage_common_stat(instance->storage, SUBGHZ_HISTORY_TMP_DIR, &file_info);
|
|
|
|
|
|
|
|
if(storage_common_stat(instance->storage, SUBGHZ_HISTORY_TMP_DIR, &file_info) == FSE_OK) {
|
|
|
|
if(file_info.flags & FSF_DIRECTORY) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Check SD card and create temporary dir if not exists,
|
|
|
|
* Result write_tmp_files without this unstable work is GUARANTEED
|
|
|
|
*
|
|
|
|
* @param instance - SubGhzHistory*
|
|
|
|
* @return - true all ok
|
|
|
|
* @return - false we have a problems
|
2022-10-01 07:39:51 +03:00
|
|
|
*/
|
2022-10-02 02:18:30 +03:00
|
|
|
bool subghz_history_check_sdcard(SubGhzHistory* instance) {
|
|
|
|
#ifdef FURI_DEBUG
|
|
|
|
FURI_LOG_I(TAG, "check_sdcard");
|
|
|
|
uint32_t start_time = furi_get_tick();
|
2022-10-01 07:39:51 +03:00
|
|
|
#endif
|
|
|
|
|
2022-10-02 02:18:30 +03:00
|
|
|
bool result = false;
|
|
|
|
// Stage 0 - check SD Card
|
2022-10-01 07:39:51 +03:00
|
|
|
FS_Error status = storage_sd_status(instance->storage);
|
2022-10-02 02:18:30 +03:00
|
|
|
if(status == FSE_OK) {
|
|
|
|
result = subghz_history_is_tmp_dir_exists(instance);
|
|
|
|
if(!subghz_history_is_tmp_dir_exists(instance)) {
|
|
|
|
result = storage_simply_mkdir(instance->storage, SUBGHZ_HISTORY_TMP_DIR);
|
|
|
|
}
|
|
|
|
} else {
|
2022-10-01 07:39:51 +03:00
|
|
|
FURI_LOG_W(TAG, "SD storage not installed! Status: %d", status);
|
|
|
|
}
|
2022-10-02 02:18:30 +03:00
|
|
|
#ifdef FURI_DEBUG
|
|
|
|
FURI_LOG_I(TAG, "Running time (check_sdcard): %d ms", furi_get_tick() - start_time);
|
|
|
|
#endif
|
2022-10-01 07:39:51 +03:00
|
|
|
|
2022-10-02 02:18:30 +03:00
|
|
|
return result;
|
|
|
|
}
|
2022-10-01 07:39:51 +03:00
|
|
|
|
2022-10-02 02:18:30 +03:00
|
|
|
/**
|
|
|
|
* @brief Recursive delete dir and files and create new temp dir
|
|
|
|
*
|
|
|
|
* @param instance - SubGhzHistory*
|
|
|
|
* @return true - if all ok
|
|
|
|
* @return false - if something failed
|
|
|
|
*/
|
|
|
|
void subghz_history_clear_tmp_dir(SubGhzHistory* instance) {
|
|
|
|
furi_assert(instance);
|
|
|
|
#ifdef FURI_DEBUG
|
|
|
|
FURI_LOG_I(TAG, "clear_tmp_dir");
|
|
|
|
#endif
|
2022-10-01 07:39:51 +03:00
|
|
|
|
2022-10-02 02:18:30 +03:00
|
|
|
if(!instance->write_tmp_files) {
|
|
|
|
// Nothing to do here!
|
|
|
|
return;
|
2022-10-01 07:47:44 +03:00
|
|
|
}
|
2022-10-02 02:18:30 +03:00
|
|
|
uint32_t start_time = furi_get_tick();
|
2022-10-01 07:39:51 +03:00
|
|
|
|
2022-10-02 02:18:30 +03:00
|
|
|
// Stage 0 - Dir exists?
|
|
|
|
bool res = subghz_history_is_tmp_dir_exists(instance);
|
|
|
|
if(res) {
|
|
|
|
// Stage 1 - delete all content if exists
|
|
|
|
FileInfo fileinfo;
|
|
|
|
storage_common_stat(instance->storage, SUBGHZ_HISTORY_TMP_DIR, &fileinfo);
|
2022-10-01 07:39:51 +03:00
|
|
|
|
2022-10-02 02:18:30 +03:00
|
|
|
if(fileinfo.flags & FSF_DIRECTORY) {
|
|
|
|
res = storage_simply_remove_recursive(instance->storage, SUBGHZ_HISTORY_TMP_DIR);
|
|
|
|
} else {
|
|
|
|
res = (storage_common_remove(instance->storage, SUBGHZ_HISTORY_TMP_DIR) == FSE_OK);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Stage 2 - create dir if necessary
|
|
|
|
res = !storage_simply_mkdir(instance->storage, SUBGHZ_HISTORY_TMP_DIR);
|
|
|
|
if(!res) {
|
|
|
|
FURI_LOG_E(TAG, "Cannot process temp dir!");
|
2022-10-01 07:47:44 +03:00
|
|
|
}
|
2022-10-01 07:39:51 +03:00
|
|
|
|
2022-10-02 02:18:30 +03:00
|
|
|
uint32_t stop_time = furi_get_tick() - start_time;
|
|
|
|
FURI_LOG_I(TAG, "Running time (clear_tmp_dir): %d ms", stop_time);
|
2022-10-01 07:39:51 +03:00
|
|
|
}
|
|
|
|
|
Skorp subghz signal archive (#667)
* SubGhz: Add millis() furi, add subghz history struct
* SubGhz: Fix subghz history
* Gubghz: Fix code repeat history, add clean history
* SubGhz: reading and adding keys to history
* Gui: Renaming Sub 1-Ghz -> SubGhz
* Archive: Renaming Sub 1-Ghz -> SubGhz
* SubGhz: Add menu history, modified button for sending a signal, changed output of data about accepted protocol
* Archive: Fix name subghz
* SubGhz: Menu navigation
* Assets: Add assets/SubGHz/icon.png
* Assets: add new icons for subghz
* SubGhz: Fix name Add manually scene
* SubGhz: Fix load icon Read scene. rename encoder struct, rename protocol function load from file, add load raw data protocol, add info pleasant signals all protocol
* SubGhz: fix memory leak
* SubGhz: change of receiving frequency for read scene
* SubGhz: Add save/load frequency and preset, add automatic configuration of transmit/receive to the desired frequency and modulation, add button "save" config scene
* SubGhz: Fix frequency and preset, fix frequency add manualli scene, fix re-executing the parser
* Furi-hal-subghz: add 2-FSK config, fix ook config 650KHz BW Tx filter
* Fix formatting and release build
* SubGhz: Delete read scene
* SubGhz: Fix frequency add manualli scene, refactoring code
* SubGhz: 2 profiles for OOK, fix broken build.
* SubGhz: Add passing static codes from read scene, add notification read scene, refactoring code
* SubGhz: fix assert on worker double stop.
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-08-28 16:51:48 +03:00
|
|
|
SubGhzHistory* subghz_history_alloc(void) {
|
2022-02-18 22:53:46 +03:00
|
|
|
SubGhzHistory* instance = malloc(sizeof(SubGhzHistory));
|
2022-03-03 12:48:56 +03:00
|
|
|
string_init(instance->tmp_string);
|
|
|
|
instance->history = malloc(sizeof(SubGhzHistoryStruct));
|
|
|
|
SubGhzHistoryItemArray_init(instance->history->data);
|
2022-10-01 07:39:51 +03:00
|
|
|
instance->storage = furi_record_open(RECORD_STORAGE);
|
2022-10-02 02:18:30 +03:00
|
|
|
instance->write_tmp_files = subghz_history_check_sdcard(instance);
|
2022-10-01 07:39:51 +03:00
|
|
|
|
2022-10-02 02:18:30 +03:00
|
|
|
if(!instance->write_tmp_files) {
|
|
|
|
FURI_LOG_E(TAG, "Unstable work! Cannot use SD Card!");
|
|
|
|
}
|
2022-10-01 07:39:51 +03:00
|
|
|
|
Skorp subghz signal archive (#667)
* SubGhz: Add millis() furi, add subghz history struct
* SubGhz: Fix subghz history
* Gubghz: Fix code repeat history, add clean history
* SubGhz: reading and adding keys to history
* Gui: Renaming Sub 1-Ghz -> SubGhz
* Archive: Renaming Sub 1-Ghz -> SubGhz
* SubGhz: Add menu history, modified button for sending a signal, changed output of data about accepted protocol
* Archive: Fix name subghz
* SubGhz: Menu navigation
* Assets: Add assets/SubGHz/icon.png
* Assets: add new icons for subghz
* SubGhz: Fix name Add manually scene
* SubGhz: Fix load icon Read scene. rename encoder struct, rename protocol function load from file, add load raw data protocol, add info pleasant signals all protocol
* SubGhz: fix memory leak
* SubGhz: change of receiving frequency for read scene
* SubGhz: Add save/load frequency and preset, add automatic configuration of transmit/receive to the desired frequency and modulation, add button "save" config scene
* SubGhz: Fix frequency and preset, fix frequency add manualli scene, fix re-executing the parser
* Furi-hal-subghz: add 2-FSK config, fix ook config 650KHz BW Tx filter
* Fix formatting and release build
* SubGhz: Delete read scene
* SubGhz: Fix frequency add manualli scene, refactoring code
* SubGhz: 2 profiles for OOK, fix broken build.
* SubGhz: Add passing static codes from read scene, add notification read scene, refactoring code
* SubGhz: fix assert on worker double stop.
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-08-28 16:51:48 +03:00
|
|
|
return instance;
|
|
|
|
}
|
|
|
|
|
2022-10-02 02:18:30 +03:00
|
|
|
/**
|
|
|
|
* @brief Free item and free all resources
|
|
|
|
*
|
|
|
|
* @param item - SubGhzHistoryItem*
|
|
|
|
*/
|
|
|
|
void subghz_history_item_free(SubGhzHistoryItem* item) {
|
|
|
|
furi_assert(item);
|
|
|
|
string_clear(item->item_str);
|
|
|
|
string_clear(item->preset->name);
|
|
|
|
string_clear(item->protocol_name);
|
|
|
|
|
|
|
|
free(item->preset);
|
|
|
|
item->type = 0;
|
|
|
|
item->is_file = false;
|
|
|
|
|
|
|
|
if(item->flipper_string != NULL) {
|
|
|
|
flipper_format_free(item->flipper_string);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-01 07:39:51 +03:00
|
|
|
/**
|
|
|
|
* @brief free all items in array
|
|
|
|
*
|
|
|
|
* @param instance
|
|
|
|
*/
|
|
|
|
void subghz_history_clean_item_array(SubGhzHistory* instance) {
|
2022-09-17 20:33:26 +03:00
|
|
|
for
|
|
|
|
M_EACH(item, instance->history->data, SubGhzHistoryItemArray_t) {
|
2022-10-02 02:18:30 +03:00
|
|
|
subghz_history_item_free(item);
|
2022-09-17 20:33:26 +03:00
|
|
|
}
|
2022-10-01 07:39:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void subghz_history_free(SubGhzHistory* instance) {
|
|
|
|
furi_assert(instance);
|
|
|
|
string_clear(instance->tmp_string);
|
|
|
|
|
|
|
|
subghz_history_clean_item_array(instance);
|
2022-03-03 12:48:56 +03:00
|
|
|
SubGhzHistoryItemArray_clear(instance->history->data);
|
|
|
|
free(instance->history);
|
2022-10-01 07:39:51 +03:00
|
|
|
|
2022-10-02 02:18:30 +03:00
|
|
|
// Delete all temporary file, on exit it's ok
|
|
|
|
subghz_history_clear_tmp_dir(instance);
|
2022-10-01 07:39:51 +03:00
|
|
|
|
|
|
|
furi_record_close(RECORD_STORAGE);
|
|
|
|
|
Skorp subghz signal archive (#667)
* SubGhz: Add millis() furi, add subghz history struct
* SubGhz: Fix subghz history
* Gubghz: Fix code repeat history, add clean history
* SubGhz: reading and adding keys to history
* Gui: Renaming Sub 1-Ghz -> SubGhz
* Archive: Renaming Sub 1-Ghz -> SubGhz
* SubGhz: Add menu history, modified button for sending a signal, changed output of data about accepted protocol
* Archive: Fix name subghz
* SubGhz: Menu navigation
* Assets: Add assets/SubGHz/icon.png
* Assets: add new icons for subghz
* SubGhz: Fix name Add manually scene
* SubGhz: Fix load icon Read scene. rename encoder struct, rename protocol function load from file, add load raw data protocol, add info pleasant signals all protocol
* SubGhz: fix memory leak
* SubGhz: change of receiving frequency for read scene
* SubGhz: Add save/load frequency and preset, add automatic configuration of transmit/receive to the desired frequency and modulation, add button "save" config scene
* SubGhz: Fix frequency and preset, fix frequency add manualli scene, fix re-executing the parser
* Furi-hal-subghz: add 2-FSK config, fix ook config 650KHz BW Tx filter
* Fix formatting and release build
* SubGhz: Delete read scene
* SubGhz: Fix frequency add manualli scene, refactoring code
* SubGhz: 2 profiles for OOK, fix broken build.
* SubGhz: Add passing static codes from read scene, add notification read scene, refactoring code
* SubGhz: fix assert on worker double stop.
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-08-28 16:51:48 +03:00
|
|
|
free(instance);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t subghz_history_get_frequency(SubGhzHistory* instance, uint16_t idx) {
|
|
|
|
furi_assert(instance);
|
2022-03-03 12:48:56 +03:00
|
|
|
SubGhzHistoryItem* item = SubGhzHistoryItemArray_get(instance->history->data, idx);
|
2022-07-26 17:16:59 +03:00
|
|
|
return item->preset->frequency;
|
Skorp subghz signal archive (#667)
* SubGhz: Add millis() furi, add subghz history struct
* SubGhz: Fix subghz history
* Gubghz: Fix code repeat history, add clean history
* SubGhz: reading and adding keys to history
* Gui: Renaming Sub 1-Ghz -> SubGhz
* Archive: Renaming Sub 1-Ghz -> SubGhz
* SubGhz: Add menu history, modified button for sending a signal, changed output of data about accepted protocol
* Archive: Fix name subghz
* SubGhz: Menu navigation
* Assets: Add assets/SubGHz/icon.png
* Assets: add new icons for subghz
* SubGhz: Fix name Add manually scene
* SubGhz: Fix load icon Read scene. rename encoder struct, rename protocol function load from file, add load raw data protocol, add info pleasant signals all protocol
* SubGhz: fix memory leak
* SubGhz: change of receiving frequency for read scene
* SubGhz: Add save/load frequency and preset, add automatic configuration of transmit/receive to the desired frequency and modulation, add button "save" config scene
* SubGhz: Fix frequency and preset, fix frequency add manualli scene, fix re-executing the parser
* Furi-hal-subghz: add 2-FSK config, fix ook config 650KHz BW Tx filter
* Fix formatting and release build
* SubGhz: Delete read scene
* SubGhz: Fix frequency add manualli scene, refactoring code
* SubGhz: 2 profiles for OOK, fix broken build.
* SubGhz: Add passing static codes from read scene, add notification read scene, refactoring code
* SubGhz: fix assert on worker double stop.
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-08-28 16:51:48 +03:00
|
|
|
}
|
|
|
|
|
2022-07-27 15:58:32 +03:00
|
|
|
SubGhzPresetDefinition* subghz_history_get_preset_def(SubGhzHistory* instance, uint16_t idx) {
|
Skorp subghz signal archive (#667)
* SubGhz: Add millis() furi, add subghz history struct
* SubGhz: Fix subghz history
* Gubghz: Fix code repeat history, add clean history
* SubGhz: reading and adding keys to history
* Gui: Renaming Sub 1-Ghz -> SubGhz
* Archive: Renaming Sub 1-Ghz -> SubGhz
* SubGhz: Add menu history, modified button for sending a signal, changed output of data about accepted protocol
* Archive: Fix name subghz
* SubGhz: Menu navigation
* Assets: Add assets/SubGHz/icon.png
* Assets: add new icons for subghz
* SubGhz: Fix name Add manually scene
* SubGhz: Fix load icon Read scene. rename encoder struct, rename protocol function load from file, add load raw data protocol, add info pleasant signals all protocol
* SubGhz: fix memory leak
* SubGhz: change of receiving frequency for read scene
* SubGhz: Add save/load frequency and preset, add automatic configuration of transmit/receive to the desired frequency and modulation, add button "save" config scene
* SubGhz: Fix frequency and preset, fix frequency add manualli scene, fix re-executing the parser
* Furi-hal-subghz: add 2-FSK config, fix ook config 650KHz BW Tx filter
* Fix formatting and release build
* SubGhz: Delete read scene
* SubGhz: Fix frequency add manualli scene, refactoring code
* SubGhz: 2 profiles for OOK, fix broken build.
* SubGhz: Add passing static codes from read scene, add notification read scene, refactoring code
* SubGhz: fix assert on worker double stop.
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-08-28 16:51:48 +03:00
|
|
|
furi_assert(instance);
|
2022-03-03 12:48:56 +03:00
|
|
|
SubGhzHistoryItem* item = SubGhzHistoryItemArray_get(instance->history->data, idx);
|
|
|
|
return item->preset;
|
Skorp subghz signal archive (#667)
* SubGhz: Add millis() furi, add subghz history struct
* SubGhz: Fix subghz history
* Gubghz: Fix code repeat history, add clean history
* SubGhz: reading and adding keys to history
* Gui: Renaming Sub 1-Ghz -> SubGhz
* Archive: Renaming Sub 1-Ghz -> SubGhz
* SubGhz: Add menu history, modified button for sending a signal, changed output of data about accepted protocol
* Archive: Fix name subghz
* SubGhz: Menu navigation
* Assets: Add assets/SubGHz/icon.png
* Assets: add new icons for subghz
* SubGhz: Fix name Add manually scene
* SubGhz: Fix load icon Read scene. rename encoder struct, rename protocol function load from file, add load raw data protocol, add info pleasant signals all protocol
* SubGhz: fix memory leak
* SubGhz: change of receiving frequency for read scene
* SubGhz: Add save/load frequency and preset, add automatic configuration of transmit/receive to the desired frequency and modulation, add button "save" config scene
* SubGhz: Fix frequency and preset, fix frequency add manualli scene, fix re-executing the parser
* Furi-hal-subghz: add 2-FSK config, fix ook config 650KHz BW Tx filter
* Fix formatting and release build
* SubGhz: Delete read scene
* SubGhz: Fix frequency add manualli scene, refactoring code
* SubGhz: 2 profiles for OOK, fix broken build.
* SubGhz: Add passing static codes from read scene, add notification read scene, refactoring code
* SubGhz: fix assert on worker double stop.
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-08-28 16:51:48 +03:00
|
|
|
}
|
|
|
|
|
2022-07-26 17:16:59 +03:00
|
|
|
const char* subghz_history_get_preset(SubGhzHistory* instance, uint16_t idx) {
|
|
|
|
furi_assert(instance);
|
|
|
|
SubGhzHistoryItem* item = SubGhzHistoryItemArray_get(instance->history->data, idx);
|
|
|
|
return string_get_cstr(item->preset->name);
|
|
|
|
}
|
|
|
|
|
2022-01-21 20:32:03 +03:00
|
|
|
void subghz_history_reset(SubGhzHistory* instance) {
|
Skorp subghz signal archive (#667)
* SubGhz: Add millis() furi, add subghz history struct
* SubGhz: Fix subghz history
* Gubghz: Fix code repeat history, add clean history
* SubGhz: reading and adding keys to history
* Gui: Renaming Sub 1-Ghz -> SubGhz
* Archive: Renaming Sub 1-Ghz -> SubGhz
* SubGhz: Add menu history, modified button for sending a signal, changed output of data about accepted protocol
* Archive: Fix name subghz
* SubGhz: Menu navigation
* Assets: Add assets/SubGHz/icon.png
* Assets: add new icons for subghz
* SubGhz: Fix name Add manually scene
* SubGhz: Fix load icon Read scene. rename encoder struct, rename protocol function load from file, add load raw data protocol, add info pleasant signals all protocol
* SubGhz: fix memory leak
* SubGhz: change of receiving frequency for read scene
* SubGhz: Add save/load frequency and preset, add automatic configuration of transmit/receive to the desired frequency and modulation, add button "save" config scene
* SubGhz: Fix frequency and preset, fix frequency add manualli scene, fix re-executing the parser
* Furi-hal-subghz: add 2-FSK config, fix ook config 650KHz BW Tx filter
* Fix formatting and release build
* SubGhz: Delete read scene
* SubGhz: Fix frequency add manualli scene, refactoring code
* SubGhz: 2 profiles for OOK, fix broken build.
* SubGhz: Add passing static codes from read scene, add notification read scene, refactoring code
* SubGhz: fix assert on worker double stop.
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-08-28 16:51:48 +03:00
|
|
|
furi_assert(instance);
|
2022-03-03 12:48:56 +03:00
|
|
|
string_reset(instance->tmp_string);
|
2022-10-01 07:39:51 +03:00
|
|
|
|
|
|
|
subghz_history_clean_item_array(instance);
|
|
|
|
|
2022-03-03 12:48:56 +03:00
|
|
|
SubGhzHistoryItemArray_reset(instance->history->data);
|
Skorp subghz signal archive (#667)
* SubGhz: Add millis() furi, add subghz history struct
* SubGhz: Fix subghz history
* Gubghz: Fix code repeat history, add clean history
* SubGhz: reading and adding keys to history
* Gui: Renaming Sub 1-Ghz -> SubGhz
* Archive: Renaming Sub 1-Ghz -> SubGhz
* SubGhz: Add menu history, modified button for sending a signal, changed output of data about accepted protocol
* Archive: Fix name subghz
* SubGhz: Menu navigation
* Assets: Add assets/SubGHz/icon.png
* Assets: add new icons for subghz
* SubGhz: Fix name Add manually scene
* SubGhz: Fix load icon Read scene. rename encoder struct, rename protocol function load from file, add load raw data protocol, add info pleasant signals all protocol
* SubGhz: fix memory leak
* SubGhz: change of receiving frequency for read scene
* SubGhz: Add save/load frequency and preset, add automatic configuration of transmit/receive to the desired frequency and modulation, add button "save" config scene
* SubGhz: Fix frequency and preset, fix frequency add manualli scene, fix re-executing the parser
* Furi-hal-subghz: add 2-FSK config, fix ook config 650KHz BW Tx filter
* Fix formatting and release build
* SubGhz: Delete read scene
* SubGhz: Fix frequency add manualli scene, refactoring code
* SubGhz: 2 profiles for OOK, fix broken build.
* SubGhz: Add passing static codes from read scene, add notification read scene, refactoring code
* SubGhz: fix assert on worker double stop.
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-08-28 16:51:48 +03:00
|
|
|
instance->last_index_write = 0;
|
2022-03-03 12:48:56 +03:00
|
|
|
instance->code_last_hash_data = 0;
|
Skorp subghz signal archive (#667)
* SubGhz: Add millis() furi, add subghz history struct
* SubGhz: Fix subghz history
* Gubghz: Fix code repeat history, add clean history
* SubGhz: reading and adding keys to history
* Gui: Renaming Sub 1-Ghz -> SubGhz
* Archive: Renaming Sub 1-Ghz -> SubGhz
* SubGhz: Add menu history, modified button for sending a signal, changed output of data about accepted protocol
* Archive: Fix name subghz
* SubGhz: Menu navigation
* Assets: Add assets/SubGHz/icon.png
* Assets: add new icons for subghz
* SubGhz: Fix name Add manually scene
* SubGhz: Fix load icon Read scene. rename encoder struct, rename protocol function load from file, add load raw data protocol, add info pleasant signals all protocol
* SubGhz: fix memory leak
* SubGhz: change of receiving frequency for read scene
* SubGhz: Add save/load frequency and preset, add automatic configuration of transmit/receive to the desired frequency and modulation, add button "save" config scene
* SubGhz: Fix frequency and preset, fix frequency add manualli scene, fix re-executing the parser
* Furi-hal-subghz: add 2-FSK config, fix ook config 650KHz BW Tx filter
* Fix formatting and release build
* SubGhz: Delete read scene
* SubGhz: Fix frequency add manualli scene, refactoring code
* SubGhz: 2 profiles for OOK, fix broken build.
* SubGhz: Add passing static codes from read scene, add notification read scene, refactoring code
* SubGhz: fix assert on worker double stop.
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-08-28 16:51:48 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
uint16_t subghz_history_get_item(SubGhzHistory* instance) {
|
|
|
|
furi_assert(instance);
|
|
|
|
return instance->last_index_write;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t subghz_history_get_type_protocol(SubGhzHistory* instance, uint16_t idx) {
|
|
|
|
furi_assert(instance);
|
2022-03-03 12:48:56 +03:00
|
|
|
SubGhzHistoryItem* item = SubGhzHistoryItemArray_get(instance->history->data, idx);
|
|
|
|
return item->type;
|
Skorp subghz signal archive (#667)
* SubGhz: Add millis() furi, add subghz history struct
* SubGhz: Fix subghz history
* Gubghz: Fix code repeat history, add clean history
* SubGhz: reading and adding keys to history
* Gui: Renaming Sub 1-Ghz -> SubGhz
* Archive: Renaming Sub 1-Ghz -> SubGhz
* SubGhz: Add menu history, modified button for sending a signal, changed output of data about accepted protocol
* Archive: Fix name subghz
* SubGhz: Menu navigation
* Assets: Add assets/SubGHz/icon.png
* Assets: add new icons for subghz
* SubGhz: Fix name Add manually scene
* SubGhz: Fix load icon Read scene. rename encoder struct, rename protocol function load from file, add load raw data protocol, add info pleasant signals all protocol
* SubGhz: fix memory leak
* SubGhz: change of receiving frequency for read scene
* SubGhz: Add save/load frequency and preset, add automatic configuration of transmit/receive to the desired frequency and modulation, add button "save" config scene
* SubGhz: Fix frequency and preset, fix frequency add manualli scene, fix re-executing the parser
* Furi-hal-subghz: add 2-FSK config, fix ook config 650KHz BW Tx filter
* Fix formatting and release build
* SubGhz: Delete read scene
* SubGhz: Fix frequency add manualli scene, refactoring code
* SubGhz: 2 profiles for OOK, fix broken build.
* SubGhz: Add passing static codes from read scene, add notification read scene, refactoring code
* SubGhz: fix assert on worker double stop.
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-08-28 16:51:48 +03:00
|
|
|
}
|
|
|
|
|
2022-03-03 12:48:56 +03:00
|
|
|
const char* subghz_history_get_protocol_name(SubGhzHistory* instance, uint16_t idx) {
|
Skorp subghz signal archive (#667)
* SubGhz: Add millis() furi, add subghz history struct
* SubGhz: Fix subghz history
* Gubghz: Fix code repeat history, add clean history
* SubGhz: reading and adding keys to history
* Gui: Renaming Sub 1-Ghz -> SubGhz
* Archive: Renaming Sub 1-Ghz -> SubGhz
* SubGhz: Add menu history, modified button for sending a signal, changed output of data about accepted protocol
* Archive: Fix name subghz
* SubGhz: Menu navigation
* Assets: Add assets/SubGHz/icon.png
* Assets: add new icons for subghz
* SubGhz: Fix name Add manually scene
* SubGhz: Fix load icon Read scene. rename encoder struct, rename protocol function load from file, add load raw data protocol, add info pleasant signals all protocol
* SubGhz: fix memory leak
* SubGhz: change of receiving frequency for read scene
* SubGhz: Add save/load frequency and preset, add automatic configuration of transmit/receive to the desired frequency and modulation, add button "save" config scene
* SubGhz: Fix frequency and preset, fix frequency add manualli scene, fix re-executing the parser
* Furi-hal-subghz: add 2-FSK config, fix ook config 650KHz BW Tx filter
* Fix formatting and release build
* SubGhz: Delete read scene
* SubGhz: Fix frequency add manualli scene, refactoring code
* SubGhz: 2 profiles for OOK, fix broken build.
* SubGhz: Add passing static codes from read scene, add notification read scene, refactoring code
* SubGhz: fix assert on worker double stop.
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-08-28 16:51:48 +03:00
|
|
|
furi_assert(instance);
|
2022-03-03 12:48:56 +03:00
|
|
|
SubGhzHistoryItem* item = SubGhzHistoryItemArray_get(instance->history->data, idx);
|
2022-10-01 07:39:51 +03:00
|
|
|
|
|
|
|
return string_get_cstr(item->protocol_name);
|
Skorp subghz signal archive (#667)
* SubGhz: Add millis() furi, add subghz history struct
* SubGhz: Fix subghz history
* Gubghz: Fix code repeat history, add clean history
* SubGhz: reading and adding keys to history
* Gui: Renaming Sub 1-Ghz -> SubGhz
* Archive: Renaming Sub 1-Ghz -> SubGhz
* SubGhz: Add menu history, modified button for sending a signal, changed output of data about accepted protocol
* Archive: Fix name subghz
* SubGhz: Menu navigation
* Assets: Add assets/SubGHz/icon.png
* Assets: add new icons for subghz
* SubGhz: Fix name Add manually scene
* SubGhz: Fix load icon Read scene. rename encoder struct, rename protocol function load from file, add load raw data protocol, add info pleasant signals all protocol
* SubGhz: fix memory leak
* SubGhz: change of receiving frequency for read scene
* SubGhz: Add save/load frequency and preset, add automatic configuration of transmit/receive to the desired frequency and modulation, add button "save" config scene
* SubGhz: Fix frequency and preset, fix frequency add manualli scene, fix re-executing the parser
* Furi-hal-subghz: add 2-FSK config, fix ook config 650KHz BW Tx filter
* Fix formatting and release build
* SubGhz: Delete read scene
* SubGhz: Fix frequency add manualli scene, refactoring code
* SubGhz: 2 profiles for OOK, fix broken build.
* SubGhz: Add passing static codes from read scene, add notification read scene, refactoring code
* SubGhz: fix assert on worker double stop.
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-08-28 16:51:48 +03:00
|
|
|
}
|
|
|
|
|
2022-03-03 12:48:56 +03:00
|
|
|
FlipperFormat* subghz_history_get_raw_data(SubGhzHistory* instance, uint16_t idx) {
|
Skorp subghz signal archive (#667)
* SubGhz: Add millis() furi, add subghz history struct
* SubGhz: Fix subghz history
* Gubghz: Fix code repeat history, add clean history
* SubGhz: reading and adding keys to history
* Gui: Renaming Sub 1-Ghz -> SubGhz
* Archive: Renaming Sub 1-Ghz -> SubGhz
* SubGhz: Add menu history, modified button for sending a signal, changed output of data about accepted protocol
* Archive: Fix name subghz
* SubGhz: Menu navigation
* Assets: Add assets/SubGHz/icon.png
* Assets: add new icons for subghz
* SubGhz: Fix name Add manually scene
* SubGhz: Fix load icon Read scene. rename encoder struct, rename protocol function load from file, add load raw data protocol, add info pleasant signals all protocol
* SubGhz: fix memory leak
* SubGhz: change of receiving frequency for read scene
* SubGhz: Add save/load frequency and preset, add automatic configuration of transmit/receive to the desired frequency and modulation, add button "save" config scene
* SubGhz: Fix frequency and preset, fix frequency add manualli scene, fix re-executing the parser
* Furi-hal-subghz: add 2-FSK config, fix ook config 650KHz BW Tx filter
* Fix formatting and release build
* SubGhz: Delete read scene
* SubGhz: Fix frequency add manualli scene, refactoring code
* SubGhz: 2 profiles for OOK, fix broken build.
* SubGhz: Add passing static codes from read scene, add notification read scene, refactoring code
* SubGhz: fix assert on worker double stop.
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-08-28 16:51:48 +03:00
|
|
|
furi_assert(instance);
|
2022-03-03 12:48:56 +03:00
|
|
|
SubGhzHistoryItem* item = SubGhzHistoryItemArray_get(instance->history->data, idx);
|
|
|
|
if(item->flipper_string) {
|
|
|
|
return item->flipper_string;
|
|
|
|
} else {
|
2022-10-01 07:39:51 +03:00
|
|
|
bool result_ok = false;
|
|
|
|
if(instance->write_tmp_files && item->is_file) {
|
|
|
|
// We have files!
|
|
|
|
string_t filename;
|
|
|
|
string_t dir_path;
|
|
|
|
string_init(filename);
|
|
|
|
string_init(dir_path);
|
|
|
|
subghz_history_generate_temp_filename(filename, idx);
|
2022-10-02 02:18:30 +03:00
|
|
|
string_init_printf(
|
2022-10-01 07:39:51 +03:00
|
|
|
dir_path, "%s/%s", SUBGHZ_HISTORY_TMP_DIR, string_get_cstr(filename));
|
|
|
|
|
|
|
|
if(storage_file_exists(instance->storage, string_get_cstr(dir_path))) {
|
2022-10-02 02:18:30 +03:00
|
|
|
#ifdef FURI_DEBUG
|
2022-10-01 07:39:51 +03:00
|
|
|
FURI_LOG_D(TAG, "Exist: %s", dir_path);
|
|
|
|
furi_delay_ms(LOG_DELAY);
|
|
|
|
#endif
|
|
|
|
// Set to current anyway it has NULL value
|
|
|
|
item->flipper_string = flipper_format_string_alloc();
|
|
|
|
Stream* dst_stream = flipper_format_get_raw_stream(item->flipper_string);
|
|
|
|
stream_clean(dst_stream);
|
|
|
|
|
|
|
|
size_t size = stream_load_from_file(
|
|
|
|
dst_stream, instance->storage, string_get_cstr(dir_path));
|
|
|
|
if(size > 0) {
|
2022-10-02 02:18:30 +03:00
|
|
|
#ifdef FURI_DEBUG
|
2022-10-01 07:39:51 +03:00
|
|
|
FURI_LOG_I(TAG, "Save ok!");
|
|
|
|
furi_delay_ms(LOG_DELAY);
|
|
|
|
#endif
|
|
|
|
// We changed contents of file, so we no needed to load
|
|
|
|
// content from disk for the next time
|
|
|
|
item->is_file = false;
|
|
|
|
result_ok = true;
|
|
|
|
} else {
|
|
|
|
FURI_LOG_E(TAG, "Stream copy failed!");
|
|
|
|
flipper_format_free(item->flipper_string);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
FURI_LOG_E(TAG, "Can't convert filename to file");
|
|
|
|
}
|
|
|
|
|
|
|
|
string_clear(filename);
|
|
|
|
string_clear(dir_path);
|
|
|
|
} else {
|
2022-10-02 02:18:30 +03:00
|
|
|
#ifdef FURI_DEBUG
|
2022-10-01 07:39:51 +03:00
|
|
|
FURI_LOG_W(TAG, "Write TMP files failed!");
|
|
|
|
furi_delay_ms(LOG_DELAY);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
return result_ok ? item->flipper_string : NULL;
|
2022-03-03 12:48:56 +03:00
|
|
|
}
|
Skorp subghz signal archive (#667)
* SubGhz: Add millis() furi, add subghz history struct
* SubGhz: Fix subghz history
* Gubghz: Fix code repeat history, add clean history
* SubGhz: reading and adding keys to history
* Gui: Renaming Sub 1-Ghz -> SubGhz
* Archive: Renaming Sub 1-Ghz -> SubGhz
* SubGhz: Add menu history, modified button for sending a signal, changed output of data about accepted protocol
* Archive: Fix name subghz
* SubGhz: Menu navigation
* Assets: Add assets/SubGHz/icon.png
* Assets: add new icons for subghz
* SubGhz: Fix name Add manually scene
* SubGhz: Fix load icon Read scene. rename encoder struct, rename protocol function load from file, add load raw data protocol, add info pleasant signals all protocol
* SubGhz: fix memory leak
* SubGhz: change of receiving frequency for read scene
* SubGhz: Add save/load frequency and preset, add automatic configuration of transmit/receive to the desired frequency and modulation, add button "save" config scene
* SubGhz: Fix frequency and preset, fix frequency add manualli scene, fix re-executing the parser
* Furi-hal-subghz: add 2-FSK config, fix ook config 650KHz BW Tx filter
* Fix formatting and release build
* SubGhz: Delete read scene
* SubGhz: Fix frequency add manualli scene, refactoring code
* SubGhz: 2 profiles for OOK, fix broken build.
* SubGhz: Add passing static codes from read scene, add notification read scene, refactoring code
* SubGhz: fix assert on worker double stop.
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-08-28 16:51:48 +03:00
|
|
|
}
|
2022-10-01 07:39:51 +03:00
|
|
|
|
2021-09-02 00:05:00 +03:00
|
|
|
bool subghz_history_get_text_space_left(SubGhzHistory* instance, string_t output) {
|
2021-08-30 23:05:09 +03:00
|
|
|
furi_assert(instance);
|
2021-09-02 00:05:00 +03:00
|
|
|
if(instance->last_index_write == SUBGHZ_HISTORY_MAX) {
|
|
|
|
if(output != NULL) string_printf(output, "Memory is FULL");
|
|
|
|
return true;
|
|
|
|
}
|
2022-10-01 07:39:51 +03:00
|
|
|
if(output != NULL) {
|
2021-09-02 00:05:00 +03:00
|
|
|
string_printf(output, "%02u/%02u", instance->last_index_write, SUBGHZ_HISTORY_MAX);
|
2022-10-01 07:39:51 +03:00
|
|
|
}
|
2021-09-02 00:05:00 +03:00
|
|
|
return false;
|
2021-08-30 23:05:09 +03:00
|
|
|
}
|
Skorp subghz signal archive (#667)
* SubGhz: Add millis() furi, add subghz history struct
* SubGhz: Fix subghz history
* Gubghz: Fix code repeat history, add clean history
* SubGhz: reading and adding keys to history
* Gui: Renaming Sub 1-Ghz -> SubGhz
* Archive: Renaming Sub 1-Ghz -> SubGhz
* SubGhz: Add menu history, modified button for sending a signal, changed output of data about accepted protocol
* Archive: Fix name subghz
* SubGhz: Menu navigation
* Assets: Add assets/SubGHz/icon.png
* Assets: add new icons for subghz
* SubGhz: Fix name Add manually scene
* SubGhz: Fix load icon Read scene. rename encoder struct, rename protocol function load from file, add load raw data protocol, add info pleasant signals all protocol
* SubGhz: fix memory leak
* SubGhz: change of receiving frequency for read scene
* SubGhz: Add save/load frequency and preset, add automatic configuration of transmit/receive to the desired frequency and modulation, add button "save" config scene
* SubGhz: Fix frequency and preset, fix frequency add manualli scene, fix re-executing the parser
* Furi-hal-subghz: add 2-FSK config, fix ook config 650KHz BW Tx filter
* Fix formatting and release build
* SubGhz: Delete read scene
* SubGhz: Fix frequency add manualli scene, refactoring code
* SubGhz: 2 profiles for OOK, fix broken build.
* SubGhz: Add passing static codes from read scene, add notification read scene, refactoring code
* SubGhz: fix assert on worker double stop.
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-08-28 16:51:48 +03:00
|
|
|
|
2022-03-03 12:48:56 +03:00
|
|
|
void subghz_history_get_text_item_menu(SubGhzHistory* instance, string_t output, uint16_t idx) {
|
|
|
|
SubGhzHistoryItem* item = SubGhzHistoryItemArray_get(instance->history->data, idx);
|
|
|
|
string_set(output, item->item_str);
|
Skorp subghz signal archive (#667)
* SubGhz: Add millis() furi, add subghz history struct
* SubGhz: Fix subghz history
* Gubghz: Fix code repeat history, add clean history
* SubGhz: reading and adding keys to history
* Gui: Renaming Sub 1-Ghz -> SubGhz
* Archive: Renaming Sub 1-Ghz -> SubGhz
* SubGhz: Add menu history, modified button for sending a signal, changed output of data about accepted protocol
* Archive: Fix name subghz
* SubGhz: Menu navigation
* Assets: Add assets/SubGHz/icon.png
* Assets: add new icons for subghz
* SubGhz: Fix name Add manually scene
* SubGhz: Fix load icon Read scene. rename encoder struct, rename protocol function load from file, add load raw data protocol, add info pleasant signals all protocol
* SubGhz: fix memory leak
* SubGhz: change of receiving frequency for read scene
* SubGhz: Add save/load frequency and preset, add automatic configuration of transmit/receive to the desired frequency and modulation, add button "save" config scene
* SubGhz: Fix frequency and preset, fix frequency add manualli scene, fix re-executing the parser
* Furi-hal-subghz: add 2-FSK config, fix ook config 650KHz BW Tx filter
* Fix formatting and release build
* SubGhz: Delete read scene
* SubGhz: Fix frequency add manualli scene, refactoring code
* SubGhz: 2 profiles for OOK, fix broken build.
* SubGhz: Add passing static codes from read scene, add notification read scene, refactoring code
* SubGhz: fix assert on worker double stop.
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-08-28 16:51:48 +03:00
|
|
|
}
|
|
|
|
|
2021-09-10 03:29:57 +03:00
|
|
|
bool subghz_history_add_to_history(
|
|
|
|
SubGhzHistory* instance,
|
|
|
|
void* context,
|
2022-07-27 15:58:32 +03:00
|
|
|
SubGhzPresetDefinition* preset) {
|
Skorp subghz signal archive (#667)
* SubGhz: Add millis() furi, add subghz history struct
* SubGhz: Fix subghz history
* Gubghz: Fix code repeat history, add clean history
* SubGhz: reading and adding keys to history
* Gui: Renaming Sub 1-Ghz -> SubGhz
* Archive: Renaming Sub 1-Ghz -> SubGhz
* SubGhz: Add menu history, modified button for sending a signal, changed output of data about accepted protocol
* Archive: Fix name subghz
* SubGhz: Menu navigation
* Assets: Add assets/SubGHz/icon.png
* Assets: add new icons for subghz
* SubGhz: Fix name Add manually scene
* SubGhz: Fix load icon Read scene. rename encoder struct, rename protocol function load from file, add load raw data protocol, add info pleasant signals all protocol
* SubGhz: fix memory leak
* SubGhz: change of receiving frequency for read scene
* SubGhz: Add save/load frequency and preset, add automatic configuration of transmit/receive to the desired frequency and modulation, add button "save" config scene
* SubGhz: Fix frequency and preset, fix frequency add manualli scene, fix re-executing the parser
* Furi-hal-subghz: add 2-FSK config, fix ook config 650KHz BW Tx filter
* Fix formatting and release build
* SubGhz: Delete read scene
* SubGhz: Fix frequency add manualli scene, refactoring code
* SubGhz: 2 profiles for OOK, fix broken build.
* SubGhz: Add passing static codes from read scene, add notification read scene, refactoring code
* SubGhz: fix assert on worker double stop.
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-08-28 16:51:48 +03:00
|
|
|
furi_assert(instance);
|
|
|
|
furi_assert(context);
|
|
|
|
|
2022-10-01 07:39:51 +03:00
|
|
|
if(instance->last_index_write >= SUBGHZ_HISTORY_MAX) {
|
|
|
|
return false;
|
|
|
|
}
|
2022-03-03 12:48:56 +03:00
|
|
|
|
|
|
|
SubGhzProtocolDecoderBase* decoder_base = context;
|
|
|
|
if((instance->code_last_hash_data ==
|
|
|
|
subghz_protocol_decoder_base_get_hash_data(decoder_base)) &&
|
2022-07-20 13:56:33 +03:00
|
|
|
((furi_get_tick() - instance->last_update_timestamp) < 500)) {
|
|
|
|
instance->last_update_timestamp = furi_get_tick();
|
2021-09-10 03:29:57 +03:00
|
|
|
return false;
|
Skorp subghz signal archive (#667)
* SubGhz: Add millis() furi, add subghz history struct
* SubGhz: Fix subghz history
* Gubghz: Fix code repeat history, add clean history
* SubGhz: reading and adding keys to history
* Gui: Renaming Sub 1-Ghz -> SubGhz
* Archive: Renaming Sub 1-Ghz -> SubGhz
* SubGhz: Add menu history, modified button for sending a signal, changed output of data about accepted protocol
* Archive: Fix name subghz
* SubGhz: Menu navigation
* Assets: Add assets/SubGHz/icon.png
* Assets: add new icons for subghz
* SubGhz: Fix name Add manually scene
* SubGhz: Fix load icon Read scene. rename encoder struct, rename protocol function load from file, add load raw data protocol, add info pleasant signals all protocol
* SubGhz: fix memory leak
* SubGhz: change of receiving frequency for read scene
* SubGhz: Add save/load frequency and preset, add automatic configuration of transmit/receive to the desired frequency and modulation, add button "save" config scene
* SubGhz: Fix frequency and preset, fix frequency add manualli scene, fix re-executing the parser
* Furi-hal-subghz: add 2-FSK config, fix ook config 650KHz BW Tx filter
* Fix formatting and release build
* SubGhz: Delete read scene
* SubGhz: Fix frequency add manualli scene, refactoring code
* SubGhz: 2 profiles for OOK, fix broken build.
* SubGhz: Add passing static codes from read scene, add notification read scene, refactoring code
* SubGhz: fix assert on worker double stop.
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-08-28 16:51:48 +03:00
|
|
|
}
|
|
|
|
|
2022-03-03 12:48:56 +03:00
|
|
|
instance->code_last_hash_data = subghz_protocol_decoder_base_get_hash_data(decoder_base);
|
2022-07-20 13:56:33 +03:00
|
|
|
instance->last_update_timestamp = furi_get_tick();
|
2022-03-03 12:48:56 +03:00
|
|
|
string_t text;
|
|
|
|
string_init(text);
|
|
|
|
SubGhzHistoryItem* item = SubGhzHistoryItemArray_push_raw(instance->history->data);
|
2022-07-27 15:58:32 +03:00
|
|
|
item->preset = malloc(sizeof(SubGhzPresetDefinition));
|
2022-03-03 12:48:56 +03:00
|
|
|
item->type = decoder_base->protocol->type;
|
2022-07-26 17:16:59 +03:00
|
|
|
item->preset->frequency = preset->frequency;
|
|
|
|
string_init(item->preset->name);
|
|
|
|
string_set(item->preset->name, preset->name);
|
|
|
|
item->preset->data = preset->data;
|
|
|
|
item->preset->data_size = preset->data_size;
|
2022-03-03 12:48:56 +03:00
|
|
|
|
|
|
|
string_init(item->item_str);
|
2022-10-01 07:39:51 +03:00
|
|
|
string_init(item->protocol_name);
|
|
|
|
|
|
|
|
// At this point file mapped to memory otherwise file cannot decoded
|
2022-03-03 12:48:56 +03:00
|
|
|
item->flipper_string = flipper_format_string_alloc();
|
2022-07-26 17:16:59 +03:00
|
|
|
subghz_protocol_decoder_base_serialize(decoder_base, item->flipper_string, preset);
|
2022-03-03 12:48:56 +03:00
|
|
|
|
|
|
|
do {
|
|
|
|
if(!flipper_format_rewind(item->flipper_string)) {
|
|
|
|
FURI_LOG_E(TAG, "Rewind error");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if(!flipper_format_read_string(item->flipper_string, "Protocol", instance->tmp_string)) {
|
|
|
|
FURI_LOG_E(TAG, "Missing Protocol");
|
|
|
|
break;
|
2022-10-01 07:39:51 +03:00
|
|
|
} else {
|
|
|
|
string_init_printf(item->protocol_name, "%s", string_get_cstr(instance->tmp_string));
|
2022-03-03 12:48:56 +03:00
|
|
|
}
|
2022-09-14 16:01:30 +03:00
|
|
|
if(!strcmp(string_get_cstr(instance->tmp_string), "RAW")) {
|
|
|
|
string_printf(
|
|
|
|
item->item_str,
|
|
|
|
"RAW %03ld.%02ld",
|
|
|
|
preset->frequency / 1000000 % 1000,
|
|
|
|
preset->frequency / 10000 % 100);
|
|
|
|
|
|
|
|
if(!flipper_format_rewind(item->flipper_string)) {
|
|
|
|
FURI_LOG_E(TAG, "Rewind error");
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
} else if(!strcmp(string_get_cstr(instance->tmp_string), "KeeLoq")) {
|
2022-06-01 16:07:53 +03:00
|
|
|
string_set_str(instance->tmp_string, "KL ");
|
2022-03-03 12:48:56 +03:00
|
|
|
if(!flipper_format_read_string(item->flipper_string, "Manufacture", text)) {
|
|
|
|
FURI_LOG_E(TAG, "Missing Protocol");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
string_cat(instance->tmp_string, text);
|
|
|
|
} else if(!strcmp(string_get_cstr(instance->tmp_string), "Star Line")) {
|
2022-06-01 16:07:53 +03:00
|
|
|
string_set_str(instance->tmp_string, "SL ");
|
2022-03-03 12:48:56 +03:00
|
|
|
if(!flipper_format_read_string(item->flipper_string, "Manufacture", text)) {
|
|
|
|
FURI_LOG_E(TAG, "Missing Protocol");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
string_cat(instance->tmp_string, text);
|
|
|
|
}
|
|
|
|
if(!flipper_format_rewind(item->flipper_string)) {
|
|
|
|
FURI_LOG_E(TAG, "Rewind error");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
uint8_t key_data[sizeof(uint64_t)] = {0};
|
|
|
|
if(!flipper_format_read_hex(item->flipper_string, "Key", key_data, sizeof(uint64_t))) {
|
|
|
|
FURI_LOG_E(TAG, "Missing Key");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
uint64_t data = 0;
|
|
|
|
for(uint8_t i = 0; i < sizeof(uint64_t); i++) {
|
|
|
|
data = (data << 8) | key_data[i];
|
|
|
|
}
|
|
|
|
if(!(uint32_t)(data >> 32)) {
|
|
|
|
string_printf(
|
|
|
|
item->item_str,
|
|
|
|
"%s %lX",
|
|
|
|
string_get_cstr(instance->tmp_string),
|
|
|
|
(uint32_t)(data & 0xFFFFFFFF));
|
|
|
|
} else {
|
|
|
|
string_printf(
|
|
|
|
item->item_str,
|
|
|
|
"%s %lX%08lX",
|
|
|
|
string_get_cstr(instance->tmp_string),
|
|
|
|
(uint32_t)(data >> 32),
|
|
|
|
(uint32_t)(data & 0xFFFFFFFF));
|
|
|
|
}
|
|
|
|
} while(false);
|
Skorp subghz signal archive (#667)
* SubGhz: Add millis() furi, add subghz history struct
* SubGhz: Fix subghz history
* Gubghz: Fix code repeat history, add clean history
* SubGhz: reading and adding keys to history
* Gui: Renaming Sub 1-Ghz -> SubGhz
* Archive: Renaming Sub 1-Ghz -> SubGhz
* SubGhz: Add menu history, modified button for sending a signal, changed output of data about accepted protocol
* Archive: Fix name subghz
* SubGhz: Menu navigation
* Assets: Add assets/SubGHz/icon.png
* Assets: add new icons for subghz
* SubGhz: Fix name Add manually scene
* SubGhz: Fix load icon Read scene. rename encoder struct, rename protocol function load from file, add load raw data protocol, add info pleasant signals all protocol
* SubGhz: fix memory leak
* SubGhz: change of receiving frequency for read scene
* SubGhz: Add save/load frequency and preset, add automatic configuration of transmit/receive to the desired frequency and modulation, add button "save" config scene
* SubGhz: Fix frequency and preset, fix frequency add manualli scene, fix re-executing the parser
* Furi-hal-subghz: add 2-FSK config, fix ook config 650KHz BW Tx filter
* Fix formatting and release build
* SubGhz: Delete read scene
* SubGhz: Fix frequency add manualli scene, refactoring code
* SubGhz: 2 profiles for OOK, fix broken build.
* SubGhz: Add passing static codes from read scene, add notification read scene, refactoring code
* SubGhz: fix assert on worker double stop.
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-08-28 16:51:48 +03:00
|
|
|
|
2022-10-01 07:39:51 +03:00
|
|
|
// If we can write to files
|
|
|
|
if(instance->write_tmp_files) {
|
|
|
|
string_t filename;
|
|
|
|
string_t dir_path;
|
|
|
|
string_init(filename);
|
|
|
|
string_init(dir_path);
|
|
|
|
|
|
|
|
subghz_history_generate_temp_filename(filename, instance->last_index_write);
|
|
|
|
string_cat_printf(dir_path, "%s/%s", SUBGHZ_HISTORY_TMP_DIR, string_get_cstr(filename));
|
2022-10-02 02:18:30 +03:00
|
|
|
#ifdef FURI_DEBUG
|
|
|
|
FURI_LOG_I(TAG, "Save temp file: %s", string_get_cstr(dir_path));
|
2022-10-01 07:39:51 +03:00
|
|
|
#endif
|
|
|
|
Stream* dst = flipper_format_get_raw_stream(item->flipper_string);
|
|
|
|
stream_rewind(dst);
|
|
|
|
if(stream_save_to_file(
|
|
|
|
dst, instance->storage, string_get_cstr(dir_path), FSOM_CREATE_ALWAYS) > 0) {
|
|
|
|
flipper_format_free(item->flipper_string);
|
|
|
|
item->flipper_string = NULL;
|
2022-10-02 02:18:30 +03:00
|
|
|
#ifdef FURI_DEBUG
|
2022-10-01 07:39:51 +03:00
|
|
|
FURI_LOG_I(TAG, "Save done!");
|
|
|
|
#endif
|
|
|
|
// This item contains fake data to load from SD
|
|
|
|
item->is_file = true;
|
|
|
|
} else {
|
|
|
|
FURI_LOG_E(TAG, "Stream copy failed!");
|
|
|
|
}
|
|
|
|
string_clear(filename);
|
|
|
|
string_clear(dir_path);
|
|
|
|
|
|
|
|
} else {
|
2022-10-02 02:18:30 +03:00
|
|
|
#ifdef FURI_DEBUG
|
|
|
|
FURI_LOG_W(TAG, "Old fashion way");
|
2022-10-01 07:39:51 +03:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2022-03-03 12:48:56 +03:00
|
|
|
string_clear(text);
|
2022-10-01 07:39:51 +03:00
|
|
|
|
Skorp subghz signal archive (#667)
* SubGhz: Add millis() furi, add subghz history struct
* SubGhz: Fix subghz history
* Gubghz: Fix code repeat history, add clean history
* SubGhz: reading and adding keys to history
* Gui: Renaming Sub 1-Ghz -> SubGhz
* Archive: Renaming Sub 1-Ghz -> SubGhz
* SubGhz: Add menu history, modified button for sending a signal, changed output of data about accepted protocol
* Archive: Fix name subghz
* SubGhz: Menu navigation
* Assets: Add assets/SubGHz/icon.png
* Assets: add new icons for subghz
* SubGhz: Fix name Add manually scene
* SubGhz: Fix load icon Read scene. rename encoder struct, rename protocol function load from file, add load raw data protocol, add info pleasant signals all protocol
* SubGhz: fix memory leak
* SubGhz: change of receiving frequency for read scene
* SubGhz: Add save/load frequency and preset, add automatic configuration of transmit/receive to the desired frequency and modulation, add button "save" config scene
* SubGhz: Fix frequency and preset, fix frequency add manualli scene, fix re-executing the parser
* Furi-hal-subghz: add 2-FSK config, fix ook config 650KHz BW Tx filter
* Fix formatting and release build
* SubGhz: Delete read scene
* SubGhz: Fix frequency add manualli scene, refactoring code
* SubGhz: 2 profiles for OOK, fix broken build.
* SubGhz: Add passing static codes from read scene, add notification read scene, refactoring code
* SubGhz: fix assert on worker double stop.
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-08-28 16:51:48 +03:00
|
|
|
instance->last_index_write++;
|
2021-09-10 03:29:57 +03:00
|
|
|
return true;
|
2022-10-02 02:18:30 +03:00
|
|
|
}
|