SubGhz: refactoring

This commit is contained in:
gid9798 2023-05-09 19:33:45 +03:00
parent d7f3b8a425
commit c69b2086b0
7 changed files with 29 additions and 31 deletions

View file

@ -355,12 +355,10 @@ void subghz_txrx_stop(SubGhzTxRx* instance) {
case SubGhzTxRxStateTx:
subghz_txrx_tx_stop(instance);
subghz_txrx_speaker_unmute(instance);
//subghz_txrx_sleep(txrx);
break;
case SubGhzTxRxStateRx:
subghz_txrx_rx_end(instance);
subghz_txrx_speaker_mute(instance);
//subghz_txrx_sleep(txrx);
break;
default:
@ -439,7 +437,7 @@ void subghz_txrx_hopper_remove_pause(SubGhzTxRx* instance) {
}
}
void subghz_txrx_hopper_set_pause(SubGhzTxRx* instance) {
void subghz_txrx_hopper_pause(SubGhzTxRx* instance) {
furi_assert(instance);
if(instance->hopper_state == SubGhzHopperStateRunning) {
instance->hopper_state = SubGhzHopperStatePause;
@ -522,7 +520,6 @@ bool subghz_txrx_load_decoder_by_name_protocol(SubGhzTxRx* instance, const char*
furi_assert(instance);
furi_assert(name_protocol);
bool res = false;
instance->decoder_result = NULL;
instance->decoder_result =
subghz_receiver_search_decoder_base_by_name(instance->receiver, name_protocol);
if(instance->decoder_result) {

View file

@ -40,7 +40,7 @@ void subghz_txrx_hopper_update(SubGhzTxRx* instance);
SubGhzHopperState subghz_txrx_hopper_get_state(SubGhzTxRx* instance);
void subghz_txrx_hopper_set_state(SubGhzTxRx* instance, SubGhzHopperState state);
void subghz_txrx_hopper_remove_pause(SubGhzTxRx* instance);
void subghz_txrx_hopper_set_pause(SubGhzTxRx* instance);
void subghz_txrx_hopper_pause(SubGhzTxRx* instance);
void subghz_txrx_speaker_on(SubGhzTxRx* instance);
void subghz_txrx_speaker_off(SubGhzTxRx* instance);

View file

@ -140,13 +140,7 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
} else {
//Restore default setting
if(subghz->raw_send_only) {
subghz_txrx_set_preset(
subghz->txrx,
"AM650",
subghz_setting_get_default_frequency(
subghz_txrx_get_setting(subghz->txrx)),
NULL,
0);
subghz_set_defalut_preset(subghz);
} else {
subghz_txrx_set_preset(
subghz->txrx, "AM650", subghz->last_settings->frequency, NULL, 0);

View file

@ -117,13 +117,12 @@ bool subghz_scene_receiver_info_on_event(void* context, SceneManagerEvent event)
SubGhz* subghz = context;
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == SubGhzCustomEventSceneReceiverInfoTxStart) {
//CC1101 Stop RX -> Start TX
subghz_txrx_hopper_set_pause(subghz->txrx);
if(!subghz_scene_receiver_info_update_parser(subghz)) {
return false;
}
//CC1101 Stop RX -> Start TX
subghz_txrx_hopper_pause(subghz->txrx);
if(!subghz_txrx_tx_start(
subghz->txrx,
subghz_history_get_raw_data(subghz->history, subghz->idx_menu_chosen))) {

View file

@ -51,16 +51,6 @@ static void subghz_rpc_command_callback(RpcAppSystemEvent event, void* context)
}
}
void subghz_blink_start(SubGhz* subghz) {
furi_assert(subghz);
notification_message(subghz->notifications, &sequence_blink_start_magenta);
}
void subghz_blink_stop(SubGhz* subghz) {
furi_assert(subghz);
notification_message(subghz->notifications, &sequence_blink_stop);
}
SubGhz* subghz_alloc(bool alloc_for_tx_only) {
SubGhz* subghz = malloc(sizeof(SubGhz));
@ -274,9 +264,7 @@ SubGhz* subghz_alloc(bool alloc_for_tx_only) {
subghz->secure_data = malloc(sizeof(SecureData));
subghz->filter = SubGhzProtocolFlag_Decodable;
subghz_txrx_receiver_set_filter(subghz->txrx, subghz->filter);
subghz_txrx_need_save_callback_set(subghz->txrx, subghz_save_to_file, subghz);
//Init Error_str

View file

@ -18,6 +18,27 @@
#define TAG "SubGhz"
void subghz_set_defalut_preset(SubGhz* subghz) {
furi_assert(subghz);
subghz_txrx_set_preset(
subghz->txrx,
"AM650",
subghz_setting_get_default_frequency(subghz_txrx_get_setting(subghz->txrx)),
NULL,
0);
}
void subghz_blink_start(SubGhz* subghz) {
furi_assert(subghz);
notification_message(subghz->notifications, &sequence_blink_stop);
notification_message(subghz->notifications, &sequence_blink_start_magenta);
}
void subghz_blink_stop(SubGhz* subghz) {
furi_assert(subghz);
notification_message(subghz->notifications, &sequence_blink_stop);
}
void subghz_dialog_message_show_only_rx(SubGhz* subghz) {
DialogsApp* dialogs = subghz->dialogs;
DialogMessage* message = dialog_message_alloc();

View file

@ -120,32 +120,31 @@ struct SubGhz {
void* rpc_ctx;
};
void subghz_set_defalut_preset(SubGhz* subghz);
void subghz_blink_start(SubGhz* subghz);
void subghz_blink_stop(SubGhz* subghz);
void subghz_dialog_message_show_only_rx(SubGhz* subghz);
bool subghz_key_load(SubGhz* subghz, const char* file_path, bool show_dialog);
bool subghz_get_next_name_file(SubGhz* subghz, uint8_t max_len);
bool subghz_save_protocol_to_file(
SubGhz* subghz,
FlipperFormat* flipper_format,
const char* dev_file_name);
void subghz_save_to_file(void* context);
bool subghz_load_protocol_from_file(SubGhz* subghz);
bool subghz_rename_file(SubGhz* subghz);
bool subghz_file_available(SubGhz* subghz);
bool subghz_delete_file(SubGhz* subghz);
void subghz_file_name_clear(SubGhz* subghz);
bool subghz_path_is_file(FuriString* path);
SubGhzLoadTypeFile subghz_get_load_type_file(SubGhz* subghz);
void subghz_lock(SubGhz* subghz);
void subghz_unlock(SubGhz* subghz);
bool subghz_is_locked(SubGhz* subghz);
SubGhzLoadTypeFile subghz_get_load_type_file(SubGhz* subghz);
void subghz_rx_key_state_set(SubGhz* subghz, SubGhzRxKeyState state);
SubGhzRxKeyState subghz_rx_key_state_get(SubGhz* subghz);