mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-15 04:19:26 -07:00
Better subghz extend handling + no reset on flash
This commit is contained in:
@@ -19,15 +19,7 @@ static bool xtreme_app_back_event_callback(void* context) {
|
|||||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||||
|
|
||||||
if(app->save_subghz) {
|
if(app->save_subghz) {
|
||||||
FlipperFormat* subghz_range = flipper_format_file_alloc(storage);
|
furi_hal_subghz_set_extend_settings(app->subghz_extend, app->subghz_bypass);
|
||||||
if(flipper_format_file_open_existing(
|
|
||||||
subghz_range, "/ext/subghz/assets/extend_range.txt")) {
|
|
||||||
flipper_format_insert_or_update_bool(
|
|
||||||
subghz_range, "use_ext_range_at_own_risk", &app->subghz_extend, 1);
|
|
||||||
flipper_format_insert_or_update_bool(
|
|
||||||
subghz_range, "ignore_default_tx_region", &app->subghz_bypass, 1);
|
|
||||||
}
|
|
||||||
flipper_format_free(subghz_range);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(app->save_level) {
|
if(app->save_level) {
|
||||||
@@ -126,16 +118,7 @@ XtremeApp* xtreme_app_alloc() {
|
|||||||
|
|
||||||
XtremeSettings* xtreme_settings = XTREME_SETTINGS();
|
XtremeSettings* xtreme_settings = XTREME_SETTINGS();
|
||||||
|
|
||||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
furi_hal_subghz_get_extend_settings(&app->subghz_extend, &app->subghz_bypass);
|
||||||
FlipperFormat* subghz_range = flipper_format_file_alloc(storage);
|
|
||||||
app->subghz_extend = false;
|
|
||||||
app->subghz_bypass = false;
|
|
||||||
if(flipper_format_file_open_existing(subghz_range, "/ext/subghz/assets/extend_range.txt")) {
|
|
||||||
flipper_format_read_bool(
|
|
||||||
subghz_range, "use_ext_range_at_own_risk", &app->subghz_extend, 1);
|
|
||||||
flipper_format_read_bool(subghz_range, "ignore_default_tx_region", &app->subghz_bypass, 1);
|
|
||||||
}
|
|
||||||
flipper_format_free(subghz_range);
|
|
||||||
|
|
||||||
Dolphin* dolphin = furi_record_open(RECORD_DOLPHIN);
|
Dolphin* dolphin = furi_record_open(RECORD_DOLPHIN);
|
||||||
DolphinStats stats = dolphin_stats(dolphin);
|
DolphinStats stats = dolphin_stats(dolphin);
|
||||||
@@ -146,6 +129,7 @@ XtremeApp* xtreme_app_alloc() {
|
|||||||
|
|
||||||
app->asset_pack = 0;
|
app->asset_pack = 0;
|
||||||
asset_packs_init(app->asset_packs);
|
asset_packs_init(app->asset_packs);
|
||||||
|
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||||
File* folder = storage_file_alloc(storage);
|
File* folder = storage_file_alloc(storage);
|
||||||
FileInfo info;
|
FileInfo info;
|
||||||
char* name = malloc(MAX_PACK_NAME_LEN);
|
char* name = malloc(MAX_PACK_NAME_LEN);
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
Filetype: Flipper SubGhz Setting File
|
|
||||||
Version: 1
|
|
||||||
|
|
||||||
# Whether to allow extended ranges that can break your flipper
|
|
||||||
use_ext_range_at_own_risk: false
|
|
||||||
|
|
||||||
# Whether to ignore the default TX region settings
|
|
||||||
ignore_default_tx_region: false
|
|
||||||
@@ -1383,6 +1383,7 @@ Function,-,furi_hal_subghz_dump_state,void,
|
|||||||
Function,+,furi_hal_subghz_enable_ext_power,void,
|
Function,+,furi_hal_subghz_enable_ext_power,void,
|
||||||
Function,+,furi_hal_subghz_flush_rx,void,
|
Function,+,furi_hal_subghz_flush_rx,void,
|
||||||
Function,+,furi_hal_subghz_flush_tx,void,
|
Function,+,furi_hal_subghz_flush_tx,void,
|
||||||
|
Function,+,furi_hal_subghz_get_extend_settings,void,"_Bool*, _Bool*"
|
||||||
Function,+,furi_hal_subghz_get_lqi,uint8_t,
|
Function,+,furi_hal_subghz_get_lqi,uint8_t,
|
||||||
Function,+,furi_hal_subghz_get_radio_type,SubGhzRadioType,
|
Function,+,furi_hal_subghz_get_radio_type,SubGhzRadioType,
|
||||||
Function,+,furi_hal_subghz_get_rolling_counter_mult,uint8_t,
|
Function,+,furi_hal_subghz_get_rolling_counter_mult,uint8_t,
|
||||||
@@ -1403,6 +1404,7 @@ Function,+,furi_hal_subghz_reset,void,
|
|||||||
Function,+,furi_hal_subghz_rx,void,
|
Function,+,furi_hal_subghz_rx,void,
|
||||||
Function,+,furi_hal_subghz_rx_pipe_not_empty,_Bool,
|
Function,+,furi_hal_subghz_rx_pipe_not_empty,_Bool,
|
||||||
Function,+,furi_hal_subghz_set_async_mirror_pin,void,const GpioPin*
|
Function,+,furi_hal_subghz_set_async_mirror_pin,void,const GpioPin*
|
||||||
|
Function,+,furi_hal_subghz_set_extend_settings,void,"_Bool, _Bool"
|
||||||
Function,+,furi_hal_subghz_set_frequency,uint32_t,uint32_t
|
Function,+,furi_hal_subghz_set_frequency,uint32_t,uint32_t
|
||||||
Function,+,furi_hal_subghz_set_frequency_and_path,uint32_t,uint32_t
|
Function,+,furi_hal_subghz_set_frequency_and_path,uint32_t,uint32_t
|
||||||
Function,+,furi_hal_subghz_set_path,void,FuriHalSubGhzPath
|
Function,+,furi_hal_subghz_set_path,void,FuriHalSubGhzPath
|
||||||
|
|||||||
|
@@ -419,21 +419,42 @@ uint32_t furi_hal_subghz_set_frequency_and_path(uint32_t value) {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool furi_hal_subghz_is_tx_allowed(uint32_t value) {
|
void furi_hal_subghz_get_extend_settings(bool* extend, bool* bypass) {
|
||||||
bool is_extended = false;
|
*extend = false;
|
||||||
bool is_allowed = false;
|
*bypass = false;
|
||||||
|
|
||||||
// TODO: !!! Move file check to another place
|
|
||||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||||
FlipperFormat* fff_data_file = flipper_format_file_alloc(storage);
|
FlipperFormat* file = flipper_format_file_alloc(storage);
|
||||||
|
|
||||||
if(flipper_format_file_open_existing(fff_data_file, "/ext/subghz/assets/extend_range.txt")) {
|
if(flipper_format_file_open_existing(file, "/ext/subghz/assets/extend_range.txt")) {
|
||||||
flipper_format_read_bool(fff_data_file, "use_ext_range_at_own_risk", &is_extended, 1);
|
flipper_format_read_bool(file, "use_ext_range_at_own_risk", extend, 1);
|
||||||
flipper_format_read_bool(fff_data_file, "ignore_default_tx_region", &is_allowed, 1);
|
flipper_format_read_bool(file, "ignore_default_tx_region", bypass, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
flipper_format_free(fff_data_file);
|
flipper_format_free(file);
|
||||||
furi_record_close(RECORD_STORAGE);
|
furi_record_close(RECORD_STORAGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void furi_hal_subghz_set_extend_settings(bool extend, bool bypass) {
|
||||||
|
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||||
|
FlipperFormat* file = flipper_format_file_alloc(storage);
|
||||||
|
|
||||||
|
do {
|
||||||
|
if(!flipper_format_file_open_always(file, "/ext/subghz/assets/extend_range.txt")) break;
|
||||||
|
if(!flipper_format_write_header_cstr(file, "Flipper SubGhz Setting File", 1)) break;
|
||||||
|
if(!flipper_format_write_comment_cstr(file, "Whether to allow extended ranges that can break your flipper")) break;
|
||||||
|
if(!flipper_format_write_bool(file, "use_ext_range_at_own_risk", &extend, 1)) break;
|
||||||
|
if(!flipper_format_write_comment_cstr(file, "Whether to ignore the default TX region settings")) break;
|
||||||
|
if(!flipper_format_write_bool(file, "ignore_default_tx_region", &bypass, 1)) break;
|
||||||
|
} while(0);
|
||||||
|
|
||||||
|
flipper_format_free(file);
|
||||||
|
furi_record_close(RECORD_STORAGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool furi_hal_subghz_is_tx_allowed(uint32_t value) {
|
||||||
|
bool is_extended;
|
||||||
|
bool is_allowed;
|
||||||
|
furi_hal_subghz_get_extend_settings(&is_extended, &is_allowed);
|
||||||
|
|
||||||
switch(furi_hal_version_get_hw_region_otp()) {
|
switch(furi_hal_version_get_hw_region_otp()) {
|
||||||
case FuriHalVersionRegionEuRu:
|
case FuriHalVersionRegionEuRu:
|
||||||
|
|||||||
@@ -223,6 +223,20 @@ bool furi_hal_subghz_is_frequency_valid(uint32_t value);
|
|||||||
*/
|
*/
|
||||||
uint32_t furi_hal_subghz_set_frequency_and_path(uint32_t value);
|
uint32_t furi_hal_subghz_set_frequency_and_path(uint32_t value);
|
||||||
|
|
||||||
|
/** Read extend and bypass settings values into out params
|
||||||
|
*
|
||||||
|
* @param extend pointer to bool for extend
|
||||||
|
* @param bypass pointer to bool for bypass
|
||||||
|
*/
|
||||||
|
void furi_hal_subghz_get_extend_settings(bool* extend, bool* bypass);
|
||||||
|
|
||||||
|
/** Set extend and bypass settings values to file
|
||||||
|
*
|
||||||
|
* @param extend bool for extend
|
||||||
|
* @param bypass bool for bypass
|
||||||
|
*/
|
||||||
|
void furi_hal_subghz_set_extend_settings(bool extend, bool bypass);
|
||||||
|
|
||||||
/** Сheck if transmission is allowed on this frequency with your current config
|
/** Сheck if transmission is allowed on this frequency with your current config
|
||||||
*
|
*
|
||||||
* @param value frequency in Hz
|
* @param value frequency in Hz
|
||||||
|
|||||||
Reference in New Issue
Block a user