Move dangerous_settings check

This commit is contained in:
gid9798
2023-05-18 10:59:08 +03:00
parent 11d4ad1e23
commit 64817ac216
5 changed files with 52 additions and 19 deletions

View File

@@ -41,6 +41,7 @@ volatile FuriHalSubGhz furi_hal_subghz = {
.rolling_counter_mult = 1,
.ext_module_power_disabled = false,
.timestamp_file_names = false,
.dangerous_frequency_i = false,
};
void furi_hal_subghz_select_radio_type(SubGhzRadioType state) {
@@ -96,6 +97,10 @@ bool furi_hal_subghz_get_timestamp_file_names(void) {
return furi_hal_subghz.timestamp_file_names;
}
void furi_hal_subghz_set_dangerous_frequency(bool state_i) {
furi_hal_subghz.dangerous_frequency_i = state_i;
}
void furi_hal_subghz_set_async_mirror_pin(const GpioPin* pin) {
furi_hal_subghz.async_mirror_pin = pin;
}
@@ -448,29 +453,19 @@ uint32_t furi_hal_subghz_set_frequency_and_path(uint32_t value) {
}
bool furi_hal_subghz_is_tx_allowed(uint32_t value) {
bool is_extended = false;
bool allow_extended_for_int = furi_hal_subghz.dangerous_frequency_i;
// TODO: !!! Move file check to another place
Storage* storage = furi_record_open(RECORD_STORAGE);
FlipperFormat* fff_data_file = flipper_format_file_alloc(storage);
if(flipper_format_file_open_existing(fff_data_file, "/ext/subghz/assets/dangerous_settings")) {
flipper_format_read_bool(
fff_data_file, "yes_i_want_to_destroy_my_flipper", &is_extended, 1);
}
flipper_format_free(fff_data_file);
furi_record_close(RECORD_STORAGE);
if(!(value >= 299999755 && value <= 350000335) && // was increased from 348 to 350
if(!(allow_extended_for_int) &&
!(value >= 299999755 && value <= 350000335) && // was increased from 348 to 350
!(value >= 386999938 && value <= 467750000) && // was increased from 464 to 467.75
!(value >= 778999847 && value <= 928000000) && !(is_extended)) {
!(value >= 778999847 && value <= 928000000)) {
FURI_LOG_I(TAG, "Frequency blocked - outside default range");
return false;
} else if(
(allow_extended_for_int) && //
!(value >= 281000000 && value <= 361000000) &&
!(value >= 378000000 && value <= 481000000) &&
!(value >= 749000000 && value <= 962000000) && is_extended) {
!(value >= 749000000 && value <= 962000000)) {
FURI_LOG_I(TAG, "Frequency blocked - outside dangerous range");
return false;
}

View File

@@ -78,8 +78,9 @@ typedef struct {
FuriHalSpiBusHandle* spi_bus_handle;
const GpioPin* cc1101_g0_pin;
uint8_t rolling_counter_mult;
bool ext_module_power_disabled;
bool timestamp_file_names;
bool ext_module_power_disabled : 1;
bool timestamp_file_names : 1;
bool dangerous_frequency_i : 1;
} FuriHalSubGhz;
extern volatile FuriHalSubGhz furi_hal_subghz;

View File

@@ -0,0 +1,3 @@
#pragma once
void furi_hal_subghz_set_dangerous_frequency(bool state_i);