Sub-GHz: Choose RSSI threshold for Hopping mode

This commit is contained in:
Willy-JL
2024-07-10 13:51:25 +01:00
parent 79d8b12c5e
commit 3df6c81947
8 changed files with 71 additions and 17 deletions

View File

@@ -23,6 +23,7 @@
#define SUBGHZ_LAST_SETTING_FIELD_REPEATER "Repeater"
#define SUBGHZ_LAST_SETTING_FIELD_ENABLE_SOUND "Sound"
#define SUBGHZ_LAST_SETTING_FIELD_AUTOSAVE "Autosave"
#define SUBGHZ_LAST_SETTING_FIELD_HOPPING_THRESHOLD "HoppingThreshold"
SubGhzLastSettings* subghz_last_settings_alloc(void) {
SubGhzLastSettings* instance = malloc(sizeof(SubGhzLastSettings));
@@ -46,6 +47,7 @@ void subghz_last_settings_load(SubGhzLastSettings* instance, size_t preset_count
// See bin_raw_value in scenes/subghz_scene_receiver_config.c
instance->filter = SubGhzProtocolFlag_Decodable;
instance->rssi = SUBGHZ_RAW_THRESHOLD_MIN;
instance->hopping_threshold = -90.0f;
Storage* storage = furi_record_open(RECORD_STORAGE);
FlipperFormat* fff_data_file = flipper_format_file_alloc(storage);
@@ -153,6 +155,13 @@ void subghz_last_settings_load(SubGhzLastSettings* instance, size_t preset_count
fff_data_file, SUBGHZ_LAST_SETTING_FIELD_AUTOSAVE, &instance->autosave, 1)) {
flipper_format_rewind(fff_data_file);
}
if(!flipper_format_read_float(
fff_data_file,
SUBGHZ_LAST_SETTING_FIELD_HOPPING_THRESHOLD,
&instance->hopping_threshold,
1)) {
flipper_format_rewind(fff_data_file);
}
} while(0);
} else {
FURI_LOG_E(TAG, "Error open file %s", SUBGHZ_LAST_SETTINGS_PATH);
@@ -265,6 +274,13 @@ bool subghz_last_settings_save(SubGhzLastSettings* instance) {
file, SUBGHZ_LAST_SETTING_FIELD_AUTOSAVE, &instance->autosave, 1)) {
break;
}
if(!flipper_format_write_float(
file,
SUBGHZ_LAST_SETTING_FIELD_HOPPING_THRESHOLD,
&instance->hopping_threshold,
1)) {
break;
}
saved = true;
} while(0);