SubGhz: show error tx start

This commit is contained in:
gid9798 2023-05-09 19:50:01 +03:00
parent c69b2086b0
commit 21cd94cc79
8 changed files with 47 additions and 26 deletions

View file

@ -225,13 +225,13 @@ static bool subghz_txrx_tx(SubGhzTxRx* instance, uint32_t frequency) {
return ret;
}
bool subghz_txrx_tx_start(SubGhzTxRx* instance, FlipperFormat* flipper_format) {
SubGhzTxRxStartTxState subghz_txrx_tx_start(SubGhzTxRx* instance, FlipperFormat* flipper_format) {
furi_assert(instance);
furi_assert(flipper_format);
subghz_txrx_stop(instance);
bool ret = false;
SubGhzTxRxStartTxState ret = SubGhzTxRxStartTxStateErrorParserOthers;
FuriString* temp_str = furi_string_alloc();
uint32_t repeat = 200;
do {
@ -259,35 +259,31 @@ bool subghz_txrx_tx_start(SubGhzTxRx* instance, FlipperFormat* flipper_format) {
instance,
subghz_setting_get_preset_data_by_name(
instance->setting, furi_string_get_cstr(instance->preset->name)));
if(instance->preset->frequency) {
if(!subghz_txrx_tx(instance, instance->preset->frequency)) {
FURI_LOG_E(TAG, "Only Rx");
ret = SubGhzTxRxStartTxStateErrorOnlyRx;
}
} else {
ret = SubGhzTxRxStartTxStateErrorParserOthers;
}
} else {
FURI_LOG_E(
TAG,
"Unknown name preset \" %s \"",
furi_string_get_cstr(instance->preset->name));
subghz_txrx_begin(
instance,
subghz_setting_get_preset_data_by_name(instance->setting, "AM650"));
ret = SubGhzTxRxStartTxStateErrorParserOthers;
}
if(instance->preset->frequency) {
ret = subghz_txrx_tx(instance, instance->preset->frequency);
} else {
ret = subghz_txrx_tx(instance, 433920000);
}
if(ret) {
if(ret == SubGhzTxRxStartTxStateOk) {
//Start TX
furi_hal_subghz_start_async_tx(
subghz_transmitter_yield, instance->transmitter);
} else {
//Todo: Show error
//subghz_dialog_message_show_only_rx(subghz);
}
} else {
//Todo: Show error
// dialog_message_show_storage_error(
// dialogs, "Error in protocol\nparameters\ndescription");
ret = SubGhzTxRxStartTxStateErrorParserOthers;
}
}
if(!ret) {
if(ret != SubGhzTxRxStartTxStateOk) {
subghz_transmitter_free(instance->transmitter);
if(instance->txrx_state != SubGhzTxRxStateIDLE) {
subghz_txrx_idle(instance);

View file

@ -10,6 +10,12 @@ typedef void (*SubGhzTxRxNeedSaveCallback)(void* context);
typedef struct SubGhzTxRx SubGhzTxRx;
typedef enum {
SubGhzTxRxStartTxStateOk,
SubGhzTxRxStartTxStateErrorOnlyRx,
SubGhzTxRxStartTxStateErrorParserOthers,
} SubGhzTxRxStartTxState;
SubGhzTxRx* subghz_txrx_alloc();
void subghz_txrx_free(SubGhzTxRx* instance);
bool subghz_txrx_is_load_database(SubGhzTxRx* instance);
@ -29,7 +35,7 @@ void subghz_txrx_get_frequency_modulation(
FuriString* frequency,
FuriString* modulation,
bool long_name);
bool subghz_txrx_tx_start(SubGhzTxRx* instance, FlipperFormat* flipper_format);
SubGhzTxRxStartTxState subghz_txrx_tx_start(SubGhzTxRx* instance, FlipperFormat* flipper_format);
void subghz_txrx_rx_start(SubGhzTxRx* instance);
void subghz_txrx_stop(SubGhzTxRx* instance);
void subghz_txrx_sleep(SubGhzTxRx* instance);

View file

@ -209,7 +209,7 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
subghz->state_notifications = SubGhzNotificationStateIDLE;
subghz_txrx_stop(subghz->txrx);
if(!subghz_txrx_tx_start(subghz->txrx, subghz_txtx_get_fff_data(subghz->txrx))) {
if(!subghz_tx_start(subghz, subghz_txtx_get_fff_data(subghz->txrx))) {
subghz_rx_key_state_set(subghz, SubGhzRxKeyStateBack);
subghz_read_raw_set_status(
subghz->subghz_read_raw,

View file

@ -123,8 +123,8 @@ bool subghz_scene_receiver_info_on_event(void* context, SceneManagerEvent event)
//CC1101 Stop RX -> Start TX
subghz_txrx_hopper_pause(subghz->txrx);
if(!subghz_txrx_tx_start(
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_remove_pause(subghz->txrx);

View file

@ -44,7 +44,7 @@ bool subghz_scene_rpc_on_event(void* context, SceneManagerEvent event) {
bool result = false;
if((subghz_txrx_get_state(subghz->txrx) == SubGhzTxRxStateSleep) &&
(state == SubGhzRpcStateLoaded)) {
result = subghz_txrx_tx_start(subghz->txrx, subghz_txtx_get_fff_data(subghz->txrx));
result = subghz_tx_start(subghz, subghz_txtx_get_fff_data(subghz->txrx));
if(result) subghz_blink_start(subghz);
}
if(!result) {

View file

@ -26,7 +26,8 @@ bool subghz_scene_transmitter_update_data_show(void* context) {
subghz_protocol_decoder_base_get_string(
subghz_txrx_get_decoder(subghz->txrx), key_str);
subghz_txrx_get_frequency_modulation(subghz->txrx, frequency_str, modulation_str, false);
subghz_txrx_get_frequency_modulation(
subghz->txrx, frequency_str, modulation_str, false);
subghz_view_transmitter_add_data_to_show(
subghz->subghz_transmitter,
furi_string_get_cstr(key_str),
@ -66,7 +67,7 @@ bool subghz_scene_transmitter_on_event(void* context, SceneManagerEvent event) {
if(event.event == SubGhzCustomEventViewTransmitterSendStart) {
subghz->state_notifications = SubGhzNotificationStateIDLE;
if(subghz_txrx_tx_start(subghz->txrx, subghz_txtx_get_fff_data(subghz->txrx))) {
if(subghz_tx_start(subghz, subghz_txtx_get_fff_data(subghz->txrx))) {
subghz->state_notifications = SubGhzNotificationStateTx;
subghz_scene_transmitter_update_data_show(subghz);
DOLPHIN_DEED(DolphinDeedSubGhzSend);
@ -82,7 +83,7 @@ bool subghz_scene_transmitter_on_event(void* context, SceneManagerEvent event) {
// Calling restore!
subghz_txrx_stop(subghz->txrx);
if(!subghz_txrx_tx_start(subghz->txrx, subghz_txtx_get_fff_data(subghz->txrx))) {
if(!subghz_tx_start(subghz, subghz_txtx_get_fff_data(subghz->txrx))) {
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowOnlyRx);
}

View file

@ -39,6 +39,23 @@ void subghz_blink_stop(SubGhz* subghz) {
notification_message(subghz->notifications, &sequence_blink_stop);
}
bool subghz_tx_start(SubGhz* subghz, FlipperFormat* flipper_format) {
switch(subghz_txrx_tx_start(subghz->txrx, flipper_format)) {
case SubGhzTxRxStartTxStateErrorParserOthers:
dialog_message_show_storage_error(
subghz->dialogs, "Error in protocol\nparameters\ndescription");
break;
case SubGhzTxRxStartTxStateErrorOnlyRx:
subghz_dialog_message_show_only_rx(subghz);
break;
default:
return true;
break;
}
return false;
}
void subghz_dialog_message_show_only_rx(SubGhz* subghz) {
DialogsApp* dialogs = subghz->dialogs;
DialogMessage* message = dialog_message_alloc();

View file

@ -124,6 +124,7 @@ void subghz_set_defalut_preset(SubGhz* subghz);
void subghz_blink_start(SubGhz* subghz);
void subghz_blink_stop(SubGhz* subghz);
bool subghz_tx_start(SubGhz* subghz, FlipperFormat* flipper_format);
void subghz_dialog_message_show_only_rx(SubGhz* subghz);
bool subghz_key_load(SubGhz* subghz, const char* file_path, bool show_dialog);