mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-24 03:29:57 -07:00
SubGhz: Ignore filters at driver level, better efficiency
This commit is contained in:
@@ -569,6 +569,13 @@ void subghz_txrx_receiver_set_filter(SubGhzTxRx* instance, SubGhzProtocolFlag fi
|
|||||||
subghz_receiver_set_filter(instance->receiver, filter);
|
subghz_receiver_set_filter(instance->receiver, filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void subghz_txrx_receiver_set_ignore_filter(
|
||||||
|
SubGhzTxRx* instance,
|
||||||
|
SubGhzProtocolFilter ignore_filter) {
|
||||||
|
furi_assert(instance);
|
||||||
|
subghz_receiver_set_ignore_filter(instance->receiver, ignore_filter);
|
||||||
|
}
|
||||||
|
|
||||||
void subghz_txrx_set_rx_callback(
|
void subghz_txrx_set_rx_callback(
|
||||||
SubGhzTxRx* instance,
|
SubGhzTxRx* instance,
|
||||||
SubGhzReceiverCallback callback,
|
SubGhzReceiverCallback callback,
|
||||||
|
|||||||
@@ -283,6 +283,16 @@ bool subghz_txrx_protocol_is_transmittable(SubGhzTxRx* instance, bool check_type
|
|||||||
*/
|
*/
|
||||||
void subghz_txrx_receiver_set_filter(SubGhzTxRx* instance, SubGhzProtocolFlag filter);
|
void subghz_txrx_receiver_set_filter(SubGhzTxRx* instance, SubGhzProtocolFlag filter);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set ignore filter, what types of decoder to skip
|
||||||
|
*
|
||||||
|
* @param instance Pointer to a SubGhzTxRx
|
||||||
|
* @param ignore_filter Ignore filter
|
||||||
|
*/
|
||||||
|
void subghz_txrx_receiver_set_ignore_filter(
|
||||||
|
SubGhzTxRx* instance,
|
||||||
|
SubGhzProtocolFilter ignore_filter);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set callback for receive data
|
* Set callback for receive data
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -125,8 +125,6 @@ static void subghz_scene_add_to_history_callback(
|
|||||||
furi_assert(context);
|
furi_assert(context);
|
||||||
SubGhz* subghz = context;
|
SubGhz* subghz = context;
|
||||||
|
|
||||||
// The check can be moved to /lib/subghz/receiver.c, but may result in false positives
|
|
||||||
if((decoder_base->protocol->filter & subghz->ignore_filter) == 0) {
|
|
||||||
SubGhzHistory* history = subghz->history;
|
SubGhzHistory* history = subghz->history;
|
||||||
FuriString* item_name = furi_string_alloc();
|
FuriString* item_name = furi_string_alloc();
|
||||||
FuriString* item_time = furi_string_alloc();
|
FuriString* item_time = furi_string_alloc();
|
||||||
@@ -166,14 +164,12 @@ static void subghz_scene_add_to_history_callback(
|
|||||||
|
|
||||||
if(subghz->remove_duplicates) {
|
if(subghz->remove_duplicates) {
|
||||||
// Look in history for signal hash
|
// Look in history for signal hash
|
||||||
uint32_t hash_data =
|
uint32_t hash_data = subghz_protocol_decoder_base_get_hash_data_long(decoder_base);
|
||||||
subghz_protocol_decoder_base_get_hash_data_long(decoder_base);
|
|
||||||
subghz_view_receiver_disable_draw_callback(subghz->subghz_receiver);
|
subghz_view_receiver_disable_draw_callback(subghz->subghz_receiver);
|
||||||
for(uint16_t i = idx; i > 0; i--) {
|
for(uint16_t i = idx; i > 0; i--) {
|
||||||
i--; // Iterating in reverse with off by one
|
i--; // Iterating in reverse with off by one
|
||||||
if(subghz_history_get_hash_data(subghz->history, i) == hash_data &&
|
if(subghz_history_get_hash_data(subghz->history, i) == hash_data &&
|
||||||
subghz_history_get_protocol(subghz->history, i) ==
|
subghz_history_get_protocol(subghz->history, i) == decoder_base->protocol) {
|
||||||
decoder_base->protocol) {
|
|
||||||
// Remove previous instance and update menu index
|
// Remove previous instance and update menu index
|
||||||
subghz_history_delete_item(subghz->history, i);
|
subghz_history_delete_item(subghz->history, i);
|
||||||
subghz_view_receiver_delete_item(subghz->subghz_receiver, i);
|
subghz_view_receiver_delete_item(subghz->subghz_receiver, i);
|
||||||
@@ -221,9 +217,7 @@ static void subghz_scene_add_to_history_callback(
|
|||||||
free(dir);
|
free(dir);
|
||||||
// Save
|
// Save
|
||||||
subghz_save_protocol_to_file(
|
subghz_save_protocol_to_file(
|
||||||
subghz,
|
subghz, subghz_history_get_raw_data(history, idx), furi_string_get_cstr(path));
|
||||||
subghz_history_get_raw_data(history, idx),
|
|
||||||
furi_string_get_cstr(path));
|
|
||||||
furi_string_free(path);
|
furi_string_free(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,9 +235,6 @@ static void subghz_scene_add_to_history_callback(
|
|||||||
furi_string_free(item_name);
|
furi_string_free(item_name);
|
||||||
furi_string_free(item_time);
|
furi_string_free(item_time);
|
||||||
subghz_rx_key_state_set(subghz, SubGhzRxKeyStateAddKey);
|
subghz_rx_key_state_set(subghz, SubGhzRxKeyStateAddKey);
|
||||||
} else {
|
|
||||||
FURI_LOG_D(TAG, "%s protocol ignored", decoder_base->protocol->name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void subghz_scene_receiver_on_enter(void* context) {
|
void subghz_scene_receiver_on_enter(void* context) {
|
||||||
@@ -264,6 +255,7 @@ void subghz_scene_receiver_on_enter(void* context) {
|
|||||||
subghz->filter = subghz->last_settings->filter;
|
subghz->filter = subghz->last_settings->filter;
|
||||||
subghz_txrx_receiver_set_filter(subghz->txrx, subghz->filter);
|
subghz_txrx_receiver_set_filter(subghz->txrx, subghz->filter);
|
||||||
subghz->ignore_filter = subghz->last_settings->ignore_filter;
|
subghz->ignore_filter = subghz->last_settings->ignore_filter;
|
||||||
|
subghz_txrx_receiver_set_ignore_filter(subghz->txrx, subghz->ignore_filter);
|
||||||
|
|
||||||
subghz_history_reset(history);
|
subghz_history_reset(history);
|
||||||
subghz_rx_key_state_set(subghz, SubGhzRxKeyStateStart);
|
subghz_rx_key_state_set(subghz, SubGhzRxKeyStateStart);
|
||||||
|
|||||||
@@ -106,6 +106,7 @@ static void subghz_scene_receiver_config_set_ignore_filter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
subghz->last_settings->ignore_filter = subghz->ignore_filter;
|
subghz->last_settings->ignore_filter = subghz->ignore_filter;
|
||||||
|
subghz_txrx_receiver_set_ignore_filter(subghz->txrx, subghz->ignore_filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t subghz_scene_receiver_config_next_frequency(const uint32_t value, void* context) {
|
uint8_t subghz_scene_receiver_config_next_frequency(const uint32_t value, void* context) {
|
||||||
@@ -431,6 +432,7 @@ static void subghz_scene_receiver_config_var_list_enter_callback(void* context,
|
|||||||
subghz->ignore_filter = 0x00;
|
subghz->ignore_filter = 0x00;
|
||||||
subghz->remove_duplicates = false;
|
subghz->remove_duplicates = false;
|
||||||
subghz_txrx_receiver_set_filter(subghz->txrx, subghz->filter);
|
subghz_txrx_receiver_set_filter(subghz->txrx, subghz->filter);
|
||||||
|
subghz_txrx_receiver_set_ignore_filter(subghz->txrx, subghz->ignore_filter);
|
||||||
subghz->last_settings->remove_duplicates = subghz->remove_duplicates;
|
subghz->last_settings->remove_duplicates = subghz->remove_duplicates;
|
||||||
subghz->last_settings->ignore_filter = subghz->ignore_filter;
|
subghz->last_settings->ignore_filter = subghz->ignore_filter;
|
||||||
subghz->last_settings->filter = subghz->filter;
|
subghz->last_settings->filter = subghz->filter;
|
||||||
|
|||||||
@@ -234,6 +234,7 @@ SubGhz* subghz_alloc(bool alloc_for_tx_only) {
|
|||||||
subghz->remove_duplicates = false;
|
subghz->remove_duplicates = false;
|
||||||
}
|
}
|
||||||
subghz_txrx_receiver_set_filter(subghz->txrx, subghz->filter);
|
subghz_txrx_receiver_set_filter(subghz->txrx, subghz->filter);
|
||||||
|
subghz_txrx_receiver_set_ignore_filter(subghz->txrx, subghz->ignore_filter);
|
||||||
subghz_txrx_set_need_save_callback(subghz->txrx, subghz_save_to_file, subghz);
|
subghz_txrx_set_need_save_callback(subghz->txrx, subghz_save_to_file, subghz);
|
||||||
|
|
||||||
if(!alloc_for_tx_only) {
|
if(!alloc_for_tx_only) {
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ ARRAY_DEF(SubGhzReceiverSlotArray, SubGhzReceiverSlot, M_POD_OPLIST);
|
|||||||
struct SubGhzReceiver {
|
struct SubGhzReceiver {
|
||||||
SubGhzReceiverSlotArray_t slots;
|
SubGhzReceiverSlotArray_t slots;
|
||||||
SubGhzProtocolFlag filter;
|
SubGhzProtocolFlag filter;
|
||||||
|
SubGhzProtocolFilter ignore_filter;
|
||||||
|
|
||||||
SubGhzReceiverCallback callback;
|
SubGhzReceiverCallback callback;
|
||||||
void* context;
|
void* context;
|
||||||
@@ -64,7 +65,8 @@ void subghz_receiver_decode(SubGhzReceiver* instance, bool level, uint32_t durat
|
|||||||
|
|
||||||
for
|
for
|
||||||
M_EACH(slot, instance->slots, SubGhzReceiverSlotArray_t) {
|
M_EACH(slot, instance->slots, SubGhzReceiverSlotArray_t) {
|
||||||
if((slot->base->protocol->flag & instance->filter) != 0) {
|
if((slot->base->protocol->flag & instance->filter) != 0 &&
|
||||||
|
(slot->base->protocol->filter & instance->ignore_filter) == 0) {
|
||||||
slot->base->protocol->decoder->feed(slot->base, level, duration);
|
slot->base->protocol->decoder->feed(slot->base, level, duration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -108,6 +110,13 @@ void subghz_receiver_set_filter(SubGhzReceiver* instance, SubGhzProtocolFlag fil
|
|||||||
instance->filter = filter;
|
instance->filter = filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void subghz_receiver_set_ignore_filter(
|
||||||
|
SubGhzReceiver* instance,
|
||||||
|
SubGhzProtocolFilter ignore_filter) {
|
||||||
|
furi_assert(instance);
|
||||||
|
instance->ignore_filter = ignore_filter;
|
||||||
|
}
|
||||||
|
|
||||||
SubGhzProtocolDecoderBase* subghz_receiver_search_decoder_base_by_name(
|
SubGhzProtocolDecoderBase* subghz_receiver_search_decoder_base_by_name(
|
||||||
SubGhzReceiver* instance,
|
SubGhzReceiver* instance,
|
||||||
const char* decoder_name) {
|
const char* decoder_name) {
|
||||||
|
|||||||
@@ -59,6 +59,15 @@ void subghz_receiver_set_rx_callback(
|
|||||||
*/
|
*/
|
||||||
void subghz_receiver_set_filter(SubGhzReceiver* instance, SubGhzProtocolFlag filter);
|
void subghz_receiver_set_filter(SubGhzReceiver* instance, SubGhzProtocolFlag filter);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the filter of receivers that will be ignored at the moment.
|
||||||
|
* @param instance Pointer to a SubGhzReceiver instance
|
||||||
|
* @param ignore_filter Ignore filter, SubGhzProtocolFilter
|
||||||
|
*/
|
||||||
|
void subghz_receiver_set_ignore_filter(
|
||||||
|
SubGhzReceiver* instance,
|
||||||
|
SubGhzProtocolFilter ignore_filter);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search for a cattery by his name.
|
* Search for a cattery by his name.
|
||||||
* @param instance Pointer to a SubGhzReceiver instance
|
* @param instance Pointer to a SubGhzReceiver instance
|
||||||
|
|||||||
@@ -3421,6 +3421,7 @@ Function,+,subghz_receiver_free,void,SubGhzReceiver*
|
|||||||
Function,+,subghz_receiver_reset,void,SubGhzReceiver*
|
Function,+,subghz_receiver_reset,void,SubGhzReceiver*
|
||||||
Function,+,subghz_receiver_search_decoder_base_by_name,SubGhzProtocolDecoderBase*,"SubGhzReceiver*, const char*"
|
Function,+,subghz_receiver_search_decoder_base_by_name,SubGhzProtocolDecoderBase*,"SubGhzReceiver*, const char*"
|
||||||
Function,+,subghz_receiver_set_filter,void,"SubGhzReceiver*, SubGhzProtocolFlag"
|
Function,+,subghz_receiver_set_filter,void,"SubGhzReceiver*, SubGhzProtocolFlag"
|
||||||
|
Function,+,subghz_receiver_set_ignore_filter,void,"SubGhzReceiver*, SubGhzProtocolFilter"
|
||||||
Function,+,subghz_receiver_set_rx_callback,void,"SubGhzReceiver*, SubGhzReceiverCallback, void*"
|
Function,+,subghz_receiver_set_rx_callback,void,"SubGhzReceiver*, SubGhzReceiverCallback, void*"
|
||||||
Function,+,subghz_setting_alloc,SubGhzSetting*,
|
Function,+,subghz_setting_alloc,SubGhzSetting*,
|
||||||
Function,+,subghz_setting_customs_presets_to_log,uint8_t,SubGhzSetting*
|
Function,+,subghz_setting_customs_presets_to_log,uint8_t,SubGhzSetting*
|
||||||
|
|||||||
|
Reference in New Issue
Block a user