Skip to content

Commit

Permalink
Merge pull request #116 from tkerby/unleashed
Browse files Browse the repository at this point in the history
Extended frequency range flags
  • Loading branch information
RogueMaster authored Jul 25, 2022
2 parents fdf478e + c0966b3 commit b6257e5
Showing 1 changed file with 54 additions and 21 deletions.
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

0 comments on commit b6257e5

Please sign in to comment.