Merge branch 'dev' into subrem_new_app

This commit is contained in:
MX
2023-05-19 04:54:04 +03:00
11 changed files with 186 additions and 61 deletions
+12 -1
View File
@@ -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=650,
)
@@ -25,11 +25,14 @@ const char* const debug_pin_text[DEBUG_P_COUNT] = {
"17(1W)", "17(1W)",
}; };
#define DEBUG_COUNTER_COUNT 3 #define DEBUG_COUNTER_COUNT 6
const char* const debug_counter_text[DEBUG_COUNTER_COUNT] = { const char* const debug_counter_text[DEBUG_COUNTER_COUNT] = {
"+1", "+1",
"+2", "+2",
"+3", "+3",
"+4",
"+5",
"+10",
}; };
static void subghz_scene_ext_module_changed(VariableItem* item) { static void subghz_scene_ext_module_changed(VariableItem* item) {
@@ -71,6 +74,15 @@ static void subghz_scene_receiver_config_set_debug_counter(VariableItem* item) {
case 2: case 2:
furi_hal_subghz_set_rolling_counter_mult(3); furi_hal_subghz_set_rolling_counter_mult(3);
break; break;
case 3:
furi_hal_subghz_set_rolling_counter_mult(4);
break;
case 4:
furi_hal_subghz_set_rolling_counter_mult(5);
break;
case 5:
furi_hal_subghz_set_rolling_counter_mult(10);
break;
default: default:
break; break;
} }
@@ -140,24 +152,58 @@ void subghz_scene_radio_settings_on_enter(void* context) {
variable_item_set_current_value_index(item, value_index); variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, timestamp_names_text[value_index]); variable_item_set_current_value_text(item, timestamp_names_text[value_index]);
item = variable_item_list_add( if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) {
subghz->variable_item_list, item = variable_item_list_add(
"Counter incr.", subghz->variable_item_list,
DEBUG_COUNTER_COUNT, "Counter incr.",
subghz_scene_receiver_config_set_debug_counter, DEBUG_COUNTER_COUNT,
subghz); subghz_scene_receiver_config_set_debug_counter,
switch(furi_hal_subghz_get_rolling_counter_mult()) { subghz);
case 1: switch(furi_hal_subghz_get_rolling_counter_mult()) {
value_index = 0; case 1:
break; value_index = 0;
case 2: break;
value_index = 1; case 2:
break; value_index = 1;
case 3: break;
value_index = 2; case 3:
break; value_index = 2;
default: break;
break; case 4:
value_index = 3;
break;
case 5:
value_index = 4;
break;
case 10:
value_index = 5;
break;
default:
break;
}
} else {
item = variable_item_list_add(
subghz->variable_item_list,
"Counter incr.",
3,
subghz_scene_receiver_config_set_debug_counter,
subghz);
switch(furi_hal_subghz_get_rolling_counter_mult()) {
case 1:
value_index = 0;
break;
case 2:
value_index = 1;
break;
case 3:
value_index = 2;
break;
default:
// Reset to default value
value_index = 0;
furi_hal_subghz_set_rolling_counter_mult(1);
break;
}
} }
variable_item_set_current_value_index(item, value_index); variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, debug_counter_text[value_index]); variable_item_set_current_value_text(item, debug_counter_text[value_index]);
@@ -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);
}
+1
View File
@@ -9,5 +9,6 @@ App(
"desktop", "desktop",
"loader", "loader",
"power", "power",
"namechange_srv",
], ],
) )
-23
View File
@@ -9,9 +9,6 @@
#include <cli/cli.h> #include <cli/cli.h>
#include <cli/cli_vcp.h> #include <cli/cli_vcp.h>
#include <toolbox/namechanger.h>
#include <bt/bt_service/bt.h>
#include "animations/animation_manager.h" #include "animations/animation_manager.h"
#include "desktop/scenes/desktop_scene.h" #include "desktop/scenes/desktop_scene.h"
#include "desktop/scenes/desktop_scene_i.h" #include "desktop/scenes/desktop_scene_i.h"
@@ -429,26 +426,6 @@ int32_t desktop_srv(void* p) {
scene_manager_next_scene(desktop->scene_manager, DesktopSceneFault); scene_manager_next_scene(desktop->scene_manager, DesktopSceneFault);
} }
// I added some very bydlo kod here, and thrown some delays to make it worse, pls don't look at it, it will make you cry from laugh
if(furi_hal_rtc_get_boot_mode() == FuriHalRtcBootModeNormal) {
if(NameChanger_Init()) {
Cli* cli = furi_record_open(RECORD_CLI);
cli_session_close(cli);
furi_delay_ms(2);
cli_session_open(cli, &cli_vcp);
furi_record_close(RECORD_CLI);
furi_delay_ms(3);
Bt* bt = furi_record_open(RECORD_BT);
if(!bt_set_profile(bt, BtProfileSerial)) {
FURI_LOG_D(TAG, "Failed to touch bluetooth to name change");
}
furi_record_close(RECORD_BT);
bt = NULL;
furi_delay_ms(3);
}
}
view_dispatcher_run(desktop->view_dispatcher); view_dispatcher_run(desktop->view_dispatcher);
desktop_free(desktop); desktop_free(desktop);
@@ -0,0 +1,8 @@
App(
appid="namechange_srv",
apptype=FlipperAppType.STARTUP,
entry_point="namechange_on_system_start",
requires=["storage", "cli", "bt"],
conflicts=["updater"],
order=600,
)
@@ -0,0 +1,46 @@
#include <furi_hal.h>
#include <cli/cli.h>
#include <cli/cli_vcp.h>
#include <storage/storage.h>
#include <toolbox/namechanger.h>
#include <bt/bt_service/bt.h>
int32_t namechange_on_system_start(void* p) {
UNUSED(p);
if(furi_hal_rtc_get_boot_mode() != FuriHalRtcBootModeNormal) {
return 0;
}
// Wait for all required services to start and create their records
uint8_t timeout = 0;
while(!furi_record_exists(RECORD_CLI) || !furi_record_exists(RECORD_BT) ||
!furi_record_exists(RECORD_STORAGE)) {
timeout++;
if(timeout > 250) {
return 0;
}
furi_delay_ms(5);
}
// Hehe bad code now here, bad bad bad, very bad, bad example, dont take it, make it better
if(NameChanger_Init()) {
Cli* cli = furi_record_open(RECORD_CLI);
cli_session_close(cli);
furi_delay_ms(2); // why i added delays here
cli_session_open(cli, &cli_vcp);
furi_record_close(RECORD_CLI);
furi_delay_ms(3);
Bt* bt = furi_record_open(RECORD_BT);
if(!bt_set_profile(bt, BtProfileSerial)) {
//FURI_LOG_D(TAG, "Failed to touch bluetooth to name change");
}
furi_record_close(RECORD_BT);
bt = NULL;
furi_delay_ms(3);
}
return 0;
}
+11 -16
View File
@@ -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;
@@ -0,0 +1,3 @@
#pragma once
void furi_hal_subghz_set_dangerous_frequency(bool state_i);
+14
View File
@@ -6,6 +6,20 @@
bool NameChanger_Init() { bool NameChanger_Init() {
Storage* storage = furi_record_open(RECORD_STORAGE); Storage* storage = furi_record_open(RECORD_STORAGE);
// Kostil + velosiped = top ficha
uint8_t timeout = 0;
while(timeout < 11) {
if(storage_sd_status(storage) == FSE_OK) break;
furi_delay_ms(250);
timeout++;
/*if(timeout == 10) {
// Failed to init namechanger, SD card not ready
furi_record_close(RECORD_STORAGE);
return false;
}*/
}
FuriString* str = furi_string_alloc(); FuriString* str = furi_string_alloc();
FlipperFormat* file = flipper_format_file_alloc(storage); FlipperFormat* file = flipper_format_file_alloc(storage);