mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-16 04:24:45 -07:00
Update multi fuzzer and subghz remote
This commit is contained in:
@@ -7,10 +7,8 @@
|
||||
// #include <lib/subghz/protocols/keeloq.h>
|
||||
// #include <lib/subghz/protocols/star_line.h>
|
||||
|
||||
#ifdef APP_SUBGHZREMOTE
|
||||
#include <lib/subghz/protocols/protocol_items.h>
|
||||
#include <lib/subghz/blocks/custom_btn.h>
|
||||
#endif
|
||||
|
||||
#define TAG "SubGhzRemote"
|
||||
|
||||
@@ -22,7 +20,7 @@ static const char* map_file_labels[SubRemSubKeyNameMaxCount][2] = {
|
||||
[SubRemSubKeyNameOk] = {"OK", "OKLABEL"},
|
||||
};
|
||||
|
||||
static void subrem_map_preset_reset(SubRemMapPreset* map_preset) {
|
||||
void subrem_map_preset_reset(SubRemMapPreset* map_preset) {
|
||||
furi_assert(map_preset);
|
||||
|
||||
for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) {
|
||||
@@ -228,9 +226,7 @@ bool subrem_tx_start_sub(SubGhzRemoteApp* app, SubRemSubFilePreset* sub_preset)
|
||||
NULL,
|
||||
0);
|
||||
|
||||
#ifdef APP_SUBGHZREMOTE
|
||||
subghz_custom_btns_reset();
|
||||
#endif
|
||||
|
||||
if(subghz_txrx_tx_start(app->txrx, sub_preset->fff_data) == SubGhzTxRxStartTxStateOk) {
|
||||
ret = true;
|
||||
@@ -246,12 +242,12 @@ bool subrem_tx_stop_sub(SubGhzRemoteApp* app, bool forced) {
|
||||
|
||||
if(forced || (sub_preset->type != SubGhzProtocolTypeRAW)) {
|
||||
subghz_txrx_stop(app->txrx);
|
||||
#ifdef APP_SUBGHZREMOTE
|
||||
|
||||
if(sub_preset->type == SubGhzProtocolTypeDynamic) {
|
||||
subghz_txrx_reset_dynamic_and_custom_btns(app->txrx);
|
||||
}
|
||||
subghz_custom_btns_reset();
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -278,3 +274,47 @@ SubRemLoadMapState subrem_load_from_file(SubGhzRemoteApp* app) {
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool subrem_save_map_to_file(SubGhzRemoteApp* app) {
|
||||
furi_assert(app);
|
||||
|
||||
const char* file_name = furi_string_get_cstr(app->file_path);
|
||||
bool saved = false;
|
||||
FlipperFormat* fff_data = flipper_format_string_alloc();
|
||||
|
||||
SubRemSubFilePreset* sub_preset;
|
||||
|
||||
flipper_format_write_header_cstr(
|
||||
fff_data, SUBREM_APP_APP_FILE_TYPE, SUBREM_APP_APP_FILE_VERSION);
|
||||
for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) {
|
||||
sub_preset = app->map_preset->subs_preset[i];
|
||||
if(!furi_string_empty(sub_preset->file_path)) {
|
||||
flipper_format_write_string(fff_data, map_file_labels[i][0], sub_preset->file_path);
|
||||
}
|
||||
}
|
||||
for(uint8_t i = 0; i < SubRemSubKeyNameMaxCount; i++) {
|
||||
sub_preset = app->map_preset->subs_preset[i];
|
||||
if(!furi_string_empty(sub_preset->file_path)) {
|
||||
flipper_format_write_string(fff_data, map_file_labels[i][1], sub_preset->label);
|
||||
}
|
||||
}
|
||||
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
Stream* flipper_format_stream = flipper_format_get_raw_stream(fff_data);
|
||||
|
||||
do {
|
||||
if(!storage_simply_remove(storage, file_name)) {
|
||||
break;
|
||||
}
|
||||
//ToDo check Write
|
||||
stream_seek(flipper_format_stream, 0, StreamOffsetFromStart);
|
||||
stream_save_to_file(flipper_format_stream, storage, file_name, FSOM_CREATE_ALWAYS);
|
||||
|
||||
saved = true;
|
||||
} while(0);
|
||||
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
flipper_format_free(fff_data);
|
||||
|
||||
return saved;
|
||||
}
|
||||
Reference in New Issue
Block a user