mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2025-02-17 13:58:32 +00:00
SubGhz: refactoring
This commit is contained in:
parent
d7f3b8a425
commit
c69b2086b0
7 changed files with 29 additions and 31 deletions
|
@ -355,12 +355,10 @@ void subghz_txrx_stop(SubGhzTxRx* instance) {
|
||||||
case SubGhzTxRxStateTx:
|
case SubGhzTxRxStateTx:
|
||||||
subghz_txrx_tx_stop(instance);
|
subghz_txrx_tx_stop(instance);
|
||||||
subghz_txrx_speaker_unmute(instance);
|
subghz_txrx_speaker_unmute(instance);
|
||||||
//subghz_txrx_sleep(txrx);
|
|
||||||
break;
|
break;
|
||||||
case SubGhzTxRxStateRx:
|
case SubGhzTxRxStateRx:
|
||||||
subghz_txrx_rx_end(instance);
|
subghz_txrx_rx_end(instance);
|
||||||
subghz_txrx_speaker_mute(instance);
|
subghz_txrx_speaker_mute(instance);
|
||||||
//subghz_txrx_sleep(txrx);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
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);
|
furi_assert(instance);
|
||||||
if(instance->hopper_state == SubGhzHopperStateRunning) {
|
if(instance->hopper_state == SubGhzHopperStateRunning) {
|
||||||
instance->hopper_state = SubGhzHopperStatePause;
|
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(instance);
|
||||||
furi_assert(name_protocol);
|
furi_assert(name_protocol);
|
||||||
bool res = false;
|
bool res = false;
|
||||||
instance->decoder_result = NULL;
|
|
||||||
instance->decoder_result =
|
instance->decoder_result =
|
||||||
subghz_receiver_search_decoder_base_by_name(instance->receiver, name_protocol);
|
subghz_receiver_search_decoder_base_by_name(instance->receiver, name_protocol);
|
||||||
if(instance->decoder_result) {
|
if(instance->decoder_result) {
|
||||||
|
|
|
@ -40,7 +40,7 @@ void subghz_txrx_hopper_update(SubGhzTxRx* instance);
|
||||||
SubGhzHopperState subghz_txrx_hopper_get_state(SubGhzTxRx* instance);
|
SubGhzHopperState subghz_txrx_hopper_get_state(SubGhzTxRx* instance);
|
||||||
void subghz_txrx_hopper_set_state(SubGhzTxRx* instance, SubGhzHopperState state);
|
void subghz_txrx_hopper_set_state(SubGhzTxRx* instance, SubGhzHopperState state);
|
||||||
void subghz_txrx_hopper_remove_pause(SubGhzTxRx* instance);
|
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_on(SubGhzTxRx* instance);
|
||||||
void subghz_txrx_speaker_off(SubGhzTxRx* instance);
|
void subghz_txrx_speaker_off(SubGhzTxRx* instance);
|
||||||
|
|
|
@ -140,13 +140,7 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
|
||||||
} else {
|
} else {
|
||||||
//Restore default setting
|
//Restore default setting
|
||||||
if(subghz->raw_send_only) {
|
if(subghz->raw_send_only) {
|
||||||
subghz_txrx_set_preset(
|
subghz_set_defalut_preset(subghz);
|
||||||
subghz->txrx,
|
|
||||||
"AM650",
|
|
||||||
subghz_setting_get_default_frequency(
|
|
||||||
subghz_txrx_get_setting(subghz->txrx)),
|
|
||||||
NULL,
|
|
||||||
0);
|
|
||||||
} else {
|
} else {
|
||||||
subghz_txrx_set_preset(
|
subghz_txrx_set_preset(
|
||||||
subghz->txrx, "AM650", subghz->last_settings->frequency, NULL, 0);
|
subghz->txrx, "AM650", subghz->last_settings->frequency, NULL, 0);
|
||||||
|
|
|
@ -117,13 +117,12 @@ bool subghz_scene_receiver_info_on_event(void* context, SceneManagerEvent event)
|
||||||
SubGhz* subghz = context;
|
SubGhz* subghz = context;
|
||||||
if(event.type == SceneManagerEventTypeCustom) {
|
if(event.type == SceneManagerEventTypeCustom) {
|
||||||
if(event.event == SubGhzCustomEventSceneReceiverInfoTxStart) {
|
if(event.event == SubGhzCustomEventSceneReceiverInfoTxStart) {
|
||||||
//CC1101 Stop RX -> Start TX
|
|
||||||
subghz_txrx_hopper_set_pause(subghz->txrx);
|
|
||||||
|
|
||||||
if(!subghz_scene_receiver_info_update_parser(subghz)) {
|
if(!subghz_scene_receiver_info_update_parser(subghz)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//CC1101 Stop RX -> Start TX
|
||||||
|
subghz_txrx_hopper_pause(subghz->txrx);
|
||||||
if(!subghz_txrx_tx_start(
|
if(!subghz_txrx_tx_start(
|
||||||
subghz->txrx,
|
subghz->txrx,
|
||||||
subghz_history_get_raw_data(subghz->history, subghz->idx_menu_chosen))) {
|
subghz_history_get_raw_data(subghz->history, subghz->idx_menu_chosen))) {
|
||||||
|
|
|
@ -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_alloc(bool alloc_for_tx_only) {
|
||||||
SubGhz* subghz = malloc(sizeof(SubGhz));
|
SubGhz* subghz = malloc(sizeof(SubGhz));
|
||||||
|
|
||||||
|
@ -274,9 +264,7 @@ SubGhz* subghz_alloc(bool alloc_for_tx_only) {
|
||||||
subghz->secure_data = malloc(sizeof(SecureData));
|
subghz->secure_data = malloc(sizeof(SecureData));
|
||||||
|
|
||||||
subghz->filter = SubGhzProtocolFlag_Decodable;
|
subghz->filter = SubGhzProtocolFlag_Decodable;
|
||||||
|
|
||||||
subghz_txrx_receiver_set_filter(subghz->txrx, subghz->filter);
|
subghz_txrx_receiver_set_filter(subghz->txrx, subghz->filter);
|
||||||
|
|
||||||
subghz_txrx_need_save_callback_set(subghz->txrx, subghz_save_to_file, subghz);
|
subghz_txrx_need_save_callback_set(subghz->txrx, subghz_save_to_file, subghz);
|
||||||
|
|
||||||
//Init Error_str
|
//Init Error_str
|
||||||
|
|
|
@ -18,6 +18,27 @@
|
||||||
|
|
||||||
#define TAG "SubGhz"
|
#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) {
|
void subghz_dialog_message_show_only_rx(SubGhz* subghz) {
|
||||||
DialogsApp* dialogs = subghz->dialogs;
|
DialogsApp* dialogs = subghz->dialogs;
|
||||||
DialogMessage* message = dialog_message_alloc();
|
DialogMessage* message = dialog_message_alloc();
|
||||||
|
|
|
@ -120,32 +120,31 @@ struct SubGhz {
|
||||||
void* rpc_ctx;
|
void* rpc_ctx;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void subghz_set_defalut_preset(SubGhz* subghz);
|
||||||
void subghz_blink_start(SubGhz* subghz);
|
void subghz_blink_start(SubGhz* subghz);
|
||||||
void subghz_blink_stop(SubGhz* subghz);
|
void subghz_blink_stop(SubGhz* subghz);
|
||||||
|
|
||||||
void subghz_dialog_message_show_only_rx(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_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_get_next_name_file(SubGhz* subghz, uint8_t max_len);
|
||||||
bool subghz_save_protocol_to_file(
|
bool subghz_save_protocol_to_file(
|
||||||
SubGhz* subghz,
|
SubGhz* subghz,
|
||||||
FlipperFormat* flipper_format,
|
FlipperFormat* flipper_format,
|
||||||
const char* dev_file_name);
|
const char* dev_file_name);
|
||||||
|
|
||||||
void subghz_save_to_file(void* context);
|
void subghz_save_to_file(void* context);
|
||||||
|
|
||||||
bool subghz_load_protocol_from_file(SubGhz* subghz);
|
bool subghz_load_protocol_from_file(SubGhz* subghz);
|
||||||
bool subghz_rename_file(SubGhz* subghz);
|
bool subghz_rename_file(SubGhz* subghz);
|
||||||
bool subghz_file_available(SubGhz* subghz);
|
bool subghz_file_available(SubGhz* subghz);
|
||||||
bool subghz_delete_file(SubGhz* subghz);
|
bool subghz_delete_file(SubGhz* subghz);
|
||||||
void subghz_file_name_clear(SubGhz* subghz);
|
void subghz_file_name_clear(SubGhz* subghz);
|
||||||
bool subghz_path_is_file(FuriString* path);
|
bool subghz_path_is_file(FuriString* path);
|
||||||
|
SubGhzLoadTypeFile subghz_get_load_type_file(SubGhz* subghz);
|
||||||
|
|
||||||
void subghz_lock(SubGhz* subghz);
|
void subghz_lock(SubGhz* subghz);
|
||||||
void subghz_unlock(SubGhz* subghz);
|
void subghz_unlock(SubGhz* subghz);
|
||||||
bool subghz_is_locked(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);
|
void subghz_rx_key_state_set(SubGhz* subghz, SubGhzRxKeyState state);
|
||||||
SubGhzRxKeyState subghz_rx_key_state_get(SubGhz* subghz);
|
SubGhzRxKeyState subghz_rx_key_state_get(SubGhz* subghz);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue