diff --git a/applications/main/subghz/scenes/subghz_scene_need_saving.c b/applications/main/subghz/scenes/subghz_scene_need_saving.c index 8bbaae2ce..8259b6e82 100644 --- a/applications/main/subghz/scenes/subghz_scene_need_saving.c +++ b/applications/main/subghz/scenes/subghz_scene_need_saving.c @@ -49,7 +49,7 @@ bool subghz_scene_need_saving_on_event(void* context, SceneManagerEvent event) { SubGhzRxKeyState state = subghz_rx_key_state_get(subghz); subghz_rx_key_state_set(subghz, SubGhzRxKeyStateIDLE); - if(state) { + if(state == SubGhzRxKeyStateExit) { subghz_txrx_set_preset( subghz->txrx, "AM650", subghz->last_settings->frequency, NULL, 0); scene_manager_search_and_switch_to_previous_scene( diff --git a/applications/main/subghz/scenes/subghz_scene_read_raw.c b/applications/main/subghz/scenes/subghz_scene_read_raw.c index a858ca355..4b8303ddd 100644 --- a/applications/main/subghz/scenes/subghz_scene_read_raw.c +++ b/applications/main/subghz/scenes/subghz_scene_read_raw.c @@ -125,6 +125,7 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) { if(event.type == SceneManagerEventTypeCustom) { switch(event.event) { case SubGhzCustomEventViewReadRAWBack: + subghz_txrx_stop(subghz->txrx); //Stop save file subghz_protocol_raw_save_to_file_stop(decoder_raw); @@ -204,8 +205,6 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) { if(subghz_file_available(subghz) && subghz_scene_read_raw_update_filename(subghz)) { //start send subghz->state_notifications = SubGhzNotificationStateIDLE; - - subghz_txrx_stop(subghz->txrx); if(!subghz_tx_start(subghz, subghz_txrx_get_fff_data(subghz->txrx))) { subghz_rx_key_state_set(subghz, SubGhzRxKeyStateBack); subghz_read_raw_set_status( @@ -273,7 +272,6 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) { if(subghz_protocol_raw_save_to_file_init(decoder_raw, RAW_FILE_NAME, &preset)) { DOLPHIN_DEED(DolphinDeedSubGhzRawRec); subghz_txrx_rx_start(subghz->txrx); - subghz->state_notifications = SubGhzNotificationStateRx; subghz_rx_key_state_set(subghz, SubGhzRxKeyStateAddKey); } else { @@ -316,7 +314,6 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) { subghz_read_raw_add_data_rssi( subghz->subghz_read_raw, ret_rssi.rssi, ret_rssi.is_above); subghz_protocol_raw_save_to_file_pause(decoder_raw, !ret_rssi.is_above); - break; case SubGhzNotificationStateTx: notification_message(subghz->notifications, &sequence_blink_magenta_10); diff --git a/applications/main/subghz/scenes/subghz_scene_receiver.c b/applications/main/subghz/scenes/subghz_scene_receiver.c index 8abb6aff3..9987449cd 100644 --- a/applications/main/subghz/scenes/subghz_scene_receiver.c +++ b/applications/main/subghz/scenes/subghz_scene_receiver.c @@ -184,7 +184,6 @@ void subghz_scene_receiver_on_enter(void* context) { } subghz->state_notifications = SubGhzNotificationStateRx; - subghz_txrx_stop(subghz->txrx); subghz_txrx_rx_start(subghz->txrx); subghz_view_receiver_set_idx_menu(subghz->subghz_receiver, subghz->idx_menu_chosen); diff --git a/applications/main/subghz/scenes/subghz_scene_receiver_config.c b/applications/main/subghz/scenes/subghz_scene_receiver_config.c index e9f84ed0e..29d55c03a 100644 --- a/applications/main/subghz/scenes/subghz_scene_receiver_config.c +++ b/applications/main/subghz/scenes/subghz_scene_receiver_config.c @@ -92,9 +92,9 @@ const char* const magellan_text[MAGELLAN_COUNT] = { uint8_t subghz_scene_receiver_config_next_frequency(const uint32_t value, void* context) { furi_assert(context); SubGhz* subghz = context; - uint8_t index = 0; SubGhzSetting* setting = subghz_txrx_get_setting(subghz->txrx); + uint8_t index = 0; for(uint8_t i = 0; i < subghz_setting_get_frequency_count(setting); i++) { if(value == subghz_setting_get_frequency(setting, i)) { index = i; @@ -186,7 +186,6 @@ static void subghz_scene_receiver_config_set_preset(VariableItem* item) { variable_item_set_current_value_text(item, preset_name); //subghz->last_settings->preset = index; SubGhzRadioPreset preset = subghz_txrx_get_preset(subghz->txrx); - subghz_txrx_set_preset( subghz->txrx, preset_name, @@ -309,12 +308,13 @@ void subghz_scene_receiver_config_on_enter(void* context) { subghz->scene_manager, SubGhzSceneReceiverConfig, (uint32_t)item); variable_item_set_current_value_index(item, value_index); char text_buf[10] = {0}; + uint32_t frequency = subghz_setting_get_frequency(setting, value_index); snprintf( text_buf, sizeof(text_buf), "%lu.%02lu", - subghz_setting_get_frequency(setting, value_index) / 1000000, - (subghz_setting_get_frequency(setting, value_index) % 1000000) / 10000); + frequency / 1000000, + (frequency % 1000000) / 10000); variable_item_set_current_value_text(item, text_buf); item = variable_item_list_add( diff --git a/applications/main/subghz/scenes/subghz_scene_receiver_info.c b/applications/main/subghz/scenes/subghz_scene_receiver_info.c index 5a4dbf5d4..c04f39cb8 100644 --- a/applications/main/subghz/scenes/subghz_scene_receiver_info.c +++ b/applications/main/subghz/scenes/subghz_scene_receiver_info.c @@ -52,7 +52,8 @@ void subghz_scene_receiver_info_draw_widget(SubGhz* subghz) { FuriString* modulation_str = furi_string_alloc(); FuriString* text = furi_string_alloc(); - subghz_txrx_get_frequency_and_modulation(subghz->txrx, frequency_str, modulation_str, false); + subghz_txrx_get_frequency_and_modulation( + subghz->txrx, frequency_str, modulation_str, false); widget_add_string_element( subghz->widget, 78, @@ -120,7 +121,6 @@ bool subghz_scene_receiver_info_on_event(void* context, SceneManagerEvent event) if(!subghz_scene_receiver_info_update_parser(subghz)) { return false; } - //CC1101 Stop RX -> Start TX subghz_txrx_hopper_pause(subghz->txrx); if(!subghz_tx_start( @@ -140,7 +140,7 @@ bool subghz_scene_receiver_info_on_event(void* context, SceneManagerEvent event) widget_reset(subghz->widget); subghz_scene_receiver_info_draw_widget(subghz); - subghz_txrx_stop(subghz->txrx); + subghz_txrx_stop(subghz->txrx); //TODO this is probably a redundant call if(!subghz->in_decoder_scene) { subghz_txrx_rx_start(subghz->txrx); diff --git a/applications/main/subghz/scenes/subghz_scene_saved.c b/applications/main/subghz/scenes/subghz_scene_saved.c index eca5ab801..8b198e339 100644 --- a/applications/main/subghz/scenes/subghz_scene_saved.c +++ b/applications/main/subghz/scenes/subghz_scene_saved.c @@ -4,7 +4,7 @@ void subghz_scene_saved_on_enter(void* context) { SubGhz* subghz = context; if(subghz_load_protocol_from_file(subghz)) { - if((subghz_get_load_type_file(subghz) == SubGhzLoadTypeFileRaw)) { + if(subghz_get_load_type_file(subghz) == SubGhzLoadTypeFileRaw) { subghz_rx_key_state_set(subghz, SubGhzRxKeyStateRAWLoad); scene_manager_next_scene(subghz->scene_manager, SubGhzSceneReadRAW); } else { diff --git a/applications/main/subghz/scenes/subghz_scene_transmitter.c b/applications/main/subghz/scenes/subghz_scene_transmitter.c index 5ac1b0a27..c3ae04a8f 100644 --- a/applications/main/subghz/scenes/subghz_scene_transmitter.c +++ b/applications/main/subghz/scenes/subghz_scene_transmitter.c @@ -81,7 +81,7 @@ bool subghz_scene_transmitter_on_event(void* context, SceneManagerEvent event) { uint8_t tmp_counter = furi_hal_subghz_get_rolling_counter_mult(); furi_hal_subghz_set_rolling_counter_mult(0); // Calling restore! - subghz_txrx_stop(subghz->txrx); + subghz_txrx_stop(subghz->txrx); //TODO this is probably a redundant call if(!subghz_tx_start(subghz, subghz_txrx_get_fff_data(subghz->txrx))) { scene_manager_next_scene( diff --git a/applications/main/subghz/subghz.c b/applications/main/subghz/subghz.c index f9413bbfb..975ec540a 100644 --- a/applications/main/subghz/subghz.c +++ b/applications/main/subghz/subghz.c @@ -428,7 +428,7 @@ int32_t subghz_app(void* p) { if(subghz_key_load(subghz, p, true)) { furi_string_set(subghz->file_path, (const char*)p); - if((subghz_get_load_type_file(subghz) == SubGhzLoadTypeFileRaw)) { + if(subghz_get_load_type_file(subghz) == SubGhzLoadTypeFileRaw) { //Load Raw TX subghz_rx_key_state_set(subghz, SubGhzRxKeyStateRAWLoad); scene_manager_next_scene(subghz->scene_manager, SubGhzSceneReadRAW); diff --git a/applications/main/subghz/subghz_i.c b/applications/main/subghz/subghz_i.c index 205c7ca02..70812ed11 100644 --- a/applications/main/subghz/subghz_i.c +++ b/applications/main/subghz/subghz_i.c @@ -133,30 +133,27 @@ bool subghz_key_load(SubGhz* subghz, const char* file_path, bool show_dialog) { if(!strcmp(furi_string_get_cstr(temp_str), "")) { break; } + SubGhzSetting* setting = subghz_txrx_get_setting(subghz->txrx); if(!strcmp(furi_string_get_cstr(temp_str), "CUSTOM")) { //Todo add Custom_preset_module //delete preset if it already exists - subghz_setting_delete_custom_preset( - subghz_txrx_get_setting(subghz->txrx), furi_string_get_cstr(temp_str)); + subghz_setting_delete_custom_preset(setting, furi_string_get_cstr(temp_str)); //load custom preset from file if(!subghz_setting_load_custom_preset( - subghz_txrx_get_setting(subghz->txrx), - furi_string_get_cstr(temp_str), - fff_data_file)) { + setting, furi_string_get_cstr(temp_str), fff_data_file)) { FURI_LOG_E(TAG, "Missing Custom preset"); break; } } - size_t preset_index = subghz_setting_get_inx_preset_by_name( - subghz_txrx_get_setting(subghz->txrx), furi_string_get_cstr(temp_str)); + size_t preset_index = + subghz_setting_get_inx_preset_by_name(setting, furi_string_get_cstr(temp_str)); subghz_txrx_set_preset( subghz->txrx, furi_string_get_cstr(temp_str), temp_data32, - subghz_setting_get_preset_data(subghz_txrx_get_setting(subghz->txrx), preset_index), - subghz_setting_get_preset_data_size( - subghz_txrx_get_setting(subghz->txrx), preset_index)); + subghz_setting_get_preset_data(setting, preset_index), + subghz_setting_get_preset_data_size(setting, preset_index)); //Load protocol if(!flipper_format_read_string(fff_data_file, "Protocol", temp_str)) {