mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2024-12-25 22:32:29 +03:00
Merge pull request #475 from gid9798/move_dangerous_settings_check
Move dangerous_settings check
This commit is contained in:
commit
276020c482
@ -10,7 +10,10 @@ App(
|
|||||||
"cli",
|
"cli",
|
||||||
"dialogs",
|
"dialogs",
|
||||||
],
|
],
|
||||||
provides=["subghz_start"],
|
provides=[
|
||||||
|
"subghz_start",
|
||||||
|
"subghz_load_dangerous_settings",
|
||||||
|
],
|
||||||
icon="A_Sub1ghz_14",
|
icon="A_Sub1ghz_14",
|
||||||
stack_size=3 * 1024,
|
stack_size=3 * 1024,
|
||||||
order=10,
|
order=10,
|
||||||
@ -23,3 +26,11 @@ App(
|
|||||||
requires=["subghz"],
|
requires=["subghz"],
|
||||||
order=40,
|
order=40,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
App(
|
||||||
|
appid="subghz_load_dangerous_settings",
|
||||||
|
apptype=FlipperAppType.STARTUP,
|
||||||
|
entry_point="subghz_dangerous_freq",
|
||||||
|
requires=["storage", "subghz"],
|
||||||
|
order=500,
|
||||||
|
)
|
||||||
|
23
applications/main/subghz/subghz_dangerous_freq.c
Normal file
23
applications/main/subghz/subghz_dangerous_freq.c
Normal 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);
|
||||||
|
}
|
@ -41,6 +41,7 @@ volatile FuriHalSubGhz furi_hal_subghz = {
|
|||||||
.rolling_counter_mult = 1,
|
.rolling_counter_mult = 1,
|
||||||
.ext_module_power_disabled = false,
|
.ext_module_power_disabled = false,
|
||||||
.timestamp_file_names = false,
|
.timestamp_file_names = false,
|
||||||
|
.dangerous_frequency_i = false,
|
||||||
};
|
};
|
||||||
|
|
||||||
void furi_hal_subghz_select_radio_type(SubGhzRadioType state) {
|
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;
|
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) {
|
void furi_hal_subghz_set_async_mirror_pin(const GpioPin* pin) {
|
||||||
furi_hal_subghz.async_mirror_pin = 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 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
|
if(!(allow_extended_for_int) &&
|
||||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
!(value >= 299999755 && value <= 350000335) && // was increased from 348 to 350
|
||||||
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
|
|
||||||
!(value >= 386999938 && value <= 467750000) && // was increased from 464 to 467.75
|
!(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");
|
FURI_LOG_I(TAG, "Frequency blocked - outside default range");
|
||||||
return false;
|
return false;
|
||||||
} else if(
|
} else if(
|
||||||
|
(allow_extended_for_int) && //
|
||||||
!(value >= 281000000 && value <= 361000000) &&
|
!(value >= 281000000 && value <= 361000000) &&
|
||||||
!(value >= 378000000 && value <= 481000000) &&
|
!(value >= 378000000 && value <= 481000000) &&
|
||||||
!(value >= 749000000 && value <= 962000000) && is_extended) {
|
!(value >= 749000000 && value <= 962000000)) {
|
||||||
FURI_LOG_I(TAG, "Frequency blocked - outside dangerous range");
|
FURI_LOG_I(TAG, "Frequency blocked - outside dangerous range");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -78,8 +78,9 @@ typedef struct {
|
|||||||
FuriHalSpiBusHandle* spi_bus_handle;
|
FuriHalSpiBusHandle* spi_bus_handle;
|
||||||
const GpioPin* cc1101_g0_pin;
|
const GpioPin* cc1101_g0_pin;
|
||||||
uint8_t rolling_counter_mult;
|
uint8_t rolling_counter_mult;
|
||||||
bool ext_module_power_disabled;
|
bool ext_module_power_disabled : 1;
|
||||||
bool timestamp_file_names;
|
bool timestamp_file_names : 1;
|
||||||
|
bool dangerous_frequency_i : 1;
|
||||||
} FuriHalSubGhz;
|
} FuriHalSubGhz;
|
||||||
|
|
||||||
extern volatile FuriHalSubGhz furi_hal_subghz;
|
extern volatile FuriHalSubGhz furi_hal_subghz;
|
||||||
|
3
firmware/targets/f7/furi_hal/furi_hal_subghz_i.h
Normal file
3
firmware/targets/f7/furi_hal/furi_hal_subghz_i.h
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
void furi_hal_subghz_set_dangerous_frequency(bool state_i);
|
Loading…
Reference in New Issue
Block a user