[FL-3106] SubGhz: better and more verbose error handling in protocols, stricter CAME validation (#2443)
* SubGhz: add error protocol * WS: add error protocol * SubGhz: error processing * SubGhz: more stringent CAME protocol restrictions * SubGhz: fix header duration CAME protocol * SubGhz: delete comments * SubGhz: sync SubGhzProtocolStatus with FuriStatus * SubGhz: update documentation and bump api_version Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
@@ -53,6 +53,7 @@ typedef enum {
|
||||
SubGhzLoadKeyStateUnknown,
|
||||
SubGhzLoadKeyStateOK,
|
||||
SubGhzLoadKeyStateParseErr,
|
||||
SubGhzLoadKeyStateProtocolDescriptionErr,
|
||||
} SubGhzLoadKeyState;
|
||||
|
||||
/** SubGhzLock */
|
||||
|
@@ -22,7 +22,9 @@ static bool subghz_scene_receiver_info_update_parser(void* context) {
|
||||
subghz->txrx->decoder_result = subghz_receiver_search_decoder_base_by_name(
|
||||
subghz->txrx->receiver,
|
||||
subghz_history_get_protocol_name(subghz->txrx->history, subghz->txrx->idx_menu_chosen));
|
||||
|
||||
if(subghz->txrx->decoder_result) {
|
||||
//todo we are trying to deserialize without checking for errors, since it is assumed that we just received this chignal
|
||||
subghz_protocol_decoder_base_deserialize(
|
||||
subghz->txrx->decoder_result,
|
||||
subghz_history_get_raw_data(subghz->txrx->history, subghz->txrx->idx_menu_chosen));
|
||||
@@ -128,7 +130,6 @@ bool subghz_scene_receiver_info_on_event(void* context, SceneManagerEvent event)
|
||||
subghz,
|
||||
subghz_history_get_raw_data(
|
||||
subghz->txrx->history, subghz->txrx->idx_menu_chosen))) {
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowOnlyRx);
|
||||
if(subghz->txrx->txrx_state == SubGhzTxRxStateTx) {
|
||||
subghz_tx_stop(subghz);
|
||||
}
|
||||
|
@@ -34,8 +34,9 @@ bool subghz_scene_set_type_submenu_gen_data_protocol(
|
||||
do {
|
||||
Stream* fff_data_stream = flipper_format_get_raw_stream(subghz->txrx->fff_data);
|
||||
stream_clean(fff_data_stream);
|
||||
if(!subghz_protocol_decoder_base_serialize(
|
||||
subghz->txrx->decoder_result, subghz->txrx->fff_data, subghz->txrx->preset)) {
|
||||
if(subghz_protocol_decoder_base_serialize(
|
||||
subghz->txrx->decoder_result, subghz->txrx->fff_data, subghz->txrx->preset) !=
|
||||
SubGhzProtocolStatusOk) {
|
||||
FURI_LOG_E(TAG, "Unable to serialize");
|
||||
break;
|
||||
}
|
||||
|
@@ -9,9 +9,8 @@ void subghz_scene_transmitter_callback(SubGhzCustomEvent event, void* context) {
|
||||
}
|
||||
|
||||
bool subghz_scene_transmitter_update_data_show(void* context) {
|
||||
//ToDo Fix
|
||||
SubGhz* subghz = context;
|
||||
|
||||
bool ret = false;
|
||||
if(subghz->txrx->decoder_result) {
|
||||
FuriString* key_str;
|
||||
FuriString* frequency_str;
|
||||
@@ -22,30 +21,29 @@ bool subghz_scene_transmitter_update_data_show(void* context) {
|
||||
modulation_str = furi_string_alloc();
|
||||
uint8_t show_button = 0;
|
||||
|
||||
subghz_protocol_decoder_base_deserialize(
|
||||
subghz->txrx->decoder_result, subghz->txrx->fff_data);
|
||||
subghz_protocol_decoder_base_get_string(subghz->txrx->decoder_result, key_str);
|
||||
if(subghz_protocol_decoder_base_deserialize(
|
||||
subghz->txrx->decoder_result, subghz->txrx->fff_data) == SubGhzProtocolStatusOk) {
|
||||
subghz_protocol_decoder_base_get_string(subghz->txrx->decoder_result, key_str);
|
||||
|
||||
if((subghz->txrx->decoder_result->protocol->flag & SubGhzProtocolFlag_Send) ==
|
||||
SubGhzProtocolFlag_Send) {
|
||||
show_button = 1;
|
||||
if((subghz->txrx->decoder_result->protocol->flag & SubGhzProtocolFlag_Send) ==
|
||||
SubGhzProtocolFlag_Send) {
|
||||
show_button = 1;
|
||||
}
|
||||
|
||||
subghz_get_frequency_modulation(subghz, frequency_str, modulation_str);
|
||||
subghz_view_transmitter_add_data_to_show(
|
||||
subghz->subghz_transmitter,
|
||||
furi_string_get_cstr(key_str),
|
||||
furi_string_get_cstr(frequency_str),
|
||||
furi_string_get_cstr(modulation_str),
|
||||
show_button);
|
||||
ret = true;
|
||||
}
|
||||
|
||||
subghz_get_frequency_modulation(subghz, frequency_str, modulation_str);
|
||||
subghz_view_transmitter_add_data_to_show(
|
||||
subghz->subghz_transmitter,
|
||||
furi_string_get_cstr(key_str),
|
||||
furi_string_get_cstr(frequency_str),
|
||||
furi_string_get_cstr(modulation_str),
|
||||
show_button);
|
||||
|
||||
furi_string_free(frequency_str);
|
||||
furi_string_free(modulation_str);
|
||||
furi_string_free(key_str);
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void subghz_scene_transmitter_on_enter(void* context) {
|
||||
|
@@ -153,7 +153,6 @@ bool subghz_tx_start(SubGhz* subghz, FlipperFormat* flipper_format) {
|
||||
FURI_LOG_E(TAG, "Missing Protocol");
|
||||
break;
|
||||
}
|
||||
//ToDo FIX
|
||||
if(!flipper_format_insert_or_update_uint32(flipper_format, "Repeat", &repeat, 1)) {
|
||||
FURI_LOG_E(TAG, "Unable Repeat");
|
||||
break;
|
||||
@@ -163,7 +162,8 @@ bool subghz_tx_start(SubGhz* subghz, FlipperFormat* flipper_format) {
|
||||
subghz->txrx->environment, furi_string_get_cstr(temp_str));
|
||||
|
||||
if(subghz->txrx->transmitter) {
|
||||
if(subghz_transmitter_deserialize(subghz->txrx->transmitter, flipper_format)) {
|
||||
if(subghz_transmitter_deserialize(subghz->txrx->transmitter, flipper_format) ==
|
||||
SubGhzProtocolStatusOk) {
|
||||
if(strcmp(furi_string_get_cstr(subghz->txrx->preset->name), "") != 0) {
|
||||
subghz_begin(
|
||||
subghz,
|
||||
@@ -186,7 +186,12 @@ bool subghz_tx_start(SubGhz* subghz, FlipperFormat* flipper_format) {
|
||||
//Start TX
|
||||
furi_hal_subghz_start_async_tx(
|
||||
subghz_transmitter_yield, subghz->txrx->transmitter);
|
||||
} else {
|
||||
subghz_dialog_message_show_only_rx(subghz);
|
||||
}
|
||||
} else {
|
||||
dialog_message_show_storage_error(
|
||||
subghz->dialogs, "Error in protocol\nparameters\ndescription");
|
||||
}
|
||||
}
|
||||
if(!ret) {
|
||||
@@ -333,8 +338,10 @@ bool subghz_key_load(SubGhz* subghz, const char* file_path, bool show_dialog) {
|
||||
subghz->txrx->decoder_result = subghz_receiver_search_decoder_base_by_name(
|
||||
subghz->txrx->receiver, furi_string_get_cstr(temp_str));
|
||||
if(subghz->txrx->decoder_result) {
|
||||
if(!subghz_protocol_decoder_base_deserialize(
|
||||
subghz->txrx->decoder_result, subghz->txrx->fff_data)) {
|
||||
SubGhzProtocolStatus status = subghz_protocol_decoder_base_deserialize(
|
||||
subghz->txrx->decoder_result, subghz->txrx->fff_data);
|
||||
if(status != SubGhzProtocolStatusOk) {
|
||||
load_key_state = SubGhzLoadKeyStateProtocolDescriptionErr;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
@@ -355,6 +362,12 @@ bool subghz_key_load(SubGhz* subghz, const char* file_path, bool show_dialog) {
|
||||
dialog_message_show_storage_error(subghz->dialogs, "Cannot parse\nfile");
|
||||
}
|
||||
return false;
|
||||
case SubGhzLoadKeyStateProtocolDescriptionErr:
|
||||
if(show_dialog) {
|
||||
dialog_message_show_storage_error(
|
||||
subghz->dialogs, "Error in protocol\nparameters\ndescription");
|
||||
}
|
||||
return false;
|
||||
|
||||
case SubGhzLoadKeyStateOK:
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user