From fec80da3f44598fdb75780bd57854042dcedb2d4 Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Thu, 17 Aug 2023 03:01:40 +0300 Subject: [PATCH] subghz - fix check, fix typos temporarily replace with internal check, commented code in function added TODO comment --- applications/main/subghz/helpers/subghz_txrx.c | 9 +++++++-- applications/main/subghz/helpers/subghz_txrx.h | 4 ++-- applications/main/subghz/subghz_i.c | 7 ++++--- .../main/subghz/views/subghz_frequency_analyzer.c | 6 +++--- applications/main/subghz_remote/helpers/subrem_presets.c | 2 +- .../main/subghz_remote/helpers/txrx/subghz_txrx.c | 4 ++-- .../main/subghz_remote/helpers/txrx/subghz_txrx.h | 4 ++-- 7 files changed, 21 insertions(+), 15 deletions(-) diff --git a/applications/main/subghz/helpers/subghz_txrx.c b/applications/main/subghz/helpers/subghz_txrx.c index d878c0e04..c08eb00aa 100644 --- a/applications/main/subghz/helpers/subghz_txrx.c +++ b/applications/main/subghz/helpers/subghz_txrx.c @@ -629,13 +629,16 @@ const char* subghz_txrx_radio_device_get_name(SubGhzTxRx* instance) { return subghz_devices_get_name(instance->radio_device); } -bool subghz_txrx_radio_device_is_frequecy_valid(SubGhzTxRx* instance, uint32_t frequency) { +bool subghz_txrx_radio_device_is_frequency_valid(SubGhzTxRx* instance, uint32_t frequency) { furi_assert(instance); return subghz_devices_is_frequency_valid(instance->radio_device, frequency); } -bool subghz_txrx_radio_device_is_tx_alowed(SubGhzTxRx* instance, uint32_t frequency) { +bool subghz_txrx_radio_device_is_tx_allowed(SubGhzTxRx* instance, uint32_t frequency) { + // TODO: Remake this function to check if the frequency is allowed on specific module - for modules not based on CC1101 furi_assert(instance); + UNUSED(frequency); + /* furi_assert(instance->txrx_state != SubGhzTxRxStateSleep); subghz_devices_idle(instance->radio_device); @@ -645,6 +648,8 @@ bool subghz_txrx_radio_device_is_tx_alowed(SubGhzTxRx* instance, uint32_t freque subghz_devices_idle(instance->radio_device); return ret; + */ + return true; } void subghz_txrx_set_debug_pin_state(SubGhzTxRx* instance, bool state) { diff --git a/applications/main/subghz/helpers/subghz_txrx.h b/applications/main/subghz/helpers/subghz_txrx.h index 76c7c8ead..12fed2a9b 100644 --- a/applications/main/subghz/helpers/subghz_txrx.h +++ b/applications/main/subghz/helpers/subghz_txrx.h @@ -334,9 +334,9 @@ const char* subghz_txrx_radio_device_get_name(SubGhzTxRx* instance); * @param instance Pointer to a SubGhzTxRx * @return bool True if the frequency is valid */ -bool subghz_txrx_radio_device_is_frequecy_valid(SubGhzTxRx* instance, uint32_t frequency); +bool subghz_txrx_radio_device_is_frequency_valid(SubGhzTxRx* instance, uint32_t frequency); -bool subghz_txrx_radio_device_is_tx_alowed(SubGhzTxRx* instance, uint32_t frequency); +bool subghz_txrx_radio_device_is_tx_allowed(SubGhzTxRx* instance, uint32_t frequency); void subghz_txrx_set_debug_pin_state(SubGhzTxRx* instance, bool state); bool subghz_txrx_get_debug_pin_state(SubGhzTxRx* instance); diff --git a/applications/main/subghz/subghz_i.c b/applications/main/subghz/subghz_i.c index f91f128cf..a6cfe9025 100644 --- a/applications/main/subghz/subghz_i.c +++ b/applications/main/subghz/subghz_i.c @@ -115,14 +115,15 @@ bool subghz_key_load(SubGhz* subghz, const char* file_path, bool show_dialog) { break; } - if(!subghz_txrx_radio_device_is_frequecy_valid(subghz->txrx, temp_data32)) { + if(!subghz_txrx_radio_device_is_frequency_valid(subghz->txrx, temp_data32)) { FURI_LOG_E(TAG, "Frequency not supported on chosen radio module"); load_key_state = SubGhzLoadKeyStateUnsuportedFreq; break; } - if(!subghz_txrx_radio_device_is_tx_alowed(subghz->txrx, temp_data32)) { - FURI_LOG_E(TAG, "This frequency can only be used for RX on chosen radio module"); + // TODO: use different frequency allowed lists for differnet modules (non cc1101) + if(!furi_hal_subghz_is_tx_allowed(temp_data32)) { + FURI_LOG_E(TAG, "This frequency can only be used for RX"); load_key_state = SubGhzLoadKeyStateOnlyRx; break; } diff --git a/applications/main/subghz/views/subghz_frequency_analyzer.c b/applications/main/subghz/views/subghz_frequency_analyzer.c index 7800c9081..9f39bb0d6 100644 --- a/applications/main/subghz/views/subghz_frequency_analyzer.c +++ b/applications/main/subghz/views/subghz_frequency_analyzer.c @@ -315,7 +315,7 @@ bool subghz_frequency_analyzer_input(InputEvent* event, void* context) { uint32_t frequency_candidate = model->history_frequency[model->selected_index]; if(frequency_candidate == 0 || // !furi_hal_subghz_is_frequency_valid(frequency_candidate) || - !subghz_txrx_radio_device_is_frequecy_valid( + !subghz_txrx_radio_device_is_frequency_valid( instance->txrx, frequency_candidate) || prev_freq_to_save == frequency_candidate) { frequency_candidate = 0; @@ -339,7 +339,7 @@ bool subghz_frequency_analyzer_input(InputEvent* event, void* context) { uint32_t frequency_candidate = subghz_frequency_find_correct(model->frequency); if(frequency_candidate == 0 || // !furi_hal_subghz_is_frequency_valid(frequency_candidate) || - !subghz_txrx_radio_device_is_frequecy_valid( + !subghz_txrx_radio_device_is_frequency_valid( instance->txrx, frequency_candidate) || prev_freq_to_save == frequency_candidate) { frequency_candidate = 0; @@ -356,7 +356,7 @@ bool subghz_frequency_analyzer_input(InputEvent* event, void* context) { uint32_t frequency_candidate = subghz_frequency_find_correct(model->frequency); if(frequency_candidate == 0 || // !furi_hal_subghz_is_frequency_valid(frequency_candidate) || - !subghz_txrx_radio_device_is_frequecy_valid( + !subghz_txrx_radio_device_is_frequency_valid( instance->txrx, frequency_candidate) || prev_freq_to_save == frequency_candidate) { frequency_candidate = 0; diff --git a/applications/main/subghz_remote/helpers/subrem_presets.c b/applications/main/subghz_remote/helpers/subrem_presets.c index 75ced8e00..ca91ccbaf 100644 --- a/applications/main/subghz_remote/helpers/subrem_presets.c +++ b/applications/main/subghz_remote/helpers/subrem_presets.c @@ -84,7 +84,7 @@ SubRemLoadSubState subrem_sub_preset_load( if(!flipper_format_read_uint32(fff_data_file, "Frequency", &temp_data32, 1)) { FURI_LOG_W(TAG, "Cannot read frequency. Set default frequency"); sub_preset->freq_preset.frequency = subghz_setting_get_default_frequency(setting); - } else if(!subghz_txrx_radio_device_is_frequecy_valid(txrx, temp_data32)) { + } else if(!subghz_txrx_radio_device_is_frequency_valid(txrx, temp_data32)) { FURI_LOG_E(TAG, "Frequency not supported on chosen radio module"); break; } diff --git a/applications/main/subghz_remote/helpers/txrx/subghz_txrx.c b/applications/main/subghz_remote/helpers/txrx/subghz_txrx.c index 8def9cf01..aa713c7a8 100644 --- a/applications/main/subghz_remote/helpers/txrx/subghz_txrx.c +++ b/applications/main/subghz_remote/helpers/txrx/subghz_txrx.c @@ -629,12 +629,12 @@ const char* subghz_txrx_radio_device_get_name(SubGhzTxRx* instance) { return subghz_devices_get_name(instance->radio_device); } -bool subghz_txrx_radio_device_is_frequecy_valid(SubGhzTxRx* instance, uint32_t frequency) { +bool subghz_txrx_radio_device_is_frequency_valid(SubGhzTxRx* instance, uint32_t frequency) { furi_assert(instance); return subghz_devices_is_frequency_valid(instance->radio_device, frequency); } -bool subghz_txrx_radio_device_is_tx_alowed(SubGhzTxRx* instance, uint32_t frequency) { +bool subghz_txrx_radio_device_is_tx_allowed(SubGhzTxRx* instance, uint32_t frequency) { furi_assert(instance); furi_assert(instance->txrx_state != SubGhzTxRxStateSleep); diff --git a/applications/main/subghz_remote/helpers/txrx/subghz_txrx.h b/applications/main/subghz_remote/helpers/txrx/subghz_txrx.h index 8bb7f2aee..4593ea20c 100644 --- a/applications/main/subghz_remote/helpers/txrx/subghz_txrx.h +++ b/applications/main/subghz_remote/helpers/txrx/subghz_txrx.h @@ -363,9 +363,9 @@ const char* subghz_txrx_radio_device_get_name(SubGhzTxRx* instance); * @param instance Pointer to a SubGhzTxRx * @return bool True if the frequency is valid */ -bool subghz_txrx_radio_device_is_frequecy_valid(SubGhzTxRx* instance, uint32_t frequency); +bool subghz_txrx_radio_device_is_frequency_valid(SubGhzTxRx* instance, uint32_t frequency); -bool subghz_txrx_radio_device_is_tx_alowed(SubGhzTxRx* instance, uint32_t frequency); +bool subghz_txrx_radio_device_is_tx_allowed(SubGhzTxRx* instance, uint32_t frequency); void subghz_txrx_set_debug_pin_state(SubGhzTxRx* instance, bool state); bool subghz_txrx_get_debug_pin_state(SubGhzTxRx* instance);