Support subghz raw in favorite timeout setting

This commit is contained in:
Willy-JL
2023-05-02 12:32:45 +01:00
parent 84c1cac63c
commit c0cf699ede
4 changed files with 46 additions and 25 deletions

View File

@@ -122,6 +122,19 @@ void subghz_scene_read_raw_on_enter(void* context) {
//set filter RAW feed
subghz_receiver_set_filter(subghz->txrx->receiver, SubGhzProtocolFlag_RAW);
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdReadRAW);
// Start sending immediately with favorites
if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneReadRAW)) {
with_view_model(
subghz->subghz_read_raw->view,
SubGhzReadRAWModel * model,
{
scene_manager_handle_custom_event(
subghz->scene_manager, SubGhzCustomEventViewReadRAWSendStart);
model->status = SubGhzReadRAWStatusTXRepeat;
},
true);
}
}
bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
@@ -278,6 +291,13 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
subghz_sleep(subghz);
}
subghz_read_raw_stop_send(subghz->subghz_read_raw);
// Exit / stop with favorites
if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneReadRAW)) {
while(scene_manager_handle_back_event(subghz->scene_manager))
;
view_dispatcher_stop(subghz->view_dispatcher);
}
consumed = true;
break;

View File

@@ -5,6 +5,7 @@
#include "subghz_i.h"
#include <lib/subghz/protocols/protocol_items.h>
#include <applications/main/archive/helpers/favorite_timeout.h>
#include <xtreme.h>
#define TAG "SubGhzApp"
@@ -456,7 +457,7 @@ int32_t subghz_app(char* p) {
furi_hal_subghz_init_radio_type(SubGhzRadioInternal);
}
// Check argument and run corresponding scene
process_favorite_launch(&p);
bool is_favorite = process_favorite_launch(&p) && XTREME_SETTINGS()->favorite_timeout;
if(p && strlen(p)) {
uint32_t rpc_ctx = 0;
@@ -476,6 +477,8 @@ int32_t subghz_app(char* p) {
if((!strcmp(subghz->txrx->decoder_result->protocol->name, "RAW"))) {
//Load Raw TX
subghz->txrx->rx_key_state = SubGhzRxKeyStateRAWLoad;
scene_manager_set_scene_state(
subghz->scene_manager, SubGhzSceneReadRAW, is_favorite);
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneReadRAW);
} else {
//Load transmitter TX

View File

@@ -11,28 +11,6 @@
#define SUBGHZ_READ_RAW_RSSI_HISTORY_SIZE 100
#define TAG "SubGhzReadRAW"
struct SubGhzReadRAW {
View* view;
SubGhzReadRAWCallback callback;
void* context;
};
typedef struct {
FuriString* frequency_str;
FuriString* preset_str;
FuriString* sample_write;
FuriString* file_name;
uint8_t* rssi_history;
uint8_t rssi_current;
bool rssi_history_end;
uint8_t ind_write;
uint8_t ind_sin;
SubGhzReadRAWStatus status;
bool raw_send_only;
float raw_threshold_rssi;
bool not_showing_samples;
} SubGhzReadRAWModel;
void subghz_read_raw_set_callback(
SubGhzReadRAW* subghz_read_raw,
SubGhzReadRAWCallback callback,

View File

@@ -5,10 +5,14 @@
#define SUBGHZ_RAW_THRESHOLD_MIN -90.0f
typedef struct SubGhzReadRAW SubGhzReadRAW;
typedef void (*SubGhzReadRAWCallback)(SubGhzCustomEvent event, void* context);
typedef struct {
View* view;
SubGhzReadRAWCallback callback;
void* context;
} SubGhzReadRAW;
typedef enum {
SubGhzReadRAWStatusStart,
SubGhzReadRAWStatusIDLE,
@@ -22,6 +26,22 @@ typedef enum {
SubGhzReadRAWStatusSaveKey,
} SubGhzReadRAWStatus;
typedef struct {
FuriString* frequency_str;
FuriString* preset_str;
FuriString* sample_write;
FuriString* file_name;
uint8_t* rssi_history;
uint8_t rssi_current;
bool rssi_history_end;
uint8_t ind_write;
uint8_t ind_sin;
SubGhzReadRAWStatus status;
bool raw_send_only;
float raw_threshold_rssi;
bool not_showing_samples;
} SubGhzReadRAWModel;
void subghz_read_raw_set_callback(
SubGhzReadRAW* subghz_read_raw,
SubGhzReadRAWCallback callback,