Save preset, RSSIm ignore values in last settings

- Save preset
- Save RSSI
- Save Ignore Starline, Cars, Magellan
- Fix types of COUNT_OF result
- Move subghz_set_default_preset to SubGhzTxRx
- In subghz_txrx_radio_device_is_tx_allowed check for SubGhzTxRxStateSleep is not working
This commit is contained in:
DerSkythe
2023-08-08 08:58:20 +04:00
parent 540862fbf2
commit 8c44dfb6af
18 changed files with 294 additions and 154 deletions

View File

@@ -1,9 +1,9 @@
/* Abandon hope, all ye who enter here. */
#include <furi/core/log.h>
#include <subghz/types.h>
#include <lib/toolbox/path.h>
#include "subghz_i.h"
#include <lib/subghz/protocols/protocol_items.h>
#define TAG "SubGhzApp"
@@ -73,7 +73,7 @@ static void subghz_load_custom_presets(SubGhzSetting* setting) {
FlipperFormat* fff_temp = flipper_format_string_alloc();
for(uint8_t i = 0; i < COUNT_OF(presets); i++) {
for(size_t i = 0; i < COUNT_OF(presets); i++) {
flipper_format_insert_or_update_string_cstr(fff_temp, "Custom_preset_data", presets[i][1]);
flipper_format_rewind(fff_temp);
@@ -195,26 +195,45 @@ SubGhz* subghz_alloc(bool alloc_for_tx_only) {
// Load last used values for Read, Read RAW, etc. or default
subghz->last_settings = subghz_last_settings_alloc();
subghz_last_settings_load(subghz->last_settings, 0);
size_t preset_count = subghz_setting_get_preset_count(setting);
subghz_last_settings_load(subghz->last_settings, preset_count);
#ifdef FURI_DEBUG
subghz_last_settings_log(subghz->last_settings, subghz->last_settings->ignore_filter);
#endif
if(!alloc_for_tx_only) {
subghz_setting_set_default_frequency(setting, subghz->last_settings->frequency);
subghz_txrx_set_preset_internal(
subghz->txrx, subghz->last_settings->frequency, subghz->last_settings->preset_index);
subghz_txrx_set_preset(subghz->txrx, "AM650", subghz->last_settings->frequency, NULL, 0);
subghz->history = subghz_history_alloc();
}
subghz_rx_key_state_set(subghz, SubGhzRxKeyStateIDLE);
subghz->secure_data = malloc(sizeof(SecureData));
subghz->filter = SubGhzProtocolFlag_Decodable;
subghz->ignore_filter = 0x0;
if(!alloc_for_tx_only) {
subghz->ignore_filter = subghz->last_settings->ignore_filter;
subghz->filter = subghz->last_settings->filter;
} else {
subghz->filter = SubGhzProtocolFlag_Decodable;
subghz->ignore_filter = 0x0;
}
subghz_txrx_receiver_set_filter(subghz->txrx, subghz->filter);
subghz_txrx_set_need_save_callback(subghz->txrx, subghz_save_to_file, subghz);
if(!alloc_for_tx_only) {
if(subghz->last_settings->rssi != 0) {
subghz_threshold_rssi_set(subghz->threshold_rssi, subghz->last_settings->rssi);
} else {
subghz->last_settings->rssi = SUBGHZ_LAST_SETTING_FREQUENCY_ANALYZER_TRIGGER;
}
}
//Init Error_str
subghz->error_str = furi_string_alloc();
#ifdef FURI_DEBUG
subghz_last_settings_log(subghz->last_settings, subghz->ignore_filter);
#endif
return subghz;
}