mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-12 12:48:35 -07:00
big merge with fz main repo
This commit is contained in:
@@ -44,6 +44,6 @@ typedef enum {
|
||||
SubGhzCustomEventViewTransmitterSendStart,
|
||||
SubGhzCustomEventViewTransmitterSendStop,
|
||||
SubGhzCustomEventViewTransmitterError,
|
||||
|
||||
|
||||
SubGhzCustomEventByteInputDone,
|
||||
} SubGhzCustomEvent;
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
|
||||
#include <furi.h>
|
||||
|
||||
#include "../subghz_i.h"
|
||||
|
||||
#define TAG "SubghzFrequencyAnalyzerWorker"
|
||||
|
||||
#define SUBGHZ_FREQUENCY_ANALYZER_THRESHOLD -95.0f
|
||||
@@ -182,6 +180,9 @@ static int32_t subghz_frequency_analyzer_worker_thread(void* context) {
|
||||
osDelay(3);
|
||||
|
||||
rssi = furi_hal_subghz_get_rssi();
|
||||
|
||||
FURI_LOG_T(TAG, "#:%u:%f", frequency, (double)rssi);
|
||||
|
||||
if(frequency_rssi.rssi < rssi) {
|
||||
frequency_rssi.rssi = rssi;
|
||||
frequency_rssi.frequency = frequency;
|
||||
@@ -222,7 +223,8 @@ static int32_t subghz_frequency_analyzer_worker_thread(void* context) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
SubGhzFrequencyAnalyzerWorker* subghz_frequency_analyzer_worker_alloc() {
|
||||
SubGhzFrequencyAnalyzerWorker* subghz_frequency_analyzer_worker_alloc(void* context) {
|
||||
furi_assert(context);
|
||||
SubGhzFrequencyAnalyzerWorker* instance = malloc(sizeof(SubGhzFrequencyAnalyzerWorker));
|
||||
|
||||
instance->thread = furi_thread_alloc();
|
||||
@@ -231,8 +233,8 @@ SubGhzFrequencyAnalyzerWorker* subghz_frequency_analyzer_worker_alloc() {
|
||||
furi_thread_set_context(instance->thread, instance);
|
||||
furi_thread_set_callback(instance->thread, subghz_frequency_analyzer_worker_thread);
|
||||
|
||||
instance->setting = subghz_setting_alloc();
|
||||
subghz_setting_load(instance->setting, "/ext/subghz/assets/setting_frequency_analyzer_user");
|
||||
SubGhz* subghz = context;
|
||||
instance->setting = subghz->setting;
|
||||
return instance;
|
||||
}
|
||||
|
||||
@@ -240,7 +242,6 @@ void subghz_frequency_analyzer_worker_free(SubGhzFrequencyAnalyzerWorker* instan
|
||||
furi_assert(instance);
|
||||
|
||||
furi_thread_free(instance->thread);
|
||||
subghz_setting_free(instance->setting);
|
||||
free(instance);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <furi_hal.h>
|
||||
#include "../subghz_i.h"
|
||||
|
||||
typedef struct SubGhzFrequencyAnalyzerWorker SubGhzFrequencyAnalyzerWorker;
|
||||
|
||||
@@ -14,9 +15,10 @@ typedef struct {
|
||||
|
||||
/** Allocate SubGhzFrequencyAnalyzerWorker
|
||||
*
|
||||
* @param context SubGhz* context
|
||||
* @return SubGhzFrequencyAnalyzerWorker*
|
||||
*/
|
||||
SubGhzFrequencyAnalyzerWorker* subghz_frequency_analyzer_worker_alloc();
|
||||
SubGhzFrequencyAnalyzerWorker* subghz_frequency_analyzer_worker_alloc(void* context);
|
||||
|
||||
/** Free SubGhzFrequencyAnalyzerWorker
|
||||
*
|
||||
|
||||
@@ -49,7 +49,7 @@ bool subghz_scene_delete_on_event(void* context, SceneManagerEvent event) {
|
||||
SubGhz* subghz = context;
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubGhzCustomEventSceneDelete) {
|
||||
strncpy(subghz->file_path_tmp, subghz->file_path, SUBGHZ_MAX_LEN_NAME);
|
||||
string_set(subghz->file_path_tmp, subghz->file_path);
|
||||
if(subghz_delete_file(subghz)) {
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneDeleteSuccess);
|
||||
} else {
|
||||
|
||||
@@ -24,7 +24,7 @@ void subghz_scene_delete_raw_on_enter(void* context) {
|
||||
char delete_str[SUBGHZ_MAX_LEN_NAME + 16];
|
||||
string_t file_name;
|
||||
string_init(file_name);
|
||||
path_extract_filename_no_ext(subghz->file_path, file_name);
|
||||
path_extract_filename(subghz->file_path, file_name, true);
|
||||
snprintf(delete_str, sizeof(delete_str), "\e#Delete %s?\e#", string_get_cstr(file_name));
|
||||
string_clear(file_name);
|
||||
|
||||
@@ -61,7 +61,7 @@ bool subghz_scene_delete_raw_on_event(void* context, SceneManagerEvent event) {
|
||||
SubGhz* subghz = context;
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubGhzCustomEventSceneDeleteRAW) {
|
||||
strncpy(subghz->file_path_tmp, subghz->file_path, SUBGHZ_MAX_LEN_NAME);
|
||||
string_set(subghz->file_path_tmp, subghz->file_path);
|
||||
if(subghz_delete_file(subghz)) {
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneDeleteSuccess);
|
||||
} else {
|
||||
|
||||
@@ -45,7 +45,7 @@ bool subghz_scene_more_raw_on_event(void* context, SceneManagerEvent event) {
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneDeleteRAW);
|
||||
return true;
|
||||
} else if(event.event == SubmenuIndexEdit) {
|
||||
memset(subghz->file_path_tmp, 0, sizeof(subghz->file_path_tmp));
|
||||
string_reset(subghz->file_path_tmp);
|
||||
scene_manager_set_scene_state(
|
||||
subghz->scene_manager, SubGhzSceneMoreRAW, SubmenuIndexEdit);
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSaveName);
|
||||
|
||||
@@ -25,7 +25,7 @@ bool subghz_scene_read_raw_update_filename(SubGhz* subghz) {
|
||||
break;
|
||||
}
|
||||
|
||||
strncpy(subghz->file_path, string_get_cstr(temp_str), SUBGHZ_MAX_LEN_NAME);
|
||||
string_set(subghz->file_path, temp_str);
|
||||
|
||||
ret = true;
|
||||
} while(false);
|
||||
@@ -75,13 +75,13 @@ void subghz_scene_read_raw_on_enter(void* context) {
|
||||
subghz_read_raw_set_status(subghz->subghz_read_raw, SubGhzReadRAWStatusIDLE, "");
|
||||
break;
|
||||
case SubGhzRxKeyStateRAWLoad:
|
||||
path_extract_filename_no_ext(subghz->file_path, file_name);
|
||||
path_extract_filename(subghz->file_path, file_name, true);
|
||||
subghz_read_raw_set_status(
|
||||
subghz->subghz_read_raw, SubGhzReadRAWStatusLoadKeyTX, string_get_cstr(file_name));
|
||||
subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE;
|
||||
break;
|
||||
case SubGhzRxKeyStateRAWSave:
|
||||
path_extract_filename_no_ext(subghz->file_path, file_name);
|
||||
path_extract_filename(subghz->file_path, file_name, true);
|
||||
subghz_read_raw_set_status(
|
||||
subghz->subghz_read_raw, SubGhzReadRAWStatusSaveKey, string_get_cstr(file_name));
|
||||
subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE;
|
||||
@@ -171,7 +171,7 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
|
||||
case SubGhzCustomEventViewReadRAWErase:
|
||||
subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE;
|
||||
if(subghz_scene_read_raw_update_filename(subghz)) {
|
||||
strncpy(subghz->file_path_tmp, subghz->file_path, SUBGHZ_MAX_LEN_NAME);
|
||||
string_set(subghz->file_path_tmp, subghz->file_path);
|
||||
subghz_delete_file(subghz);
|
||||
}
|
||||
notification_message(subghz->notifications, &sequence_reset_rgb);
|
||||
@@ -281,7 +281,6 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
|
||||
, datetime.year, datetime.month, datetime.day
|
||||
, datetime.hour, datetime.minute
|
||||
);
|
||||
|
||||
if(subghz_protocol_raw_save_to_file_init(
|
||||
(SubGhzProtocolDecoderRAW*)subghz->txrx->decoder_result,
|
||||
strings[0],
|
||||
@@ -296,7 +295,7 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
|
||||
subghz->state_notifications = SubGhzNotificationStateRx;
|
||||
subghz->txrx->rx_key_state = SubGhzRxKeyStateAddKey;
|
||||
} else {
|
||||
string_set(subghz->error_str, "Function requires\nan SD card.");
|
||||
string_set_str(subghz->error_str, "Function requires\nan SD card.");
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,6 +84,7 @@ void subghz_scene_receiver_info_on_enter(void* context) {
|
||||
subghz_scene_receiver_info_callback,
|
||||
subghz);
|
||||
}
|
||||
// Removed static check
|
||||
if(((subghz->txrx->decoder_result->protocol->flag & SubGhzProtocolFlag_Send) ==
|
||||
SubGhzProtocolFlag_Send) &&
|
||||
subghz->txrx->decoder_result->protocol->encoder->deserialize) {
|
||||
@@ -157,6 +158,7 @@ bool subghz_scene_receiver_info_on_event(void* context, SceneManagerEvent event)
|
||||
if(!subghz_scene_receiver_info_update_parser(subghz)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if((subghz->txrx->decoder_result->protocol->flag & SubGhzProtocolFlag_Save) ==
|
||||
SubGhzProtocolFlag_Save) {
|
||||
subghz_file_name_clear(subghz);
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#include "../subghz_i.h"
|
||||
#include "m-string.h"
|
||||
#include "subghz/types.h"
|
||||
#include <lib/toolbox/random_name.h>
|
||||
#include "../helpers/subghz_custom_event.h"
|
||||
#include <lib/subghz/protocols/raw.h>
|
||||
@@ -20,45 +22,49 @@ void subghz_scene_save_name_on_enter(void* context) {
|
||||
bool dev_name_empty = false;
|
||||
|
||||
string_t file_name;
|
||||
string_t dir_name;
|
||||
string_init(file_name);
|
||||
string_init(dir_name);
|
||||
|
||||
if(!strcmp(subghz->file_path, "")) {
|
||||
if(!subghz_path_is_file(subghz->file_path)) {
|
||||
char file_name_buf[SUBGHZ_MAX_LEN_NAME] = {0};
|
||||
set_random_name(file_name_buf, SUBGHZ_MAX_LEN_NAME);
|
||||
string_set(file_name, file_name_buf);
|
||||
strncpy(subghz->file_dir, SUBGHZ_APP_FOLDER, SUBGHZ_MAX_LEN_NAME);
|
||||
string_set_str(file_name, file_name_buf);
|
||||
string_set_str(subghz->file_path, SUBGHZ_APP_FOLDER);
|
||||
//highlighting the entire filename by default
|
||||
dev_name_empty = true;
|
||||
} else {
|
||||
strncpy(subghz->file_path_tmp, subghz->file_path, SUBGHZ_MAX_LEN_NAME);
|
||||
path_extract_dirname(subghz->file_path, file_name);
|
||||
strncpy(subghz->file_dir, string_get_cstr(file_name), SUBGHZ_MAX_LEN_NAME);
|
||||
path_extract_filename_no_ext(subghz->file_path, file_name);
|
||||
string_set(subghz->file_path_tmp, subghz->file_path);
|
||||
path_extract_dirname(string_get_cstr(subghz->file_path), dir_name);
|
||||
path_extract_filename(subghz->file_path, file_name, true);
|
||||
if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneReadRAW) !=
|
||||
SubGhzCustomEventManagerNoSet) {
|
||||
subghz_get_next_name_file(subghz, SUBGHZ_MAX_LEN_NAME);
|
||||
path_extract_filename_no_ext(subghz->file_path, file_name);
|
||||
path_extract_filename(subghz->file_path, file_name, true);
|
||||
if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneReadRAW) ==
|
||||
SubGhzCustomEventManagerSetRAW) {
|
||||
dev_name_empty = true;
|
||||
}
|
||||
}
|
||||
string_set(subghz->file_path, dir_name);
|
||||
}
|
||||
strncpy(subghz->file_path, string_get_cstr(file_name), SUBGHZ_MAX_LEN_NAME);
|
||||
|
||||
strncpy(subghz->file_name_tmp, string_get_cstr(file_name), SUBGHZ_MAX_LEN_NAME);
|
||||
text_input_set_header_text(text_input, "Name signal");
|
||||
text_input_set_result_callback(
|
||||
text_input,
|
||||
subghz_scene_save_name_text_input_callback,
|
||||
subghz,
|
||||
subghz->file_path,
|
||||
subghz->file_name_tmp,
|
||||
MAX_TEXT_INPUT_LEN, // buffer size
|
||||
dev_name_empty);
|
||||
|
||||
ValidatorIsFile* validator_is_file =
|
||||
validator_is_file_alloc_init(subghz->file_dir, SUBGHZ_APP_EXTENSION, NULL);
|
||||
ValidatorIsFile* validator_is_file = validator_is_file_alloc_init(
|
||||
string_get_cstr(subghz->file_path), SUBGHZ_APP_EXTENSION, NULL);
|
||||
text_input_set_validator(text_input, validator_is_file_callback, validator_is_file);
|
||||
|
||||
string_clear(file_name);
|
||||
string_clear(dir_name);
|
||||
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdTextInput);
|
||||
}
|
||||
@@ -66,18 +72,15 @@ void subghz_scene_save_name_on_enter(void* context) {
|
||||
bool subghz_scene_save_name_on_event(void* context, SceneManagerEvent event) {
|
||||
SubGhz* subghz = context;
|
||||
if(event.type == SceneManagerEventTypeBack) {
|
||||
strncpy(subghz->file_path, subghz->file_path_tmp, SUBGHZ_MAX_LEN_NAME);
|
||||
string_set(subghz->file_path, subghz->file_path_tmp);
|
||||
scene_manager_previous_scene(subghz->scene_manager);
|
||||
return true;
|
||||
} else if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubGhzCustomEventSceneSaveName) {
|
||||
if(strcmp(subghz->file_path, "")) {
|
||||
string_t temp_str;
|
||||
string_init_printf(
|
||||
temp_str, "%s/%s%s", subghz->file_dir, subghz->file_path, SUBGHZ_APP_EXTENSION);
|
||||
strncpy(subghz->file_path, string_get_cstr(temp_str), SUBGHZ_MAX_LEN_NAME);
|
||||
string_clear(temp_str);
|
||||
if(strcmp(subghz->file_path_tmp, "")) {
|
||||
if(strcmp(subghz->file_name_tmp, "")) {
|
||||
string_cat_printf(
|
||||
subghz->file_path, "/%s%s", subghz->file_name_tmp, SUBGHZ_APP_EXTENSION);
|
||||
if(subghz_path_is_file(subghz->file_path_tmp)) {
|
||||
if(!subghz_rename_file(subghz)) {
|
||||
return false;
|
||||
}
|
||||
@@ -85,7 +88,7 @@ bool subghz_scene_save_name_on_event(void* context, SceneManagerEvent event) {
|
||||
if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneSetType) !=
|
||||
SubGhzCustomEventManagerNoSet) {
|
||||
subghz_save_protocol_to_file(
|
||||
subghz, subghz->txrx->fff_data, subghz->file_path);
|
||||
subghz, subghz->txrx->fff_data, string_get_cstr(subghz->file_path));
|
||||
scene_manager_set_scene_state(
|
||||
subghz->scene_manager,
|
||||
SubGhzSceneSetType,
|
||||
@@ -95,13 +98,14 @@ bool subghz_scene_save_name_on_event(void* context, SceneManagerEvent event) {
|
||||
subghz,
|
||||
subghz_history_get_raw_data(
|
||||
subghz->txrx->history, subghz->txrx->idx_menu_chosen),
|
||||
subghz->file_path);
|
||||
string_get_cstr(subghz->file_path));
|
||||
}
|
||||
}
|
||||
|
||||
if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneReadRAW) !=
|
||||
SubGhzCustomEventManagerNoSet) {
|
||||
subghz_protocol_raw_gen_fff_data(subghz->txrx->fff_data, subghz->file_path);
|
||||
subghz_protocol_raw_gen_fff_data(
|
||||
subghz->txrx->fff_data, string_get_cstr(subghz->file_path));
|
||||
scene_manager_set_scene_state(
|
||||
subghz->scene_manager, SubGhzSceneReadRAW, SubGhzCustomEventManagerNoSet);
|
||||
} else {
|
||||
@@ -111,7 +115,7 @@ bool subghz_scene_save_name_on_event(void* context, SceneManagerEvent event) {
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSaveSuccess);
|
||||
return true;
|
||||
} else {
|
||||
string_set(subghz->error_str, "No name file");
|
||||
string_set_str(subghz->error_str, "No name file");
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowErrorSub);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ bool subghz_scene_set_type_submenu_gen_data_protocol(
|
||||
subghz_receiver_search_decoder_base_by_name(subghz->txrx->receiver, protocol_name);
|
||||
|
||||
if(subghz->txrx->decoder_result == NULL) {
|
||||
string_set(subghz->error_str, "Protocol not found");
|
||||
string_set_str(subghz->error_str, "Protocol not found");
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowErrorSub);
|
||||
return false;
|
||||
}
|
||||
@@ -340,7 +340,7 @@ bool subghz_scene_set_type_on_event(void* context, SceneManagerEvent event) {
|
||||
}
|
||||
subghz_transmitter_free(subghz->txrx->transmitter);
|
||||
if(!generated_protocol) {
|
||||
string_set(
|
||||
string_set_str(
|
||||
subghz->error_str, "Function requires\nan SD card with\nfresh databases.");
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError);
|
||||
}
|
||||
@@ -364,12 +364,12 @@ bool subghz_scene_set_type_on_event(void* context, SceneManagerEvent event) {
|
||||
}
|
||||
subghz_transmitter_free(subghz->txrx->transmitter);
|
||||
if(!generated_protocol) {
|
||||
string_set(
|
||||
string_set_str(
|
||||
subghz->error_str, "Function requires\nan SD card with\nfresh databases.");
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError);
|
||||
}
|
||||
break;
|
||||
case SubmenuIndexLiftMaster_315_00:
|
||||
case SubmenuIndexLiftMaster_315_00:
|
||||
while(!subghz_protocol_secplus_v1_check_fixed(key)) {
|
||||
key = subghz_random_serial();
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ bool subghz_scene_transmitter_on_event(void* context, SceneManagerEvent event) {
|
||||
subghz->scene_manager, SubGhzSceneStart);
|
||||
return true;
|
||||
} else if(event.event == SubGhzCustomEventViewTransmitterError) {
|
||||
string_set(subghz->error_str, "Protocol not found");
|
||||
string_set_str(subghz->error_str, "Protocol not found");
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowErrorSub);
|
||||
}
|
||||
} else if(event.type == SceneManagerEventTypeTick) {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
/* Abandon hope, all ye who enter here. */
|
||||
|
||||
#include "m-string.h"
|
||||
#include "subghz/types.h"
|
||||
#include "subghz_i.h"
|
||||
#include <lib/toolbox/path.h>
|
||||
|
||||
@@ -24,6 +26,9 @@ void subghz_tick_event_callback(void* context) {
|
||||
SubGhz* subghz_alloc() {
|
||||
SubGhz* subghz = malloc(sizeof(SubGhz));
|
||||
|
||||
string_init(subghz->file_path);
|
||||
string_init(subghz->file_path_tmp);
|
||||
|
||||
// GUI
|
||||
subghz->gui = furi_record_open("gui");
|
||||
|
||||
@@ -144,6 +149,7 @@ SubGhz* subghz_alloc() {
|
||||
subghz->txrx->worker = subghz_worker_alloc();
|
||||
subghz->txrx->fff_data = flipper_format_string_alloc();
|
||||
subghz->txrx->secure_data = malloc(sizeof(SecureData));
|
||||
|
||||
subghz->txrx->environment = subghz_environment_alloc();
|
||||
subghz_environment_set_came_atomo_rainbow_table_file_name(
|
||||
subghz->txrx->environment, "/ext/subghz/assets/came_atomo");
|
||||
@@ -251,9 +257,9 @@ void subghz_free(SubGhz* subghz) {
|
||||
furi_record_close("notification");
|
||||
subghz->notifications = NULL;
|
||||
|
||||
// About birds
|
||||
furi_assert(subghz->file_path[SUBGHZ_MAX_LEN_NAME] == 0);
|
||||
furi_assert(subghz->file_path_tmp[SUBGHZ_MAX_LEN_NAME] == 0);
|
||||
// Path strings
|
||||
string_clear(subghz->file_path);
|
||||
string_clear(subghz->file_path_tmp);
|
||||
|
||||
// The rest
|
||||
free(subghz);
|
||||
@@ -270,7 +276,7 @@ int32_t subghz_app(void* p) {
|
||||
// Check argument and run corresponding scene
|
||||
if(p) {
|
||||
if(subghz_key_load(subghz, p)) {
|
||||
strncpy(subghz->file_path, p, SUBGHZ_MAX_LEN_NAME);
|
||||
string_set_str(subghz->file_path, p);
|
||||
|
||||
if((!strcmp(subghz->txrx->decoder_result->protocol->name, "RAW"))) {
|
||||
//Load Raw TX
|
||||
@@ -286,12 +292,13 @@ int32_t subghz_app(void* p) {
|
||||
view_dispatcher_stop(subghz->view_dispatcher);
|
||||
}
|
||||
} else {
|
||||
string_set_str(subghz->file_path, SUBGHZ_APP_FOLDER);
|
||||
if(load_database) {
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneStart);
|
||||
} else {
|
||||
scene_manager_set_scene_state(
|
||||
subghz->scene_manager, SubGhzSceneShowError, SubGhzCustomEventManagerSet);
|
||||
string_set(
|
||||
string_set_str(
|
||||
subghz->error_str,
|
||||
"No SD card or\ndatabase found.\nSome app function\nmay be reduced.");
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError);
|
||||
|
||||
@@ -303,7 +303,7 @@ void subghz_cli_command_decode_raw(Cli* cli, string_t args, void* context) {
|
||||
UNUSED(context);
|
||||
string_t file_name;
|
||||
string_init(file_name);
|
||||
string_set(file_name, "/any/subghz/test.sub");
|
||||
string_set_str(file_name, "/any/subghz/test.sub");
|
||||
|
||||
Storage* storage = furi_record_open("storage");
|
||||
FlipperFormat* fff_data_file = flipper_format_file_alloc(storage);
|
||||
|
||||
@@ -169,14 +169,14 @@ bool subghz_history_add_to_history(
|
||||
break;
|
||||
}
|
||||
if(!strcmp(string_get_cstr(instance->tmp_string), "KeeLoq")) {
|
||||
string_set(instance->tmp_string, "KL ");
|
||||
string_set_str(instance->tmp_string, "KL ");
|
||||
if(!flipper_format_read_string(item->flipper_string, "Manufacture", text)) {
|
||||
FURI_LOG_E(TAG, "Missing Protocol");
|
||||
break;
|
||||
}
|
||||
string_cat(instance->tmp_string, text);
|
||||
} else if(!strcmp(string_get_cstr(instance->tmp_string), "Star Line")) {
|
||||
string_set(instance->tmp_string, "SL ");
|
||||
string_set_str(instance->tmp_string, "SL ");
|
||||
if(!flipper_format_read_string(item->flipper_string, "Manufacture", text)) {
|
||||
FURI_LOG_E(TAG, "Missing Protocol");
|
||||
break;
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
#include "subghz_i.h"
|
||||
|
||||
#include "assets_icons.h"
|
||||
#include "m-string.h"
|
||||
#include "subghz/types.h"
|
||||
#include <math.h>
|
||||
#include <furi.h>
|
||||
#include <furi_hal.h>
|
||||
@@ -45,11 +48,11 @@ void subghz_get_frequency_modulation(SubGhz* subghz, string_t frequency, string_
|
||||
if(modulation != NULL) {
|
||||
if(subghz->txrx->preset == FuriHalSubGhzPresetOok650Async ||
|
||||
subghz->txrx->preset == FuriHalSubGhzPresetOok270Async) {
|
||||
string_set(modulation, "AM");
|
||||
string_set_str(modulation, "AM");
|
||||
} else if(
|
||||
subghz->txrx->preset == FuriHalSubGhzPreset2FSKDev238Async ||
|
||||
subghz->txrx->preset == FuriHalSubGhzPreset2FSKDev476Async) {
|
||||
string_set(modulation, "FM");
|
||||
string_set_str(modulation, "FM");
|
||||
} else {
|
||||
furi_crash("SugGhz: Modulation is incorrect.");
|
||||
}
|
||||
@@ -191,8 +194,9 @@ void subghz_tx_stop(SubGhz* subghz) {
|
||||
|
||||
//if protocol dynamic then we save the last upload
|
||||
if((subghz->txrx->decoder_result->protocol->type == SubGhzProtocolTypeDynamic) &&
|
||||
(strcmp(subghz->file_path, ""))) {
|
||||
subghz_save_protocol_to_file(subghz, subghz->txrx->fff_data, subghz->file_path);
|
||||
(subghz_path_is_file(subghz->file_path))) {
|
||||
subghz_save_protocol_to_file(
|
||||
subghz, subghz->txrx->fff_data, string_get_cstr(subghz->file_path));
|
||||
}
|
||||
subghz_idle(subghz);
|
||||
notification_message(subghz->notifications, &sequence_reset_red);
|
||||
@@ -334,10 +338,10 @@ bool subghz_get_next_name_file(SubGhz* subghz, uint8_t max_len) {
|
||||
|
||||
bool res = false;
|
||||
|
||||
if(strcmp(subghz->file_path, "")) {
|
||||
if(subghz_path_is_file(subghz->file_path)) {
|
||||
//get the name of the next free file
|
||||
path_extract_filename_no_ext(subghz->file_path, file_name);
|
||||
path_extract_dirname(subghz->file_path, file_path);
|
||||
path_extract_filename(subghz->file_path, file_name, true);
|
||||
path_extract_dirname(string_get_cstr(subghz->file_path), file_path);
|
||||
|
||||
storage_get_next_filename(
|
||||
storage,
|
||||
@@ -353,7 +357,7 @@ bool subghz_get_next_name_file(SubGhz* subghz, uint8_t max_len) {
|
||||
string_get_cstr(file_path),
|
||||
string_get_cstr(file_name),
|
||||
SUBGHZ_APP_EXTENSION);
|
||||
strncpy(subghz->file_path, string_get_cstr(temp_str), SUBGHZ_MAX_LEN_NAME);
|
||||
string_set(subghz->file_path, temp_str);
|
||||
res = true;
|
||||
}
|
||||
|
||||
@@ -413,19 +417,17 @@ bool subghz_load_protocol_from_file(SubGhz* subghz) {
|
||||
string_init(file_path);
|
||||
|
||||
// Input events and views are managed by file_select
|
||||
bool res = dialog_file_select_show(
|
||||
bool res = dialog_file_browser_show(
|
||||
subghz->dialogs,
|
||||
SUBGHZ_APP_FOLDER,
|
||||
SUBGHZ_APP_EXTENSION,
|
||||
subghz->file_path,
|
||||
sizeof(subghz->file_path),
|
||||
NULL);
|
||||
subghz->file_path,
|
||||
SUBGHZ_APP_EXTENSION,
|
||||
true,
|
||||
&I_sub1_10px,
|
||||
true);
|
||||
|
||||
if(res) {
|
||||
string_printf(
|
||||
file_path, "%s/%s%s", SUBGHZ_APP_FOLDER, subghz->file_path, SUBGHZ_APP_EXTENSION);
|
||||
strncpy(subghz->file_path, string_get_cstr(file_path), SUBGHZ_MAX_LEN_NAME);
|
||||
res = subghz_key_load(subghz, subghz->file_path);
|
||||
res = subghz_key_load(subghz, string_get_cstr(subghz->file_path));
|
||||
}
|
||||
|
||||
string_clear(file_path);
|
||||
@@ -439,9 +441,9 @@ bool subghz_rename_file(SubGhz* subghz) {
|
||||
|
||||
Storage* storage = furi_record_open("storage");
|
||||
|
||||
if(strcmp(subghz->file_path_tmp, subghz->file_path)) {
|
||||
FS_Error fs_result =
|
||||
storage_common_rename(storage, subghz->file_path_tmp, subghz->file_path);
|
||||
if(string_cmp(subghz->file_path_tmp, subghz->file_path)) {
|
||||
FS_Error fs_result = storage_common_rename(
|
||||
storage, string_get_cstr(subghz->file_path_tmp), string_get_cstr(subghz->file_path));
|
||||
|
||||
if(fs_result != FSE_OK) {
|
||||
dialog_message_show_storage_error(subghz->dialogs, "Cannot rename\n file/directory");
|
||||
@@ -457,7 +459,7 @@ bool subghz_delete_file(SubGhz* subghz) {
|
||||
furi_assert(subghz);
|
||||
|
||||
Storage* storage = furi_record_open("storage");
|
||||
bool result = storage_simply_remove(storage, subghz->file_path_tmp);
|
||||
bool result = storage_simply_remove(storage, string_get_cstr(subghz->file_path_tmp));
|
||||
furi_record_close("storage");
|
||||
|
||||
subghz_file_name_clear(subghz);
|
||||
@@ -467,8 +469,12 @@ bool subghz_delete_file(SubGhz* subghz) {
|
||||
|
||||
void subghz_file_name_clear(SubGhz* subghz) {
|
||||
furi_assert(subghz);
|
||||
memset(subghz->file_path, 0, sizeof(subghz->file_path));
|
||||
memset(subghz->file_path_tmp, 0, sizeof(subghz->file_path_tmp));
|
||||
string_set_str(subghz->file_path, SUBGHZ_APP_FOLDER);
|
||||
string_reset(subghz->file_path_tmp);
|
||||
}
|
||||
|
||||
bool subghz_path_is_file(string_t path) {
|
||||
return string_end_with_str_p(path, SUBGHZ_APP_EXTENSION);
|
||||
}
|
||||
|
||||
uint32_t subghz_random_serial(void) {
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
#include <gui/modules/variable_item_list.h>
|
||||
#include <lib/toolbox/path.h>
|
||||
|
||||
#define SUBGHZ_MAX_LEN_NAME 250
|
||||
#define SUBGHZ_MAX_LEN_NAME 64
|
||||
|
||||
/** SubGhzNotification state */
|
||||
typedef enum {
|
||||
@@ -128,10 +128,9 @@ struct SubGhz {
|
||||
ByteInput* byte_input;
|
||||
Widget* widget;
|
||||
DialogsApp* dialogs;
|
||||
char file_path[SUBGHZ_MAX_LEN_NAME + 1];
|
||||
char file_path_tmp[SUBGHZ_MAX_LEN_NAME + 1];
|
||||
//ToDo you can get rid of it, you need to refactor text input to return the path to the folder
|
||||
char file_dir[SUBGHZ_MAX_LEN_NAME + 1];
|
||||
string_t file_path;
|
||||
string_t file_path_tmp;
|
||||
char file_name_tmp[SUBGHZ_MAX_LEN_NAME];
|
||||
SubGhzNotificationState state_notifications;
|
||||
|
||||
SubGhzViewReceiver* subghz_receiver;
|
||||
@@ -183,5 +182,6 @@ bool subghz_load_protocol_from_file(SubGhz* subghz);
|
||||
bool subghz_rename_file(SubGhz* subghz);
|
||||
bool subghz_delete_file(SubGhz* subghz);
|
||||
void subghz_file_name_clear(SubGhz* subghz);
|
||||
bool subghz_path_is_file(string_t path);
|
||||
uint32_t subghz_random_serial(void);
|
||||
void subghz_hopper_update(SubGhz* subghz);
|
||||
|
||||
@@ -7,16 +7,14 @@
|
||||
|
||||
#define TAG "SubGhzSetting"
|
||||
|
||||
#define SUBGHZ_SETTING_FILE_VERSION 1
|
||||
#define SUBGHZ_SETTING_FILE_TYPE "Flipper SubGhz Setting File"
|
||||
#define SUBGHZ_SETTING_FILE_VERSION 1
|
||||
|
||||
typedef enum {
|
||||
SubGhzSettingStateNoLoad = 0,
|
||||
SubGhzSettingStateLoadFrequencyDefault,
|
||||
SubGhzSettingStateOkLoad,
|
||||
} SubGhzSettingState;
|
||||
#define FREQUENCY_FLAG_DEFAULT (1 << 31)
|
||||
#define FREQUENCY_MASK (0xFFFFFFFF ^ FREQUENCY_FLAG_DEFAULT)
|
||||
|
||||
static const uint32_t subghz_frequencies[] = {
|
||||
/* Default */
|
||||
static const uint32_t subghz_frequency_list[] = {
|
||||
/* 300 - 348 */
|
||||
300000000,
|
||||
302757000, /* FCC ID N6U303NTX */
|
||||
@@ -36,8 +34,7 @@ static const uint32_t subghz_frequencies[] = {
|
||||
433220000, /* 2016-2020 Honda */
|
||||
433420000,
|
||||
433889000, /* ROGUE? */
|
||||
|
||||
433920000, /* LPD433 mid */
|
||||
433920000 | FREQUENCY_FLAG_DEFAULT, /* LPD433 mid */
|
||||
434420000,
|
||||
434775000, /* LPD433 last channels */
|
||||
438900000,
|
||||
@@ -51,7 +48,9 @@ static const uint32_t subghz_frequencies[] = {
|
||||
928000000,
|
||||
0,
|
||||
};
|
||||
static const uint32_t subghz_hopper_frequencies[] = {
|
||||
|
||||
static const uint32_t subghz_hopper_frequency_list[] = {
|
||||
310000000,
|
||||
315000000,
|
||||
318000000,
|
||||
390000000,
|
||||
@@ -59,13 +58,14 @@ static const uint32_t subghz_hopper_frequencies[] = {
|
||||
868350000,
|
||||
0,
|
||||
};
|
||||
static const uint32_t subghz_frequency_default_index = 9;
|
||||
|
||||
static const uint32_t subghz_frequencies_region_eu_ru[] = {
|
||||
/* Europe and Russia */
|
||||
static const uint32_t subghz_frequency_list_region_eu_ru[] = {
|
||||
/* 300 - 348 */
|
||||
300000000,
|
||||
303875000,
|
||||
304250000,
|
||||
310000000,
|
||||
315000000,
|
||||
318000000,
|
||||
|
||||
@@ -74,7 +74,7 @@ static const uint32_t subghz_frequencies_region_eu_ru[] = {
|
||||
418000000,
|
||||
433075000, /* LPD433 first */
|
||||
433420000,
|
||||
433920000, /* LPD433 mid */
|
||||
433920000 | FREQUENCY_FLAG_DEFAULT, /* LPD433 mid */
|
||||
434420000,
|
||||
434775000, /* LPD433 last channels */
|
||||
438900000,
|
||||
@@ -85,7 +85,8 @@ static const uint32_t subghz_frequencies_region_eu_ru[] = {
|
||||
925000000,
|
||||
0,
|
||||
};
|
||||
static const uint32_t subghz_hopper_frequencies_region_eu_ru[] = {
|
||||
static const uint32_t subghz_hopper_frequency_list_region_eu_ru[] = {
|
||||
310000000,
|
||||
315000000,
|
||||
318000000,
|
||||
390000000,
|
||||
@@ -93,13 +94,14 @@ static const uint32_t subghz_hopper_frequencies_region_eu_ru[] = {
|
||||
868350000,
|
||||
0,
|
||||
};
|
||||
static const uint32_t subghz_frequency_default_index_region_eu_ru = 9;
|
||||
|
||||
static const uint32_t subghz_frequencies_region_us_ca_au[] = {
|
||||
/* Region 0 */
|
||||
static const uint32_t subghz_frequency_list_region_us_ca_au[] = {
|
||||
/* 300 - 348 */
|
||||
300000000,
|
||||
303875000,
|
||||
304250000,
|
||||
310000000,
|
||||
315000000,
|
||||
318000000,
|
||||
|
||||
@@ -108,7 +110,7 @@ static const uint32_t subghz_frequencies_region_us_ca_au[] = {
|
||||
418000000,
|
||||
433075000, /* LPD433 first */
|
||||
433420000,
|
||||
433920000, /* LPD433 mid */
|
||||
433920000 | FREQUENCY_FLAG_DEFAULT, /* LPD433 mid */
|
||||
434420000,
|
||||
434775000, /* LPD433 last channels */
|
||||
438900000,
|
||||
@@ -119,7 +121,8 @@ static const uint32_t subghz_frequencies_region_us_ca_au[] = {
|
||||
925000000,
|
||||
0,
|
||||
};
|
||||
static const uint32_t subghz_hopper_frequencies_region_us_ca_au[] = {
|
||||
static const uint32_t subghz_hopper_frequency_list_region_us_ca_au[] = {
|
||||
310000000,
|
||||
315000000,
|
||||
318000000,
|
||||
390000000,
|
||||
@@ -127,13 +130,13 @@ static const uint32_t subghz_hopper_frequencies_region_us_ca_au[] = {
|
||||
868350000,
|
||||
0,
|
||||
};
|
||||
static const uint32_t subghz_frequency_default_index_region_us_ca_au = 9;
|
||||
|
||||
static const uint32_t subghz_frequencies_region_jp[] = {
|
||||
static const uint32_t subghz_frequency_list_region_jp[] = {
|
||||
/* 300 - 348 */
|
||||
300000000,
|
||||
303875000,
|
||||
304250000,
|
||||
310000000,
|
||||
315000000,
|
||||
318000000,
|
||||
|
||||
@@ -142,7 +145,7 @@ static const uint32_t subghz_frequencies_region_jp[] = {
|
||||
418000000,
|
||||
433075000, /* LPD433 first */
|
||||
433420000,
|
||||
433920000, /* LPD433 mid */
|
||||
433920000 | FREQUENCY_FLAG_DEFAULT, /* LPD433 mid */
|
||||
434420000,
|
||||
434775000, /* LPD433 last channels */
|
||||
438900000,
|
||||
@@ -153,7 +156,8 @@ static const uint32_t subghz_frequencies_region_jp[] = {
|
||||
925000000,
|
||||
0,
|
||||
};
|
||||
static const uint32_t subghz_hopper_frequencies_region_jp[] = {
|
||||
static const uint32_t subghz_hopper_frequency_list_region_jp[] = {
|
||||
310000000,
|
||||
315000000,
|
||||
318000000,
|
||||
390000000,
|
||||
@@ -161,72 +165,68 @@ static const uint32_t subghz_hopper_frequencies_region_jp[] = {
|
||||
868350000,
|
||||
0,
|
||||
};
|
||||
static const uint32_t subghz_frequency_default_index_region_jp = 9;
|
||||
|
||||
LIST_DEF(FrequenciesList, uint32_t)
|
||||
LIST_DEF(FrequencyList, uint32_t)
|
||||
|
||||
#define M_OPL_FrequencyList_t() LIST_OPLIST(FrequencyList)
|
||||
|
||||
struct SubGhzSetting {
|
||||
FrequenciesList_t frequencies;
|
||||
FrequenciesList_t hopper_frequencies;
|
||||
size_t frequencies_count;
|
||||
size_t hopper_frequencies_count;
|
||||
uint32_t frequency_default_index;
|
||||
FrequencyList_t frequencies;
|
||||
FrequencyList_t hopper_frequencies;
|
||||
};
|
||||
|
||||
SubGhzSetting* subghz_setting_alloc(void) {
|
||||
SubGhzSetting* instance = malloc(sizeof(SubGhzSetting));
|
||||
FrequenciesList_init(instance->frequencies);
|
||||
FrequenciesList_init(instance->hopper_frequencies);
|
||||
FrequencyList_init(instance->frequencies);
|
||||
FrequencyList_init(instance->hopper_frequencies);
|
||||
return instance;
|
||||
}
|
||||
|
||||
void subghz_setting_free(SubGhzSetting* instance) {
|
||||
furi_assert(instance);
|
||||
FrequenciesList_clear(instance->frequencies);
|
||||
FrequenciesList_clear(instance->hopper_frequencies);
|
||||
FrequencyList_clear(instance->frequencies);
|
||||
FrequencyList_clear(instance->hopper_frequencies);
|
||||
free(instance);
|
||||
}
|
||||
|
||||
void subghz_setting_load_default(
|
||||
static void subghz_setting_load_default_region(
|
||||
SubGhzSetting* instance,
|
||||
const uint32_t frequencies[],
|
||||
const uint32_t hopper_frequencies[],
|
||||
const uint32_t frequency_default_index) {
|
||||
const uint32_t hopper_frequencies[]) {
|
||||
furi_assert(instance);
|
||||
size_t i = 0;
|
||||
FrequenciesList_clear(instance->frequencies);
|
||||
FrequenciesList_clear(instance->hopper_frequencies);
|
||||
i = 0;
|
||||
while(frequencies[i]) {
|
||||
FrequenciesList_push_back(instance->frequencies, frequencies[i]);
|
||||
i++;
|
||||
}
|
||||
instance->frequencies_count = i;
|
||||
|
||||
i = 0;
|
||||
while(hopper_frequencies[i]) {
|
||||
FrequenciesList_push_back(instance->hopper_frequencies, hopper_frequencies[i]);
|
||||
i++;
|
||||
}
|
||||
instance->hopper_frequencies_count = i;
|
||||
FrequencyList_reset(instance->frequencies);
|
||||
FrequencyList_reset(instance->hopper_frequencies);
|
||||
|
||||
instance->frequency_default_index = frequency_default_index;
|
||||
while(*frequencies) {
|
||||
FrequencyList_push_back(instance->frequencies, *frequencies);
|
||||
frequencies++;
|
||||
}
|
||||
|
||||
while(*hopper_frequencies) {
|
||||
FrequencyList_push_back(instance->hopper_frequencies, *hopper_frequencies);
|
||||
hopper_frequencies++;
|
||||
}
|
||||
}
|
||||
|
||||
// Region check removed
|
||||
void subghz_setting_load_default(SubGhzSetting* instance) {
|
||||
subghz_setting_load_default_region(
|
||||
instance, subghz_frequency_list, subghz_hopper_frequency_list);
|
||||
}
|
||||
|
||||
void subghz_setting_load(SubGhzSetting* instance, const char* file_path) {
|
||||
furi_assert(instance);
|
||||
|
||||
FrequenciesList_clear(instance->frequencies);
|
||||
FrequenciesList_clear(instance->hopper_frequencies);
|
||||
|
||||
Storage* storage = furi_record_open("storage");
|
||||
FlipperFormat* fff_data_file = flipper_format_file_alloc(storage);
|
||||
|
||||
string_t temp_str;
|
||||
string_init(temp_str);
|
||||
uint32_t temp_data32;
|
||||
SubGhzSettingState loading = SubGhzSettingStateNoLoad;
|
||||
uint16_t i = 0;
|
||||
bool temp_bool;
|
||||
|
||||
subghz_setting_load_default(instance);
|
||||
|
||||
if(file_path) {
|
||||
do {
|
||||
@@ -247,63 +247,60 @@ void subghz_setting_load(SubGhzSetting* instance, const char* file_path) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Standard frequencies (optional)
|
||||
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;
|
||||
}
|
||||
i = 0;
|
||||
while(flipper_format_read_uint32(
|
||||
fff_data_file, "Frequency", (uint32_t*)&temp_data32, 1)) {
|
||||
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);
|
||||
FrequenciesList_push_back(instance->frequencies, temp_data32);
|
||||
i++;
|
||||
FrequencyList_push_back(instance->frequencies, temp_data32);
|
||||
} else {
|
||||
FURI_LOG_E(TAG, "Frequency not supported %lu", temp_data32);
|
||||
}
|
||||
}
|
||||
instance->frequencies_count = i;
|
||||
|
||||
// Load hopper frequencies
|
||||
if(!flipper_format_rewind(fff_data_file)) {
|
||||
FURI_LOG_E(TAG, "Rewind error");
|
||||
break;
|
||||
}
|
||||
i = 0;
|
||||
while(flipper_format_read_uint32(
|
||||
fff_data_file, "Hopper_frequency", (uint32_t*)&temp_data32, 1)) {
|
||||
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);
|
||||
FrequenciesList_push_back(instance->hopper_frequencies, temp_data32);
|
||||
i++;
|
||||
FrequencyList_push_back(instance->hopper_frequencies, temp_data32);
|
||||
} else {
|
||||
FURI_LOG_E(TAG, "Hopper frequency not supported %lu", temp_data32);
|
||||
}
|
||||
}
|
||||
instance->hopper_frequencies_count = i;
|
||||
|
||||
// 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, "Frequency_default", (uint32_t*)&temp_data32, 1)) {
|
||||
FURI_LOG_E(TAG, "Frequency default missing");
|
||||
break;
|
||||
}
|
||||
|
||||
for(i = 0; i < instance->frequencies_count; i++) {
|
||||
if(subghz_setting_get_frequency(instance, i) == temp_data32) {
|
||||
instance->frequency_default_index = i;
|
||||
FURI_LOG_I(TAG, "Frequency default index %lu", i);
|
||||
loading = SubGhzSettingStateLoadFrequencyDefault;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(loading == SubGhzSettingStateLoadFrequencyDefault) {
|
||||
loading = SubGhzSettingStateOkLoad;
|
||||
} else {
|
||||
FURI_LOG_E(TAG, "Frequency default index missing");
|
||||
if(flipper_format_read_uint32(fff_data_file, "default_frequency", &temp_data32, 1)) {
|
||||
for
|
||||
M_EACH(frequency, instance->frequencies, FrequencyList_t) {
|
||||
*frequency &= FREQUENCY_MASK;
|
||||
if(*frequency == temp_data32) {
|
||||
*frequency |= FREQUENCY_FLAG_DEFAULT;
|
||||
}
|
||||
}
|
||||
}
|
||||
} while(false);
|
||||
}
|
||||
@@ -312,67 +309,56 @@ void subghz_setting_load(SubGhzSetting* instance, const char* file_path) {
|
||||
flipper_format_free(fff_data_file);
|
||||
furi_record_close("storage");
|
||||
|
||||
if(loading != SubGhzSettingStateOkLoad) {
|
||||
switch(furi_hal_version_get_hw_region()) {
|
||||
case FuriHalVersionRegionEuRu:
|
||||
subghz_setting_load_default(
|
||||
instance,
|
||||
subghz_frequencies_region_eu_ru,
|
||||
subghz_hopper_frequencies_region_eu_ru,
|
||||
subghz_frequency_default_index_region_eu_ru);
|
||||
break;
|
||||
case FuriHalVersionRegionUsCaAu:
|
||||
subghz_setting_load_default(
|
||||
instance,
|
||||
subghz_frequencies_region_us_ca_au,
|
||||
subghz_hopper_frequencies_region_us_ca_au,
|
||||
subghz_frequency_default_index_region_us_ca_au);
|
||||
break;
|
||||
case FuriHalVersionRegionJp:
|
||||
subghz_setting_load_default(
|
||||
instance,
|
||||
subghz_frequencies_region_jp,
|
||||
subghz_hopper_frequencies_region_jp,
|
||||
subghz_frequency_default_index_region_jp);
|
||||
break;
|
||||
|
||||
default:
|
||||
subghz_setting_load_default(
|
||||
instance,
|
||||
subghz_frequencies,
|
||||
subghz_hopper_frequencies,
|
||||
subghz_frequency_default_index);
|
||||
break;
|
||||
}
|
||||
if(!FrequencyList_size(instance->frequencies) ||
|
||||
!FrequencyList_size(instance->hopper_frequencies)) {
|
||||
FURI_LOG_E(TAG, "Error loading user settings, loading default settings");
|
||||
subghz_setting_load_default(instance);
|
||||
}
|
||||
}
|
||||
|
||||
size_t subghz_setting_get_frequency_count(SubGhzSetting* instance) {
|
||||
furi_assert(instance);
|
||||
return instance->frequencies_count;
|
||||
return FrequencyList_size(instance->frequencies);
|
||||
}
|
||||
|
||||
size_t subghz_setting_get_hopper_frequency_count(SubGhzSetting* instance) {
|
||||
furi_assert(instance);
|
||||
return instance->hopper_frequencies_count;
|
||||
return FrequencyList_size(instance->hopper_frequencies);
|
||||
}
|
||||
|
||||
uint32_t subghz_setting_get_frequency(SubGhzSetting* instance, size_t idx) {
|
||||
furi_assert(instance);
|
||||
return *FrequenciesList_get(instance->frequencies, idx);
|
||||
uint32_t* ret = FrequencyList_get(instance->frequencies, idx);
|
||||
if(ret) {
|
||||
return (*ret) & FREQUENCY_MASK;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t subghz_setting_get_hopper_frequency(SubGhzSetting* instance, size_t idx) {
|
||||
furi_assert(instance);
|
||||
return *FrequenciesList_get(instance->hopper_frequencies, idx);
|
||||
uint32_t* ret = FrequencyList_get(instance->hopper_frequencies, idx);
|
||||
if(ret) {
|
||||
return *ret;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t subghz_setting_get_frequency_default_index(SubGhzSetting* instance) {
|
||||
furi_assert(instance);
|
||||
return instance->frequency_default_index;
|
||||
for(size_t i = 0; i < FrequencyList_size(instance->frequencies); i++) {
|
||||
uint32_t frequency = *FrequencyList_get(instance->frequencies, i);
|
||||
if(frequency & FREQUENCY_FLAG_DEFAULT) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t subghz_setting_get_default_frequency(SubGhzSetting* instance) {
|
||||
furi_assert(instance);
|
||||
return *FrequenciesList_get(instance->frequencies, instance->frequency_default_index);
|
||||
return subghz_setting_get_frequency(
|
||||
instance, subghz_setting_get_frequency_default_index(instance));
|
||||
}
|
||||
|
||||
@@ -111,9 +111,9 @@ void subghz_view_receiver_add_data_statusbar(
|
||||
furi_assert(subghz_receiver);
|
||||
with_view_model(
|
||||
subghz_receiver->view, (SubGhzViewReceiverModel * model) {
|
||||
string_set(model->frequency_str, frequency_str);
|
||||
string_set(model->preset_str, preset_str);
|
||||
string_set(model->history_stat_str, history_stat_str);
|
||||
string_set_str(model->frequency_str, frequency_str);
|
||||
string_set_str(model->preset_str, preset_str);
|
||||
string_set_str(model->history_stat_str, history_stat_str);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ void subghz_frequency_analyzer_enter(void* context) {
|
||||
SubGhzFrequencyAnalyzer* instance = context;
|
||||
|
||||
//Start worker
|
||||
instance->worker = subghz_frequency_analyzer_worker_alloc();
|
||||
instance->worker = subghz_frequency_analyzer_worker_alloc(instance->context);
|
||||
|
||||
subghz_frequency_analyzer_worker_set_pair_callback(
|
||||
instance->worker,
|
||||
|
||||
@@ -46,8 +46,8 @@ void subghz_read_raw_add_data_statusbar(
|
||||
furi_assert(instance);
|
||||
with_view_model(
|
||||
instance->view, (SubGhzReadRAWModel * model) {
|
||||
string_set(model->frequency_str, frequency_str);
|
||||
string_set(model->preset_str, preset_str);
|
||||
string_set_str(model->frequency_str, frequency_str);
|
||||
string_set_str(model->preset_str, preset_str);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
@@ -372,7 +372,7 @@ bool subghz_read_raw_input(InputEvent* event, void* context) {
|
||||
model->satus = SubGhzReadRAWStatusStart;
|
||||
model->rssi_history_end = false;
|
||||
model->ind_write = 0;
|
||||
string_set(model->sample_write, "0 spl.");
|
||||
string_set_str(model->sample_write, "0 spl.");
|
||||
string_reset(model->file_name);
|
||||
instance->callback(SubGhzCustomEventViewReadRAWErase, instance->context);
|
||||
}
|
||||
@@ -424,7 +424,7 @@ void subghz_read_raw_set_status(
|
||||
model->rssi_history_end = false;
|
||||
model->ind_write = 0;
|
||||
string_reset(model->file_name);
|
||||
string_set(model->sample_write, "0 spl.");
|
||||
string_set_str(model->sample_write, "0 spl.");
|
||||
return true;
|
||||
});
|
||||
break;
|
||||
@@ -441,8 +441,8 @@ void subghz_read_raw_set_status(
|
||||
model->satus = SubGhzReadRAWStatusLoadKeyIDLE;
|
||||
model->rssi_history_end = false;
|
||||
model->ind_write = 0;
|
||||
string_set(model->file_name, file_name);
|
||||
string_set(model->sample_write, "RAW");
|
||||
string_set_str(model->file_name, file_name);
|
||||
string_set_str(model->sample_write, "RAW");
|
||||
return true;
|
||||
});
|
||||
break;
|
||||
@@ -451,8 +451,8 @@ void subghz_read_raw_set_status(
|
||||
instance->view, (SubGhzReadRAWModel * model) {
|
||||
model->satus = SubGhzReadRAWStatusLoadKeyIDLE;
|
||||
if(!model->ind_write) {
|
||||
string_set(model->file_name, file_name);
|
||||
string_set(model->sample_write, "RAW");
|
||||
string_set_str(model->file_name, file_name);
|
||||
string_set_str(model->sample_write, "RAW");
|
||||
} else {
|
||||
string_reset(model->file_name);
|
||||
}
|
||||
|
||||
@@ -36,9 +36,9 @@ void subghz_view_transmitter_add_data_to_show(
|
||||
furi_assert(subghz_transmitter);
|
||||
with_view_model(
|
||||
subghz_transmitter->view, (SubGhzViewTransmitterModel * model) {
|
||||
string_set(model->key_str, key_str);
|
||||
string_set(model->frequency_str, frequency_str);
|
||||
string_set(model->preset_str, preset_str);
|
||||
string_set_str(model->key_str, key_str);
|
||||
string_set_str(model->frequency_str, frequency_str);
|
||||
string_set_str(model->preset_str, preset_str);
|
||||
model->show_button = show_button;
|
||||
return true;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user