From 1e76c2d840c1b9d5f9d09080cd3b4f0abeeb5139 Mon Sep 17 00:00:00 2001 From: gid9798 <30450294+gid9798@users.noreply.github.com> Date: Wed, 21 Jun 2023 11:24:16 +0300 Subject: [PATCH] SubRem Apps: update --- .../helpers/subrem_presets.c | 5 ++--- .../helpers/txrx/subghz_txrx.c | 22 ++++++++++++------- .../helpers/txrx/subghz_txrx.h | 2 ++ .../subghz_remote/helpers/subrem_presets.c | 4 ++-- .../scenes/subrem_scene_remote.c | 2 +- 5 files changed, 21 insertions(+), 14 deletions(-) diff --git a/applications/external/subghz_remote_configurator/helpers/subrem_presets.c b/applications/external/subghz_remote_configurator/helpers/subrem_presets.c index d491af2f7..75ced8e00 100644 --- a/applications/external/subghz_remote_configurator/helpers/subrem_presets.c +++ b/applications/external/subghz_remote_configurator/helpers/subrem_presets.c @@ -84,9 +84,8 @@ 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(!furi_hal_subghz_is_tx_allowed(temp_data32)) { - // TODO - FURI_LOG_E(TAG, "This frequency can only be used for RX"); + } else if(!subghz_txrx_radio_device_is_frequecy_valid(txrx, temp_data32)) { + FURI_LOG_E(TAG, "Frequency not supported on chosen radio module"); break; } sub_preset->freq_preset.frequency = temp_data32; diff --git a/applications/external/subghz_remote_configurator/helpers/txrx/subghz_txrx.c b/applications/external/subghz_remote_configurator/helpers/txrx/subghz_txrx.c index e4309dcad..223876c36 100644 --- a/applications/external/subghz_remote_configurator/helpers/txrx/subghz_txrx.c +++ b/applications/external/subghz_remote_configurator/helpers/txrx/subghz_txrx.c @@ -167,10 +167,6 @@ static void subghz_txrx_begin(SubGhzTxRx* instance, uint8_t* preset_data) { static uint32_t subghz_txrx_rx(SubGhzTxRx* instance, uint32_t frequency) { furi_assert(instance); - // TODO - if(!furi_hal_subghz_is_frequency_valid(frequency)) { - furi_crash("SubGhz: Incorrect RX frequency."); - } furi_assert( instance->txrx_state != SubGhzTxRxStateRx && instance->txrx_state != SubGhzTxRxStateSleep); @@ -216,11 +212,8 @@ void subghz_txrx_sleep(SubGhzTxRx* instance) { static bool subghz_txrx_tx(SubGhzTxRx* instance, uint32_t frequency) { furi_assert(instance); - // TODO - if(!furi_hal_subghz_is_frequency_valid(frequency)) { - furi_crash("SubGhz: Incorrect TX frequency."); - } furi_assert(instance->txrx_state != SubGhzTxRxStateSleep); + subghz_devices_idle(instance->radio_device); subghz_devices_set_frequency(instance->radio_device, frequency); @@ -637,6 +630,19 @@ bool subghz_txrx_radio_device_is_frequecy_valid(SubGhzTxRx* instance, uint32_t f return subghz_devices_is_frequency_valid(instance->radio_device, frequency); } +bool subghz_txrx_radio_device_is_tx_alowed(SubGhzTxRx* instance, uint32_t frequency) { + furi_assert(instance); + furi_assert(instance->txrx_state != SubGhzTxRxStateSleep); + + subghz_devices_idle(instance->radio_device); + subghz_devices_set_frequency(instance->radio_device, frequency); + + bool ret = subghz_devices_set_tx(instance->radio_device); + subghz_devices_idle(instance->radio_device); + + return ret; +} + void subghz_txrx_set_debug_pin_state(SubGhzTxRx* instance, bool state) { furi_assert(instance); instance->debug_pin_state = state; diff --git a/applications/external/subghz_remote_configurator/helpers/txrx/subghz_txrx.h b/applications/external/subghz_remote_configurator/helpers/txrx/subghz_txrx.h index 46f09a665..93748e2de 100644 --- a/applications/external/subghz_remote_configurator/helpers/txrx/subghz_txrx.h +++ b/applications/external/subghz_remote_configurator/helpers/txrx/subghz_txrx.h @@ -365,6 +365,8 @@ const char* subghz_txrx_radio_device_get_name(SubGhzTxRx* instance); */ bool subghz_txrx_radio_device_is_frequecy_valid(SubGhzTxRx* instance, uint32_t frequency); +bool subghz_txrx_radio_device_is_tx_alowed(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_remote/helpers/subrem_presets.c b/applications/main/subghz_remote/helpers/subrem_presets.c index 45da793d7..75ced8e00 100644 --- a/applications/main/subghz_remote/helpers/subrem_presets.c +++ b/applications/main/subghz_remote/helpers/subrem_presets.c @@ -84,8 +84,8 @@ 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(!furi_hal_subghz_is_tx_allowed(temp_data32)) { - FURI_LOG_E(TAG, "This frequency can only be used for RX"); + } else if(!subghz_txrx_radio_device_is_frequecy_valid(txrx, temp_data32)) { + FURI_LOG_E(TAG, "Frequency not supported on chosen radio module"); break; } sub_preset->freq_preset.frequency = temp_data32; diff --git a/applications/main/subghz_remote/scenes/subrem_scene_remote.c b/applications/main/subghz_remote/scenes/subrem_scene_remote.c index a2e307fd9..ebc582991 100644 --- a/applications/main/subghz_remote/scenes/subrem_scene_remote.c +++ b/applications/main/subghz_remote/scenes/subrem_scene_remote.c @@ -80,7 +80,7 @@ bool subrem_scene_remote_on_event(void* context, SceneManagerEvent event) { } else { subrem_view_remote_set_state( app->subrem_remote_view, SubRemViewRemoteStateIdle, 0); - notification_message(app->notifications, &sequence_blink_stop); + notification_message(app->notifications, &sequence_blink_red_100); } return true; } else if(event.event == SubRemCustomEventViewRemoteForcedStop) {