Merge pull request #475 from gid9798/move_dangerous_settings_check

Move dangerous_settings check
This commit is contained in:
MX 2023-05-19 03:32:35 +03:00 committed by GitHub
commit 276020c482
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 52 additions and 19 deletions

View File

@ -10,7 +10,10 @@ App(
"cli",
"dialogs",
],
provides=["subghz_start"],
provides=[
"subghz_start",
"subghz_load_dangerous_settings",
],
icon="A_Sub1ghz_14",
stack_size=3 * 1024,
order=10,
@ -23,3 +26,11 @@ App(
requires=["subghz"],
order=40,
)
App(
appid="subghz_load_dangerous_settings",
apptype=FlipperAppType.STARTUP,
entry_point="subghz_dangerous_freq",
requires=["storage", "subghz"],
order=500,
)

View File

@ -0,0 +1,23 @@
#include <furi.h>
#include <furi_hal.h>
#include <firmware/targets/f7/furi_hal/furi_hal_subghz_i.h>
#include <flipper_format/flipper_format_i.h>
void subghz_dangerous_freq() {
bool is_extended_i = false;
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_i, 1);
}
furi_hal_subghz_set_dangerous_frequency(is_extended_i);
flipper_format_free(fff_data_file);
furi_record_close(RECORD_STORAGE);
}

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);