Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

Commit

Permalink
"Use Defaults = Off" for just static/hopper frequencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Willy-JL committed Feb 14, 2024
1 parent 3818624 commit 25713dc
Showing 1 changed file with 22 additions and 24 deletions.
46 changes: 22 additions & 24 deletions lib/subghz/subghz_setting.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,26 +162,20 @@ static void subghz_setting_load_default_preset(
memcpy(&item->custom_preset_data[0], &preset_data[0], item->custom_preset_data_size);
}

static void subghz_setting_load_default_region(
SubGhzSetting* instance,
const uint32_t frequencies[],
const uint32_t hopper_frequencies[]) {
static void subghz_setting_load_frequencies(FrequencyList_t list, const uint32_t* frequencies) {
while(*frequencies) {
FrequencyList_push_back(list, *frequencies);
frequencies++;
}
}

static void subghz_setting_load_default_region(SubGhzSetting* instance) {
furi_assert(instance);

FrequencyList_reset(instance->frequencies);
FrequencyList_reset(instance->hopper_frequencies);
subghz_setting_preset_reset(instance);

while(*frequencies) {
FrequencyList_push_back(instance->frequencies, *frequencies);
frequencies++;
}

while(*hopper_frequencies) {
FrequencyList_push_back(instance->hopper_frequencies, *hopper_frequencies);
hopper_frequencies++;
}

subghz_setting_load_default_preset(
instance, "AM270", subghz_device_cc1101_preset_ook_270khz_async_regs);
subghz_setting_load_default_preset(
Expand All @@ -194,8 +188,7 @@ static void subghz_setting_load_default_region(

// Region check removed
void subghz_setting_load_default(SubGhzSetting* instance) {
subghz_setting_load_default_region(
instance, subghz_frequency_list, subghz_hopper_frequency_list);
subghz_setting_load_default_region(instance);
}

void subghz_setting_load(SubGhzSetting* instance, const char* file_path) {
Expand Down Expand Up @@ -234,11 +227,12 @@ void subghz_setting_load(SubGhzSetting* instance, const char* file_path) {
temp_bool = true;
flipper_format_read_bool(fff_data_file, "Add_standard_frequencies", &temp_bool, 1);
if(!temp_bool) {
FURI_LOG_I(TAG, "Removing standard frequencies");
FrequencyList_reset(instance->frequencies);
FrequencyList_reset(instance->hopper_frequencies);
FURI_LOG_I(TAG, "Skipping standard frequencies");
} else {
FURI_LOG_I(TAG, "Keeping standard frequencies");
FURI_LOG_I(TAG, "Adding standard frequencies");
subghz_setting_load_frequencies(instance->frequencies, subghz_frequency_list);
subghz_setting_load_frequencies(
instance->hopper_frequencies, subghz_hopper_frequency_list);
}

// Load frequencies
Expand Down Expand Up @@ -299,10 +293,14 @@ void subghz_setting_load(SubGhzSetting* instance, const char* file_path) {
flipper_format_free(fff_data_file);
furi_record_close(RECORD_STORAGE);

if(!FrequencyList_size(instance->frequencies) ||
!FrequencyList_size(instance->hopper_frequencies)) {
FURI_LOG_E(TAG, "Error loading user settings, loading default settings");
subghz_setting_load_default(instance);
if(!FrequencyList_size(instance->frequencies)) {
FURI_LOG_E(TAG, "Empty static frequency list, loading default ones");
subghz_setting_load_frequencies(instance->frequencies, subghz_frequency_list);
}
if(!FrequencyList_size(instance->hopper_frequencies)) {
FURI_LOG_E(TAG, "Empty hopper frequency list, loading default ones");
subghz_setting_load_frequencies(
instance->hopper_frequencies, subghz_hopper_frequency_list);
}
}

Expand Down

0 comments on commit 25713dc

Please sign in to comment.