Fix incompatibility with OFW in subghz part + improve speed

SubGHz app launch times improved, also setting_user file no longer added by firmware, this update will remove this file, be sure to backup!
Now this file is actually should be created by user and will be not removed every update!
This commit is contained in:
MX 2022-12-11 00:42:26 +03:00
parent 63b40992ef
commit 17ea9315e0
No known key found for this signature in database
GPG key ID: 6C4C311DFD4B4AB5
10 changed files with 173 additions and 185 deletions

View file

@ -182,11 +182,54 @@ SubGhz* subghz_alloc(bool alloc_for_tx_only) {
//init setting
subghz->setting = subghz_setting_alloc();
if(alloc_for_tx_only) {
subghz_setting_load(subghz->setting, EXT_PATH("subghz/assets/setting_user"), false);
} else {
subghz_setting_load(subghz->setting, EXT_PATH("subghz/assets/setting_user"), true);
}
subghz_setting_load(subghz->setting, EXT_PATH("subghz/assets/setting_user"));
// Custom Presets load without using config file
FlipperFormat* temp_fm_preset = flipper_format_string_alloc();
flipper_format_write_string_cstr(
temp_fm_preset,
(const char*)"Custom_preset_data",
(const char*)"02 0D 0B 06 08 32 07 04 14 00 13 02 12 04 11 83 10 67 15 24 18 18 19 16 1D 91 1C 00 1B 07 20 FB 22 10 21 56 00 00 C0 00 00 00 00 00 00 00");
flipper_format_rewind(temp_fm_preset);
subghz_setting_load_custom_preset(subghz->setting, (const char*)"FM95", temp_fm_preset);
flipper_format_free(temp_fm_preset);
// #2-FSK 200khz BW / 135kHz Filter/ 15.86Khz Deviation + Ramping
FlipperFormat* temp_fm_preset2 = flipper_format_string_alloc();
flipper_format_write_string_cstr(
temp_fm_preset2,
(const char*)"Custom_preset_data",
(const char*)"02 0D 03 47 08 32 0B 06 15 32 14 00 13 00 12 00 11 32 10 A7 18 18 19 1D 1D 92 1C 00 1B 04 20 FB 22 17 21 B6 00 00 00 12 0E 34 60 C5 C1 C0");
flipper_format_rewind(temp_fm_preset2);
subghz_setting_load_custom_preset(subghz->setting, (const char*)"FM15k", temp_fm_preset2);
flipper_format_free(temp_fm_preset2);
// # HND - FM presets
FlipperFormat* temp_fm_preset3 = flipper_format_string_alloc();
flipper_format_write_string_cstr(
temp_fm_preset3,
(const char*)"Custom_preset_data",
(const char*)"02 0D 0B 06 08 32 07 04 14 00 13 02 12 04 11 36 10 69 15 32 18 18 19 16 1D 91 1C 00 1B 07 20 FB 22 10 21 56 00 00 C0 00 00 00 00 00 00 00");
flipper_format_rewind(temp_fm_preset3);
subghz_setting_load_custom_preset(subghz->setting, (const char*)"HND_1", temp_fm_preset3);
flipper_format_free(temp_fm_preset3);
FlipperFormat* temp_fm_preset4 = flipper_format_string_alloc();
flipper_format_write_string_cstr(
temp_fm_preset4,
(const char*)"Custom_preset_data",
(const char*)"02 0D 0B 06 08 32 07 04 14 00 13 02 12 07 11 36 10 E9 15 32 18 18 19 16 1D 92 1C 40 1B 03 20 FB 22 10 21 56 00 00 C0 00 00 00 00 00 00 00");
flipper_format_rewind(temp_fm_preset4);
subghz_setting_load_custom_preset(subghz->setting, (const char*)"HND_2", temp_fm_preset4);
flipper_format_free(temp_fm_preset4);
// custom presets loading - end
// Load last used values for Read, Read RAW, etc. or default
if(!alloc_for_tx_only) {

View file

@ -706,7 +706,7 @@ static void input_callback(InputEvent* input_event, void* ctx) {
void unirfremix_subghz_alloc(UniRFRemix* app) {
// load subghz presets
app->setting = subghz_setting_alloc();
subghz_setting_load(app->setting, EXT_PATH("subghz/assets/setting_user"), false);
subghz_setting_load(app->setting, EXT_PATH("subghz/assets/setting_user"));
// load mfcodes
app->environment = subghz_environment_alloc();

View file

@ -5,9 +5,6 @@
#include <lib/flipper_format/flipper_format.h>
#include "protocols/protocol_items.h"
// Comment next line to build on OFW
#define IS_UNLEASHED
static bool pocsag_pager_app_custom_event_callback(void* context, uint32_t event) {
furi_assert(context);
POCSAGPagerApp* app = context;
@ -84,12 +81,10 @@ POCSAGPagerApp* pocsag_pager_app_alloc() {
//init setting
app->setting = subghz_setting_alloc();
//ToDo FIX file name setting
#ifdef IS_UNLEASHED
subghz_setting_load(app->setting, EXT_PATH("pocsag/settings.txt"), true);
#else
//ToDo FIX file name setting
subghz_setting_load(app->setting, EXT_PATH("pocsag/settings.txt"));
#endif
//init Worker & Protocol & History
app->lock = PCSGLockOff;
app->txrx = malloc(sizeof(POCSAGPagerTxRx));
@ -108,16 +103,6 @@ POCSAGPagerApp* pocsag_pager_app_alloc() {
flipper_format_free(temp_fm_preset);
FlipperFormat* temp_fm_preset2 = flipper_format_string_alloc();
flipper_format_write_string_cstr(
temp_fm_preset2,
(const char*)"Custom_preset_data",
(const char*)"02 0D 0B 06 08 32 07 04 14 00 13 02 12 04 11 83 10 67 15 31 18 18 19 16 1D 91 1C 00 1B 07 20 FB 22 10 21 56 00 00 C0 00 00 00 00 00 00 00");
flipper_format_rewind(temp_fm_preset2);
subghz_setting_load_custom_preset(app->setting, (const char*)"FM150", temp_fm_preset2);
flipper_format_free(temp_fm_preset2);
// custom presets loading - end
pcsg_preset_init(app, "FM95", 439987500, NULL, 0);

View file

@ -81,7 +81,7 @@ WeatherStationApp* weather_station_app_alloc() {
app->setting = subghz_setting_alloc();
//ToDo FIX file name setting
subghz_setting_load(app->setting, EXT_PATH("subghz/assets/setting_user"), true);
subghz_setting_load(app->setting, EXT_PATH("subghz/assets/setting_user"));
//init Worker & Protocol & History
app->lock = WSLockOff;

View file

@ -4,7 +4,9 @@
# for adding manufacture keys
# AABBCCDDEEFFAABB:X:NAME\r\n
# AABBCCDDEEFFAABB - man 64 bit
# X - encryption method 1 - Simple Learning, 2 - Normal_Learning, 3 - Secure_Learning, 4 - Magic_xor_type1 Learning, 5 - FAAC, 6 - Magic Serial typ1
# X - encryption method - 1 - Simple Learning, 2 - Normal_Learning, 3 - Secure_Learning,
# 4 - Magic_xor_type1 Learning, 5 - FAAC SLH,
# 6 - Magic Serial typ1, 7 - Magic Serial typ2, 8 - Magic Serial typ3
# 0 - iterates over both previous and man in direct and reverse byte sequence
# NAME - name (string without spaces) max 64 characters long
Filetype: Flipper SubGhz Keystore File

View file

@ -1,101 +0,0 @@
# to use manual settings and prevent them from being deleted on upgrade, rename *_user.example files to *_user
Filetype: Flipper SubGhz Setting File
Version: 1
# Add All Standard frequencies
Add_standard_frequencies: false
# Default Frequency: used as default for "Read" and "Read Raw"
Default_frequency: 433920000
# Frequencies used for "Read", "Read Raw" and "Frequency Analyzer" - they added after default ones if enabled in Add_standard_frequencies
Frequency: 300000000
Frequency: 302757000
Frequency: 303875000
Frequency: 304250000
Frequency: 307000000
Frequency: 307500000
Frequency: 307800000
Frequency: 309000000
Frequency: 310000000
Frequency: 312000000
Frequency: 312100000
Frequency: 312200000
Frequency: 313000000
Frequency: 313850000
Frequency: 314000000
Frequency: 314350000
Frequency: 314980000
Frequency: 315000000
Frequency: 318000000
Frequency: 330000000
Frequency: 345000000
Frequency: 348000000
Frequency: 387000000
Frequency: 390000000
Frequency: 418000000
Frequency: 433075000
Frequency: 433220000
Frequency: 433420000
Frequency: 433657070
Frequency: 433889000
Frequency: 433920000
Frequency: 434075000
Frequency: 434176948
Frequency: 434190000
Frequency: 434390000
Frequency: 434420000
Frequency: 434620000
Frequency: 434775000
Frequency: 438900000
Frequency: 440175000
Frequency: 464000000
Frequency: 779000000
Frequency: 868350000
Frequency: 868400000
Frequency: 868800000
Frequency: 868950000
Frequency: 906400000
Frequency: 915000000
Frequency: 925000000
Frequency: 928000000
# Frequencies used for hopping mode (keep this list small or flipper will miss signal) - they added after default ones if enabled in Add_standard_frequencies
Hopper_frequency: 310000000
Hopper_frequency: 315000000
Hopper_frequency: 390000000
Hopper_frequency: 433920000
Hopper_frequency: 434420000
Hopper_frequency: 868350000
# Custom preset examples
# format for CC1101 "Custom_preset_data:" XX YY XX YY .. 00 00 ZZ ZZ ZZ ZZ ZZ ZZ ZZ ZZ, where: XX-register, YY - register data, 00 00 - end load register, ZZ - 8 byte Pa table register
#Custom_preset_name: AM_1
#Custom_preset_module: CC1101
#Custom_preset_data: 02 0D 03 07 08 32 0B 06 14 00 13 00 12 30 11 32 10 17 18 18 19 18 1D 91 1C 00 1B 07 20 FB 22 11 21 B6 00 00 00 C0 00 00 00 00 00 00
#Custom_preset_name: AM_2
#Custom_preset_module: CC1101
#Custom_preset_data: 02 0D 03 07 08 32 0B 06 14 00 13 00 12 30 11 32 10 17 18 18 19 18 1D 91 1C 00 1B 07 20 FB 22 11 21 B6 00 00 00 C0 00 00 00 00 00 00
# Custom presets added in Unleashed FW
# -- Some presets from forum.flipperzero.one --
#2-FSK 200khz BW / 135kHz Filter/ 15.86Khz Deviation + Ramping
Custom_preset_name: FM15k
Custom_preset_module: CC1101
Custom_preset_data: 02 0D 03 47 08 32 0B 06 15 32 14 00 13 00 12 00 11 32 10 A7 18 18 19 1D 1D 92 1C 00 1B 04 20 FB 22 17 21 B6 00 00 00 12 0E 34 60 C5 C1 C0
# -- Other presets --
# Honda Presets
Custom_preset_name: HND_1
Custom_preset_module: CC1101
# G2 G3 G4 D L0 L1 L2
Custom_preset_data: 02 0D 0B 06 08 32 07 04 14 00 13 02 12 04 11 36 10 69 15 32 18 18 19 16 1D 91 1C 00 1B 07 20 FB 22 10 21 56 00 00 C0 00 00 00 00 00 00 00
Custom_preset_name: HND_2
Custom_preset_module: CC1101
# G2 G3 G4 D L0 L1 L2
Custom_preset_data: 02 0D 0B 06 08 32 07 04 14 00 13 02 12 07 11 36 10 E9 15 32 18 18 19 16 1D 92 1C 40 1B 03 20 FB 22 10 21 56 00 00 C0 00 00 00 00 00 00 00

View file

@ -0,0 +1,29 @@
# to use manual settings and prevent them from being deleted on upgrade, rename *_user.example files to *_user
Filetype: Flipper SubGhz Setting File
Version: 1
# Add Standard frequencies for your region
#Add_standard_frequencies: true
# Default Frequency: used as default for "Read" and "Read Raw"
#Default_frequency: 433920000
# Frequencies used for "Read", "Read Raw" and "Frequency Analyzer"
#Frequency: 300000000
#Frequency: 310000000
#Frequency: 320000000
# Frequencies used for hopping mode (keep this list small or flipper will miss signal)
#Hopper_frequency: 300000000
#Hopper_frequency: 310000000
#Hopper_frequency: 310000000
# Custom preset
# format for CC1101 "Custom_preset_data:" XX YY XX YY .. 00 00 ZZ ZZ ZZ ZZ ZZ ZZ ZZ ZZ, where: XX-register, YY - register data, 00 00 - end load register, ZZ - 8 byte Pa table register
#Custom_preset_name: AM_1
#Custom_preset_module: CC1101
#Custom_preset_data: 02 0D 03 07 08 32 0B 06 14 00 13 00 12 30 11 32 10 17 18 18 19 18 1D 91 1C 00 1B 07 20 FB 22 11 21 B6 00 00 00 C0 00 00 00 00 00 00
#Custom_preset_name: AM_2
#Custom_preset_module: CC1101
#Custom_preset_data: 02 0D 03 07 08 32 0B 06 14 00 13 00 12 30 11 32 10 17 18 18 19 18 1D 91 1C 00 1B 07 20 FB 22 11 21 B6 00 00 00 C0 00 00 00 00 00 00

View file

@ -3044,7 +3044,7 @@ Function,+,subghz_setting_get_preset_data,uint8_t*,"SubGhzSetting*, size_t"
Function,+,subghz_setting_get_preset_data_by_name,uint8_t*,"SubGhzSetting*, const char*"
Function,+,subghz_setting_get_preset_data_size,size_t,"SubGhzSetting*, size_t"
Function,+,subghz_setting_get_preset_name,const char*,"SubGhzSetting*, size_t"
Function,+,subghz_setting_load,void,"SubGhzSetting*, const char*, _Bool"
Function,+,subghz_setting_load,void,"SubGhzSetting*, const char*"
Function,+,subghz_setting_load_custom_preset,_Bool,"SubGhzSetting*, const char*, FlipperFormat*"
Function,+,subghz_setting_set_default_frequency,void,"SubGhzSetting*, uint32_t"
Function,+,subghz_transmitter_alloc_init,SubGhzTransmitter*,"SubGhzEnvironment*, const char*"

1 entry status name type params
3044 Function + subghz_setting_get_preset_data_by_name uint8_t* SubGhzSetting*, const char*
3045 Function + subghz_setting_get_preset_data_size size_t SubGhzSetting*, size_t
3046 Function + subghz_setting_get_preset_name const char* SubGhzSetting*, size_t
3047 Function + subghz_setting_load void SubGhzSetting*, const char*, _Bool SubGhzSetting*, const char*
3048 Function + subghz_setting_load_custom_preset _Bool SubGhzSetting*, const char*, FlipperFormat*
3049 Function + subghz_setting_set_default_frequency void SubGhzSetting*, uint32_t
3050 Function + subghz_transmitter_alloc_init SubGhzTransmitter* SubGhzEnvironment*, const char*

View file

@ -18,26 +18,59 @@
static const uint32_t subghz_frequency_list[] = {
/* 300 - 348 */
300000000,
302757000,
303875000,
304250000,
307000000,
307500000,
307800000,
309000000,
310000000,
312000000,
312100000,
312200000,
313000000,
313850000,
314000000,
314350000,
314980000,
315000000,
318000000,
330000000,
345000000,
348000000,
/* 387 - 464 */
387000000,
390000000,
418000000,
433075000, /* LPD433 first */
433220000,
433420000,
433657070,
433889000,
433920000 | FREQUENCY_FLAG_DEFAULT, /* LPD433 mid */
434075000,
434176948,
434190000,
434390000,
434420000,
434620000,
434775000, /* LPD433 last channels */
438900000,
440175000,
464000000,
/* 779 - 928 */
779000000,
868350000,
868400000,
868800000,
868950000,
906400000,
915000000,
925000000,
928000000,
0,
};
@ -182,7 +215,7 @@ void subghz_setting_load_default(SubGhzSetting* instance) {
instance, subghz_frequency_list, subghz_hopper_frequency_list);
}
void subghz_setting_load(SubGhzSetting* instance, const char* file_path, bool not_skip_frequencies) {
void subghz_setting_load(SubGhzSetting* instance, const char* file_path) {
furi_assert(instance);
Storage* storage = furi_record_open(RECORD_STORAGE);
@ -215,67 +248,64 @@ void subghz_setting_load(SubGhzSetting* instance, const char* file_path, bool no
}
// Standard frequencies (optional)
if(not_skip_frequencies) {
temp_bool = true;
flipper_format_read_bool(fff_data_file, "Add_standard_frequencies", &temp_bool, 1);
if(!temp_bool) {
FURI_LOG_I(TAG, "Removing standard frequencies");
FrequencyList_reset(instance->frequencies);
FrequencyList_reset(instance->hopper_frequencies);
temp_bool = true;
flipper_format_read_bool(fff_data_file, "Add_standard_frequencies", &temp_bool, 1);
if(!temp_bool) {
FURI_LOG_I(TAG, "Removing standard frequencies");
FrequencyList_reset(instance->frequencies);
FrequencyList_reset(instance->hopper_frequencies);
} else {
FURI_LOG_I(TAG, "Keeping standard frequencies");
}
// Load frequencies
if(!flipper_format_rewind(fff_data_file)) {
FURI_LOG_E(TAG, "Rewind error");
break;
}
while(flipper_format_read_uint32(
fff_data_file, "Frequency", (uint32_t*)&temp_data32, 1)) {
if(furi_hal_subghz_is_frequency_valid(temp_data32)) {
FURI_LOG_I(TAG, "Frequency loaded %lu", temp_data32);
FrequencyList_push_back(instance->frequencies, temp_data32);
} else {
FURI_LOG_I(TAG, "Keeping standard frequencies");
FURI_LOG_E(TAG, "Frequency not supported %lu", temp_data32);
}
}
// Load frequencies
if(!flipper_format_rewind(fff_data_file)) {
FURI_LOG_E(TAG, "Rewind error");
break;
}
while(flipper_format_read_uint32(
fff_data_file, "Frequency", (uint32_t*)&temp_data32, 1)) {
if(furi_hal_subghz_is_frequency_valid(temp_data32)) {
FURI_LOG_I(TAG, "Frequency loaded %lu", temp_data32);
FrequencyList_push_back(instance->frequencies, temp_data32);
} else {
FURI_LOG_E(TAG, "Frequency not supported %lu", temp_data32);
}
// Load hopper frequencies
if(!flipper_format_rewind(fff_data_file)) {
FURI_LOG_E(TAG, "Rewind error");
break;
}
while(flipper_format_read_uint32(
fff_data_file, "Hopper_frequency", (uint32_t*)&temp_data32, 1)) {
if(furi_hal_subghz_is_frequency_valid(temp_data32)) {
FURI_LOG_I(TAG, "Hopper frequency loaded %lu", temp_data32);
FrequencyList_push_back(instance->hopper_frequencies, temp_data32);
} else {
FURI_LOG_E(TAG, "Hopper frequency not supported %lu", temp_data32);
}
}
// Load hopper frequencies
if(!flipper_format_rewind(fff_data_file)) {
FURI_LOG_E(TAG, "Rewind error");
break;
}
while(flipper_format_read_uint32(
fff_data_file, "Hopper_frequency", (uint32_t*)&temp_data32, 1)) {
if(furi_hal_subghz_is_frequency_valid(temp_data32)) {
FURI_LOG_I(TAG, "Hopper frequency loaded %lu", temp_data32);
FrequencyList_push_back(instance->hopper_frequencies, temp_data32);
} else {
FURI_LOG_E(TAG, "Hopper frequency not supported %lu", temp_data32);
}
}
// Default frequency (optional)
if(!flipper_format_rewind(fff_data_file)) {
FURI_LOG_E(TAG, "Rewind error");
break;
}
if(flipper_format_read_uint32(fff_data_file, "Default_frequency", &temp_data32, 1)) {
subghz_setting_set_default_frequency(instance, temp_data32);
}
// Default frequency (optional)
if(!flipper_format_rewind(fff_data_file)) {
FURI_LOG_E(TAG, "Rewind error");
break;
}
if(flipper_format_read_uint32(
fff_data_file, "Default_frequency", &temp_data32, 1)) {
subghz_setting_set_default_frequency(instance, temp_data32);
}
// custom preset (optional)
if(!flipper_format_rewind(fff_data_file)) {
FURI_LOG_E(TAG, "Rewind error");
break;
}
while(flipper_format_read_string(fff_data_file, "Custom_preset_name", temp_str)) {
FURI_LOG_I(TAG, "Custom preset loaded %s", furi_string_get_cstr(temp_str));
subghz_setting_load_custom_preset(
instance, furi_string_get_cstr(temp_str), fff_data_file);
}
// custom preset (optional)
if(!flipper_format_rewind(fff_data_file)) {
FURI_LOG_E(TAG, "Rewind error");
break;
}
while(flipper_format_read_string(fff_data_file, "Custom_preset_name", temp_str)) {
FURI_LOG_I(TAG, "Custom preset loaded %s", furi_string_get_cstr(temp_str));
subghz_setting_load_custom_preset(
instance, furi_string_get_cstr(temp_str), fff_data_file);
}
} while(false);

View file

@ -18,7 +18,7 @@ SubGhzSetting* subghz_setting_alloc(void);
void subghz_setting_free(SubGhzSetting* instance);
void subghz_setting_load(SubGhzSetting* instance, const char* file_path, bool not_skip_frequencies);
void subghz_setting_load(SubGhzSetting* instance, const char* file_path);
size_t subghz_setting_get_frequency_count(SubGhzSetting* instance);