Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion applications/main/subghz/application.fam
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
App(
appid="subghz",
name="Sub-GHz",
apptype=FlipperAppType.APP,
apptype=FlipperAppType.EXTERNAL,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Temporary for testing. Todo: Revert.

targets=["f7"],
cdefines=["APP_SUBGHZ"],
entry_point="subghz_app",
Expand Down
10 changes: 10 additions & 0 deletions applications/main/subghz/helpers/subghz_txrx.c
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,16 @@ SubGhzSpeakerState subghz_txrx_speaker_get_state(SubGhzTxRx* instance) {
return instance->speaker_state;
}

void subghz_txrx_autosave_set_state(SubGhzTxRx* instance, SubGhzAutosaveState state) {
furi_assert(instance);
instance->autosave_state = state;
}

SubGhzAutosaveState subghz_txrx_autosave_get_state(SubGhzTxRx* instance) {
furi_assert(instance);
return instance->autosave_state;
}

bool subghz_txrx_load_decoder_by_name_protocol(SubGhzTxRx* instance, const char* name_protocol) {
furi_assert(instance);
furi_assert(name_protocol);
Expand Down
16 changes: 16 additions & 0 deletions applications/main/subghz/helpers/subghz_txrx.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,22 @@ void subghz_txrx_speaker_set_state(SubGhzTxRx* instance, SubGhzSpeakerState stat
*/
SubGhzSpeakerState subghz_txrx_speaker_get_state(SubGhzTxRx* instance);

/**
* Set state autosave
*
* @param instance Pointer to a SubGhzTxRx
* @param state State autosave
*/
void subghz_txrx_autosave_set_state(SubGhzTxRx* instance, SubGhzAutosaveState state);

/**
* Get state autosave
*
* @param instance Pointer to a SubGhzTxRx
* @return SubGhzAutosaveState
*/
SubGhzAutosaveState subghz_txrx_autosave_get_state(SubGhzTxRx* instance);

/**
* load decoder by name protocol
*
Expand Down
2 changes: 2 additions & 0 deletions applications/main/subghz/helpers/subghz_txrx_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ struct SubGhzTxRx {
const SubGhzDevice* radio_device;
SubGhzRadioDeviceType radio_device_type;

SubGhzAutosaveState autosave_state;

SubGhzTxRxNeedSaveCallback need_save_callback;
void* need_save_context;

Expand Down
6 changes: 6 additions & 0 deletions applications/main/subghz/helpers/subghz_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ typedef enum {
SubGhzLockOn,
} SubGhzLock;

/** SubGhz RAW Autosave */
typedef enum {
AutosaveOff,
AutosaveOn,
} SubGhzAutosaveState;

typedef enum {
SubGhzViewIdMenu,
SubGhzViewIdReceiver,
Expand Down
28 changes: 28 additions & 0 deletions applications/main/subghz/scenes/subghz_scene_receiver_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const uint32_t speaker_value[SPEAKER_COUNT] = {
SubGhzSpeakerStateShutdown,
SubGhzSpeakerStateEnable,
};

#define BIN_RAW_COUNT 2
const char* const bin_raw_text[BIN_RAW_COUNT] = {
"OFF",
Expand All @@ -71,12 +72,23 @@ const uint32_t bin_raw_value[BIN_RAW_COUNT] = {
SubGhzProtocolFlag_Decodable,
SubGhzProtocolFlag_Decodable | SubGhzProtocolFlag_BinRAW,
};

#define PROTOCOL_IGNORE_COUNT 2
const char* const protocol_ignore_text[PROTOCOL_IGNORE_COUNT] = {
"OFF",
"ON",
};

#define AUTOSAVE_COUNT 2
const char* const autosave_text[AUTOSAVE_COUNT] = {
"OFF",
"ON",
};
const uint32_t autosave_value[AUTOSAVE_COUNT] = {
AutosaveOff,
AutosaveOn,
};

uint8_t subghz_scene_receiver_config_next_frequency(const uint32_t value, void* context) {
furi_assert(context);
SubGhz* subghz = context;
Expand Down Expand Up @@ -276,6 +288,10 @@ static void subghz_scene_receiver_config_set_magellan(VariableItem* item) {
subghz_scene_receiver_config_set_ignore_filter(item, SubGhzProtocolFlag_Magelan);
}

static void subghz_scene_receiver_config_set_autosave(VariableItem* item) {
subghz_scene_receiver_config_set_ignore_filter(item, SubGhzProtocolFlag_Autosave);
}

static void subghz_scene_receiver_config_var_list_enter_callback(void* context, uint32_t index) {
furi_assert(context);
SubGhz* subghz = context;
Expand Down Expand Up @@ -389,6 +405,18 @@ void subghz_scene_receiver_config_on_enter(void* context) {
subghz->ignore_filter, SubGhzProtocolFlag_Magelan);
variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, protocol_ignore_text[value_index]);

item = variable_item_list_add(
subghz->variable_item_list,
"Autosave RAW:",
AUTOSAVE_COUNT,
subghz_scene_receiver_config_set_autosave,
subghz);

value_index = value_index_uint32(
subghz_txrx_autosave_get_state(subghz->txrx), autosave_value, AUTOSAVE_COUNT);
variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, autosave_text[value_index]);
}

// Enable speaker, will send all incoming noises and signals to speaker so you can listen how your remote sounds like :)
Expand Down
4 changes: 3 additions & 1 deletion applications/main/subghz/subghz_history.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,14 @@ FlipperFormat* subghz_history_get_raw_data(SubGhzHistory* instance, uint16_t idx
return NULL;
}
}

bool subghz_history_get_text_space_left(SubGhzHistory* instance, FuriString* output) {
furi_assert(instance);
if(memmgr_get_free_heap() < SUBGHZ_HISTORY_FREE_HEAP) {
if(output != NULL) furi_string_printf(output, " Free heap LOW");
return true;
}
if(instance->last_index_write == SUBGHZ_HISTORY_MAX) {
if(instance->last_index_write == SUBGHZ_HISTORY_MAX && SubGhzProtocolFlag_Autosave) {
if(output != NULL) furi_string_printf(output, " Memory is FULL");
return true;
}
Expand All @@ -165,6 +166,7 @@ bool subghz_history_get_text_space_left(SubGhzHistory* instance, FuriString* out
uint16_t subghz_history_get_last_index(SubGhzHistory* instance) {
return instance->last_index_write;
}

void subghz_history_get_text_item_menu(SubGhzHistory* instance, FuriString* output, uint16_t idx) {
SubGhzHistoryItem* item = SubGhzHistoryItemArray_get(instance->history->data, idx);
furi_string_set(output, item->item_str);
Expand Down
1 change: 1 addition & 0 deletions applications/main/subghz/subghz_history.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <furi_hal.h>
#include <lib/flipper_format/flipper_format.h>
#include <lib/subghz/types.h>
#include "helpers/subghz_txrx.h"

typedef struct SubGhzHistory SubGhzHistory;

Expand Down
1 change: 1 addition & 0 deletions lib/subghz/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ typedef enum {
SubGhzProtocolFlag_StarLine = (1 << 11),
SubGhzProtocolFlag_AutoAlarms = (1 << 12),
SubGhzProtocolFlag_Magelan = (1 << 13),
SubGhzProtocolFlag_Autosave = (1 << 14),
} SubGhzProtocolFlag;

struct SubGhzProtocol {
Expand Down