Skip to content

Commit

Permalink
SubGHZ Viewing a Key, turn Receive notification off and stop the Radi…
Browse files Browse the repository at this point in the history
…o until Receive is fixed.
  • Loading branch information
LeeroysHub committed Nov 15, 2023
1 parent 8d2bf08 commit 34f98ae
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 29 deletions.
29 changes: 15 additions & 14 deletions applications/main/subghz/scenes/subghz_scene_receiver.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,23 +288,24 @@ bool subghz_scene_receiver_on_event(void* context, SceneManagerEvent event) {
subghz_receiver_rssi(subghz->subghz_receiver, ret_rssi.rssi);
subghz_protocol_decoder_bin_raw_data_input_rssi(
(SubGhzProtocolDecoderBinRAW*)subghz_txrx_get_decoder(subghz->txrx), ret_rssi.rssi);
}

switch(subghz->state_notifications) {
case SubGhzNotificationStateRx:
notification_message(subghz->notifications, &sequence_blink_cyan_10);
break;
case SubGhzNotificationStateRxDone:
if(!subghz_is_locked(subghz)) {
notification_message(subghz->notifications, &subghz_sequence_rx);
} else {
notification_message(subghz->notifications, &subghz_sequence_rx_locked);
}
subghz->state_notifications = SubGhzNotificationStateRx;
break;
default:
break;
switch(subghz->state_notifications) {
case SubGhzNotificationStateRx:
notification_message(subghz->notifications, &sequence_blink_cyan_10);
break;
case SubGhzNotificationStateRxDone:
if(!subghz_is_locked(subghz)) {
notification_message(subghz->notifications, &subghz_sequence_rx);
} else {
notification_message(subghz->notifications, &subghz_sequence_rx_locked);
}
subghz->state_notifications = SubGhzNotificationStateRx;
break;
default:
break;
}

return consumed;
}

Expand Down
48 changes: 33 additions & 15 deletions applications/main/subghz/scenes/subghz_scene_receiver_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

#define TAG "SubGhzSceneReceiverInfo"

uint32_t SavedHopperState;

void subghz_scene_receiver_info_callback(GuiButtonType result, InputType type, void* context) {
furi_assert(context);
SubGhz* subghz = context;
Expand Down Expand Up @@ -109,12 +111,22 @@ void subghz_scene_receiver_info_on_enter(void* context) {
SubGhz* subghz = context;

subghz_custom_btns_reset();

subghz_scene_receiver_info_draw_widget(subghz);

/* This does not work. The receiving does not happen, and they know it.
So, why do we turn on the notification that we receive?
THe user thinks its receiving, dont matter if SubGHZ is technically on.
if(!subghz_history_get_text_space_left(subghz->history, NULL)) {
subghz->state_notifications = SubGhzNotificationStateRx;
}
*/

//I am turning off the Radio, if the FLipper people want to fix the bug they can!
subghz->state_notifications = SubGhzNotificationStateIDLE;
subghz_txrx_stop(subghz->txrx);
subghz_txrx_hopper_pause(subghz->txrx);
SavedHopperState = subghz_txrx_hopper_get_state(subghz->txrx);
subghz_txrx_hopper_set_state(subghz->txrx, SubGhzHopperStateOFF);
}

bool subghz_scene_receiver_info_on_event(void* context, SceneManagerEvent event) {
Expand All @@ -125,13 +137,13 @@ bool subghz_scene_receiver_info_on_event(void* context, SceneManagerEvent event)
return false;
}
//CC1101 Stop RX -> Start TX
subghz_txrx_hopper_pause(subghz->txrx);
//subghz_txrx_hopper_pause(subghz->txrx);
if(!subghz_tx_start(
subghz,
subghz_history_get_raw_data(subghz->history, subghz->idx_menu_chosen))) {
subghz_txrx_rx_start(subghz->txrx);
subghz_txrx_hopper_unpause(subghz->txrx);
subghz->state_notifications = SubGhzNotificationStateRx;
//subghz_txrx_rx_start(subghz->txrx);
//subghz_txrx_hopper_unpause(subghz->txrx);
subghz->state_notifications = SubGhzNotificationStateIDLE;
} else {
subghz->state_notifications = SubGhzNotificationStateTx;
}
Expand All @@ -144,21 +156,21 @@ bool subghz_scene_receiver_info_on_event(void* context, SceneManagerEvent event)
subghz_scene_receiver_info_draw_widget(subghz);

subghz_txrx_stop(subghz->txrx);
if(!scene_manager_has_previous_scene(subghz->scene_manager, SubGhzSceneDecodeRAW)) {
subghz_txrx_rx_start(subghz->txrx);

subghz_txrx_hopper_unpause(subghz->txrx);
if(!subghz_history_get_text_space_left(subghz->history, NULL)) {
subghz->state_notifications = SubGhzNotificationStateRx;
}
}
//if(!scene_manager_has_previous_scene(subghz->scene_manager, SubGhzSceneDecodeRAW)) {
//subghz_txrx_rx_start(subghz->txrx);

//subghz_txrx_hopper_unpause(subghz->txrx);
//if(!subghz_history_get_text_space_left(subghz->history, NULL)) {
// subghz->state_notifications = SubGhzNotificationStateIDLE;
//}
//}
return true;
} else if(event.event == SubGhzCustomEventSceneReceiverInfoSave) {
//CC1101 Stop RX -> Save
subghz->state_notifications = SubGhzNotificationStateIDLE;
subghz_txrx_hopper_set_state(subghz->txrx, SubGhzHopperStateOFF);
//subghz_txrx_hopper_set_state(subghz->txrx, SubGhzHopperStateOFF);

subghz_txrx_stop(subghz->txrx);
//subghz_txrx_stop(subghz->txrx);
if(!subghz_scene_receiver_info_update_parser(subghz)) {
return false;
}
Expand Down Expand Up @@ -197,4 +209,10 @@ void subghz_scene_receiver_info_on_exit(void* context) {

widget_reset(subghz->widget);
subghz_txrx_reset_dynamic_and_custom_btns(subghz->txrx);

/* Proper fix now! Start the radio again. */
subghz->state_notifications = SubGhzNotificationStateRx;
subghz_txrx_hopper_set_state(subghz->txrx, SavedHopperState);
subghz_txrx_rx_start(subghz->txrx);
subghz_txrx_hopper_unpause(subghz->txrx);
}
15 changes: 15 additions & 0 deletions applications/main/subghz/scenes/subghz_scene_save_name.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#define MAX_TEXT_INPUT_LEN 23

uint32_t SavedHopperState2; //3 Strikes its out and Ill change the model!

void subghz_scene_save_name_text_input_callback(void* context) {
furi_assert(context);
SubGhz* subghz = context;
Expand Down Expand Up @@ -119,6 +121,13 @@ void subghz_scene_save_name_on_enter(void* context) {
furi_string_free(file_name);
furi_string_free(dir_name);

//I am turning off the Radio, if the FLipper people want to fix the bug they can!
subghz->state_notifications = SubGhzNotificationStateIDLE;
subghz_txrx_stop(subghz->txrx);
subghz_txrx_hopper_pause(subghz->txrx);
SavedHopperState2 = subghz_txrx_hopper_get_state(subghz->txrx);
subghz_txrx_hopper_set_state(subghz->txrx, SubGhzHopperStateOFF);

view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdTextInput);
}

Expand Down Expand Up @@ -216,6 +225,12 @@ void subghz_scene_save_name_on_exit(void* context) {
text_input_set_validator(subghz->text_input, NULL, NULL);
validator_is_file_free(validator_context);

/* Proper fix now! Start the radio again. */
subghz->state_notifications = SubGhzNotificationStateRx;
subghz_txrx_hopper_set_state(subghz->txrx, SavedHopperState2);
subghz_txrx_rx_start(subghz->txrx);
subghz_txrx_hopper_unpause(subghz->txrx);

// Clear view
text_input_reset(subghz->text_input);
}

0 comments on commit 34f98ae

Please sign in to comment.