Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extended frequency range flags #116

Merged
merged 4 commits into from
Jul 25, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 54 additions & 21 deletions firmware/targets/f7/furi_hal/furi_hal_subghz.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,27 +253,60 @@ uint8_t furi_hal_subghz_get_lqi() {
return data[0] & 0x7F;
}

bool furi_hal_subghz_is_frequency_valid(uint32_t value) {
if(!(value >= 299999755 && value <= 348000335) &&
!(value >= 386999938 && value <= 464000000) &&
!(value >= 778999847 && value <= 928000000)) {
return false;
}

return true;
}

uint32_t furi_hal_subghz_set_frequency_and_path(uint32_t value) {
value = furi_hal_subghz_set_frequency(value);
if(value >= 299999755 && value <= 348000335) {
furi_hal_subghz_set_path(FuriHalSubGhzPath315);
} else if(value >= 386999938 && value <= 464000000) {
furi_hal_subghz_set_path(FuriHalSubGhzPath433);
} else if(value >= 778999847 && value <= 928000000) {
furi_hal_subghz_set_path(FuriHalSubGhzPath868);
} else {
furi_crash("SubGhz: Incorrect frequency during set.");
}
/*
Modified to the full YARD Stick One extended range of 281-361 MHz, 378-481 MHz, and 749-962 MHz.
These changes are at your own risk. The PLL may not lock and FZ devs have warned of possible damage
Set flag use_ext_range_at_own_risk in setting_user to use
*/

bool furi_hal_subghz_is_frequency_valid(uint32_t value) {
FURI_LOG_I(TAG, "Checking if frequency is valid");
bool is_extended = false;

Storage* storage = furi_record_open("storage");
FlipperFormat* fff_data_file = flipper_format_file_alloc(storage);

if(flipper_format_file_open_existing(fff_data_file, "/ext/subghz/assets/extend_range")) {
flipper_format_read_bool(fff_data_file, "use_ext_range_at_own_risk", &is_extended, 1);
FURI_LOG_I(TAG, "Using extended frequencies at own risk");
} else{
FURI_LOG_I(TAG, "Keeping standard frequency ranges");
}

flipper_format_free(fff_data_file);
furi_record_close("storage");


// No flag - test original range, flag set, test extended range
if(!(value >= 299999755 && value <= 348000335) &&
!(value >= 386999938 && value <= 464000000) &&
!(value >= 778999847 && value <= 928000000) &&
!(is_extended)) {
FURI_LOG_I(TAG, "Frequency blocked - outside standard range");
return false;
} else if(!(value >= 281000000 && value <= 361000000) &&
!(value >= 378000000 && value <= 481000000) &&
!(value >= 749000000 && value <= 962000000) &&
is_extended) {
FURI_LOG_I(TAG, "Frequency blocked - outside extended range");
return false;
}

return true;
}

uint32_t furi_hal_subghz_set_frequency_and_path(uint32_t value) {
// Set these values to the extended frequency range only. They dont define if you can transmit but do select the correct RF path
value = furi_hal_subghz_set_frequency(value);
if(value >= 281000000 && value <= 361000000) {
furi_hal_subghz_set_path(FuriHalSubGhzPath315);
} else if(value >= 378000000 && value <= 481000000) {
furi_hal_subghz_set_path(FuriHalSubGhzPath433);
} else if(value >= 749000000 && value <= 962000000) {
furi_hal_subghz_set_path(FuriHalSubGhzPath868);
} else {
furi_crash("SubGhz: Incorrect frequency during set.");
}
return value;
}

Expand Down