diff --git a/applications/subghz/subghz_cli.c b/applications/subghz/subghz_cli.c index a77fe3a9..a6f4f5f3 100644 --- a/applications/subghz/subghz_cli.c +++ b/applications/subghz/subghz_cli.c @@ -5,17 +5,8 @@ #include #include -#define CC1101_FREQUENCY_RANGE_STR \ - "300000000...348000000 or 387000000...464000000 or 779000000...928000000" - -bool subghz_check_frequency_range(uint32_t frequency) { - if(!(frequency >= 300000000 && frequency <= 348000000) && - !(frequency >= 387000000 && frequency <= 464000000) && - !(frequency >= 779000000 && frequency <= 928000000)) { - return false; - } - return true; -} +#define SUBGHZ_FREQUENCY_RANGE_STR \ + "299999755...348000000 or 386999938...464000000 or 778999847...928000000" void subghz_cli_init() { Cli* cli = furi_record_open("cli"); @@ -40,9 +31,9 @@ void subghz_cli_command_tx_carrier(Cli* cli, string_t args, void* context) { cli_print_usage("subghz_tx_carrier", "", string_get_cstr(args)); return; } - if(!subghz_check_frequency_range(frequency)) { + if(!api_hal_subghz_is_frequency_valid(frequency)) { printf( - "Frequency must be in " CC1101_FREQUENCY_RANGE_STR " range, not %lu\r\n", + "Frequency must be in " SUBGHZ_FREQUENCY_RANGE_STR " range, not %lu\r\n", frequency); return; } @@ -77,9 +68,9 @@ void subghz_cli_command_rx_carrier(Cli* cli, string_t args, void* context) { cli_print_usage("subghz_tx_carrier", "", string_get_cstr(args)); return; } - if(!subghz_check_frequency_range(frequency)) { + if(!api_hal_subghz_is_frequency_valid(frequency)) { printf( - "Frequency must be in " CC1101_FREQUENCY_RANGE_STR " range, not %lu\r\n", + "Frequency must be in " SUBGHZ_FREQUENCY_RANGE_STR " range, not %lu\r\n", frequency); return; } @@ -127,9 +118,9 @@ void subghz_cli_command_tx(Cli* cli, string_t args, void* context) { string_get_cstr(args)); return; } - if(!subghz_check_frequency_range(frequency)) { + if(!api_hal_subghz_is_frequency_valid(frequency)) { printf( - "Frequency must be in " CC1101_FREQUENCY_RANGE_STR " range, not %lu\r\n", + "Frequency must be in " SUBGHZ_FREQUENCY_RANGE_STR " range, not %lu\r\n", frequency); return; } @@ -209,9 +200,9 @@ void subghz_cli_command_rx(Cli* cli, string_t args, void* context) { cli_print_usage("subghz_rx", "", string_get_cstr(args)); return; } - if(!subghz_check_frequency_range(frequency)) { + if(!api_hal_subghz_is_frequency_valid(frequency)) { printf( - "Frequency must be in " CC1101_FREQUENCY_RANGE_STR " range, not %lu\r\n", + "Frequency must be in " SUBGHZ_FREQUENCY_RANGE_STR " range, not %lu\r\n", frequency); return; } diff --git a/firmware/targets/api-hal-include/api-hal-subghz.h b/firmware/targets/api-hal-include/api-hal-subghz.h index 73d1c1fe..d6aa1f8b 100644 --- a/firmware/targets/api-hal-include/api-hal-subghz.h +++ b/firmware/targets/api-hal-include/api-hal-subghz.h @@ -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 diff --git a/firmware/targets/f6/api-hal/api-hal-subghz.c b/firmware/targets/f6/api-hal/api-hal-subghz.c index 87621a7f..3b11c7f8 100644 --- a/firmware/targets/f6/api-hal/api-hal-subghz.c +++ b/firmware/targets/f6/api-hal/api-hal-subghz.c @@ -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);