From 500ca0758afb3a776ec053570634ef796514c7ab Mon Sep 17 00:00:00 2001 From: DerSkythe Date: Fri, 4 Aug 2023 18:52:16 +0400 Subject: [PATCH] Save hopping in last settings - Save hopping state - Add easy logging to SubGhzLastSettings - Add to CLI alias 'l' for log command - Fix misspelled names --- .../main/subghz/helpers/subghz_txrx.c | 18 ++++---- .../main/subghz/helpers/subghz_txrx.h | 6 +-- .../subghz/scenes/subghz_scene_decode_raw.c | 9 ++-- .../subghz/scenes/subghz_scene_receiver.c | 23 +++++++--- .../scenes/subghz_scene_receiver_config.c | 38 +++++++++------- .../subghz/scenes/subghz_scene_save_success.c | 2 +- applications/main/subghz/subghz.c | 14 +----- applications/main/subghz/subghz_i.c | 4 +- .../main/subghz/subghz_last_settings.c | 44 ++++++++++++++++--- .../main/subghz/subghz_last_settings.h | 3 ++ applications/main/subghz/views/receiver.c | 12 ++++- applications/main/subghz/views/receiver.h | 3 +- .../subghz/views/subghz_frequency_analyzer.c | 6 +-- applications/services/cli/cli_commands.c | 1 + 14 files changed, 118 insertions(+), 65 deletions(-) diff --git a/applications/main/subghz/helpers/subghz_txrx.c b/applications/main/subghz/helpers/subghz_txrx.c index d878c0e04..57dea99f5 100644 --- a/applications/main/subghz/helpers/subghz_txrx.c +++ b/applications/main/subghz/helpers/subghz_txrx.c @@ -3,10 +3,9 @@ #include #include #include - #include -#define TAG "SubGhz" +#define TAG "SubGhzTxRx" static void subghz_txrx_radio_device_power_on(SubGhzTxRx* instance) { UNUSED(instance); @@ -383,10 +382,11 @@ void subghz_txrx_hopper_update(SubGhzTxRx* instance) { default: break; } - float rssi = -127.0f; + // Init value isn't using + // float rssi = -127.0f; if(instance->hopper_state != SubGhzHopperStateRSSITimeOut) { // See RSSI Calculation timings in CC1101 17.3 RSSI - rssi = subghz_devices_get_rssi(instance->radio_device); + float rssi = subghz_devices_get_rssi(instance->radio_device); // Stay if RSSI is high enough if(rssi > -90.0f) { @@ -407,7 +407,7 @@ void subghz_txrx_hopper_update(SubGhzTxRx* instance) { if(instance->txrx_state == SubGhzTxRxStateRx) { subghz_txrx_rx_end(instance); - }; + } if(instance->txrx_state == SubGhzTxRxStateIDLE) { subghz_receiver_reset(instance->receiver); instance->preset->frequency = @@ -554,7 +554,7 @@ void subghz_txrx_receiver_set_filter(SubGhzTxRx* instance, SubGhzProtocolFlag fi subghz_receiver_set_filter(instance->receiver, filter); } -void subghz_txrx_set_rx_calback( +void subghz_txrx_set_rx_callback( SubGhzTxRx* instance, SubGhzReceiverCallback callback, void* context) { @@ -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); @@ -667,4 +667,4 @@ void subghz_txrx_reset_dynamic_and_custom_btns(SubGhzTxRx* instance) { SubGhzReceiver* subghz_txrx_get_receiver(SubGhzTxRx* instance) { furi_assert(instance); return instance->receiver; -} \ No newline at end of file +} diff --git a/applications/main/subghz/helpers/subghz_txrx.h b/applications/main/subghz/helpers/subghz_txrx.h index 76c7c8ead..c31915d30 100644 --- a/applications/main/subghz/helpers/subghz_txrx.h +++ b/applications/main/subghz/helpers/subghz_txrx.h @@ -274,7 +274,7 @@ void subghz_txrx_receiver_set_filter(SubGhzTxRx* instance, SubGhzProtocolFlag fi * @param callback Callback for receive data * @param context Context for callback */ -void subghz_txrx_set_rx_calback( +void subghz_txrx_set_rx_callback( SubGhzTxRx* instance, SubGhzReceiverCallback callback, void* context); @@ -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/scenes/subghz_scene_decode_raw.c b/applications/main/subghz/scenes/subghz_scene_decode_raw.c index 988a61c8b..1b076ae27 100644 --- a/applications/main/subghz/scenes/subghz_scene_decode_raw.c +++ b/applications/main/subghz/scenes/subghz_scene_decode_raw.c @@ -21,13 +21,14 @@ static void subghz_scene_receiver_update_statusbar(void* context) { subghz->subghz_receiver, furi_string_get_cstr(frequency_str), furi_string_get_cstr(modulation_str), - furi_string_get_cstr(history_stat_str)); + furi_string_get_cstr(history_stat_str), + subghz_txrx_hopper_get_state(subghz->txrx) != SubGhzHopperStateOFF); furi_string_free(frequency_str); furi_string_free(modulation_str); } else { subghz_view_receiver_add_data_statusbar( - subghz->subghz_receiver, furi_string_get_cstr(history_stat_str), "", ""); + subghz->subghz_receiver, furi_string_get_cstr(history_stat_str), "", "", false); } furi_string_free(history_stat_str); } @@ -154,7 +155,7 @@ void subghz_scene_decode_raw_on_enter(void* context) { subghz_view_receiver_set_callback( subghz->subghz_receiver, subghz_scene_decode_raw_callback, subghz); - subghz_txrx_set_rx_calback(subghz->txrx, subghz_scene_add_to_history_callback, subghz); + subghz_txrx_set_rx_callback(subghz->txrx, subghz_scene_add_to_history_callback, subghz); subghz_txrx_receiver_set_filter(subghz->txrx, SubGhzProtocolFlag_Decodable); @@ -202,7 +203,7 @@ bool subghz_scene_decode_raw_on_event(void* context, SceneManagerEvent event) { subghz->scene_manager, SubGhzSceneDecodeRAW, SubGhzDecodeRawStateStart); subghz->idx_menu_chosen = 0; - subghz_txrx_set_rx_calback(subghz->txrx, NULL, subghz); + subghz_txrx_set_rx_callback(subghz->txrx, NULL, subghz); if(subghz_file_encoder_worker_is_running(subghz->decode_raw_file_worker_encoder)) { subghz_file_encoder_worker_stop(subghz->decode_raw_file_worker_encoder); diff --git a/applications/main/subghz/scenes/subghz_scene_receiver.c b/applications/main/subghz/scenes/subghz_scene_receiver.c index ac09ebcea..dd7b4cf02 100644 --- a/applications/main/subghz/scenes/subghz_scene_receiver.c +++ b/applications/main/subghz/scenes/subghz_scene_receiver.c @@ -70,13 +70,14 @@ static void subghz_scene_receiver_update_statusbar(void* context) { subghz->subghz_receiver, furi_string_get_cstr(frequency_str), furi_string_get_cstr(modulation_str), - furi_string_get_cstr(history_stat_str)); + furi_string_get_cstr(history_stat_str), + subghz_txrx_hopper_get_state(subghz->txrx) != SubGhzHopperStateOFF); furi_string_free(frequency_str); furi_string_free(modulation_str); } else { subghz_view_receiver_add_data_statusbar( - subghz->subghz_receiver, furi_string_get_cstr(history_stat_str), "", ""); + subghz->subghz_receiver, furi_string_get_cstr(history_stat_str), "", "", false); subghz->state_notifications = SubGhzNotificationStateIDLE; } furi_string_free(history_stat_str); @@ -151,7 +152,7 @@ void subghz_scene_receiver_on_enter(void* context) { subghz_view_receiver_set_lock(subghz->subghz_receiver, subghz_is_locked(subghz)); subghz_view_receiver_set_mode(subghz->subghz_receiver, SubGhzViewReceiverModeLive); - //Load history to receiver + // Load history to receiver subghz_view_receiver_exit(subghz->subghz_receiver); for(uint8_t i = 0; i < subghz_history_get_item(history); i++) { furi_string_reset(item_name); @@ -167,14 +168,24 @@ void subghz_scene_receiver_on_enter(void* context) { } furi_string_free(item_name); furi_string_free(item_time); - subghz_scene_receiver_update_statusbar(subghz); + subghz_view_receiver_set_callback( subghz->subghz_receiver, subghz_scene_receiver_callback, subghz); - subghz_txrx_set_rx_calback(subghz->txrx, subghz_scene_add_to_history_callback, subghz); + subghz_txrx_set_rx_callback(subghz->txrx, subghz_scene_add_to_history_callback, subghz); if(!subghz_history_get_text_space_left(subghz->history, NULL)) { subghz->state_notifications = SubGhzNotificationStateRx; } + + // Check if hopping was enabled +#ifdef FURI_DEBUG + subghz_last_settings_log(subghz->last_settings); +#endif + if(subghz->last_settings->enable_hopping) { + subghz_txrx_hopper_set_state(subghz->txrx, SubGhzHopperStateRunning); + } + + subghz_scene_receiver_update_statusbar(subghz); subghz_txrx_rx_start(subghz->txrx); subghz_view_receiver_set_idx_menu(subghz->subghz_receiver, subghz->idx_menu_chosen); @@ -198,7 +209,7 @@ bool subghz_scene_receiver_on_event(void* context, SceneManagerEvent event) { subghz->state_notifications = SubGhzNotificationStateIDLE; subghz_txrx_stop(subghz->txrx); subghz_txrx_hopper_set_state(subghz->txrx, SubGhzHopperStateOFF); - subghz_txrx_set_rx_calback(subghz->txrx, NULL, subghz); + subghz_txrx_set_rx_callback(subghz->txrx, NULL, subghz); if(subghz_rx_key_state_get(subghz) == SubGhzRxKeyStateAddKey) { subghz_rx_key_state_set(subghz, SubGhzRxKeyStateExit); diff --git a/applications/main/subghz/scenes/subghz_scene_receiver_config.c b/applications/main/subghz/scenes/subghz_scene_receiver_config.c index 62ee53871..8a8c21653 100644 --- a/applications/main/subghz/scenes/subghz_scene_receiver_config.c +++ b/applications/main/subghz/scenes/subghz_scene_receiver_config.c @@ -1,6 +1,8 @@ #include "../subghz_i.h" #include +#define TAG "SubGhzSceneReceiverConfig" + enum SubGhzSettingIndex { SubGhzSettingIndexFrequency, SubGhzSettingIndexHopping, @@ -14,6 +16,10 @@ enum SubGhzSettingIndex { SubGhzSettingIndexRAWThresholdRSSI, }; +static inline const char* bool_to_char(bool value) { + return value ? "ON" : "OFF"; +} + #define RAW_THRESHOLD_RSSI_COUNT 11 const char* const raw_threshold_rssi_text[RAW_THRESHOLD_RSSI_COUNT] = { "-----", @@ -111,23 +117,18 @@ uint8_t subghz_scene_receiver_config_next_preset(const char* preset_name, void* return index; } -uint8_t subghz_scene_receiver_config_hopper_value_index( - const uint32_t value, - const uint32_t values[], - uint8_t values_count, - void* context) { +SubGhzHopperState subghz_scene_receiver_config_hopper_value_index(void* context) { furi_assert(context); - UNUSED(values_count); SubGhz* subghz = context; - if(value == values[0]) { - return 0; + if(subghz_txrx_hopper_get_state(subghz->txrx) == SubGhzHopperStateOFF) { + return SubGhzHopperStateOFF; } else { variable_item_set_current_value_text( (VariableItem*)scene_manager_get_scene_state( subghz->scene_manager, SubGhzSceneReceiverConfig), " -----"); - return 1; + return SubGhzHopperStateRunning; } } @@ -184,13 +185,14 @@ static void subghz_scene_receiver_config_set_preset(VariableItem* item) { static void subghz_scene_receiver_config_set_hopping_running(VariableItem* item) { SubGhz* subghz = variable_item_get_context(item); - uint8_t index = variable_item_get_current_value_index(item); + SubGhzHopperState index = variable_item_get_current_value_index(item); SubGhzSetting* setting = subghz_txrx_get_setting(subghz->txrx); VariableItem* frequency_item = (VariableItem*)scene_manager_get_scene_state( subghz->scene_manager, SubGhzSceneReceiverConfig); - variable_item_set_current_value_text(item, hopping_text[index]); - if(hopping_value[index] == SubGhzHopperStateOFF) { + variable_item_set_current_value_text(item, hopping_text[(uint8_t)index]); + + if(index == SubGhzHopperStateOFF) { char text_buf[10] = {0}; uint32_t frequency = subghz_setting_get_default_frequency(setting); SubGhzRadioPreset preset = subghz_txrx_get_preset(subghz->txrx); @@ -203,6 +205,7 @@ static void subghz_scene_receiver_config_set_hopping_running(VariableItem* item) (frequency % 1000000) / 10000); variable_item_set_current_value_text(frequency_item, text_buf); + // Maybe better add one more function with only with the frequency argument? subghz_txrx_set_preset( subghz->txrx, furi_string_get_cstr(preset.name), @@ -216,8 +219,11 @@ static void subghz_scene_receiver_config_set_hopping_running(VariableItem* item) variable_item_set_current_value_index( frequency_item, subghz_setting_get_frequency_default_index(setting)); } - - subghz_txrx_hopper_set_state(subghz->txrx, hopping_value[index]); + subghz->last_settings->enable_hopping = index != SubGhzHopperStateOFF; +#ifdef FURI_DEBUG + subghz_last_settings_log(subghz->last_settings); +#endif + subghz_txrx_hopper_set_state(subghz->txrx, index); } static void subghz_scene_receiver_config_set_speaker(VariableItem* item) { @@ -333,8 +339,8 @@ void subghz_scene_receiver_config_on_enter(void* context) { HOPPING_COUNT, subghz_scene_receiver_config_set_hopping_running, subghz); - value_index = subghz_scene_receiver_config_hopper_value_index( - subghz_txrx_hopper_get_state(subghz->txrx), hopping_value, HOPPING_COUNT, subghz); + value_index = subghz_scene_receiver_config_hopper_value_index(subghz); + variable_item_set_current_value_index(item, value_index); variable_item_set_current_value_text(item, hopping_text[value_index]); } diff --git a/applications/main/subghz/scenes/subghz_scene_save_success.c b/applications/main/subghz/scenes/subghz_scene_save_success.c index 6a5346492..276e5ecc0 100644 --- a/applications/main/subghz/scenes/subghz_scene_save_success.c +++ b/applications/main/subghz/scenes/subghz_scene_save_success.c @@ -42,7 +42,7 @@ bool subghz_scene_save_success_on_event(void* context, SceneManagerEvent event) subghz->scene_manager, SubGhzSceneDecodeRAW, SubGhzDecodeRawStateStart); subghz->idx_menu_chosen = 0; - subghz_txrx_set_rx_calback(subghz->txrx, NULL, subghz); + subghz_txrx_set_rx_callback(subghz->txrx, NULL, subghz); if(subghz_file_encoder_worker_is_running(subghz->decode_raw_file_worker_encoder)) { subghz_file_encoder_worker_stop(subghz->decode_raw_file_worker_encoder); diff --git a/applications/main/subghz/subghz.c b/applications/main/subghz/subghz.c index 2af334db6..302976a28 100644 --- a/applications/main/subghz/subghz.c +++ b/applications/main/subghz/subghz.c @@ -197,26 +197,14 @@ SubGhz* subghz_alloc(bool alloc_for_tx_only) { subghz->last_settings = subghz_last_settings_alloc(); subghz_last_settings_load(subghz->last_settings, 0); if(!alloc_for_tx_only) { -#if FURI_DEBUG - FURI_LOG_D( - TAG, - "last frequency: %ld, preset: %ld", - subghz->last_settings->frequency, - subghz->last_settings->preset); -#endif subghz_setting_set_default_frequency(setting, subghz->last_settings->frequency); - } - if(!alloc_for_tx_only) { subghz_txrx_set_preset(subghz->txrx, "AM650", subghz->last_settings->frequency, NULL, 0); + subghz->history = subghz_history_alloc(); } subghz_rx_key_state_set(subghz, SubGhzRxKeyStateIDLE); - if(!alloc_for_tx_only) { - subghz->history = subghz_history_alloc(); - } - subghz->secure_data = malloc(sizeof(SecureData)); subghz->filter = SubGhzProtocolFlag_Decodable; diff --git a/applications/main/subghz/subghz_i.c b/applications/main/subghz/subghz_i.c index f91f128cf..dbfe3d426 100644 --- a/applications/main/subghz/subghz_i.c +++ b/applications/main/subghz/subghz_i.c @@ -115,13 +115,13 @@ 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)) { + if(!subghz_txrx_radio_device_is_tx_allowed(subghz->txrx, temp_data32)) { FURI_LOG_E(TAG, "This frequency can only be used for RX on chosen radio module"); load_key_state = SubGhzLoadKeyStateOnlyRx; break; diff --git a/applications/main/subghz/subghz_last_settings.c b/applications/main/subghz/subghz_last_settings.c index 465312b19..84a3b18de 100644 --- a/applications/main/subghz/subghz_last_settings.c +++ b/applications/main/subghz/subghz_last_settings.c @@ -21,6 +21,11 @@ #define SUBGHZ_LAST_SETTING_FIELD_EXTERNAL_MODULE_POWER "ExtPower" #define SUBGHZ_LAST_SETTING_FIELD_TIMESTAMP_FILE_NAMES "TimestampNames" #define SUBGHZ_LAST_SETTING_FIELD_EXTERNAL_MODULE_POWER_AMP "ExtPowerAmp" +#define SUBGHZ_LAST_SETTING_FIELD_HOPPING_ENABLE "Hopping" + +static inline const char* bool_to_char(bool value) { + return value ? "ON" : "OFF"; +} SubGhzLastSettings* subghz_last_settings_alloc(void) { SubGhzLastSettings* instance = malloc(sizeof(SubGhzLastSettings)); @@ -35,9 +40,6 @@ void subghz_last_settings_free(SubGhzLastSettings* instance) { void subghz_last_settings_load(SubGhzLastSettings* instance, size_t preset_count) { UNUSED(preset_count); furi_assert(instance); -#ifdef FURI_DEBUG - FURI_LOG_I(TAG, "subghz_last_settings_load"); -#endif Storage* storage = furi_record_open(RECORD_STORAGE); FlipperFormat* fff_data_file = flipper_format_file_alloc(storage); @@ -49,6 +51,7 @@ void subghz_last_settings_load(SubGhzLastSettings* instance, size_t preset_count bool temp_external_module_power_5v_disable = false; bool temp_external_module_power_amp = false; bool temp_timestamp_file_names = false; + bool temp_enable_hopping = false; //int32_t temp_preset = 0; bool frequency_analyzer_feedback_level_was_read = false; bool frequency_analyzer_trigger_was_read = false; @@ -90,7 +93,11 @@ void subghz_last_settings_load(SubGhzLastSettings* instance, size_t preset_count SUBGHZ_LAST_SETTING_FIELD_EXTERNAL_MODULE_POWER_AMP, (bool*)&temp_external_module_power_amp, 1); - + flipper_format_read_bool( + fff_data_file, + SUBGHZ_LAST_SETTING_FIELD_HOPPING_ENABLE, + (bool*)&temp_enable_hopping, + 1); } else { FURI_LOG_E(TAG, "Error open file %s", SUBGHZ_LAST_SETTINGS_PATH); } @@ -105,6 +112,7 @@ void subghz_last_settings_load(SubGhzLastSettings* instance, size_t preset_count instance->external_module_enabled = false; instance->timestamp_file_names = false; instance->external_module_power_amp = false; + instance->enable_hopping = false; } else { instance->frequency = temp_frequency; @@ -130,6 +138,8 @@ void subghz_last_settings_load(SubGhzLastSettings* instance, size_t preset_count // External power amp CC1101 instance->external_module_power_amp = temp_external_module_power_amp; + instance->enable_hopping = temp_enable_hopping; + // Set globally in furi hal furi_hal_subghz_set_ext_power_amp(instance->external_module_power_amp); @@ -137,6 +147,9 @@ void subghz_last_settings_load(SubGhzLastSettings* instance, size_t preset_count instance->preset = temp_preset; }*/ } +#ifdef FURI_DEBUG + subghz_last_settings_log(instance); +#endif flipper_format_file_close(fff_data_file); flipper_format_free(fff_data_file); @@ -146,7 +159,7 @@ void subghz_last_settings_load(SubGhzLastSettings* instance, size_t preset_count bool subghz_last_settings_save(SubGhzLastSettings* instance) { furi_assert(instance); #ifdef FURI_DEBUG - FURI_LOG_I(TAG, "last_settings_save"); + subghz_last_settings_log(instance); #endif bool saved = false; @@ -217,6 +230,10 @@ bool subghz_last_settings_save(SubGhzLastSettings* instance) { 1)) { break; } + if(!flipper_format_insert_or_update_bool( + file, SUBGHZ_LAST_SETTING_FIELD_HOPPING_ENABLE, &instance->enable_hopping, 1)) { + break; + } saved = true; } while(0); @@ -230,3 +247,20 @@ bool subghz_last_settings_save(SubGhzLastSettings* instance) { return saved; } + +void subghz_last_settings_log(SubGhzLastSettings* instance) { + furi_assert(instance); + + FURI_LOG_I( + TAG, + "Frequency: %03ld.%02ld, FeedbackLevel: %ld, FATrigger: %.2f, External: %s, ExtPower: %s, TimestampNames: %s, ExtPowerAmp: %s, Hopping: %s", + instance->frequency / 1000000 % 1000, + instance->frequency / 10000 % 100, + instance->frequency_analyzer_feedback_level, + (double)instance->frequency_analyzer_trigger, + bool_to_char(instance->external_module_enabled), + bool_to_char(instance->external_module_power_5v_disable), + bool_to_char(instance->timestamp_file_names), + bool_to_char(instance->external_module_power_amp), + bool_to_char(instance->enable_hopping)); +} diff --git a/applications/main/subghz/subghz_last_settings.h b/applications/main/subghz/subghz_last_settings.h index c351cb6a5..d24d876d8 100644 --- a/applications/main/subghz/subghz_last_settings.h +++ b/applications/main/subghz/subghz_last_settings.h @@ -16,6 +16,7 @@ typedef struct { bool external_module_power_amp; // saved so as not to change the version bool timestamp_file_names; + bool enable_hopping; } SubGhzLastSettings; SubGhzLastSettings* subghz_last_settings_alloc(void); @@ -25,3 +26,5 @@ void subghz_last_settings_free(SubGhzLastSettings* instance); void subghz_last_settings_load(SubGhzLastSettings* instance, size_t preset_count); bool subghz_last_settings_save(SubGhzLastSettings* instance); + +void subghz_last_settings_log(SubGhzLastSettings* instance); diff --git a/applications/main/subghz/views/receiver.c b/applications/main/subghz/views/receiver.c index 9d514b8ca..5e4d068c3 100644 --- a/applications/main/subghz/views/receiver.c +++ b/applications/main/subghz/views/receiver.c @@ -62,6 +62,7 @@ typedef struct { FuriString* preset_str; FuriString* history_stat_str; FuriString* progress_str; + bool hopping_enabled; SubGhzReceiverHistory* history; uint16_t idx; uint16_t list_offset; @@ -200,7 +201,8 @@ void subghz_view_receiver_add_data_statusbar( SubGhzViewReceiver* subghz_receiver, const char* frequency_str, const char* preset_str, - const char* history_stat_str) { + const char* history_stat_str, + bool hopping_enabled) { furi_assert(subghz_receiver); with_view_model( subghz_receiver->view, @@ -209,6 +211,7 @@ void subghz_view_receiver_add_data_statusbar( furi_string_set(model->frequency_str, frequency_str); furi_string_set(model->preset_str, preset_str); furi_string_set(model->history_stat_str, history_stat_str); + model->hopping_enabled = hopping_enabled; }, true); } @@ -311,7 +314,6 @@ void subghz_view_receiver_draw(Canvas* canvas, SubGhzViewReceiverModel* model) { canvas_set_color(canvas, ColorBlack); if(model->history_item == 0) { - // TODO if(model->mode == SubGhzViewReceiverModeLive) { canvas_draw_icon( canvas, @@ -323,6 +325,12 @@ void subghz_view_receiver_draw(Canvas* canvas, SubGhzViewReceiverModel* model) { canvas_draw_str(canvas, 63, 46, "Scanning..."); //canvas_draw_line(canvas, 46, 51, 125, 51); canvas_set_font(canvas, FontSecondary); + + if(model->hopping_enabled) { + const uint8_t vertical_offset = 7; + const uint8_t horizontal_offset = 3; + canvas_draw_icon(canvas, horizontal_offset, vertical_offset, &I_Dynamic_9x7); + } } else { canvas_draw_icon( canvas, diff --git a/applications/main/subghz/views/receiver.h b/applications/main/subghz/views/receiver.h index 57718cfc4..264d8a983 100644 --- a/applications/main/subghz/views/receiver.h +++ b/applications/main/subghz/views/receiver.h @@ -31,7 +31,8 @@ void subghz_view_receiver_add_data_statusbar( SubGhzViewReceiver* subghz_receiver, const char* frequency_str, const char* preset_str, - const char* history_stat_str); + const char* history_stat_str, + bool hopping_enabled); void subghz_view_receiver_set_radio_device_type( SubGhzViewReceiver* subghz_receiver, 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/services/cli/cli_commands.c b/applications/services/cli/cli_commands.c index 58dfb9300..2c40fdc16 100644 --- a/applications/services/cli/cli_commands.c +++ b/applications/services/cli/cli_commands.c @@ -473,6 +473,7 @@ void cli_commands_init(Cli* cli) { cli_add_command(cli, "uptime", CliCommandFlagDefault, cli_command_uptime, NULL); cli_add_command(cli, "date", CliCommandFlagParallelSafe, cli_command_date, NULL); cli_add_command(cli, "log", CliCommandFlagParallelSafe, cli_command_log, NULL); + cli_add_command(cli, "l", CliCommandFlagParallelSafe, cli_command_log, NULL); cli_add_command(cli, "sysctl", CliCommandFlagDefault, cli_command_sysctl, NULL); cli_add_command(cli, "ps", CliCommandFlagParallelSafe, cli_command_ps, NULL); cli_add_command(cli, "free", CliCommandFlagParallelSafe, cli_command_free, NULL);