[FL-1590] SubGhz: fix incorrect limits on frequency that were causing crashes #607

This commit is contained in:
あく
2021-07-27 14:47:45 +03:00
committed by GitHub
parent 2313b948c6
commit 4c1ac2a13d
3 changed files with 27 additions and 22 deletions

View File

@@ -104,6 +104,11 @@ void api_hal_subghz_tx();
/** Get RSSI value in dBm */
float api_hal_subghz_get_rssi();
/** Check if frequency is in valid range
* @return true if frequncy is valid, otherwise false
*/
bool api_hal_subghz_is_frequency_valid(uint32_t value);
/** Set frequency and path
* This function automatically selects antenna matching network
* @param frequency in herz

View File

@@ -242,13 +242,22 @@ float api_hal_subghz_get_rssi() {
return rssi;
}
bool api_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 api_hal_subghz_set_frequency_and_path(uint32_t value) {
value = api_hal_subghz_set_frequency(value);
if(value >= 300000000 && value <= 348000335) {
if(value >= 299999755 && value <= 348000335) {
api_hal_subghz_set_path(ApiHalSubGhzPath315);
} else if(value >= 387000000 && value <= 464000000) {
} else if(value >= 386999938 && value <= 464000000) {
api_hal_subghz_set_path(ApiHalSubGhzPath433);
} else if(value >= 779000000 && value <= 928000000) {
} else if(value >= 778999847 && value <= 928000000) {
api_hal_subghz_set_path(ApiHalSubGhzPath868);
} else {
furi_check(0);