SubGhz: refactoring

This commit is contained in:
gid9798 2023-05-09 15:58:56 +03:00
parent 076f6785cb
commit 4cbdbd9ef5
7 changed files with 17 additions and 9 deletions

View File

@ -170,7 +170,7 @@ void subghz_scene_decode_raw_on_enter(void* context) {
subghz_receiver_set_rx_callback(
subghz->txrx->receiver, subghz_scene_add_to_history_callback, subghz);
subghz_receiver_set_filter(subghz->txrx->receiver, SubGhzProtocolFlag_Decodable);
subghz_txrx_receiver_set_filter(subghz->txrx, SubGhzProtocolFlag_Decodable);
if(subghz->decode_raw_state == SubGhzDecodeRawStateStart) {
//Decode RAW to history

View File

@ -117,7 +117,7 @@ void subghz_scene_read_raw_on_enter(void* context) {
furi_check(subghz_txrx_load_decoder_by_name_protocol(subghz->txrx, SUBGHZ_PROTOCOL_RAW_NAME));
//set filter RAW feed
subghz_receiver_set_filter(subghz->txrx->receiver, SubGhzProtocolFlag_RAW);
subghz_txrx_receiver_set_filter(subghz->txrx, SubGhzProtocolFlag_RAW);
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdReadRAW);
}
@ -359,5 +359,5 @@ void subghz_scene_read_raw_on_exit(void* context) {
notification_message(subghz->notifications, &sequence_reset_rgb);
//filter restoration
subghz_receiver_set_filter(subghz->txrx->receiver, subghz->txrx->filter);
subghz_txrx_receiver_set_filter(subghz->txrx, subghz->filter);
}

View File

@ -256,8 +256,8 @@ static void subghz_scene_receiver_config_set_bin_raw(VariableItem* item) {
uint8_t index = variable_item_get_current_value_index(item);
variable_item_set_current_value_text(item, bin_raw_text[index]);
subghz->txrx->filter = bin_raw_value[index];
subghz_receiver_set_filter(subghz->txrx->receiver, subghz->txrx->filter);
subghz->filter = bin_raw_value[index];
subghz_txrx_receiver_set_filter(subghz->txrx, subghz->filter);
}
static void subghz_scene_receiver_config_set_raw_threshold_rssi(VariableItem* item) {
@ -363,7 +363,7 @@ void subghz_scene_receiver_config_on_enter(void* context) {
BIN_RAW_COUNT,
subghz_scene_receiver_config_set_bin_raw,
subghz);
value_index = value_index_uint32(subghz->txrx->filter, bin_raw_value, BIN_RAW_COUNT);
value_index = value_index_uint32(subghz->filter, bin_raw_value, BIN_RAW_COUNT);
variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, bin_raw_text[value_index]);
}

View File

@ -305,8 +305,9 @@ SubGhz* subghz_alloc(bool alloc_for_tx_only) {
subghz_environment_set_protocol_registry(
subghz->txrx->environment, (void*)&subghz_protocol_registry);
subghz->txrx->receiver = subghz_receiver_alloc_init(subghz->txrx->environment);
subghz->txrx->filter = SubGhzProtocolFlag_Decodable;
subghz_receiver_set_filter(subghz->txrx->receiver, subghz->txrx->filter);
subghz->filter = SubGhzProtocolFlag_Decodable;
subghz_txrx_receiver_set_filter(subghz->txrx, subghz->filter);
subghz_worker_set_overrun_callback(
subghz->txrx->worker, (SubGhzWorkerOverrunCallback)subghz_receiver_reset);

View File

@ -94,6 +94,7 @@ struct SubGhz {
#endif
SubGhzLastSettings* last_settings;
SubGhzProtocolFlag filter;
FuriString* error_str;
SubGhzLock lock;

View File

@ -466,6 +466,11 @@ bool subghz_txrx_protocol_is_send(SubGhzTxRx* txrx, bool check_type) {
txrx->decoder_result->protocol->encoder->deserialize);
}
void subghz_txrx_receiver_set_filter(SubGhzTxRx* txrx, SubGhzProtocolFlag filter) {
furi_assert(txrx);
subghz_receiver_set_filter(txrx->receiver, filter);
}
//#############Create new Key##############
#include <lib/subghz/protocols/protocol_items.h>
#include <lib/subghz/protocols/keeloq.h>

View File

@ -16,7 +16,6 @@ struct SubGhzTxRx {
SubGhzEnvironment* environment;
SubGhzReceiver* receiver;
SubGhzTransmitter* transmitter;
SubGhzProtocolFlag filter;
SubGhzProtocolDecoderBase* decoder_result;
FlipperFormat* fff_data;
@ -87,6 +86,8 @@ SubGhzSetting* subghz_txrx_get_setting(SubGhzTxRx* txrx);
bool subghz_txrx_protocol_is_preserved(SubGhzTxRx* txrx);
bool subghz_txrx_protocol_is_send(SubGhzTxRx* txrx, bool check_type);
void subghz_txrx_receiver_set_filter(SubGhzTxRx* txrx, SubGhzProtocolFlag filter);
//#############Create new Key##############
bool subghz_gen_data_protocol(
void* context,