Merge branch 'UNLEASHED' into 420

This commit is contained in:
RogueMaster
2022-10-03 13:01:35 -04:00
25 changed files with 609 additions and 332 deletions

View File

@@ -86,3 +86,5 @@ typedef enum {
SubGhzViewReceiverModeLive, SubGhzViewReceiverModeLive,
SubGhzViewReceiverModeFile, SubGhzViewReceiverModeFile,
} SubGhzViewReceiverMode; } SubGhzViewReceiverMode;
#define SUBGHZ_HISTORY_REMOVE_SAVED_ITEMS 1

View File

@@ -13,9 +13,11 @@ ADD_SCENE(subghz, saved_menu, SavedMenu)
ADD_SCENE(subghz, delete, Delete) ADD_SCENE(subghz, delete, Delete)
ADD_SCENE(subghz, delete_success, DeleteSuccess) ADD_SCENE(subghz, delete_success, DeleteSuccess)
ADD_SCENE(subghz, test, Test) ADD_SCENE(subghz, test, Test)
ADD_SCENE(subghz, test_static, TestStatic)
ADD_SCENE(subghz, test_carrier, TestCarrier) ADD_SCENE(subghz, test_carrier, TestCarrier)
#if FURI_DEBUG
ADD_SCENE(subghz, test_static, TestStatic)
ADD_SCENE(subghz, test_packet, TestPacket) ADD_SCENE(subghz, test_packet, TestPacket)
#endif
ADD_SCENE(subghz, set_type, SetType) ADD_SCENE(subghz, set_type, SetType)
ADD_SCENE(subghz, set_fix_faac_868, SetFixFaac868) ADD_SCENE(subghz, set_fix_faac_868, SetFixFaac868)
ADD_SCENE(subghz, set_cnt_faac_868, SetCntFaac868) ADD_SCENE(subghz, set_cnt_faac_868, SetCntFaac868)

View File

@@ -31,7 +31,7 @@ bool subghz_scene_frequency_analyzer_on_event(void* context, SceneManagerEvent e
return true; return true;
} else if(event.event == SubGhzCustomEventViewReceiverUnlock) { } else if(event.event == SubGhzCustomEventViewReceiverUnlock) {
// Don't need to save, we already saved on short event // Don't need to save, we already saved on short event
#if FURI_DEBUG #ifdef FURI_DEBUG
FURI_LOG_W(TAG, "Goto next scene!"); FURI_LOG_W(TAG, "Goto next scene!");
#endif #endif
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneReceiver); scene_manager_next_scene(subghz->scene_manager, SubGhzSceneReceiver);

View File

@@ -135,12 +135,22 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneNeedSaving); scene_manager_next_scene(subghz->scene_manager, SubGhzSceneNeedSaving);
} else { } else {
//Restore default setting //Restore default setting
if(subghz->raw_send_only) {
subghz_preset_init( subghz_preset_init(
subghz, subghz,
subghz_setting_get_preset_name(subghz->setting, subghz->last_settings->preset), "AM650",
subghz_setting_get_default_frequency(subghz->setting),
NULL,
0);
} else {
subghz_preset_init(
subghz,
subghz_setting_get_preset_name(
subghz->setting, subghz->last_settings->preset),
subghz->last_settings->frequency, subghz->last_settings->frequency,
NULL, NULL,
0); 0);
}
if(!scene_manager_search_and_switch_to_previous_scene( if(!scene_manager_search_and_switch_to_previous_scene(
subghz->scene_manager, SubGhzSceneSaved)) { subghz->scene_manager, SubGhzSceneSaved)) {
if(!scene_manager_search_and_switch_to_previous_scene( if(!scene_manager_search_and_switch_to_previous_scene(
@@ -379,6 +389,10 @@ void subghz_scene_read_raw_on_exit(void* context) {
subghz->state_notifications = SubGhzNotificationStateIDLE; subghz->state_notifications = SubGhzNotificationStateIDLE;
notification_message(subghz->notifications, &sequence_reset_rgb); notification_message(subghz->notifications, &sequence_reset_rgb);
//filter restoration //filter restoration
#ifdef SUBGHZ_SAVE_DETECT_RAW_SETTING
subghz_last_settings_set_detect_raw_values(subghz); subghz_last_settings_set_detect_raw_values(subghz);
#else
subghz_receiver_set_filter(subghz->txrx->receiver, SubGhzProtocolFlag_Decodable);
#endif
} }

View File

@@ -6,6 +6,8 @@
const NotificationSequence subghz_sequence_rx = { const NotificationSequence subghz_sequence_rx = {
&message_green_255, &message_green_255,
&message_display_backlight_on,
&message_vibro_on, &message_vibro_on,
&message_note_c6, &message_note_c6,
&message_delay_50, &message_delay_50,
@@ -185,6 +187,7 @@ bool subghz_scene_receiver_on_event(void* context, SceneManagerEvent event) {
consumed = true; consumed = true;
break; break;
case SubGhzCustomEventViewReceiverOK: case SubGhzCustomEventViewReceiverOK:
// Show file info, scene: receiver_info
subghz->txrx->idx_menu_chosen = subghz->txrx->idx_menu_chosen =
subghz_view_receiver_get_idx_menu(subghz->subghz_receiver); subghz_view_receiver_get_idx_menu(subghz->subghz_receiver);
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneReceiverInfo); scene_manager_next_scene(subghz->scene_manager, SubGhzSceneReceiverInfo);

View File

@@ -29,6 +29,13 @@ const char* const detect_raw_text[DETECT_RAW_COUNT] = {
"ON", "ON",
}; };
#ifndef SUBGHZ_SAVE_DETECT_RAW_SETTING
const SubGhzProtocolFlag detect_raw_value[DETECT_RAW_COUNT] = {
SubGhzProtocolFlag_Decodable,
SubGhzProtocolFlag_Decodable | SubGhzProtocolFlag_RAW,
};
#endif
#define RSSI_THRESHOLD_COUNT 7 #define RSSI_THRESHOLD_COUNT 7
const char* const rssi_threshold_text[RSSI_THRESHOLD_COUNT] = { const char* const rssi_threshold_text[RSSI_THRESHOLD_COUNT] = {
"-72db", "-72db",
@@ -100,6 +107,22 @@ uint8_t subghz_scene_receiver_config_hopper_value_index(
} }
} }
#ifndef SUBGHZ_SAVE_DETECT_RAW_SETTING
uint8_t subghz_scene_receiver_config_detect_raw_value_index(
const SubGhzProtocolFlag value,
const SubGhzProtocolFlag values[],
uint8_t values_count) {
uint8_t index = 0;
for(uint8_t i = 0; i < values_count; i++) {
if(value == values[i]) {
index = i;
break;
}
}
return index;
}
#endif
uint8_t subghz_scene_receiver_config_rssi_threshold_value_index( uint8_t subghz_scene_receiver_config_rssi_threshold_value_index(
const int value, const int value,
const int values[], const int values[],
@@ -167,9 +190,18 @@ static void subghz_scene_receiver_config_set_detect_raw(VariableItem* item) {
uint8_t index = variable_item_get_current_value_index(item); uint8_t index = variable_item_get_current_value_index(item);
variable_item_set_current_value_text(item, detect_raw_text[index]); variable_item_set_current_value_text(item, detect_raw_text[index]);
#ifdef SUBGHZ_SAVE_DETECT_RAW_SETTING
subghz->last_settings->detect_raw = index; subghz->last_settings->detect_raw = index;
subghz_last_settings_set_detect_raw_values(subghz); subghz_last_settings_set_detect_raw_values(subghz);
#else
subghz_receiver_set_filter(subghz->txrx->receiver, detect_raw_value[index]);
subghz_protocol_decoder_raw_set_auto_mode(
subghz_receiver_search_decoder_base_by_name(
subghz->txrx->receiver, SUBGHZ_PROTOCOL_RAW_NAME),
(index == 1));
#endif
} }
static void subghz_scene_receiver_config_set_hopping_running(VariableItem* item) { static void subghz_scene_receiver_config_set_hopping_running(VariableItem* item) {
@@ -222,10 +254,10 @@ void subghz_scene_receiver_config_on_enter(void* context) {
VariableItem* item; VariableItem* item;
uint8_t value_index; uint8_t value_index;
#if FURI_DEBUG #ifdef FURI_DEBUG
FURI_LOG_D( FURI_LOG_D(
TAG, TAG,
"last frequency: %d, preset: %d", "Last frequency: %d, Preset: %d",
subghz->last_settings->frequency, subghz->last_settings->frequency,
subghz->last_settings->preset); subghz->last_settings->preset);
#endif #endif
@@ -282,7 +314,14 @@ void subghz_scene_receiver_config_on_enter(void* context) {
DETECT_RAW_COUNT, DETECT_RAW_COUNT,
subghz_scene_receiver_config_set_detect_raw, subghz_scene_receiver_config_set_detect_raw,
subghz); subghz);
#ifdef SUBGHZ_SAVE_DETECT_RAW_SETTING
value_index = subghz->last_settings->detect_raw; value_index = subghz->last_settings->detect_raw;
#else
value_index = subghz_scene_receiver_config_detect_raw_value_index(
subghz_receiver_get_filter(subghz->txrx->receiver),
detect_raw_value,
DETECT_RAW_COUNT);
#endif
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, detect_raw_text[value_index]); variable_item_set_current_value_text(item, detect_raw_text[value_index]);

View File

@@ -1,4 +1,6 @@
#include "../subghz_i.h" #include "../subghz_i.h"
#include <lib/subghz/protocols/keeloq.h>
#include <lib/subghz/protocols/star_line.h>
typedef enum { typedef enum {
SubGhzRpcStateIdle, SubGhzRpcStateIdle,
@@ -97,4 +99,9 @@ void subghz_scene_rpc_on_exit(void* context) {
popup_set_header(popup, NULL, 0, 0, AlignCenter, AlignBottom); popup_set_header(popup, NULL, 0, 0, AlignCenter, AlignBottom);
popup_set_text(popup, NULL, 0, 0, AlignCenter, AlignTop); popup_set_text(popup, NULL, 0, 0, AlignCenter, AlignTop);
popup_set_icon(popup, 0, 0, NULL); popup_set_icon(popup, 0, 0, NULL);
keeloq_reset_mfname();
keeloq_reset_kl_type();
star_line_reset_mfname();
star_line_reset_kl_type();
} }

View File

@@ -21,7 +21,15 @@ void subghz_scene_start_on_enter(void* context) {
if(subghz->state_notifications == SubGhzNotificationStateStarting) { if(subghz->state_notifications == SubGhzNotificationStateStarting) {
subghz->state_notifications = SubGhzNotificationStateIDLE; subghz->state_notifications = SubGhzNotificationStateIDLE;
} }
#ifdef SUBGHZ_SAVE_DETECT_RAW_SETTING
subghz_last_settings_set_detect_raw_values(subghz); subghz_last_settings_set_detect_raw_values(subghz);
#else
subghz_protocol_decoder_raw_set_auto_mode(
subghz_receiver_search_decoder_base_by_name(
subghz->txrx->receiver, SUBGHZ_PROTOCOL_RAW_NAME),
false);
subghz_receiver_set_filter(subghz->txrx->receiver, SubGhzProtocolFlag_Decodable);
#endif
submenu_add_item( submenu_add_item(
subghz->submenu, "Read", SubmenuIndexRead, subghz_scene_start_submenu_callback, subghz); subghz->submenu, "Read", SubmenuIndexRead, subghz_scene_start_submenu_callback, subghz);
@@ -89,6 +97,7 @@ bool subghz_scene_start_on_event(void* context, SceneManagerEvent event) {
subghz->scene_manager, SubGhzSceneStart, SubmenuIndexFrequencyAnalyzer); subghz->scene_manager, SubGhzSceneStart, SubmenuIndexFrequencyAnalyzer);
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneFrequencyAnalyzer); scene_manager_next_scene(subghz->scene_manager, SubGhzSceneFrequencyAnalyzer);
return true; return true;
} else if(event.event == SubmenuIndexTest) { } else if(event.event == SubmenuIndexTest) {
scene_manager_set_scene_state( scene_manager_set_scene_state(
subghz->scene_manager, SubGhzSceneStart, SubmenuIndexTest); subghz->scene_manager, SubGhzSceneStart, SubmenuIndexTest);

View File

@@ -20,11 +20,12 @@ void subghz_scene_test_on_enter(void* context) {
SubmenuIndexCarrier, SubmenuIndexCarrier,
subghz_scene_test_submenu_callback, subghz_scene_test_submenu_callback,
subghz); subghz);
#if FURI_DEBUG
submenu_add_item( submenu_add_item(
subghz->submenu, "Packet", SubmenuIndexPacket, subghz_scene_test_submenu_callback, subghz); subghz->submenu, "Packet", SubmenuIndexPacket, subghz_scene_test_submenu_callback, subghz);
submenu_add_item( submenu_add_item(
subghz->submenu, "Static", SubmenuIndexStatic, subghz_scene_test_submenu_callback, subghz); subghz->submenu, "Static", SubmenuIndexStatic, subghz_scene_test_submenu_callback, subghz);
#endif
submenu_set_selected_item( submenu_set_selected_item(
subghz->submenu, scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneTest)); subghz->submenu, scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneTest));
@@ -40,7 +41,9 @@ bool subghz_scene_test_on_event(void* context, SceneManagerEvent event) {
subghz->scene_manager, SubGhzSceneTest, SubmenuIndexCarrier); subghz->scene_manager, SubGhzSceneTest, SubmenuIndexCarrier);
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneTestCarrier); scene_manager_next_scene(subghz->scene_manager, SubGhzSceneTestCarrier);
return true; return true;
} else if(event.event == SubmenuIndexPacket) { }
#if FURI_DEBUG
else if(event.event == SubmenuIndexPacket) {
scene_manager_set_scene_state( scene_manager_set_scene_state(
subghz->scene_manager, SubGhzSceneTest, SubmenuIndexPacket); subghz->scene_manager, SubGhzSceneTest, SubmenuIndexPacket);
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneTestPacket); scene_manager_next_scene(subghz->scene_manager, SubGhzSceneTestPacket);
@@ -51,6 +54,7 @@ bool subghz_scene_test_on_event(void* context, SceneManagerEvent event) {
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneTestStatic); scene_manager_next_scene(subghz->scene_manager, SubGhzSceneTestStatic);
return true; return true;
} }
#endif
} }
return false; return false;
} }

View File

@@ -1,3 +1,4 @@
#if FURI_DEBUG
#include "../subghz_i.h" #include "../subghz_i.h"
#include "../views/subghz_test_packet.h" #include "../views/subghz_test_packet.h"
@@ -28,3 +29,4 @@ bool subghz_scene_test_packet_on_event(void* context, SceneManagerEvent event) {
void subghz_scene_test_packet_on_exit(void* context) { void subghz_scene_test_packet_on_exit(void* context) {
UNUSED(context); UNUSED(context);
} }
#endif

View File

@@ -1,3 +1,4 @@
#if FURI_DEBUG
#include "../subghz_i.h" #include "../subghz_i.h"
#include "../views/subghz_test_static.h" #include "../views/subghz_test_static.h"
@@ -28,3 +29,4 @@ bool subghz_scene_test_static_on_event(void* context, SceneManagerEvent event) {
void subghz_scene_test_static_on_exit(void* context) { void subghz_scene_test_static_on_exit(void* context) {
UNUSED(context); UNUSED(context);
} }
#endif

View File

@@ -61,7 +61,7 @@ void subghz_blink_stop(SubGhz* instance) {
notification_message(instance->notifications, &sequence_blink_stop); notification_message(instance->notifications, &sequence_blink_stop);
} }
SubGhz* subghz_alloc() { SubGhz* subghz_alloc(bool alloc_for_tx_only) {
SubGhz* subghz = malloc(sizeof(SubGhz)); SubGhz* subghz = malloc(sizeof(SubGhz));
string_init(subghz->file_path); string_init(subghz->file_path);
@@ -88,6 +88,7 @@ SubGhz* subghz_alloc() {
// Open Notification record // Open Notification record
subghz->notifications = furi_record_open(RECORD_NOTIFICATION); subghz->notifications = furi_record_open(RECORD_NOTIFICATION);
if(!alloc_for_tx_only) {
// SubMenu // SubMenu
subghz->submenu = submenu_alloc(); subghz->submenu = submenu_alloc();
view_dispatcher_add_view( view_dispatcher_add_view(
@@ -99,27 +100,31 @@ SubGhz* subghz_alloc() {
subghz->view_dispatcher, subghz->view_dispatcher,
SubGhzViewIdReceiver, SubGhzViewIdReceiver,
subghz_view_receiver_get_view(subghz->subghz_receiver)); subghz_view_receiver_get_view(subghz->subghz_receiver));
}
// Popup // Popup
subghz->popup = popup_alloc(); subghz->popup = popup_alloc();
view_dispatcher_add_view( view_dispatcher_add_view(
subghz->view_dispatcher, SubGhzViewIdPopup, popup_get_view(subghz->popup)); subghz->view_dispatcher, SubGhzViewIdPopup, popup_get_view(subghz->popup));
if(!alloc_for_tx_only) {
// Text Input // Text Input
subghz->text_input = text_input_alloc(); subghz->text_input = text_input_alloc();
view_dispatcher_add_view( view_dispatcher_add_view(
subghz->view_dispatcher, SubGhzViewIdTextInput, text_input_get_view(subghz->text_input)); subghz->view_dispatcher,
SubGhzViewIdTextInput,
text_input_get_view(subghz->text_input));
// Byte Input // Byte Input
subghz->byte_input = byte_input_alloc(); subghz->byte_input = byte_input_alloc();
view_dispatcher_add_view( view_dispatcher_add_view(
subghz->view_dispatcher, SubGhzViewIdByteInput, byte_input_get_view(subghz->byte_input)); subghz->view_dispatcher,
SubGhzViewIdByteInput,
byte_input_get_view(subghz->byte_input));
// Custom Widget // Custom Widget
subghz->widget = widget_alloc(); subghz->widget = widget_alloc();
view_dispatcher_add_view( view_dispatcher_add_view(
subghz->view_dispatcher, SubGhzViewIdWidget, widget_get_view(subghz->widget)); subghz->view_dispatcher, SubGhzViewIdWidget, widget_get_view(subghz->widget));
}
//Dialog //Dialog
subghz->dialogs = furi_record_open(RECORD_DIALOGS); subghz->dialogs = furi_record_open(RECORD_DIALOGS);
@@ -129,7 +134,7 @@ SubGhz* subghz_alloc() {
subghz->view_dispatcher, subghz->view_dispatcher,
SubGhzViewIdTransmitter, SubGhzViewIdTransmitter,
subghz_view_transmitter_get_view(subghz->subghz_transmitter)); subghz_view_transmitter_get_view(subghz->subghz_transmitter));
if(!alloc_for_tx_only) {
// Variable Item List // Variable Item List
subghz->variable_item_list = variable_item_list_alloc(); subghz->variable_item_list = variable_item_list_alloc();
view_dispatcher_add_view( view_dispatcher_add_view(
@@ -144,20 +149,21 @@ SubGhz* subghz_alloc() {
SubGhzViewIdFrequencyAnalyzer, SubGhzViewIdFrequencyAnalyzer,
subghz_frequency_analyzer_get_view(subghz->subghz_frequency_analyzer)); subghz_frequency_analyzer_get_view(subghz->subghz_frequency_analyzer));
// Read RAW
subghz->subghz_read_raw = subghz_read_raw_alloc();
view_dispatcher_add_view(
subghz->view_dispatcher,
SubGhzViewIdReadRAW,
subghz_read_raw_get_view(subghz->subghz_read_raw));
// Carrier Test Module // Carrier Test Module
subghz->subghz_test_carrier = subghz_test_carrier_alloc(); subghz->subghz_test_carrier = subghz_test_carrier_alloc();
view_dispatcher_add_view( view_dispatcher_add_view(
subghz->view_dispatcher, subghz->view_dispatcher,
SubGhzViewIdTestCarrier, SubGhzViewIdTestCarrier,
subghz_test_carrier_get_view(subghz->subghz_test_carrier)); subghz_test_carrier_get_view(subghz->subghz_test_carrier));
}
// Read RAW
subghz->subghz_read_raw = subghz_read_raw_alloc(alloc_for_tx_only);
view_dispatcher_add_view(
subghz->view_dispatcher,
SubGhzViewIdReadRAW,
subghz_read_raw_get_view(subghz->subghz_read_raw));
#if FURI_DEBUG
// Packet Test // Packet Test
subghz->subghz_test_packet = subghz_test_packet_alloc(); subghz->subghz_test_packet = subghz_test_packet_alloc();
view_dispatcher_add_view( view_dispatcher_add_view(
@@ -171,42 +177,64 @@ SubGhz* subghz_alloc() {
subghz->view_dispatcher, subghz->view_dispatcher,
SubGhzViewIdStatic, SubGhzViewIdStatic,
subghz_test_static_get_view(subghz->subghz_test_static)); subghz_test_static_get_view(subghz->subghz_test_static));
#endif
//init setting //init setting
subghz->setting = subghz_setting_alloc(); subghz->setting = subghz_setting_alloc();
subghz_setting_load(subghz->setting, EXT_PATH("subghz/assets/setting_user.txt")); if(alloc_for_tx_only) {
subghz_setting_load(subghz->setting, EXT_PATH("subghz/assets/setting_user.txt"), false);
} else {
subghz_setting_load(subghz->setting, EXT_PATH("subghz/assets/setting_user.txt"), true);
}
// Load last used values for Read, Read RAW, etc. or default // Load last used values for Read, Read RAW, etc. or default
if(!alloc_for_tx_only) {
subghz->last_settings = subghz_last_settings_alloc(); subghz->last_settings = subghz_last_settings_alloc();
subghz_last_settings_load( subghz_last_settings_load(
subghz->last_settings, subghz_setting_get_preset_count(subghz->setting)); subghz->last_settings, subghz_setting_get_preset_count(subghz->setting));
#if FURI_DEBUG #if FURI_DEBUG
#ifdef SUBGHZ_SAVE_DETECT_RAW_SETTING
FURI_LOG_D( FURI_LOG_D(
TAG, TAG,
"last frequency: %d, preset: %d, detect_raw: %d", "last frequency: %d, preset: %d, detect_raw: %d",
subghz->last_settings->frequency, subghz->last_settings->frequency,
subghz->last_settings->preset, subghz->last_settings->preset,
subghz->last_settings->detect_raw); subghz->last_settings->detect_raw);
#else
FURI_LOG_D(
TAG,
"last frequency: %d, preset: %d",
subghz->last_settings->frequency,
subghz->last_settings->preset);
#endif
#endif #endif
subghz_setting_set_default_frequency(subghz->setting, subghz->last_settings->frequency); subghz_setting_set_default_frequency(subghz->setting, subghz->last_settings->frequency);
}
//init Worker & Protocol & History & KeyBoard //init Worker & Protocol & History & KeyBoard
subghz->lock = SubGhzLockOff; subghz->lock = SubGhzLockOff;
subghz->txrx = malloc(sizeof(SubGhzTxRx)); subghz->txrx = malloc(sizeof(SubGhzTxRx));
subghz->txrx->preset = malloc(sizeof(SubGhzPresetDefinition)); subghz->txrx->preset = malloc(sizeof(SubGhzPresetDefinition));
string_init(subghz->txrx->preset->name); string_init(subghz->txrx->preset->name);
if(!alloc_for_tx_only) {
subghz_preset_init( subghz_preset_init(
subghz, subghz,
subghz_setting_get_preset_name(subghz->setting, subghz->last_settings->preset), subghz_setting_get_preset_name(subghz->setting, subghz->last_settings->preset),
subghz->last_settings->frequency, subghz->last_settings->frequency,
NULL, NULL,
0); 0);
} else {
subghz_preset_init(
subghz, "AM650", subghz_setting_get_default_frequency(subghz->setting), NULL, 0);
}
subghz->txrx->txrx_state = SubGhzTxRxStateSleep; subghz->txrx->txrx_state = SubGhzTxRxStateSleep;
subghz->txrx->hopper_state = SubGhzHopperStateOFF; subghz->txrx->hopper_state = SubGhzHopperStateOFF;
subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE; subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE;
if(!alloc_for_tx_only) {
subghz->txrx->history = subghz_history_alloc(); subghz->txrx->history = subghz_history_alloc();
}
subghz->txrx->worker = subghz_worker_alloc(); subghz->txrx->worker = subghz_worker_alloc();
subghz->txrx->fff_data = flipper_format_string_alloc(); subghz->txrx->fff_data = flipper_format_string_alloc();
subghz->txrx->secure_data = malloc(sizeof(SecureData)); subghz->txrx->secure_data = malloc(sizeof(SecureData));
@@ -215,8 +243,13 @@ SubGhz* subghz_alloc() {
subghz->txrx->environment, EXT_PATH("subghz/assets/came_atomo")); subghz->txrx->environment, EXT_PATH("subghz/assets/came_atomo"));
subghz_environment_set_nice_flor_s_rainbow_table_file_name( subghz_environment_set_nice_flor_s_rainbow_table_file_name(
subghz->txrx->environment, EXT_PATH("subghz/assets/nice_flor_s")); subghz->txrx->environment, EXT_PATH("subghz/assets/nice_flor_s"));
subghz->txrx->receiver = subghz_receiver_alloc_init(subghz->txrx->environment); subghz->txrx->receiver = subghz_receiver_alloc_init(subghz->txrx->environment);
#ifdef SUBGHZ_SAVE_DETECT_RAW_SETTING
subghz_last_settings_set_detect_raw_values(subghz); subghz_last_settings_set_detect_raw_values(subghz);
#else
subghz_receiver_set_filter(subghz->txrx->receiver, SubGhzProtocolFlag_Decodable);
#endif
subghz_worker_set_overrun_callback( subghz_worker_set_overrun_callback(
subghz->txrx->worker, (SubGhzWorkerOverrunCallback)subghz_receiver_reset); subghz->txrx->worker, (SubGhzWorkerOverrunCallback)subghz_receiver_reset);
@@ -230,7 +263,7 @@ SubGhz* subghz_alloc() {
return subghz; return subghz;
} }
void subghz_free(SubGhz* subghz) { void subghz_free(SubGhz* subghz, bool alloc_for_tx_only) {
furi_assert(subghz); furi_assert(subghz);
if(subghz->rpc_ctx) { if(subghz->rpc_ctx) {
@@ -240,17 +273,20 @@ void subghz_free(SubGhz* subghz) {
subghz->rpc_ctx = NULL; subghz->rpc_ctx = NULL;
} }
#if FURI_DEBUG
// Packet Test // Packet Test
view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdTestPacket); view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdTestPacket);
subghz_test_packet_free(subghz->subghz_test_packet); subghz_test_packet_free(subghz->subghz_test_packet);
// Carrier Test
view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdTestCarrier);
subghz_test_carrier_free(subghz->subghz_test_carrier);
// Static // Static
view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdStatic); view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdStatic);
subghz_test_static_free(subghz->subghz_test_static); subghz_test_static_free(subghz->subghz_test_static);
#endif
if(!alloc_for_tx_only) {
// Carrier Test
view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdTestCarrier);
subghz_test_carrier_free(subghz->subghz_test_carrier);
// Receiver // Receiver
view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdReceiver); view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdReceiver);
@@ -267,14 +303,14 @@ void subghz_free(SubGhz* subghz) {
// Custom Widget // Custom Widget
view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdWidget); view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdWidget);
widget_free(subghz->widget); widget_free(subghz->widget);
}
//Dialog //Dialog
furi_record_close(RECORD_DIALOGS); furi_record_close(RECORD_DIALOGS);
// Transmitter // Transmitter
view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdTransmitter); view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdTransmitter);
subghz_view_transmitter_free(subghz->subghz_transmitter); subghz_view_transmitter_free(subghz->subghz_transmitter);
if(!alloc_for_tx_only) {
// Variable Item List // Variable Item List
view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdVariableItemList); view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdVariableItemList);
variable_item_list_free(subghz->variable_item_list); variable_item_list_free(subghz->variable_item_list);
@@ -282,15 +318,15 @@ void subghz_free(SubGhz* subghz) {
// Frequency Analyzer // Frequency Analyzer
view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdFrequencyAnalyzer); view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdFrequencyAnalyzer);
subghz_frequency_analyzer_free(subghz->subghz_frequency_analyzer); subghz_frequency_analyzer_free(subghz->subghz_frequency_analyzer);
}
// Read RAW // Read RAW
view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdReadRAW); view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdReadRAW);
subghz_read_raw_free(subghz->subghz_read_raw); subghz_read_raw_free(subghz->subghz_read_raw);
if(!alloc_for_tx_only) {
// Submenu // Submenu
view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdMenu); view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdMenu);
submenu_free(subghz->submenu); submenu_free(subghz->submenu);
}
// Popup // Popup
view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdPopup); view_dispatcher_remove_view(subghz->view_dispatcher, SubGhzViewIdPopup);
popup_free(subghz->popup); popup_free(subghz->popup);
@@ -307,14 +343,21 @@ void subghz_free(SubGhz* subghz) {
//setting //setting
subghz_setting_free(subghz->setting); subghz_setting_free(subghz->setting);
if(!alloc_for_tx_only) {
subghz_last_settings_free(subghz->last_settings); subghz_last_settings_free(subghz->last_settings);
}
//Worker & Protocol & History //Worker & Protocol & History
subghz_receiver_free(subghz->txrx->receiver); subghz_receiver_free(subghz->txrx->receiver);
subghz_environment_free(subghz->txrx->environment); subghz_environment_free(subghz->txrx->environment);
subghz_worker_free(subghz->txrx->worker); subghz_worker_free(subghz->txrx->worker);
flipper_format_free(subghz->txrx->fff_data); flipper_format_free(subghz->txrx->fff_data);
if(!alloc_for_tx_only) {
subghz_history_free(subghz->txrx->history); subghz_history_free(subghz->txrx->history);
}
string_clear(subghz->txrx->preset->name); string_clear(subghz->txrx->preset->name);
free(subghz->txrx->preset); free(subghz->txrx->preset);
free(subghz->txrx->secure_data); free(subghz->txrx->secure_data);
@@ -336,7 +379,20 @@ void subghz_free(SubGhz* subghz) {
} }
int32_t subghz_app(void* p) { int32_t subghz_app(void* p) {
SubGhz* subghz = subghz_alloc(); bool alloc_for_tx;
if(p && strlen(p)) {
alloc_for_tx = true;
} else {
alloc_for_tx = false;
}
SubGhz* subghz = subghz_alloc(alloc_for_tx);
if(alloc_for_tx) {
subghz->raw_send_only = true;
} else {
subghz->raw_send_only = false;
}
//Load database //Load database
bool load_database = subghz_environment_load_keystore( bool load_database = subghz_environment_load_keystore(
@@ -395,7 +451,7 @@ int32_t subghz_app(void* p) {
furi_hal_power_suppress_charge_exit(); furi_hal_power_suppress_charge_exit();
subghz_free(subghz); subghz_free(subghz, alloc_for_tx);
return 0; return 0;
} }

View File

@@ -1,11 +1,21 @@
#include "subghz_history.h" #include "subghz_history.h"
#include "subghz_history_private.h"
#include <lib/subghz/receiver.h> #include <lib/subghz/receiver.h>
#include <flipper_format/flipper_format_i.h> #include <flipper_format/flipper_format_i.h>
#define SUBGHZ_HISTORY_MAX 65 #define SUBGHZ_HISTORY_MAX 65
/**
* @brief Settings for temporary files
*
*/
#define SUBGHZ_HISTORY_TMP_DIR EXT_PATH("subghz/tmp_history") #define SUBGHZ_HISTORY_TMP_DIR EXT_PATH("subghz/tmp_history")
#define SUBGHZ_HISTORY_TMP_EXTENSION ".tmp" #define SUBGHZ_HISTORY_TMP_EXTENSION ".tmp"
#define SUBGHZ_HISTORY_TMP_FILE_KEY "Filename" #define SUBGHZ_HISTORY_TMP_SIGNAL_MAX_LEVEL_DURATION 700
#define SUBGHZ_HISTORY_TMP_SIGNAL_MIN_LEVEL_DURATION 100
#define SUBGHZ_HISTORY_TMP_REMOVE_FILES false
#define SUBGHZ_HISTORY_TMP_RAW_KEY "RAW_Data"
#define TAG "SubGhzHistory" #define TAG "SubGhzHistory"
typedef struct { typedef struct {
@@ -35,73 +45,85 @@ struct SubGhzHistory {
SubGhzHistoryStruct* history; SubGhzHistoryStruct* history;
}; };
#if FURI_DEBUG #ifdef FURI_DEBUG
#define LOG_DELAY 1 #define LOG_DELAY 0
#endif #endif
/**
* @brief Generate filename like 000.tmp
*
* @param filename
* @param index - index of file, timestamp doesn't accepted!
*/
void subghz_history_generate_temp_filename(string_t filename, uint32_t index) { void subghz_history_generate_temp_filename(string_t filename, uint32_t index) {
FuriHalRtcDateTime datetime = {0}; FuriHalRtcDateTime datetime = {0};
furi_hal_rtc_get_datetime(&datetime); furi_hal_rtc_get_datetime(&datetime);
string_init_printf(filename, "%03d%s", index, SUBGHZ_HISTORY_TMP_EXTENSION); string_init_printf(filename, "%03d%s", index, SUBGHZ_HISTORY_TMP_EXTENSION);
} }
/** bool subghz_history_is_tmp_dir_exists(SubGhzHistory* instance) {
* @brief Check SD card, recursive delete dir and files and create new dir FileInfo file_info;
* storage_common_stat(instance->storage, SUBGHZ_HISTORY_TMP_DIR, &file_info);
* @param instance
* @param only_remove_dir
* @return true - if all ok
* @return false - if something failed
*/
bool subghz_history_clear_dir_or_create(SubGhzHistory* instance, bool only_remove_dir) {
#if FURI_DEBUG
FURI_LOG_D(TAG, "subghz_history_clear_dir_or_create: %s", only_remove_dir ? "true" : "false");
furi_delay_ms(LOG_DELAY);
#endif
// Stage 0 - SD installed? if(storage_common_stat(instance->storage, SUBGHZ_HISTORY_TMP_DIR, &file_info) == FSE_OK) {
FS_Error status = storage_sd_status(instance->storage); if(file_info.flags & FSF_DIRECTORY) {
if(status != FSE_OK) { return true;
FURI_LOG_W(TAG, "SD storage not installed! Status: %d", status); }
return false;
} }
return false;
}
bool subghz_history_check_sdcard(SubGhzHistory* instance) {
#ifdef FURI_DEBUG
FURI_LOG_I(TAG, "check_sdcard");
uint32_t start_time = furi_get_tick();
#endif
bool result = false;
// Stage 0 - check SD Card
FS_Error status = storage_sd_status(instance->storage);
if(status == FSE_OK) {
result = subghz_history_is_tmp_dir_exists(instance);
if(!subghz_history_is_tmp_dir_exists(instance)) {
result = storage_simply_mkdir(instance->storage, SUBGHZ_HISTORY_TMP_DIR);
}
} else {
FURI_LOG_W(TAG, "SD storage not installed! Status: %d", status);
}
#ifdef FURI_DEBUG
FURI_LOG_I(TAG, "Running time (check_sdcard): %d ms", furi_get_tick() - start_time);
#endif
return result;
}
void subghz_history_clear_tmp_dir(SubGhzHistory* instance) {
furi_assert(instance);
#ifdef FURI_DEBUG
FURI_LOG_I(TAG, "clear_tmp_dir");
#endif
if(!instance->write_tmp_files) {
// Nothing to do here!
return;
}
uint32_t start_time = furi_get_tick();
#ifdef SUBGHZ_HISTORY_TMP_REMOVE_FILES
// Stage 0 - Dir exists?
bool res = subghz_history_is_tmp_dir_exists(instance);
if(res) {
// Stage 1 - delete all content if exists // Stage 1 - delete all content if exists
FileInfo fileinfo; FileInfo fileinfo;
storage_common_stat(instance->storage, SUBGHZ_HISTORY_TMP_DIR, &fileinfo); storage_common_stat(instance->storage, SUBGHZ_HISTORY_TMP_DIR, &fileinfo);
// This is temp res = fileinfo.flags & FSF_DIRECTORY ?
bool res = false; //instance->write_tmp_files = true; storage_simply_remove_recursive(instance->storage, SUBGHZ_HISTORY_TMP_DIR) :
(storage_common_remove(instance->storage, SUBGHZ_HISTORY_TMP_DIR) == FSE_OK);
// Uncomment it
if(fileinfo.flags & FSF_DIRECTORY) {
res = storage_simply_remove_recursive(instance->storage, SUBGHZ_HISTORY_TMP_DIR);
} else {
res = (storage_common_remove(instance->storage, SUBGHZ_HISTORY_TMP_DIR) == FSE_OK);
} }
#if FURI_DEBUG // Stage 2 - create dir if necessary
FURI_LOG_D(TAG, "storage_common_remove done: %s", res ? "true" : "false"); res = !storage_simply_mkdir(instance->storage, SUBGHZ_HISTORY_TMP_DIR);
furi_delay_ms(LOG_DELAY); if(!res) {
#endif FURI_LOG_E(TAG, "Cannot process temp dir!");
// Uncomment it
// Stage 2 - create dir
if(!only_remove_dir && res) {
res = storage_simply_mkdir(instance->storage, SUBGHZ_HISTORY_TMP_DIR);
#if FURI_DEBUG
FURI_LOG_D(TAG, "storage_simply_mkdir done: %s", res ? "true" : "false");
furi_delay_ms(LOG_DELAY);
#endif
} }
#endif
return res; uint32_t stop_time = furi_get_tick() - start_time;
FURI_LOG_I(TAG, "Running time (clear_tmp_dir): %d ms", stop_time);
} }
SubGhzHistory* subghz_history_alloc(void) { SubGhzHistory* subghz_history_alloc(void) {
@@ -110,26 +132,18 @@ SubGhzHistory* subghz_history_alloc(void) {
instance->history = malloc(sizeof(SubGhzHistoryStruct)); instance->history = malloc(sizeof(SubGhzHistoryStruct));
SubGhzHistoryItemArray_init(instance->history->data); SubGhzHistoryItemArray_init(instance->history->data);
instance->storage = furi_record_open(RECORD_STORAGE); instance->storage = furi_record_open(RECORD_STORAGE);
instance->write_tmp_files = false; instance->write_tmp_files = subghz_history_check_sdcard(instance);
#if FURI_DEBUG if(!instance->write_tmp_files) {
FURI_LOG_D(TAG, "BEFORE subghz_history_clear_dir_or_create"); FURI_LOG_E(TAG, "Unstable work! Cannot use SD Card!");
furi_delay_ms(LOG_DELAY); }
#endif
// Check if we can write files on SD
instance->write_tmp_files = subghz_history_clear_dir_or_create(instance, false);
return instance; return instance;
} }
/** void subghz_history_item_free(void* current_item) {
* @brief free all items in array furi_assert(current_item);
* SubGhzHistoryItem* item = (SubGhzHistoryItem*)current_item;
* @param instance
*/
void subghz_history_clean_item_array(SubGhzHistory* instance) {
for
M_EACH(item, instance->history->data, SubGhzHistoryItemArray_t) {
string_clear(item->item_str); string_clear(item->item_str);
string_clear(item->preset->name); string_clear(item->preset->name);
string_clear(item->protocol_name); string_clear(item->protocol_name);
@@ -141,6 +155,12 @@ void subghz_history_clean_item_array(SubGhzHistory* instance) {
if(item->flipper_string != NULL) { if(item->flipper_string != NULL) {
flipper_format_free(item->flipper_string); flipper_format_free(item->flipper_string);
} }
}
void subghz_history_clean_item_array(SubGhzHistory* instance) {
for
M_EACH(item, instance->history->data, SubGhzHistoryItemArray_t) {
subghz_history_item_free(item);
} }
} }
@@ -152,9 +172,8 @@ void subghz_history_free(SubGhzHistory* instance) {
SubGhzHistoryItemArray_clear(instance->history->data); SubGhzHistoryItemArray_clear(instance->history->data);
free(instance->history); free(instance->history);
if(instance->write_tmp_files) { // Delete all temporary file, on exit it's ok
instance->write_tmp_files = subghz_history_clear_dir_or_create(instance, true); subghz_history_clear_tmp_dir(instance);
}
furi_record_close(RECORD_STORAGE); furi_record_close(RECORD_STORAGE);
@@ -188,10 +207,6 @@ void subghz_history_reset(SubGhzHistory* instance) {
SubGhzHistoryItemArray_reset(instance->history->data); SubGhzHistoryItemArray_reset(instance->history->data);
instance->last_index_write = 0; instance->last_index_write = 0;
instance->code_last_hash_data = 0; instance->code_last_hash_data = 0;
if(instance->write_tmp_files) {
instance->write_tmp_files = subghz_history_clear_dir_or_create(instance, false);
}
} }
uint16_t subghz_history_get_item(SubGhzHistory* instance) { uint16_t subghz_history_get_item(SubGhzHistory* instance) {
@@ -221,22 +236,16 @@ FlipperFormat* subghz_history_get_raw_data(SubGhzHistory* instance, uint16_t idx
bool result_ok = false; bool result_ok = false;
if(instance->write_tmp_files && item->is_file) { if(instance->write_tmp_files && item->is_file) {
// We have files! // We have files!
#if FURI_DEBUG
FURI_LOG_D(TAG, "We have files!");
furi_delay_ms(LOG_DELAY);
#endif
string_t filename; string_t filename;
string_t dir_path; string_t dir_path;
string_init(filename); string_init(filename);
string_init(dir_path); string_init(dir_path);
subghz_history_generate_temp_filename(filename, idx); subghz_history_generate_temp_filename(filename, idx);
string_cat_printf( string_init_printf(
dir_path, "%s/%s", SUBGHZ_HISTORY_TMP_DIR, string_get_cstr(filename)); dir_path, "%s/%s", SUBGHZ_HISTORY_TMP_DIR, string_get_cstr(filename));
// string_init_printf(
// dir_path, "%s/%s", SUBGHZ_HISTORY_TMP_DIR, string_get_cstr(filename));
if(storage_file_exists(instance->storage, string_get_cstr(dir_path))) { if(storage_file_exists(instance->storage, string_get_cstr(dir_path))) {
#if FURI_DEBUG #ifdef FURI_DEBUG
FURI_LOG_D(TAG, "Exist: %s", dir_path); FURI_LOG_D(TAG, "Exist: %s", dir_path);
furi_delay_ms(LOG_DELAY); furi_delay_ms(LOG_DELAY);
#endif #endif
@@ -248,7 +257,7 @@ FlipperFormat* subghz_history_get_raw_data(SubGhzHistory* instance, uint16_t idx
size_t size = stream_load_from_file( size_t size = stream_load_from_file(
dst_stream, instance->storage, string_get_cstr(dir_path)); dst_stream, instance->storage, string_get_cstr(dir_path));
if(size > 0) { if(size > 0) {
#if FURI_DEBUG #ifdef FURI_DEBUG
FURI_LOG_I(TAG, "Save ok!"); FURI_LOG_I(TAG, "Save ok!");
furi_delay_ms(LOG_DELAY); furi_delay_ms(LOG_DELAY);
#endif #endif
@@ -267,7 +276,7 @@ FlipperFormat* subghz_history_get_raw_data(SubGhzHistory* instance, uint16_t idx
string_clear(filename); string_clear(filename);
string_clear(dir_path); string_clear(dir_path);
} else { } else {
#if FURI_DEBUG #ifdef FURI_DEBUG
FURI_LOG_W(TAG, "Write TMP files failed!"); FURI_LOG_W(TAG, "Write TMP files failed!");
furi_delay_ms(LOG_DELAY); furi_delay_ms(LOG_DELAY);
#endif #endif
@@ -314,7 +323,6 @@ bool subghz_history_add_to_history(
instance->code_last_hash_data = subghz_protocol_decoder_base_get_hash_data(decoder_base); instance->code_last_hash_data = subghz_protocol_decoder_base_get_hash_data(decoder_base);
instance->last_update_timestamp = furi_get_tick(); instance->last_update_timestamp = furi_get_tick();
string_t text; string_t text;
string_init(text); string_init(text);
SubGhzHistoryItem* item = SubGhzHistoryItemArray_push_raw(instance->history->data); SubGhzHistoryItem* item = SubGhzHistoryItemArray_push_raw(instance->history->data);
@@ -329,7 +337,9 @@ bool subghz_history_add_to_history(
string_init(item->item_str); string_init(item->item_str);
string_init(item->protocol_name); string_init(item->protocol_name);
// At this point file mapped to memory otherwise file cannot decoded bool tmp_file_for_raw = false;
// At this point file mapped to memory otherwise file cannot decode
item->flipper_string = flipper_format_string_alloc(); item->flipper_string = flipper_format_string_alloc();
subghz_protocol_decoder_base_serialize(decoder_base, item->flipper_string, preset); subghz_protocol_decoder_base_serialize(decoder_base, item->flipper_string, preset);
@@ -343,9 +353,6 @@ bool subghz_history_add_to_history(
break; break;
} else { } else {
string_init_printf(item->protocol_name, "%s", string_get_cstr(instance->tmp_string)); string_init_printf(item->protocol_name, "%s", string_get_cstr(instance->tmp_string));
#if FURI_DEBUG
FURI_LOG_I(TAG, "File protocol: %s", string_get_cstr(item->protocol_name));
#endif
} }
if(!strcmp(string_get_cstr(instance->tmp_string), "RAW")) { if(!strcmp(string_get_cstr(instance->tmp_string), "RAW")) {
string_printf( string_printf(
@@ -357,7 +364,7 @@ bool subghz_history_add_to_history(
if(!flipper_format_rewind(item->flipper_string)) { if(!flipper_format_rewind(item->flipper_string)) {
FURI_LOG_E(TAG, "Rewind error"); FURI_LOG_E(TAG, "Rewind error");
} }
tmp_file_for_raw = true;
break; break;
} else if(!strcmp(string_get_cstr(instance->tmp_string), "KeeLoq")) { } else if(!strcmp(string_get_cstr(instance->tmp_string), "KeeLoq")) {
string_set_str(instance->tmp_string, "KL "); string_set_str(instance->tmp_string, "KL ");
@@ -403,18 +410,8 @@ bool subghz_history_add_to_history(
} }
} while(false); } while(false);
// Copy streams
// Thinking that some data may be saved
// Stream* src = flipper_format_get_raw_stream(flipper_string);
// stream_seek(src, 0, StreamOffsetFromStart);
// Stream* dst = string_stream_alloc();
// stream_clean(dst);
// stream_copy_full(src, dst);
// If we can write to files // If we can write to files
//bool no_close = false; if(instance->write_tmp_files && tmp_file_for_raw) {
if(instance->write_tmp_files) {
string_t filename; string_t filename;
string_t dir_path; string_t dir_path;
string_init(filename); string_init(filename);
@@ -422,21 +419,58 @@ bool subghz_history_add_to_history(
subghz_history_generate_temp_filename(filename, instance->last_index_write); subghz_history_generate_temp_filename(filename, instance->last_index_write);
string_cat_printf(dir_path, "%s/%s", SUBGHZ_HISTORY_TMP_DIR, string_get_cstr(filename)); string_cat_printf(dir_path, "%s/%s", SUBGHZ_HISTORY_TMP_DIR, string_get_cstr(filename));
#if FURI_DEBUG #ifdef FURI_DEBUG
FURI_LOG_I(TAG, "Let's do some hack. Create file %s", string_get_cstr(dir_path)); FURI_LOG_I(TAG, "Save temp file: %s", string_get_cstr(dir_path));
#endif
if(!subghz_history_tmp_write_file_split(instance, item, dir_path)) {
// Plan B!
subghz_history_tmp_write_file_full(instance, item, dir_path);
}
string_clear(filename);
string_clear(dir_path);
} else {
#ifdef FURI_DEBUG
FURI_LOG_I(TAG, "Old fashion way");
#endif
}
string_clear(text);
instance->last_index_write++;
return true;
}
bool subghz_history_tmp_write_file_split(
SubGhzHistory* instance,
void* current_item,
string_t dir_path) {
UNUSED(instance);
UNUSED(current_item);
UNUSED(dir_path);
/*furi_assert(instance);
furi_assert(current_item);
furi_assert(dir_path);*/
//SubGhzHistoryItem* item = (SubGhzHistoryItem*)current_item;
return false;
}
void subghz_history_tmp_write_file_full(
SubGhzHistory* instance,
void* current_item,
string_t dir_path) {
SubGhzHistoryItem* item = (SubGhzHistoryItem*)current_item;
#ifdef FURI_DEBUG
FURI_LOG_W(TAG, "Save temp file full: %s", string_get_cstr(dir_path));
#endif #endif
Stream* dst = flipper_format_get_raw_stream(item->flipper_string); Stream* dst = flipper_format_get_raw_stream(item->flipper_string);
stream_rewind(dst); stream_rewind(dst);
// stream_seek(dst, 0, StreamOffsetFromStart); if(stream_save_to_file(dst, instance->storage, string_get_cstr(dir_path), FSOM_CREATE_ALWAYS) >
if(stream_save_to_file( 0) {
dst, instance->storage, string_get_cstr(dir_path), FSOM_CREATE_ALWAYS) > 0) {
// Free flipper_format
//flipper_format_free(flipper_string);
//flipper_string = NULL;
//stream_free(dst);
flipper_format_free(item->flipper_string); flipper_format_free(item->flipper_string);
item->flipper_string = NULL; item->flipper_string = NULL;
#if FURI_DEBUG #ifdef FURI_DEBUG
FURI_LOG_I(TAG, "Save done!"); FURI_LOG_I(TAG, "Save done!");
#endif #endif
// This item contains fake data to load from SD // This item contains fake data to load from SD
@@ -444,21 +478,4 @@ bool subghz_history_add_to_history(
} else { } else {
FURI_LOG_E(TAG, "Stream copy failed!"); FURI_LOG_E(TAG, "Stream copy failed!");
} }
string_clear(filename);
string_clear(dir_path);
/* }*/
} else {
#if FURI_DEBUG
FURI_LOG_I(TAG, "Old fashion way");
#endif
// Old fashion way
//item->flipper_string = dst;
}
//flipper_format_free(flipper_string);
string_clear(text);
instance->last_index_write++;
return true;
} }

View File

@@ -0,0 +1,79 @@
#pragma once
#include "subghz_history.h"
/**
* @brief Generate filename like 000.tmp
*
* @param filename - input parameter
* @param index - index of file, timestamp doesn't accepted!
*/
void subghz_history_generate_temp_filename(string_t filename, uint32_t index);
/**
* @brief Check if directory for temporary files is exists
*
* @param instance SubGhzHistory*
* @return true
* @return false
*/
bool subghz_history_is_tmp_dir_exists(SubGhzHistory* instance);
/**
* @brief Check SD card and create temporary dir if not exists,
* Result write_tmp_files without this unstable work is GUARANTEED
*
* @param instance - SubGhzHistory*
* @return - true all ok
* @return - false we have a problems
*/
bool subghz_history_check_sdcard(SubGhzHistory* instance);
/**
* @brief Recursive delete dir and files and create new temp dir
*
* @param instance - SubGhzHistory*
* @return true - if all ok
* @return false - if something failed
*/
void subghz_history_clear_tmp_dir(SubGhzHistory* instance);
/**
* @brief Free item and free all resources
*
* @param current_item - SubGhzHistoryItem*
*/
void subghz_history_item_free(void* current_item);
/**
* @brief free all items in array
*
* @param instance
*/
void subghz_history_clean_item_array(SubGhzHistory* instance);
/**
* @brief Write temp file fully, without spliting
*
* @param instance - SubGhzHistory*
* @param current_item - SubGhzHistoryItem*
* @param dir_path - full path to file
*/
void subghz_history_tmp_write_file_full(
SubGhzHistory* instance,
void* current_item,
string_t dir_path);
/**
* @brief Write temp splited to lines
*
* @param instance - SubGhzHistory*
* @param current_item - SubGhzHistoryItem*
* @param dir_path - full path to file
* @return true - file saved
* @return false - error occured
*/
bool subghz_history_tmp_write_file_split(
SubGhzHistory* instance,
void* current_item,
string_t dir_path);

View File

@@ -7,10 +7,11 @@
#include "views/subghz_frequency_analyzer.h" #include "views/subghz_frequency_analyzer.h"
#include "views/subghz_read_raw.h" #include "views/subghz_read_raw.h"
#include "views/subghz_test_static.h"
#include "views/subghz_test_carrier.h" #include "views/subghz_test_carrier.h"
#if FURI_DEBUG
#include "views/subghz_test_static.h"
#include "views/subghz_test_packet.h" #include "views/subghz_test_packet.h"
#endif
// #include <furi.h> // #include <furi.h>
// #include <furi_hal.h> // #include <furi_hal.h>
#include <gui/gui.h> #include <gui/gui.h>
@@ -96,9 +97,12 @@ struct SubGhz {
SubGhzFrequencyAnalyzer* subghz_frequency_analyzer; SubGhzFrequencyAnalyzer* subghz_frequency_analyzer;
SubGhzReadRAW* subghz_read_raw; SubGhzReadRAW* subghz_read_raw;
SubGhzTestStatic* subghz_test_static; bool raw_send_only;
SubGhzTestCarrier* subghz_test_carrier; SubGhzTestCarrier* subghz_test_carrier;
#if FURI_DEBUG
SubGhzTestStatic* subghz_test_static;
SubGhzTestPacket* subghz_test_packet; SubGhzTestPacket* subghz_test_packet;
#endif
string_t error_str; string_t error_str;
SubGhzSetting* setting; SubGhzSetting* setting;
SubGhzLastSettings* last_settings; SubGhzLastSettings* last_settings;

View File

@@ -1,6 +1,8 @@
#include "subghz_last_settings.h" #include "subghz_last_settings.h"
#include "subghz_i.h" #include "subghz_i.h"
#ifdef SUBGHZ_SAVE_DETECT_RAW_SETTING
#include <lib/subghz/protocols/raw.h> #include <lib/subghz/protocols/raw.h>
#endif
#define TAG "SubGhzLastSettings" #define TAG "SubGhzLastSettings"
@@ -11,11 +13,14 @@
// "AM270", "AM650", "FM238", "FM476", // "AM270", "AM650", "FM238", "FM476",
#define SUBGHZ_LAST_SETTING_DEFAULT_PRESET 1 #define SUBGHZ_LAST_SETTING_DEFAULT_PRESET 1
#define SUBGHZ_LAST_SETTING_DEFAULT_FREQUENCY 433920000 #define SUBGHZ_LAST_SETTING_DEFAULT_FREQUENCY 433920000
#ifdef SUBGHZ_SAVE_DETECT_RAW_SETTING
#define SUBGHZ_LAST_SETTING_DEFAULT_READ_RAW 0 #define SUBGHZ_LAST_SETTING_DEFAULT_READ_RAW 0
#define SUBGHZ_LAST_SETTING_FIELD_DETECT_RAW "DetectRaw"
#endif
#define SUBGHZ_LAST_SETTING_FIELD_FREQUENCY "Frequency" #define SUBGHZ_LAST_SETTING_FIELD_FREQUENCY "Frequency"
#define SUBGHZ_LAST_SETTING_FIELD_PRESET "Preset" #define SUBGHZ_LAST_SETTING_FIELD_PRESET "Preset"
#define SUBGHZ_LAST_SETTING_FIELD_DETECT_RAW "DetectRaw"
SubGhzLastSettings* subghz_last_settings_alloc(void) { SubGhzLastSettings* subghz_last_settings_alloc(void) {
SubGhzLastSettings* instance = malloc(sizeof(SubGhzLastSettings)); SubGhzLastSettings* instance = malloc(sizeof(SubGhzLastSettings));
@@ -29,7 +34,7 @@ void subghz_last_settings_free(SubGhzLastSettings* instance) {
void subghz_last_settings_load(SubGhzLastSettings* instance, size_t preset_count) { void subghz_last_settings_load(SubGhzLastSettings* instance, size_t preset_count) {
furi_assert(instance); furi_assert(instance);
#if FURI_DEBUG #ifdef FURI_DEBUG
FURI_LOG_I(TAG, "subghz_last_settings_load"); FURI_LOG_I(TAG, "subghz_last_settings_load");
#endif #endif
@@ -38,7 +43,9 @@ void subghz_last_settings_load(SubGhzLastSettings* instance, size_t preset_count
uint32_t temp_frequency = 0; uint32_t temp_frequency = 0;
int32_t temp_preset = 0; int32_t temp_preset = 0;
#ifdef SUBGHZ_SAVE_DETECT_RAW_SETTING
uint32_t temp_read_raw = 0; uint32_t temp_read_raw = 0;
#endif
if(FSE_OK == storage_sd_status(storage) && SUBGHZ_LAST_SETTINGS_PATH && if(FSE_OK == storage_sd_status(storage) && SUBGHZ_LAST_SETTINGS_PATH &&
flipper_format_file_open_existing(fff_data_file, SUBGHZ_LAST_SETTINGS_PATH)) { flipper_format_file_open_existing(fff_data_file, SUBGHZ_LAST_SETTINGS_PATH)) {
@@ -46,8 +53,10 @@ void subghz_last_settings_load(SubGhzLastSettings* instance, size_t preset_count
fff_data_file, SUBGHZ_LAST_SETTING_FIELD_PRESET, (int32_t*)&temp_preset, 1); fff_data_file, SUBGHZ_LAST_SETTING_FIELD_PRESET, (int32_t*)&temp_preset, 1);
flipper_format_read_uint32( flipper_format_read_uint32(
fff_data_file, SUBGHZ_LAST_SETTING_FIELD_FREQUENCY, (uint32_t*)&temp_frequency, 1); fff_data_file, SUBGHZ_LAST_SETTING_FIELD_FREQUENCY, (uint32_t*)&temp_frequency, 1);
#ifdef SUBGHZ_SAVE_DETECT_RAW_SETTING
flipper_format_read_uint32( flipper_format_read_uint32(
fff_data_file, SUBGHZ_LAST_SETTING_FIELD_DETECT_RAW, (uint32_t*)&temp_read_raw, 1); fff_data_file, SUBGHZ_LAST_SETTING_FIELD_DETECT_RAW, (uint32_t*)&temp_read_raw, 1);
#endif
} else { } else {
FURI_LOG_E(TAG, "Error open file %s", SUBGHZ_LAST_SETTINGS_PATH); FURI_LOG_E(TAG, "Error open file %s", SUBGHZ_LAST_SETTINGS_PATH);
} }
@@ -56,10 +65,14 @@ void subghz_last_settings_load(SubGhzLastSettings* instance, size_t preset_count
FURI_LOG_W(TAG, "Last used frequency not found or can't be used!"); FURI_LOG_W(TAG, "Last used frequency not found or can't be used!");
instance->frequency = SUBGHZ_LAST_SETTING_DEFAULT_FREQUENCY; instance->frequency = SUBGHZ_LAST_SETTING_DEFAULT_FREQUENCY;
instance->preset = SUBGHZ_LAST_SETTING_DEFAULT_PRESET; instance->preset = SUBGHZ_LAST_SETTING_DEFAULT_PRESET;
#ifdef SUBGHZ_SAVE_DETECT_RAW_SETTING
instance->detect_raw = SUBGHZ_LAST_SETTING_DEFAULT_READ_RAW; instance->detect_raw = SUBGHZ_LAST_SETTING_DEFAULT_READ_RAW;
#endif
} else { } else {
instance->frequency = temp_frequency; instance->frequency = temp_frequency;
#ifdef SUBGHZ_SAVE_DETECT_RAW_SETTING
instance->detect_raw = temp_read_raw; instance->detect_raw = temp_read_raw;
#endif
if(temp_preset > (int32_t)preset_count - 1 || temp_preset < 0) { if(temp_preset > (int32_t)preset_count - 1 || temp_preset < 0) {
FURI_LOG_W(TAG, "Last used preset no found"); FURI_LOG_W(TAG, "Last used preset no found");
@@ -76,8 +89,8 @@ void subghz_last_settings_load(SubGhzLastSettings* instance, size_t preset_count
bool subghz_last_settings_save(SubGhzLastSettings* instance) { bool subghz_last_settings_save(SubGhzLastSettings* instance) {
furi_assert(instance); furi_assert(instance);
#if FURI_DEBUG #ifdef FURI_DEBUG
FURI_LOG_I(TAG, "subghz_last_settings_save"); FURI_LOG_I(TAG, "last_settings_save");
#endif #endif
bool saved = false; bool saved = false;
@@ -105,10 +118,12 @@ bool subghz_last_settings_save(SubGhzLastSettings* instance) {
file, SUBGHZ_LAST_SETTING_FIELD_FREQUENCY, &instance->frequency, 1)) { file, SUBGHZ_LAST_SETTING_FIELD_FREQUENCY, &instance->frequency, 1)) {
break; break;
} }
#ifdef SUBGHZ_SAVE_DETECT_RAW_SETTING
if(!flipper_format_insert_or_update_uint32( if(!flipper_format_insert_or_update_uint32(
file, SUBGHZ_LAST_SETTING_FIELD_DETECT_RAW, &instance->detect_raw, 1)) { file, SUBGHZ_LAST_SETTING_FIELD_DETECT_RAW, &instance->detect_raw, 1)) {
break; break;
} }
#endif
saved = true; saved = true;
} while(0); } while(0);
@@ -123,6 +138,7 @@ bool subghz_last_settings_save(SubGhzLastSettings* instance) {
return saved; return saved;
} }
#ifdef SUBGHZ_SAVE_DETECT_RAW_SETTING
void subghz_last_settings_set_detect_raw_values(void* context) { void subghz_last_settings_set_detect_raw_values(void* context) {
furi_assert(context); furi_assert(context);
SubGhz* instance = (SubGhz*)context; SubGhz* instance = (SubGhz*)context;
@@ -134,3 +150,4 @@ void subghz_last_settings_set_detect_raw_values(void* context) {
instance->txrx->receiver, SUBGHZ_PROTOCOL_RAW_NAME), instance->txrx->receiver, SUBGHZ_PROTOCOL_RAW_NAME),
is_detect_raw); is_detect_raw);
} }
#endif

View File

@@ -1,17 +1,23 @@
#pragma once #pragma once
// Enable saving detect raw setting state
// #define SUBGHZ_SAVE_DETECT_RAW_SETTING 1
#include <furi_hal.h> #include <furi_hal.h>
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#include <storage/storage.h> #include <storage/storage.h>
#ifdef SUBGHZ_SAVE_DETECT_RAW_SETTING
#include <lib/subghz/protocols/base.h> #include <lib/subghz/protocols/base.h>
#define DETECT_RAW_FALSE SubGhzProtocolFlag_Decodable #define DETECT_RAW_FALSE SubGhzProtocolFlag_Decodable
#define DETECT_RAW_TRUE SubGhzProtocolFlag_Decodable | SubGhzProtocolFlag_RAW #define DETECT_RAW_TRUE SubGhzProtocolFlag_Decodable | SubGhzProtocolFlag_RAW
#endif
typedef struct { typedef struct {
uint32_t frequency; uint32_t frequency;
#ifdef SUBGHZ_SAVE_DETECT_RAW_SETTING
uint32_t detect_raw; uint32_t detect_raw;
#endif
int32_t preset; int32_t preset;
} SubGhzLastSettings; } SubGhzLastSettings;
@@ -22,5 +28,6 @@ void subghz_last_settings_free(SubGhzLastSettings* instance);
void subghz_last_settings_load(SubGhzLastSettings* instance, size_t preset_count); void subghz_last_settings_load(SubGhzLastSettings* instance, size_t preset_count);
bool subghz_last_settings_save(SubGhzLastSettings* instance); bool subghz_last_settings_save(SubGhzLastSettings* instance);
#ifdef SUBGHZ_SAVE_DETECT_RAW_SETTING
void subghz_last_settings_set_detect_raw_values(void* context); void subghz_last_settings_set_detect_raw_values(void* context);
#endif

View File

@@ -181,7 +181,7 @@ void subghz_setting_load_default(SubGhzSetting* instance) {
instance, subghz_frequency_list, subghz_hopper_frequency_list); instance, subghz_frequency_list, subghz_hopper_frequency_list);
} }
void subghz_setting_load(SubGhzSetting* instance, const char* file_path) { void subghz_setting_load(SubGhzSetting* instance, const char* file_path, bool not_skip_frequencies) {
furi_assert(instance); furi_assert(instance);
Storage* storage = furi_record_open(RECORD_STORAGE); Storage* storage = furi_record_open(RECORD_STORAGE);
@@ -214,6 +214,7 @@ void subghz_setting_load(SubGhzSetting* instance, const char* file_path) {
} }
// Standard frequencies (optional) // Standard frequencies (optional)
if(not_skip_frequencies) {
temp_bool = true; temp_bool = true;
flipper_format_read_bool(fff_data_file, "Add_standard_frequencies", &temp_bool, 1); flipper_format_read_bool(fff_data_file, "Add_standard_frequencies", &temp_bool, 1);
if(!temp_bool) { if(!temp_bool) {
@@ -259,9 +260,11 @@ void subghz_setting_load(SubGhzSetting* instance, const char* file_path) {
FURI_LOG_E(TAG, "Rewind error"); FURI_LOG_E(TAG, "Rewind error");
break; break;
} }
if(flipper_format_read_uint32(fff_data_file, "Default_frequency", &temp_data32, 1)) { if(flipper_format_read_uint32(
fff_data_file, "Default_frequency", &temp_data32, 1)) {
subghz_setting_set_default_frequency(instance, temp_data32); subghz_setting_set_default_frequency(instance, temp_data32);
} }
}
// custom preset (optional) // custom preset (optional)
if(!flipper_format_rewind(fff_data_file)) { if(!flipper_format_rewind(fff_data_file)) {

View File

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

View File

@@ -194,7 +194,7 @@ uint32_t subghz_frequency_find_correct(uint32_t input) {
uint32_t prev_freq = 0; uint32_t prev_freq = 0;
uint32_t current = 0; uint32_t current = 0;
uint32_t result = 0; uint32_t result = 0;
#if FURI_DEBUG #ifdef FURI_DEBUG
FURI_LOG_D(TAG, "input: %d", input); FURI_LOG_D(TAG, "input: %d", input);
#endif #endif
for(size_t i = 0; i < sizeof(subghz_frequency_list); i++) { for(size_t i = 0; i < sizeof(subghz_frequency_list); i++) {
@@ -274,7 +274,7 @@ bool subghz_frequency_analyzer_input(InputEvent* event, void* context) {
frequency_candidate = subghz_frequency_find_correct(frequency_candidate); frequency_candidate = subghz_frequency_find_correct(frequency_candidate);
} }
if(frequency_candidate > 0 && frequency_candidate != model->frequency_to_save) { if(frequency_candidate > 0 && frequency_candidate != model->frequency_to_save) {
#if FURI_DEBUG #ifdef FURI_DEBUG
FURI_LOG_D( FURI_LOG_D(
TAG, TAG,
"frequency_to_save: %d, candidate: %d", "frequency_to_save: %d, candidate: %d",
@@ -289,7 +289,7 @@ bool subghz_frequency_analyzer_input(InputEvent* event, void* context) {
return true; return true;
}); });
#if FURI_DEBUG #ifdef FURI_DEBUG
FURI_LOG_I( FURI_LOG_I(
TAG, TAG,
"updated: %d, long: %d, type: %d", "updated: %d, long: %d, type: %d",
@@ -304,7 +304,7 @@ bool subghz_frequency_analyzer_input(InputEvent* event, void* context) {
// First device receive short, then when user release button we get long // First device receive short, then when user release button we get long
if(event->type == InputTypeLong) { if(event->type == InputTypeLong) {
#if FURI_DEBUG #ifdef FURI_DEBUG
FURI_LOG_I(TAG, "Longpress!"); FURI_LOG_I(TAG, "Longpress!");
#endif #endif
// Stop blinking // Stop blinking

View File

@@ -27,6 +27,7 @@ typedef struct {
uint8_t ind_write; uint8_t ind_write;
uint8_t ind_sin; uint8_t ind_sin;
SubGhzReadRAWStatus status; SubGhzReadRAWStatus status;
bool raw_send_only;
} SubGhzReadRAWModel; } SubGhzReadRAWModel;
void subghz_read_raw_set_callback( void subghz_read_raw_set_callback(
@@ -232,9 +233,11 @@ void subghz_read_raw_draw(Canvas* canvas, SubGhzReadRAWModel* model) {
elements_button_right(canvas, "Save"); elements_button_right(canvas, "Save");
break; break;
case SubGhzReadRAWStatusLoadKeyIDLE: case SubGhzReadRAWStatusLoadKeyIDLE:
if(!model->raw_send_only) {
elements_button_left(canvas, "New"); elements_button_left(canvas, "New");
elements_button_center(canvas, "Send");
elements_button_right(canvas, "More"); elements_button_right(canvas, "More");
}
elements_button_center(canvas, "Send");
elements_text_box( elements_text_box(
canvas, canvas,
4, 4,
@@ -362,6 +365,7 @@ bool subghz_read_raw_input(InputEvent* event, void* context) {
} else if(event->key == InputKeyLeft && event->type == InputTypeShort) { } else if(event->key == InputKeyLeft && event->type == InputTypeShort) {
with_view_model( with_view_model(
instance->view, (SubGhzReadRAWModel * model) { instance->view, (SubGhzReadRAWModel * model) {
if(!model->raw_send_only) {
if(model->status == SubGhzReadRAWStatusStart) { if(model->status == SubGhzReadRAWStatusStart) {
//Config //Config
instance->callback(SubGhzCustomEventViewReadRAWConfig, instance->context); instance->callback(SubGhzCustomEventViewReadRAWConfig, instance->context);
@@ -376,11 +380,13 @@ bool subghz_read_raw_input(InputEvent* event, void* context) {
string_reset(model->file_name); string_reset(model->file_name);
instance->callback(SubGhzCustomEventViewReadRAWErase, instance->context); instance->callback(SubGhzCustomEventViewReadRAWErase, instance->context);
} }
}
return true; return true;
}); });
} else if(event->key == InputKeyRight && event->type == InputTypeShort) { } else if(event->key == InputKeyRight && event->type == InputTypeShort) {
with_view_model( with_view_model(
instance->view, (SubGhzReadRAWModel * model) { instance->view, (SubGhzReadRAWModel * model) {
if(!model->raw_send_only) {
if(model->status == SubGhzReadRAWStatusIDLE) { if(model->status == SubGhzReadRAWStatusIDLE) {
//Save //Save
instance->callback(SubGhzCustomEventViewReadRAWSave, instance->context); instance->callback(SubGhzCustomEventViewReadRAWSave, instance->context);
@@ -388,6 +394,7 @@ bool subghz_read_raw_input(InputEvent* event, void* context) {
//More //More
instance->callback(SubGhzCustomEventViewReadRAWMore, instance->context); instance->callback(SubGhzCustomEventViewReadRAWMore, instance->context);
} }
}
return true; return true;
}); });
} else if(event->key == InputKeyOk && event->type == InputTypeShort) { } else if(event->key == InputKeyOk && event->type == InputTypeShort) {
@@ -487,7 +494,7 @@ void subghz_read_raw_exit(void* context) {
}); });
} }
SubGhzReadRAW* subghz_read_raw_alloc() { SubGhzReadRAW* subghz_read_raw_alloc(bool raw_send_only) {
SubGhzReadRAW* instance = malloc(sizeof(SubGhzReadRAW)); SubGhzReadRAW* instance = malloc(sizeof(SubGhzReadRAW));
// View allocation and configuration // View allocation and configuration
@@ -505,6 +512,7 @@ SubGhzReadRAW* subghz_read_raw_alloc() {
string_init(model->preset_str); string_init(model->preset_str);
string_init(model->sample_write); string_init(model->sample_write);
string_init(model->file_name); string_init(model->file_name);
model->raw_send_only = raw_send_only;
model->rssi_history = malloc(SUBGHZ_READ_RAW_RSSI_HISTORY_SIZE * sizeof(uint8_t)); model->rssi_history = malloc(SUBGHZ_READ_RAW_RSSI_HISTORY_SIZE * sizeof(uint8_t));
return true; return true;
}); });

View File

@@ -25,7 +25,7 @@ void subghz_read_raw_set_callback(
SubGhzReadRAWCallback callback, SubGhzReadRAWCallback callback,
void* context); void* context);
SubGhzReadRAW* subghz_read_raw_alloc(); SubGhzReadRAW* subghz_read_raw_alloc(bool raw_send_only);
void subghz_read_raw_free(SubGhzReadRAW* subghz_static); void subghz_read_raw_free(SubGhzReadRAW* subghz_static);

View File

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

View File

@@ -14,6 +14,7 @@
#define ASSETS_DIR "assets" #define ASSETS_DIR "assets"
#define BADUSB_LAYOUTS_DIR "layouts" #define BADUSB_LAYOUTS_DIR "layouts"
#define SUBGHZ_TEMP_DIR "tmp_history"
#define BROWSER_ROOT STORAGE_ANY_PATH_PREFIX #define BROWSER_ROOT STORAGE_ANY_PATH_PREFIX
#define FILE_NAME_LEN_MAX 256 #define FILE_NAME_LEN_MAX 256
#define LONG_LOAD_THRESHOLD 100 #define LONG_LOAD_THRESHOLD 100
@@ -80,7 +81,8 @@ static bool browser_filter_by_name(BrowserWorker* browser, string_t name, bool i
// Skip assets folders (if enabled) // Skip assets folders (if enabled)
if(browser->skip_assets) { if(browser->skip_assets) {
return ((string_cmp_str(name, ASSETS_DIR) == 0) ? (false) : (true)) && return ((string_cmp_str(name, ASSETS_DIR) == 0) ? (false) : (true)) &&
((string_cmp_str(name, BADUSB_LAYOUTS_DIR) == 0) ? (false) : (true)); ((string_cmp_str(name, BADUSB_LAYOUTS_DIR) == 0) ? (false) : (true)) &&
((string_cmp_str(name, SUBGHZ_TEMP_DIR) == 0) ? (false) : (true));
} else { } else {
return true; return true;
} }