mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-05-12 19:58:36 -07:00
[FL-2230] SubGhz: protocol API refactoring (#969)
* SubGhz: protocols library refactoring * SubGhz: new architecture and refactoring * SubGhz: simplify protocol structure, remove unused types * SubGhz: rename Subghz to SubGhz * SubGhz: add environment concept Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com> Co-authored-by: DrZlo13 <who.just.the.doctor@gmail.com>
This commit is contained in:
@@ -5,7 +5,7 @@ void subghz_scene_delete_callback(GuiButtonType result, InputType type, void* co
|
||||
furi_assert(context);
|
||||
SubGhz* subghz = context;
|
||||
if((result == GuiButtonTypeRight) && (type == InputTypeShort)) {
|
||||
view_dispatcher_send_custom_event(subghz->view_dispatcher, SubghzCustomEventSceneDelete);
|
||||
view_dispatcher_send_custom_event(subghz->view_dispatcher, SubGhzCustomEventSceneDelete);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,8 +31,7 @@ void subghz_scene_delete_on_enter(void* context) {
|
||||
AlignTop,
|
||||
FontSecondary,
|
||||
string_get_cstr(modulation_str));
|
||||
|
||||
subghz->txrx->protocol_result->to_string(subghz->txrx->protocol_result, text);
|
||||
subghz_protocol_decoder_base_get_string(subghz->txrx->decoder_result, text);
|
||||
widget_add_string_multiline_element(
|
||||
subghz->widget, 0, 0, AlignLeft, AlignTop, FontSecondary, string_get_cstr(text));
|
||||
|
||||
@@ -43,13 +42,13 @@ void subghz_scene_delete_on_enter(void* context) {
|
||||
widget_add_button_element(
|
||||
subghz->widget, GuiButtonTypeRight, "Delete", subghz_scene_delete_callback, subghz);
|
||||
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewWidget);
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdWidget);
|
||||
}
|
||||
|
||||
bool subghz_scene_delete_on_event(void* context, SceneManagerEvent event) {
|
||||
SubGhz* subghz = context;
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubghzCustomEventSceneDelete) {
|
||||
if(event.event == SubGhzCustomEventSceneDelete) {
|
||||
strcpy(subghz->file_name_tmp, subghz->file_name);
|
||||
if(subghz_delete_file(subghz)) {
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneDeleteSuccess);
|
||||
|
||||
@@ -6,10 +6,10 @@ void subghz_scene_delete_raw_callback(GuiButtonType result, InputType type, void
|
||||
SubGhz* subghz = context;
|
||||
if((result == GuiButtonTypeRight) && (type == InputTypeShort)) {
|
||||
view_dispatcher_send_custom_event(
|
||||
subghz->view_dispatcher, SubghzCustomEventSceneDeleteRAW);
|
||||
subghz->view_dispatcher, SubGhzCustomEventSceneDeleteRAW);
|
||||
} else if((result == GuiButtonTypeLeft) && (type == InputTypeShort)) {
|
||||
view_dispatcher_send_custom_event(
|
||||
subghz->view_dispatcher, SubghzCustomEventSceneDeleteRAWBack);
|
||||
subghz->view_dispatcher, SubGhzCustomEventSceneDeleteRAWBack);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,13 +49,13 @@ void subghz_scene_delete_raw_on_enter(void* context) {
|
||||
widget_add_button_element(
|
||||
subghz->widget, GuiButtonTypeLeft, "Back", subghz_scene_delete_raw_callback, subghz);
|
||||
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewWidget);
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdWidget);
|
||||
}
|
||||
|
||||
bool subghz_scene_delete_raw_on_event(void* context, SceneManagerEvent event) {
|
||||
SubGhz* subghz = context;
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubghzCustomEventSceneDeleteRAW) {
|
||||
if(event.event == SubGhzCustomEventSceneDeleteRAW) {
|
||||
strcpy(subghz->file_name_tmp, subghz->file_name);
|
||||
if(subghz_delete_file(subghz)) {
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneDeleteSuccess);
|
||||
@@ -64,7 +64,7 @@ bool subghz_scene_delete_raw_on_event(void* context, SceneManagerEvent event) {
|
||||
subghz->scene_manager, SubGhzSceneStart);
|
||||
}
|
||||
return true;
|
||||
} else if(event.event == SubghzCustomEventSceneDeleteRAWBack) {
|
||||
} else if(event.event == SubGhzCustomEventSceneDeleteRAWBack) {
|
||||
return scene_manager_previous_scene(subghz->scene_manager);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
void subghz_scene_delete_success_popup_callback(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
view_dispatcher_send_custom_event(
|
||||
subghz->view_dispatcher, SubghzCustomEventSceneDeleteSuccess);
|
||||
subghz->view_dispatcher, SubGhzCustomEventSceneDeleteSuccess);
|
||||
}
|
||||
|
||||
void subghz_scene_delete_success_on_enter(void* context) {
|
||||
@@ -18,14 +18,14 @@ void subghz_scene_delete_success_on_enter(void* context) {
|
||||
popup_set_context(popup, subghz);
|
||||
popup_set_callback(popup, subghz_scene_delete_success_popup_callback);
|
||||
popup_enable_timeout(popup);
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewPopup);
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdPopup);
|
||||
}
|
||||
|
||||
bool subghz_scene_delete_success_on_event(void* context, SceneManagerEvent event) {
|
||||
SubGhz* subghz = context;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubghzCustomEventSceneDeleteSuccess) {
|
||||
if(event.event == SubGhzCustomEventSceneDeleteSuccess) {
|
||||
if(!scene_manager_search_and_switch_to_previous_scene(
|
||||
subghz->scene_manager, SubGhzSceneSaved)) {
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSaved);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include "../views/subghz_frequency_analyzer.h"
|
||||
#include <dolphin/dolphin.h>
|
||||
|
||||
void subghz_scene_frequency_analyzer_callback(SubghzCustomEvent event, void* context) {
|
||||
void subghz_scene_frequency_analyzer_callback(SubGhzCustomEvent event, void* context) {
|
||||
furi_assert(context);
|
||||
SubGhz* subghz = context;
|
||||
view_dispatcher_send_custom_event(subghz->view_dispatcher, event);
|
||||
@@ -13,7 +13,7 @@ void subghz_scene_frequency_analyzer_on_enter(void* context) {
|
||||
DOLPHIN_DEED(DolphinDeedSubGhzFrequencyAnalyzer);
|
||||
subghz_frequency_analyzer_set_callback(
|
||||
subghz->subghz_frequency_analyzer, subghz_scene_frequency_analyzer_callback, subghz);
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewFrequencyAnalyzer);
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdFrequencyAnalyzer);
|
||||
}
|
||||
|
||||
bool subghz_scene_frequency_analyzer_on_event(void* context, SceneManagerEvent event) {
|
||||
|
||||
@@ -30,7 +30,7 @@ void subghz_scene_more_raw_on_enter(void* context) {
|
||||
submenu_set_selected_item(
|
||||
subghz->submenu, scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneMoreRAW));
|
||||
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewMenu);
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdMenu);
|
||||
}
|
||||
|
||||
bool subghz_scene_more_raw_on_event(void* context, SceneManagerEvent event) {
|
||||
@@ -39,7 +39,7 @@ bool subghz_scene_more_raw_on_event(void* context, SceneManagerEvent event) {
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubmenuIndexDelete) {
|
||||
scene_manager_set_scene_state(
|
||||
subghz->scene_manager, SubGhzSceneReadRAW, SubghzCustomEventManagerNoSet);
|
||||
subghz->scene_manager, SubGhzSceneReadRAW, SubGhzCustomEventManagerNoSet);
|
||||
scene_manager_set_scene_state(
|
||||
subghz->scene_manager, SubGhzSceneMoreRAW, SubmenuIndexDelete);
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneDeleteRAW);
|
||||
|
||||
@@ -6,9 +6,9 @@ void subghz_scene_need_saving_callback(GuiButtonType result, InputType type, voi
|
||||
SubGhz* subghz = context;
|
||||
|
||||
if((result == GuiButtonTypeRight) && (type == InputTypeShort)) {
|
||||
view_dispatcher_send_custom_event(subghz->view_dispatcher, SubghzCustomEventSceneStay);
|
||||
view_dispatcher_send_custom_event(subghz->view_dispatcher, SubGhzCustomEventSceneStay);
|
||||
} else if((result == GuiButtonTypeLeft) && (type == InputTypeShort)) {
|
||||
view_dispatcher_send_custom_event(subghz->view_dispatcher, SubghzCustomEventSceneExit);
|
||||
view_dispatcher_send_custom_event(subghz->view_dispatcher, SubGhzCustomEventSceneExit);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ void subghz_scene_need_saving_on_enter(void* context) {
|
||||
widget_add_button_element(
|
||||
subghz->widget, GuiButtonTypeLeft, "Exit", subghz_scene_need_saving_callback, subghz);
|
||||
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewWidget);
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdWidget);
|
||||
}
|
||||
|
||||
bool subghz_scene_need_saving_on_event(void* context, SceneManagerEvent event) {
|
||||
@@ -41,11 +41,11 @@ bool subghz_scene_need_saving_on_event(void* context, SceneManagerEvent event) {
|
||||
scene_manager_previous_scene(subghz->scene_manager);
|
||||
return true;
|
||||
} else if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubghzCustomEventSceneStay) {
|
||||
if(event.event == SubGhzCustomEventSceneStay) {
|
||||
subghz->txrx->rx_key_state = SubGhzRxKeyStateBack;
|
||||
scene_manager_previous_scene(subghz->scene_manager);
|
||||
return true;
|
||||
} else if(event.event == SubghzCustomEventSceneExit) {
|
||||
} else if(event.event == SubGhzCustomEventSceneExit) {
|
||||
if(subghz->txrx->rx_key_state == SubGhzRxKeyStateExit) {
|
||||
subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE;
|
||||
scene_manager_search_and_switch_to_previous_scene(
|
||||
|
||||
@@ -1,35 +1,35 @@
|
||||
#include "../subghz_i.h"
|
||||
#include "../views/subghz_read_raw.h"
|
||||
#include <dolphin/dolphin.h>
|
||||
#include <lib/subghz/protocols/subghz_protocol_raw.h>
|
||||
#include <lib/subghz/subghz_parser.h>
|
||||
#include <lib/subghz/protocols/raw.h>
|
||||
#include <lib/toolbox/path.h>
|
||||
|
||||
#define RAW_FILE_NAME "Raw_signal_"
|
||||
#define TAG "SubGhzSceneReadRAW"
|
||||
|
||||
bool subghz_scene_read_raw_update_filename(SubGhz* subghz) {
|
||||
bool ret = false;
|
||||
//set the path to read the file
|
||||
if(strcmp(
|
||||
subghz_protocol_raw_get_last_file_name(
|
||||
(SubGhzProtocolRAW*)subghz->txrx->protocol_result),
|
||||
"")) {
|
||||
string_t temp_str;
|
||||
string_init_printf(
|
||||
temp_str,
|
||||
"%s",
|
||||
subghz_protocol_raw_get_last_file_name(
|
||||
(SubGhzProtocolRAW*)subghz->txrx->protocol_result));
|
||||
string_t temp_str;
|
||||
string_init(temp_str);
|
||||
do {
|
||||
if(!flipper_format_rewind(subghz->txrx->fff_data)) {
|
||||
FURI_LOG_E(TAG, "Rewind error");
|
||||
break;
|
||||
}
|
||||
|
||||
if(!flipper_format_read_string(subghz->txrx->fff_data, "File_name", temp_str)) {
|
||||
FURI_LOG_E(TAG, "Missing File_name");
|
||||
break;
|
||||
}
|
||||
|
||||
path_extract_filename_no_ext(string_get_cstr(temp_str), temp_str);
|
||||
strcpy(subghz->file_name, string_get_cstr(temp_str));
|
||||
string_printf(
|
||||
temp_str, "%s/%s%s", SUBGHZ_APP_FOLDER, subghz->file_name, SUBGHZ_APP_EXTENSION);
|
||||
|
||||
subghz_protocol_raw_set_last_file_name(
|
||||
(SubGhzProtocolRAW*)subghz->txrx->protocol_result, string_get_cstr(temp_str));
|
||||
string_clear(temp_str);
|
||||
ret = true;
|
||||
}
|
||||
} while(false);
|
||||
|
||||
string_clear(temp_str);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ static void subghz_scene_read_raw_update_statusbar(void* context) {
|
||||
string_clear(modulation_str);
|
||||
}
|
||||
|
||||
void subghz_scene_read_raw_callback(SubghzCustomEvent event, void* context) {
|
||||
void subghz_scene_read_raw_callback(SubGhzCustomEvent event, void* context) {
|
||||
furi_assert(context);
|
||||
SubGhz* subghz = context;
|
||||
view_dispatcher_send_custom_event(subghz->view_dispatcher, event);
|
||||
@@ -61,7 +61,7 @@ void subghz_scene_read_raw_callback_end_tx(void* context) {
|
||||
furi_assert(context);
|
||||
SubGhz* subghz = context;
|
||||
view_dispatcher_send_custom_event(
|
||||
subghz->view_dispatcher, SubghzCustomEventViewReadRAWSendStop);
|
||||
subghz->view_dispatcher, SubGhzCustomEventViewReadRAWSendStop);
|
||||
}
|
||||
|
||||
void subghz_scene_read_raw_on_enter(void* context) {
|
||||
@@ -69,46 +69,43 @@ void subghz_scene_read_raw_on_enter(void* context) {
|
||||
|
||||
switch(subghz->txrx->rx_key_state) {
|
||||
case SubGhzRxKeyStateBack:
|
||||
subghz_read_raw_set_status(subghz->subghz_read_raw, SubghzReadRAWStatusIDLE, "");
|
||||
subghz_read_raw_set_status(subghz->subghz_read_raw, SubGhzReadRAWStatusIDLE, "");
|
||||
break;
|
||||
case SubGhzRxKeyStateRAWLoad:
|
||||
subghz_read_raw_set_status(
|
||||
subghz->subghz_read_raw, SubghzReadRAWStatusLoadKeyTX, subghz->file_name);
|
||||
subghz->subghz_read_raw, SubGhzReadRAWStatusLoadKeyTX, subghz->file_name);
|
||||
subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE;
|
||||
break;
|
||||
case SubGhzRxKeyStateRAWSave:
|
||||
subghz_read_raw_set_status(
|
||||
subghz->subghz_read_raw, SubghzReadRAWStatusSaveKey, subghz->file_name);
|
||||
subghz->subghz_read_raw, SubGhzReadRAWStatusSaveKey, subghz->file_name);
|
||||
subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE;
|
||||
break;
|
||||
default:
|
||||
subghz_read_raw_set_status(subghz->subghz_read_raw, SubghzReadRAWStatusStart, "");
|
||||
subghz_read_raw_set_status(subghz->subghz_read_raw, SubGhzReadRAWStatusStart, "");
|
||||
subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE;
|
||||
break;
|
||||
}
|
||||
|
||||
subghz_scene_read_raw_update_statusbar(subghz);
|
||||
|
||||
//set callback view raw
|
||||
subghz_read_raw_set_callback(subghz->subghz_read_raw, subghz_scene_read_raw_callback, subghz);
|
||||
|
||||
subghz->txrx->protocol_result = subghz_parser_get_by_name(subghz->txrx->parser, "RAW");
|
||||
furi_assert(subghz->txrx->protocol_result);
|
||||
subghz->txrx->decoder_result =
|
||||
subghz_receiver_search_decoder_base_by_name(subghz->txrx->receiver, "RAW");
|
||||
furi_assert(subghz->txrx->decoder_result);
|
||||
|
||||
subghz_worker_set_pair_callback(
|
||||
subghz->txrx->worker, (SubGhzWorkerPairCallback)subghz_parser_raw_parse);
|
||||
|
||||
subghz_protocol_raw_file_encoder_worker_set_callback_end(
|
||||
(SubGhzProtocolRAW*)subghz->txrx->protocol_result,
|
||||
subghz_scene_read_raw_callback_end_tx,
|
||||
subghz);
|
||||
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewReadRAW);
|
||||
//set filter RAW feed
|
||||
subghz_receiver_set_filter(subghz->txrx->receiver, SubGhzProtocolFlag_RAW);
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdReadRAW);
|
||||
}
|
||||
|
||||
bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
|
||||
SubGhz* subghz = context;
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
switch(event.event) {
|
||||
case SubghzCustomEventViewReadRAWBack:
|
||||
case SubGhzCustomEventViewReadRAWBack:
|
||||
//Stop TX
|
||||
if(subghz->txrx->txrx_state == SubGhzTxRxStateTx) {
|
||||
subghz_tx_stop(subghz);
|
||||
@@ -121,7 +118,7 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
|
||||
};
|
||||
//Stop save file
|
||||
subghz_protocol_raw_save_to_file_stop(
|
||||
(SubGhzProtocolRAW*)subghz->txrx->protocol_result);
|
||||
(SubGhzProtocolDecoderRAW*)subghz->txrx->decoder_result);
|
||||
subghz->state_notifications = SubGhzNotificationStateIDLE;
|
||||
//needed save?
|
||||
if((subghz->txrx->rx_key_state == SubGhzRxKeyStateAddKey) ||
|
||||
@@ -144,7 +141,7 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
|
||||
return true;
|
||||
break;
|
||||
|
||||
case SubghzCustomEventViewReadRAWTXRXStop:
|
||||
case SubGhzCustomEventViewReadRAWTXRXStop:
|
||||
//Stop TX
|
||||
if(subghz->txrx->txrx_state == SubGhzTxRxStateTx) {
|
||||
subghz_tx_stop(subghz);
|
||||
@@ -159,27 +156,27 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
|
||||
return true;
|
||||
break;
|
||||
|
||||
case SubghzCustomEventViewReadRAWConfig:
|
||||
case SubGhzCustomEventViewReadRAWConfig:
|
||||
scene_manager_set_scene_state(
|
||||
subghz->scene_manager, SubGhzSceneReadRAW, SubghzCustomEventManagerSet);
|
||||
subghz->scene_manager, SubGhzSceneReadRAW, SubGhzCustomEventManagerSet);
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneReceiverConfig);
|
||||
return true;
|
||||
break;
|
||||
|
||||
case SubghzCustomEventViewReadRAWErase:
|
||||
case SubGhzCustomEventViewReadRAWErase:
|
||||
subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE;
|
||||
return true;
|
||||
break;
|
||||
|
||||
case SubghzCustomEventViewReadRAWVibro:
|
||||
case SubGhzCustomEventViewReadRAWVibro:
|
||||
notification_message(subghz->notifications, &sequence_single_vibro);
|
||||
return true;
|
||||
break;
|
||||
|
||||
case SubghzCustomEventViewReadRAWMore:
|
||||
case SubGhzCustomEventViewReadRAWMore:
|
||||
if(subghz_scene_read_raw_update_filename(subghz)) {
|
||||
scene_manager_set_scene_state(
|
||||
subghz->scene_manager, SubGhzSceneReadRAW, SubghzCustomEventManagerSet);
|
||||
subghz->scene_manager, SubGhzSceneReadRAW, SubGhzCustomEventManagerSet);
|
||||
subghz->txrx->rx_key_state = SubGhzRxKeyStateRAWLoad;
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneMoreRAW);
|
||||
return true;
|
||||
@@ -188,7 +185,8 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
|
||||
}
|
||||
break;
|
||||
|
||||
case SubghzCustomEventViewReadRAWSendStart:
|
||||
case SubGhzCustomEventViewReadRAWSendStart:
|
||||
|
||||
if(subghz_scene_read_raw_update_filename(subghz)) {
|
||||
//start send
|
||||
subghz->state_notifications = SubGhzNotificationStateIDLE;
|
||||
@@ -197,10 +195,17 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
|
||||
}
|
||||
if((subghz->txrx->txrx_state == SubGhzTxRxStateIDLE) ||
|
||||
(subghz->txrx->txrx_state == SubGhzTxRxStateSleep)) {
|
||||
if(!subghz_tx_start(subghz)) {
|
||||
//ToDo FIX
|
||||
|
||||
if(!subghz_tx_start(subghz, subghz->txrx->fff_data)) {
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowOnlyRx);
|
||||
} else {
|
||||
DOLPHIN_DEED(DolphinDeedSubGhzSend);
|
||||
// set callback end tx
|
||||
subghz_protocol_raw_file_encoder_worker_set_callback_end(
|
||||
(SubGhzProtocolEncoderRAW*)subghz->txrx->transmitter->protocol_instance,
|
||||
subghz_scene_read_raw_callback_end_tx,
|
||||
subghz);
|
||||
subghz->state_notifications = SubGhzNotificationStateTX;
|
||||
}
|
||||
}
|
||||
@@ -208,7 +213,7 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
|
||||
return true;
|
||||
break;
|
||||
|
||||
case SubghzCustomEventViewReadRAWSendStop:
|
||||
case SubGhzCustomEventViewReadRAWSendStop:
|
||||
subghz->state_notifications = SubGhzNotificationStateIDLE;
|
||||
if(subghz->txrx->txrx_state == SubGhzTxRxStateTx) {
|
||||
subghz_tx_stop(subghz);
|
||||
@@ -218,13 +223,14 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
|
||||
return true;
|
||||
break;
|
||||
|
||||
case SubghzCustomEventViewReadRAWIDLE:
|
||||
case SubGhzCustomEventViewReadRAWIDLE:
|
||||
if(subghz->txrx->txrx_state == SubGhzTxRxStateRx) {
|
||||
subghz_rx_end(subghz);
|
||||
subghz_sleep(subghz);
|
||||
};
|
||||
subghz_protocol_raw_save_to_file_stop(
|
||||
(SubGhzProtocolRAW*)subghz->txrx->protocol_result);
|
||||
(SubGhzProtocolDecoderRAW*)subghz->txrx->decoder_result);
|
||||
subghz_protocol_raw_gen_fff_data(subghz->txrx->fff_data, RAW_FILE_NAME);
|
||||
subghz->state_notifications = SubGhzNotificationStateIDLE;
|
||||
|
||||
subghz->txrx->rx_key_state = SubGhzRxKeyStateAddKey;
|
||||
@@ -232,16 +238,16 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
|
||||
return true;
|
||||
break;
|
||||
|
||||
case SubghzCustomEventViewReadRAWREC:
|
||||
case SubGhzCustomEventViewReadRAWREC:
|
||||
if(subghz->txrx->rx_key_state != SubGhzRxKeyStateIDLE) {
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneNeedSaving);
|
||||
} else {
|
||||
subghz_get_preset_name(subghz, subghz->error_str);
|
||||
//subghz_get_preset_name(subghz, subghz->error_str);
|
||||
if(subghz_protocol_raw_save_to_file_init(
|
||||
(SubGhzProtocolRAW*)subghz->txrx->protocol_result,
|
||||
(SubGhzProtocolDecoderRAW*)subghz->txrx->decoder_result,
|
||||
RAW_FILE_NAME,
|
||||
subghz->txrx->frequency,
|
||||
string_get_cstr(subghz->error_str))) {
|
||||
subghz->txrx->preset)) {
|
||||
DOLPHIN_DEED(DolphinDeedSubGhzRawRec);
|
||||
if((subghz->txrx->txrx_state == SubGhzTxRxStateIDLE) ||
|
||||
(subghz->txrx->txrx_state == SubGhzTxRxStateSleep)) {
|
||||
@@ -258,10 +264,10 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
|
||||
return true;
|
||||
break;
|
||||
|
||||
case SubghzCustomEventViewReadRAWSave:
|
||||
case SubGhzCustomEventViewReadRAWSave:
|
||||
if(subghz_scene_read_raw_update_filename(subghz)) {
|
||||
scene_manager_set_scene_state(
|
||||
subghz->scene_manager, SubGhzSceneReadRAW, SubghzCustomEventManagerSetRAW);
|
||||
subghz->scene_manager, SubGhzSceneReadRAW, SubGhzCustomEventManagerSetRAW);
|
||||
subghz->txrx->rx_key_state = SubGhzRxKeyStateBack;
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSaveName);
|
||||
}
|
||||
@@ -278,7 +284,7 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
|
||||
subghz_read_raw_update_sample_write(
|
||||
subghz->subghz_read_raw,
|
||||
subghz_protocol_raw_get_sample_write(
|
||||
(SubGhzProtocolRAW*)subghz->txrx->protocol_result));
|
||||
(SubGhzProtocolDecoderRAW*)subghz->txrx->decoder_result));
|
||||
subghz_read_raw_add_data_rssi(subghz->subghz_read_raw, furi_hal_subghz_get_rssi());
|
||||
break;
|
||||
case SubGhzNotificationStateTX:
|
||||
@@ -302,7 +308,6 @@ void subghz_scene_read_raw_on_exit(void* context) {
|
||||
};
|
||||
subghz->state_notifications = SubGhzNotificationStateIDLE;
|
||||
|
||||
//Сallback restoration
|
||||
subghz_worker_set_pair_callback(
|
||||
subghz->txrx->worker, (SubGhzWorkerPairCallback)subghz_parser_parse);
|
||||
//filter restoration
|
||||
subghz_receiver_set_filter(subghz->txrx->receiver, SubGhzProtocolFlag_Decodable);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "../subghz_i.h"
|
||||
#include "../views/subghz_receiver.h"
|
||||
#include "../views/receiver.h"
|
||||
|
||||
static void subghz_scene_receiver_update_statusbar(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
@@ -14,7 +14,7 @@ static void subghz_scene_receiver_update_statusbar(void* context) {
|
||||
|
||||
subghz_get_frequency_modulation(subghz, frequency_str, modulation_str);
|
||||
|
||||
subghz_receiver_add_data_statusbar(
|
||||
subghz_view_receiver_add_data_statusbar(
|
||||
subghz->subghz_receiver,
|
||||
string_get_cstr(frequency_str),
|
||||
string_get_cstr(modulation_str),
|
||||
@@ -23,36 +23,41 @@ static void subghz_scene_receiver_update_statusbar(void* context) {
|
||||
string_clear(frequency_str);
|
||||
string_clear(modulation_str);
|
||||
} else {
|
||||
subghz_receiver_add_data_statusbar(
|
||||
subghz_view_receiver_add_data_statusbar(
|
||||
subghz->subghz_receiver, string_get_cstr(history_stat_str), "", "");
|
||||
subghz->state_notifications = SubGhzNotificationStateIDLE;
|
||||
}
|
||||
string_clear(history_stat_str);
|
||||
}
|
||||
|
||||
void subghz_scene_receiver_callback(SubghzCustomEvent event, void* context) {
|
||||
void subghz_scene_receiver_callback(SubGhzCustomEvent event, void* context) {
|
||||
furi_assert(context);
|
||||
SubGhz* subghz = context;
|
||||
view_dispatcher_send_custom_event(subghz->view_dispatcher, event);
|
||||
}
|
||||
|
||||
void subghz_scene_add_to_history_callback(SubGhzProtocolCommon* parser, void* context) {
|
||||
static void subghz_scene_add_to_history_callback(
|
||||
SubGhzReceiver* receiver,
|
||||
SubGhzProtocolDecoderBase* decoder_base,
|
||||
void* context) {
|
||||
furi_assert(context);
|
||||
SubGhz* subghz = context;
|
||||
string_t str_buff;
|
||||
string_init(str_buff);
|
||||
|
||||
if(subghz_history_add_to_history(
|
||||
subghz->txrx->history, parser, subghz->txrx->frequency, subghz->txrx->preset)) {
|
||||
subghz_parser_reset(subghz->txrx->parser);
|
||||
subghz->txrx->history, decoder_base, subghz->txrx->frequency, subghz->txrx->preset)) {
|
||||
subghz_receiver_reset(receiver);
|
||||
string_reset(str_buff);
|
||||
|
||||
subghz_history_get_text_item_menu(
|
||||
subghz->txrx->history, str_buff, subghz_history_get_item(subghz->txrx->history) - 1);
|
||||
subghz_receiver_add_item_to_menu(
|
||||
subghz_view_receiver_add_item_to_menu(
|
||||
subghz->subghz_receiver,
|
||||
string_get_cstr(str_buff),
|
||||
subghz_history_get_type_protocol(
|
||||
subghz->txrx->history, subghz_history_get_item(subghz->txrx->history) - 1));
|
||||
|
||||
subghz_scene_receiver_update_statusbar(subghz);
|
||||
}
|
||||
string_clear(str_buff);
|
||||
@@ -70,11 +75,11 @@ void subghz_scene_receiver_on_enter(void* context) {
|
||||
}
|
||||
|
||||
//Load history to receiver
|
||||
subghz_receiver_exit(subghz->subghz_receiver);
|
||||
subghz_view_receiver_exit(subghz->subghz_receiver);
|
||||
for(uint8_t i = 0; i < subghz_history_get_item(subghz->txrx->history); i++) {
|
||||
string_reset(str_buff);
|
||||
subghz_history_get_text_item_menu(subghz->txrx->history, str_buff, i);
|
||||
subghz_receiver_add_item_to_menu(
|
||||
subghz_view_receiver_add_item_to_menu(
|
||||
subghz->subghz_receiver,
|
||||
string_get_cstr(str_buff),
|
||||
subghz_history_get_type_protocol(subghz->txrx->history, i));
|
||||
@@ -82,8 +87,10 @@ void subghz_scene_receiver_on_enter(void* context) {
|
||||
}
|
||||
string_clear(str_buff);
|
||||
subghz_scene_receiver_update_statusbar(subghz);
|
||||
subghz_receiver_set_callback(subghz->subghz_receiver, subghz_scene_receiver_callback, subghz);
|
||||
subghz_parser_enable_dump(subghz->txrx->parser, subghz_scene_add_to_history_callback, subghz);
|
||||
subghz_view_receiver_set_callback(
|
||||
subghz->subghz_receiver, subghz_scene_receiver_callback, subghz);
|
||||
subghz_receiver_set_rx_callback(
|
||||
subghz->txrx->receiver, subghz_scene_add_to_history_callback, subghz);
|
||||
|
||||
subghz->state_notifications = SubGhzNotificationStateRX;
|
||||
if(subghz->txrx->txrx_state == SubGhzTxRxStateRx) {
|
||||
@@ -94,9 +101,9 @@ void subghz_scene_receiver_on_enter(void* context) {
|
||||
subghz_begin(subghz, subghz->txrx->preset);
|
||||
subghz_rx(subghz, subghz->txrx->frequency);
|
||||
}
|
||||
subghz_receiver_set_idx_menu(subghz->subghz_receiver, subghz->txrx->idx_menu_chosen);
|
||||
subghz_view_receiver_set_idx_menu(subghz->subghz_receiver, subghz->txrx->idx_menu_chosen);
|
||||
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewReceiver);
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdReceiver);
|
||||
}
|
||||
|
||||
bool subghz_scene_receiver_on_event(void* context, SceneManagerEvent event) {
|
||||
@@ -104,7 +111,7 @@ bool subghz_scene_receiver_on_event(void* context, SceneManagerEvent event) {
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
switch(event.event) {
|
||||
case SubghzCustomEventViewReceverBack:
|
||||
case SubGhzCustomEventViewReceverBack:
|
||||
|
||||
// Stop CC1101 Rx
|
||||
subghz->state_notifications = SubGhzNotificationStateIDLE;
|
||||
@@ -116,7 +123,7 @@ bool subghz_scene_receiver_on_event(void* context, SceneManagerEvent event) {
|
||||
subghz->txrx->frequency = subghz_frequencies[subghz_frequencies_433_92];
|
||||
subghz->txrx->preset = FuriHalSubGhzPresetOok650Async;
|
||||
subghz->txrx->idx_menu_chosen = 0;
|
||||
subghz_parser_enable_dump(subghz->txrx->parser, NULL, subghz);
|
||||
subghz_receiver_set_rx_callback(subghz->txrx->receiver, NULL, subghz);
|
||||
|
||||
if(subghz->txrx->rx_key_state == SubGhzRxKeyStateAddKey) {
|
||||
subghz->txrx->rx_key_state = SubGhzRxKeyStateExit;
|
||||
@@ -127,14 +134,16 @@ bool subghz_scene_receiver_on_event(void* context, SceneManagerEvent event) {
|
||||
}
|
||||
return true;
|
||||
break;
|
||||
case SubghzCustomEventViewReceverOK:
|
||||
subghz->txrx->idx_menu_chosen = subghz_receiver_get_idx_menu(subghz->subghz_receiver);
|
||||
case SubGhzCustomEventViewReceverOK:
|
||||
subghz->txrx->idx_menu_chosen =
|
||||
subghz_view_receiver_get_idx_menu(subghz->subghz_receiver);
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneReceiverInfo);
|
||||
return true;
|
||||
break;
|
||||
case SubghzCustomEventViewReceverConfig:
|
||||
case SubGhzCustomEventViewReceverConfig:
|
||||
subghz->state_notifications = SubGhzNotificationStateIDLE;
|
||||
subghz->txrx->idx_menu_chosen = subghz_receiver_get_idx_menu(subghz->subghz_receiver);
|
||||
subghz->txrx->idx_menu_chosen =
|
||||
subghz_view_receiver_get_idx_menu(subghz->subghz_receiver);
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneReceiverConfig);
|
||||
return true;
|
||||
break;
|
||||
|
||||
@@ -127,7 +127,7 @@ void subghz_scene_receiver_config_on_enter(void* context) {
|
||||
variable_item_set_current_value_text(item, subghz_frequencies_text[value_index]);
|
||||
|
||||
if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneReadRAW) !=
|
||||
SubghzCustomEventManagerSet) {
|
||||
SubGhzCustomEventManagerSet) {
|
||||
item = variable_item_list_add(
|
||||
subghz->variable_item_list,
|
||||
"Hopping:",
|
||||
@@ -151,7 +151,7 @@ void subghz_scene_receiver_config_on_enter(void* context) {
|
||||
variable_item_set_current_value_index(item, value_index);
|
||||
variable_item_set_current_value_text(item, preset_text[value_index]);
|
||||
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewVariableItemList);
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdVariableItemList);
|
||||
}
|
||||
|
||||
bool subghz_scene_receiver_config_on_event(void* context, SceneManagerEvent event) {
|
||||
@@ -163,5 +163,5 @@ void subghz_scene_receiver_config_on_exit(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
variable_item_list_reset(subghz->variable_item_list);
|
||||
scene_manager_set_scene_state(
|
||||
subghz->scene_manager, SubGhzSceneReadRAW, SubghzCustomEventManagerNoSet);
|
||||
subghz->scene_manager, SubGhzSceneReadRAW, SubGhzCustomEventManagerNoSet);
|
||||
}
|
||||
|
||||
@@ -8,25 +8,24 @@ void subghz_scene_receiver_info_callback(GuiButtonType result, InputType type, v
|
||||
|
||||
if((result == GuiButtonTypeCenter) && (type == InputTypePress)) {
|
||||
view_dispatcher_send_custom_event(
|
||||
subghz->view_dispatcher, SubghzCustomEventSceneReceiverInfoTxStart);
|
||||
subghz->view_dispatcher, SubGhzCustomEventSceneReceiverInfoTxStart);
|
||||
} else if((result == GuiButtonTypeCenter) && (type == InputTypeRelease)) {
|
||||
view_dispatcher_send_custom_event(
|
||||
subghz->view_dispatcher, SubghzCustomEventSceneReceiverInfoTxStop);
|
||||
subghz->view_dispatcher, SubGhzCustomEventSceneReceiverInfoTxStop);
|
||||
} else if((result == GuiButtonTypeRight) && (type == InputTypeShort)) {
|
||||
view_dispatcher_send_custom_event(
|
||||
subghz->view_dispatcher, SubghzCustomEventSceneReceiverInfoSave);
|
||||
subghz->view_dispatcher, SubGhzCustomEventSceneReceiverInfoSave);
|
||||
}
|
||||
}
|
||||
|
||||
static bool subghz_scene_receiver_info_update_parser(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
subghz->txrx->protocol_result = subghz_parser_get_by_name(
|
||||
subghz->txrx->parser,
|
||||
subghz_history_get_name(subghz->txrx->history, subghz->txrx->idx_menu_chosen));
|
||||
|
||||
if(subghz->txrx->protocol_result->to_load_protocol != NULL) {
|
||||
subghz->txrx->protocol_result->to_load_protocol(
|
||||
subghz->txrx->protocol_result,
|
||||
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) {
|
||||
subghz_protocol_decoder_base_deserialize(
|
||||
subghz->txrx->decoder_result,
|
||||
subghz_history_get_raw_data(subghz->txrx->history, subghz->txrx->idx_menu_chosen));
|
||||
subghz->txrx->frequency =
|
||||
subghz_history_get_frequency(subghz->txrx->history, subghz->txrx->idx_menu_chosen);
|
||||
@@ -68,8 +67,7 @@ void subghz_scene_receiver_info_on_enter(void* context) {
|
||||
AlignTop,
|
||||
FontSecondary,
|
||||
string_get_cstr(modulation_str));
|
||||
|
||||
subghz->txrx->protocol_result->to_string(subghz->txrx->protocol_result, text);
|
||||
subghz_protocol_decoder_base_get_string(subghz->txrx->decoder_result, text);
|
||||
widget_add_string_multiline_element(
|
||||
subghz->widget, 0, 0, AlignLeft, AlignTop, FontSecondary, string_get_cstr(text));
|
||||
|
||||
@@ -77,14 +75,19 @@ void subghz_scene_receiver_info_on_enter(void* context) {
|
||||
string_clear(modulation_str);
|
||||
string_clear(text);
|
||||
|
||||
if(subghz->txrx->protocol_result && subghz->txrx->protocol_result->to_save_file &&
|
||||
strcmp(subghz->txrx->protocol_result->name, "KeeLoq")) {
|
||||
if((subghz->txrx->decoder_result->protocol->flag & SubGhzProtocolFlag_Save) ==
|
||||
SubGhzProtocolFlag_Save) {
|
||||
widget_add_button_element(
|
||||
subghz->widget,
|
||||
GuiButtonTypeRight,
|
||||
"Save",
|
||||
subghz_scene_receiver_info_callback,
|
||||
subghz);
|
||||
}
|
||||
if(((subghz->txrx->decoder_result->protocol->flag & SubGhzProtocolFlag_Send) ==
|
||||
SubGhzProtocolFlag_Send) &&
|
||||
subghz->txrx->decoder_result->protocol->encoder->deserialize &&
|
||||
subghz->txrx->decoder_result->protocol->type == SubGhzProtocolTypeStatic) {
|
||||
widget_add_button_element(
|
||||
subghz->widget,
|
||||
GuiButtonTypeCenter,
|
||||
@@ -92,20 +95,19 @@ void subghz_scene_receiver_info_on_enter(void* context) {
|
||||
subghz_scene_receiver_info_callback,
|
||||
subghz);
|
||||
}
|
||||
|
||||
} else {
|
||||
widget_add_icon_element(subghz->widget, 32, 12, &I_DolphinFirstStart7_61x51);
|
||||
widget_add_string_element(
|
||||
subghz->widget, 13, 8, AlignLeft, AlignBottom, FontSecondary, "Error history parse.");
|
||||
}
|
||||
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewWidget);
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdWidget);
|
||||
}
|
||||
|
||||
bool subghz_scene_receiver_info_on_event(void* context, SceneManagerEvent event) {
|
||||
SubGhz* subghz = context;
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubghzCustomEventSceneReceiverInfoTxStart) {
|
||||
if(event.event == SubGhzCustomEventSceneReceiverInfoTxStart) {
|
||||
//CC1101 Stop RX -> Start TX
|
||||
if(subghz->txrx->hopper_state != SubGhzHopperStateOFF) {
|
||||
subghz->txrx->hopper_state = SubGhzHopperStatePause;
|
||||
@@ -118,14 +120,17 @@ bool subghz_scene_receiver_info_on_event(void* context, SceneManagerEvent event)
|
||||
}
|
||||
if(subghz->txrx->txrx_state == SubGhzTxRxStateIDLE ||
|
||||
subghz->txrx->txrx_state == SubGhzTxRxStateSleep) {
|
||||
if(!subghz_tx_start(subghz)) {
|
||||
if(!subghz_tx_start(
|
||||
subghz,
|
||||
subghz_history_get_raw_data(
|
||||
subghz->txrx->history, subghz->txrx->idx_menu_chosen))) {
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowOnlyRx);
|
||||
} else {
|
||||
subghz->state_notifications = SubGhzNotificationStateTX;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else if(event.event == SubghzCustomEventSceneReceiverInfoTxStop) {
|
||||
} else if(event.event == SubGhzCustomEventSceneReceiverInfoTxStop) {
|
||||
//CC1101 Stop Tx -> Start RX
|
||||
subghz->state_notifications = SubGhzNotificationStateIDLE;
|
||||
if(subghz->txrx->txrx_state == SubGhzTxRxStateTx) {
|
||||
@@ -140,7 +145,7 @@ bool subghz_scene_receiver_info_on_event(void* context, SceneManagerEvent event)
|
||||
}
|
||||
subghz->state_notifications = SubGhzNotificationStateRX;
|
||||
return true;
|
||||
} else if(event.event == SubghzCustomEventSceneReceiverInfoSave) {
|
||||
} else if(event.event == SubGhzCustomEventSceneReceiverInfoSave) {
|
||||
//CC1101 Stop RX -> Save
|
||||
subghz->state_notifications = SubGhzNotificationStateIDLE;
|
||||
if(subghz->txrx->hopper_state != SubGhzHopperStateOFF) {
|
||||
@@ -153,8 +158,9 @@ bool subghz_scene_receiver_info_on_event(void* context, SceneManagerEvent event)
|
||||
if(!subghz_scene_receiver_info_update_parser(subghz)) {
|
||||
return false;
|
||||
}
|
||||
if(subghz->txrx->protocol_result && subghz->txrx->protocol_result->to_save_file &&
|
||||
strcmp(subghz->txrx->protocol_result->name, "KeeLoq")) {
|
||||
|
||||
if((subghz->txrx->decoder_result->protocol->flag & SubGhzProtocolFlag_Save) ==
|
||||
SubGhzProtocolFlag_Save) {
|
||||
subghz_file_name_clear(subghz);
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSaveName);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
#include "../subghz_i.h"
|
||||
#include <lib/toolbox/random_name.h>
|
||||
#include "../helpers/subghz_custom_event.h"
|
||||
#include <lib/subghz/protocols/subghz_protocol_raw.h>
|
||||
#include <lib/subghz/protocols/raw.h>
|
||||
#include <gui/modules/validators.h>
|
||||
|
||||
void subghz_scene_save_name_text_input_callback(void* context) {
|
||||
furi_assert(context);
|
||||
SubGhz* subghz = context;
|
||||
view_dispatcher_send_custom_event(subghz->view_dispatcher, SubghzCustomEventSceneSaveName);
|
||||
view_dispatcher_send_custom_event(subghz->view_dispatcher, SubGhzCustomEventSceneSaveName);
|
||||
}
|
||||
|
||||
void subghz_scene_save_name_on_enter(void* context) {
|
||||
@@ -24,10 +24,10 @@ void subghz_scene_save_name_on_enter(void* context) {
|
||||
} else {
|
||||
strcpy(subghz->file_name_tmp, subghz->file_name);
|
||||
if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneReadRAW) !=
|
||||
SubghzCustomEventManagerNoSet) {
|
||||
SubGhzCustomEventManagerNoSet) {
|
||||
subghz_get_next_name_file(subghz);
|
||||
if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneReadRAW) ==
|
||||
SubghzCustomEventManagerSetRAW) {
|
||||
SubGhzCustomEventManagerSetRAW) {
|
||||
dev_name_empty = true;
|
||||
}
|
||||
}
|
||||
@@ -46,7 +46,7 @@ void subghz_scene_save_name_on_enter(void* context) {
|
||||
validator_is_file_alloc_init(SUBGHZ_APP_FOLDER, SUBGHZ_APP_EXTENSION);
|
||||
text_input_set_validator(text_input, validator_is_file_callback, validator_is_file);
|
||||
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewTextInput);
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdTextInput);
|
||||
}
|
||||
|
||||
bool subghz_scene_save_name_on_event(void* context, SceneManagerEvent event) {
|
||||
@@ -56,22 +56,35 @@ bool subghz_scene_save_name_on_event(void* context, SceneManagerEvent event) {
|
||||
scene_manager_previous_scene(subghz->scene_manager);
|
||||
return true;
|
||||
} else if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubghzCustomEventSceneSaveName) {
|
||||
if(event.event == SubGhzCustomEventSceneSaveName) {
|
||||
if(strcmp(subghz->file_name, "")) {
|
||||
if(strcmp(subghz->file_name_tmp, "")) {
|
||||
if(!subghz_rename_file(subghz)) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
subghz_save_protocol_to_file(subghz, subghz->file_name);
|
||||
if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneSetType) !=
|
||||
SubGhzCustomEventManagerNoSet) {
|
||||
subghz_save_protocol_to_file(
|
||||
subghz, subghz->txrx->fff_data, subghz->file_name);
|
||||
scene_manager_set_scene_state(
|
||||
subghz->scene_manager,
|
||||
SubGhzSceneSetType,
|
||||
SubGhzCustomEventManagerNoSet);
|
||||
} else {
|
||||
subghz_save_protocol_to_file(
|
||||
subghz,
|
||||
subghz_history_get_raw_data(
|
||||
subghz->txrx->history, subghz->txrx->idx_menu_chosen),
|
||||
subghz->file_name);
|
||||
}
|
||||
}
|
||||
|
||||
if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneReadRAW) !=
|
||||
SubghzCustomEventManagerNoSet) {
|
||||
subghz_protocol_raw_set_last_file_name(
|
||||
(SubGhzProtocolRAW*)subghz->txrx->protocol_result, subghz->file_name);
|
||||
SubGhzCustomEventManagerNoSet) {
|
||||
subghz_protocol_raw_gen_fff_data(subghz->txrx->fff_data, subghz->file_name);
|
||||
scene_manager_set_scene_state(
|
||||
subghz->scene_manager, SubGhzSceneReadRAW, SubghzCustomEventManagerNoSet);
|
||||
subghz->scene_manager, SubGhzSceneReadRAW, SubGhzCustomEventManagerNoSet);
|
||||
} else {
|
||||
subghz_file_name_clear(subghz);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
void subghz_scene_save_success_popup_callback(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
view_dispatcher_send_custom_event(subghz->view_dispatcher, SubghzCustomEventSceneSaveSuccess);
|
||||
view_dispatcher_send_custom_event(subghz->view_dispatcher, SubGhzCustomEventSceneSaveSuccess);
|
||||
}
|
||||
|
||||
void subghz_scene_save_success_on_enter(void* context) {
|
||||
@@ -20,13 +20,13 @@ void subghz_scene_save_success_on_enter(void* context) {
|
||||
popup_set_context(popup, subghz);
|
||||
popup_set_callback(popup, subghz_scene_save_success_popup_callback);
|
||||
popup_enable_timeout(popup);
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewPopup);
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdPopup);
|
||||
}
|
||||
|
||||
bool subghz_scene_save_success_on_event(void* context, SceneManagerEvent event) {
|
||||
SubGhz* subghz = context;
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubghzCustomEventSceneSaveSuccess) {
|
||||
if(event.event == SubGhzCustomEventSceneSaveSuccess) {
|
||||
if(!scene_manager_search_and_switch_to_previous_scene(
|
||||
subghz->scene_manager, SubGhzSceneReceiver)) {
|
||||
subghz->txrx->rx_key_state = SubGhzRxKeyStateRAWSave;
|
||||
|
||||
@@ -4,7 +4,7 @@ void subghz_scene_saved_on_enter(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
|
||||
if(subghz_load_protocol_from_file(subghz)) {
|
||||
if((!strcmp(subghz->txrx->protocol_result->name, "RAW"))) {
|
||||
if((!strcmp(subghz->txrx->decoder_result->protocol->name, "RAW"))) {
|
||||
subghz->txrx->rx_key_state = SubGhzRxKeyStateRAWLoad;
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneReadRAW);
|
||||
} else {
|
||||
|
||||
@@ -38,7 +38,7 @@ void subghz_scene_saved_menu_on_enter(void* context) {
|
||||
subghz->submenu,
|
||||
scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneSavedMenu));
|
||||
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewMenu);
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdMenu);
|
||||
}
|
||||
|
||||
bool subghz_scene_saved_menu_on_event(void* context, SceneManagerEvent event) {
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
#include "../subghz_i.h"
|
||||
#include "../lib/subghz/protocols/subghz_protocol_keeloq.h"
|
||||
#include <lib/subghz/protocols/keeloq.h>
|
||||
#include <lib/subghz/blocks/math.h>
|
||||
#include <dolphin/dolphin.h>
|
||||
#include <flipper_format/flipper_format_i.h>
|
||||
#include <lib/toolbox/stream/stream.h>
|
||||
|
||||
#define TAG "SubGhzSetType"
|
||||
|
||||
enum SubmenuIndex {
|
||||
SubmenuIndexPricenton,
|
||||
@@ -15,15 +20,52 @@ enum SubmenuIndex {
|
||||
SubmenuIndexDoorHan,
|
||||
};
|
||||
|
||||
bool subghz_scene_set_type_submenu_to_find_protocol(void* context, const char* protocol_name) {
|
||||
bool subghz_scene_set_type_submenu_gen_data_protocol(
|
||||
void* context,
|
||||
const char* protocol_name,
|
||||
uint64_t key,
|
||||
uint32_t bit) {
|
||||
furi_assert(context);
|
||||
SubGhz* subghz = context;
|
||||
subghz->txrx->protocol_result = subghz_parser_get_by_name(subghz->txrx->parser, protocol_name);
|
||||
if(subghz->txrx->protocol_result == NULL) {
|
||||
|
||||
bool res = false;
|
||||
|
||||
subghz->txrx->decoder_result =
|
||||
subghz_receiver_search_decoder_base_by_name(subghz->txrx->receiver, protocol_name);
|
||||
|
||||
if(subghz->txrx->decoder_result == NULL) {
|
||||
string_set(subghz->error_str, "Protocol not found");
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowErrorSub);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
||||
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_frequencies[subghz_frequencies_433_92],
|
||||
FuriHalSubGhzPresetOok650Async)) {
|
||||
FURI_LOG_E(TAG, "Unable to serialize");
|
||||
break;
|
||||
}
|
||||
if(!flipper_format_update_uint32(subghz->txrx->fff_data, "Bit", &bit, 1)) {
|
||||
FURI_LOG_E(TAG, "Unable to update Bit");
|
||||
break;
|
||||
}
|
||||
|
||||
uint8_t key_data[sizeof(uint64_t)] = {0};
|
||||
for(size_t i = 0; i < sizeof(uint64_t); i++) {
|
||||
key_data[sizeof(uint64_t) - i - 1] = (key >> i * 8) & 0xFF;
|
||||
}
|
||||
if(!flipper_format_update_hex(subghz->txrx->fff_data, "Key", key_data, sizeof(uint64_t))) {
|
||||
FURI_LOG_E(TAG, "Unable to update Key");
|
||||
break;
|
||||
}
|
||||
res = true;
|
||||
} while(false);
|
||||
return res;
|
||||
}
|
||||
|
||||
void subghz_scene_set_type_submenu_callback(void* context, uint32_t index) {
|
||||
@@ -90,7 +132,7 @@ void subghz_scene_set_type_on_enter(void* context) {
|
||||
submenu_set_selected_item(
|
||||
subghz->submenu, scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneSetType));
|
||||
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewMenu);
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdMenu);
|
||||
}
|
||||
|
||||
bool subghz_scene_set_type_on_event(void* context, SceneManagerEvent event) {
|
||||
@@ -98,54 +140,45 @@ bool subghz_scene_set_type_on_event(void* context, SceneManagerEvent event) {
|
||||
bool generated_protocol = false;
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
//ToDo Fix
|
||||
uint32_t key = subghz_random_serial();
|
||||
switch(event.event) {
|
||||
case SubmenuIndexPricenton:
|
||||
if(subghz_scene_set_type_submenu_to_find_protocol(subghz, "Princeton")) {
|
||||
subghz->txrx->protocol_result->code_last_count_bit = 24;
|
||||
key = (key & 0x00FFFFF0) | 0x4; //btn 0x1, 0x2, 0x4, 0x8
|
||||
subghz->txrx->protocol_result->code_last_found = key;
|
||||
key = (key & 0x00FFFFF0) | 0x4; //btn 0x1, 0x2, 0x4, 0x8
|
||||
if(subghz_scene_set_type_submenu_gen_data_protocol(subghz, "Princeton", key, 24)) {
|
||||
uint32_t te = 400;
|
||||
flipper_format_update_uint32(subghz->txrx->fff_data, "TE", (uint32_t*)&te, 1);
|
||||
generated_protocol = true;
|
||||
}
|
||||
break;
|
||||
case SubmenuIndexNiceFlo12bit:
|
||||
if(subghz_scene_set_type_submenu_to_find_protocol(subghz, "Nice FLO")) {
|
||||
subghz->txrx->protocol_result->code_last_count_bit = 12;
|
||||
key = (key & 0x0000FFF0) | 0x1; //btn 0x1, 0x2, 0x4
|
||||
subghz->txrx->protocol_result->code_last_found = key;
|
||||
key = (key & 0x0000FFF0) | 0x1; //btn 0x1, 0x2, 0x4
|
||||
if(subghz_scene_set_type_submenu_gen_data_protocol(subghz, "Nice FLO", key, 12)) {
|
||||
generated_protocol = true;
|
||||
}
|
||||
break;
|
||||
case SubmenuIndexNiceFlo24bit:
|
||||
if(subghz_scene_set_type_submenu_to_find_protocol(subghz, "Nice FLO")) {
|
||||
subghz->txrx->protocol_result->code_last_count_bit = 24;
|
||||
key = (key & 0x00FFFFF0) | 0x4; //btn 0x1, 0x2, 0x4, 0x8
|
||||
subghz->txrx->protocol_result->code_last_found = key;
|
||||
key = (key & 0x00FFFFF0) | 0x4; //btn 0x1, 0x2, 0x4, 0x8
|
||||
if(subghz_scene_set_type_submenu_gen_data_protocol(subghz, "Nice FLO", key, 24)) {
|
||||
generated_protocol = true;
|
||||
}
|
||||
break;
|
||||
case SubmenuIndexCAME12bit:
|
||||
if(subghz_scene_set_type_submenu_to_find_protocol(subghz, "CAME")) {
|
||||
subghz->txrx->protocol_result->code_last_count_bit = 12;
|
||||
key = (key & 0x0000FFF0) | 0x1; //btn 0x1, 0x2, 0x4
|
||||
subghz->txrx->protocol_result->code_last_found = key;
|
||||
key = (key & 0x0000FFF0) | 0x1; //btn 0x1, 0x2, 0x4
|
||||
if(subghz_scene_set_type_submenu_gen_data_protocol(subghz, "CAME", key, 12)) {
|
||||
generated_protocol = true;
|
||||
}
|
||||
break;
|
||||
case SubmenuIndexCAME24bit:
|
||||
if(subghz_scene_set_type_submenu_to_find_protocol(subghz, "CAME")) {
|
||||
subghz->txrx->protocol_result->code_last_count_bit = 24;
|
||||
key = (key & 0x00FFFFF0) | 0x4; //btn 0x1, 0x2, 0x4, 0x8
|
||||
subghz->txrx->protocol_result->code_last_found = key;
|
||||
key = (key & 0x00FFFFF0) | 0x4; //btn 0x1, 0x2, 0x4, 0x8
|
||||
if(subghz_scene_set_type_submenu_gen_data_protocol(subghz, "CAME", key, 24)) {
|
||||
generated_protocol = true;
|
||||
}
|
||||
break;
|
||||
case SubmenuIndexCAMETwee:
|
||||
if(subghz_scene_set_type_submenu_to_find_protocol(subghz, "CAME TWEE")) {
|
||||
subghz->txrx->protocol_result->code_last_count_bit = 54;
|
||||
key = (key & 0x0FFFFFF0);
|
||||
subghz->txrx->protocol_result->code_last_found = 0x003FFF7200000000 |
|
||||
(key ^ 0xE0E0E0EE);
|
||||
key = (key & 0x0FFFFFF0);
|
||||
key = 0x003FFF7200000000 | (key ^ 0xE0E0E0EE);
|
||||
if(subghz_scene_set_type_submenu_gen_data_protocol(subghz, "CAME TWEE", key, 54)) {
|
||||
generated_protocol = true;
|
||||
}
|
||||
break;
|
||||
@@ -156,32 +189,34 @@ bool subghz_scene_set_type_on_event(void* context, SceneManagerEvent event) {
|
||||
// /* code */
|
||||
// break;
|
||||
case SubmenuIndexGateTX:
|
||||
if(subghz_scene_set_type_submenu_to_find_protocol(subghz, "GateTX")) {
|
||||
subghz->txrx->protocol_result->code_last_count_bit = 24;
|
||||
key = (key & 0x00F0FF00) | 0xF << 16 | 0x40; //btn 0xF, 0xC, 0xA, 0x6 (?)
|
||||
subghz->txrx->protocol_result->code_last_found =
|
||||
subghz_protocol_common_reverse_key(
|
||||
key, subghz->txrx->protocol_result->code_last_count_bit);
|
||||
key = (key & 0x00F0FF00) | 0xF << 16 | 0x40; //btn 0xF, 0xC, 0xA, 0x6 (?)
|
||||
uint64_t rev_key = subghz_protocol_blocks_reverse_key(key, 24);
|
||||
if(subghz_scene_set_type_submenu_gen_data_protocol(subghz, "GateTX", rev_key, 24)) {
|
||||
generated_protocol = true;
|
||||
}
|
||||
break;
|
||||
case SubmenuIndexDoorHan:
|
||||
if(subghz_scene_set_type_submenu_to_find_protocol(subghz, "KeeLoq")) {
|
||||
subghz->txrx->protocol_result->code_last_count_bit = 64;
|
||||
subghz->txrx->protocol_result->serial = key & 0x0FFFFFFF;
|
||||
subghz->txrx->protocol_result->btn = 0x2; //btn 0x1, 0x2, 0x4, 0x8
|
||||
subghz->txrx->protocol_result->cnt = 0x0003;
|
||||
if(subghz_protocol_keeloq_set_manufacture_name(
|
||||
subghz->txrx->protocol_result, "DoorHan")) {
|
||||
subghz->txrx->protocol_result->code_last_found =
|
||||
subghz_protocol_keeloq_gen_key(subghz->txrx->protocol_result);
|
||||
generated_protocol = true;
|
||||
} else {
|
||||
generated_protocol = false;
|
||||
string_set(
|
||||
subghz->error_str, "Function requires\nan SD card with\nfresh databases.");
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError);
|
||||
}
|
||||
subghz->txrx->transmitter =
|
||||
subghz_transmitter_alloc_init(subghz->txrx->environment, "KeeLoq");
|
||||
if(subghz->txrx->transmitter) {
|
||||
subghz_protocol_keeloq_create_data(
|
||||
subghz->txrx->transmitter->protocol_instance,
|
||||
subghz->txrx->fff_data,
|
||||
key & 0x0FFFFFFF,
|
||||
0x2,
|
||||
0x0003,
|
||||
"DoorHan",
|
||||
subghz_frequencies[subghz_frequencies_433_92],
|
||||
FuriHalSubGhzPresetOok650Async);
|
||||
generated_protocol = true;
|
||||
} else {
|
||||
generated_protocol = false;
|
||||
}
|
||||
subghz_transmitter_free(subghz->txrx->transmitter);
|
||||
if(!generated_protocol) {
|
||||
string_set(
|
||||
subghz->error_str, "Function requires\nan SD card with\nfresh databases.");
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -190,10 +225,10 @@ bool subghz_scene_set_type_on_event(void* context, SceneManagerEvent event) {
|
||||
}
|
||||
|
||||
if(generated_protocol) {
|
||||
subghz->txrx->frequency = subghz_frequencies[subghz_frequencies_433_92];
|
||||
subghz->txrx->preset = FuriHalSubGhzPresetOok650Async;
|
||||
subghz_file_name_clear(subghz);
|
||||
DOLPHIN_DEED(DolphinDeedSubGhzAddManually);
|
||||
scene_manager_set_scene_state(
|
||||
subghz->scene_manager, SubGhzSceneSetType, SubGhzCustomEventManagerSet);
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSaveName);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -7,10 +7,10 @@ void subghz_scene_show_error_callback(GuiButtonType result, InputType type, void
|
||||
|
||||
if((result == GuiButtonTypeRight) && (type == InputTypeShort)) {
|
||||
view_dispatcher_send_custom_event(
|
||||
subghz->view_dispatcher, SubghzCustomEventSceneShowErrorOk);
|
||||
subghz->view_dispatcher, SubGhzCustomEventSceneShowErrorOk);
|
||||
} else if((result == GuiButtonTypeLeft) && (type == InputTypeShort)) {
|
||||
view_dispatcher_send_custom_event(
|
||||
subghz->view_dispatcher, SubghzCustomEventSceneShowErrorBack);
|
||||
subghz->view_dispatcher, SubGhzCustomEventSceneShowErrorBack);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ void subghz_scene_show_error_on_enter(void* context) {
|
||||
FontSecondary,
|
||||
string_get_cstr(subghz->error_str));
|
||||
if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneShowError) ==
|
||||
SubghzCustomEventManagerSet) {
|
||||
SubGhzCustomEventManagerSet) {
|
||||
widget_add_button_element(
|
||||
subghz->widget, GuiButtonTypeRight, "Ok", subghz_scene_show_error_callback, subghz);
|
||||
}
|
||||
@@ -36,14 +36,14 @@ void subghz_scene_show_error_on_enter(void* context) {
|
||||
widget_add_button_element(
|
||||
subghz->widget, GuiButtonTypeLeft, "Back", subghz_scene_show_error_callback, subghz);
|
||||
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewWidget);
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdWidget);
|
||||
}
|
||||
|
||||
bool subghz_scene_show_error_on_event(void* context, SceneManagerEvent event) {
|
||||
SubGhz* subghz = context;
|
||||
if(event.type == SceneManagerEventTypeBack) {
|
||||
if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneShowError) ==
|
||||
SubghzCustomEventManagerSet) {
|
||||
SubGhzCustomEventManagerSet) {
|
||||
return false;
|
||||
} else {
|
||||
scene_manager_search_and_switch_to_previous_scene(
|
||||
@@ -51,15 +51,15 @@ bool subghz_scene_show_error_on_event(void* context, SceneManagerEvent event) {
|
||||
}
|
||||
return true;
|
||||
} else if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubghzCustomEventSceneShowErrorOk) {
|
||||
if(event.event == SubGhzCustomEventSceneShowErrorOk) {
|
||||
if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneShowError) ==
|
||||
SubghzCustomEventManagerSet) {
|
||||
SubGhzCustomEventManagerSet) {
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneStart);
|
||||
}
|
||||
return true;
|
||||
} else if(event.event == SubghzCustomEventSceneShowErrorBack) {
|
||||
} else if(event.event == SubGhzCustomEventSceneShowErrorBack) {
|
||||
if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneShowError) ==
|
||||
SubghzCustomEventManagerSet) {
|
||||
SubGhzCustomEventManagerSet) {
|
||||
//exit app
|
||||
if(!scene_manager_previous_scene(subghz->scene_manager)) {
|
||||
scene_manager_stop(subghz->scene_manager);
|
||||
@@ -78,7 +78,7 @@ bool subghz_scene_show_error_on_event(void* context, SceneManagerEvent event) {
|
||||
void subghz_scene_show_error_on_exit(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
scene_manager_set_scene_state(
|
||||
subghz->scene_manager, SubGhzSceneShowError, SubghzCustomEventManagerNoSet);
|
||||
subghz->scene_manager, SubGhzSceneShowError, SubGhzCustomEventManagerNoSet);
|
||||
widget_reset(subghz->widget);
|
||||
string_reset(subghz->error_str);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
void subghz_scene_show_error_sub_popup_callback(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
view_dispatcher_send_custom_event(subghz->view_dispatcher, SubghzCustomEventSceneShowErrorSub);
|
||||
view_dispatcher_send_custom_event(subghz->view_dispatcher, SubGhzCustomEventSceneShowErrorSub);
|
||||
}
|
||||
|
||||
void subghz_scene_show_error_sub_on_enter(void* context) {
|
||||
@@ -17,13 +17,13 @@ void subghz_scene_show_error_sub_on_enter(void* context) {
|
||||
popup_set_context(popup, subghz);
|
||||
popup_set_callback(popup, subghz_scene_show_error_sub_popup_callback);
|
||||
popup_enable_timeout(popup);
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewPopup);
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdPopup);
|
||||
}
|
||||
|
||||
bool subghz_scene_show_error_sub_on_event(void* context, SceneManagerEvent event) {
|
||||
SubGhz* subghz = context;
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubghzCustomEventSceneShowErrorSub) {
|
||||
if(event.event == SubGhzCustomEventSceneShowErrorSub) {
|
||||
scene_manager_search_and_switch_to_previous_scene(
|
||||
subghz->scene_manager, SubGhzSceneStart);
|
||||
return true;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
void subghz_scene_show_only_rx_popup_callback(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
view_dispatcher_send_custom_event(subghz->view_dispatcher, SubghzCustomEventSceneShowOnlyRX);
|
||||
view_dispatcher_send_custom_event(subghz->view_dispatcher, SubGhzCustomEventSceneShowOnlyRX);
|
||||
}
|
||||
|
||||
void subghz_scene_show_only_rx_on_enter(void* context) {
|
||||
@@ -23,13 +23,13 @@ void subghz_scene_show_only_rx_on_enter(void* context) {
|
||||
popup_set_context(popup, subghz);
|
||||
popup_set_callback(popup, subghz_scene_show_only_rx_popup_callback);
|
||||
popup_enable_timeout(popup);
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewPopup);
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdPopup);
|
||||
}
|
||||
|
||||
const bool subghz_scene_show_only_rx_on_event(void* context, SceneManagerEvent event) {
|
||||
SubGhz* subghz = context;
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubghzCustomEventSceneShowOnlyRX) {
|
||||
if(event.event == SubGhzCustomEventSceneShowOnlyRX) {
|
||||
scene_manager_previous_scene(subghz->scene_manager);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ void subghz_scene_start_on_enter(void* context) {
|
||||
submenu_set_selected_item(
|
||||
subghz->submenu, scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneStart));
|
||||
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewMenu);
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdMenu);
|
||||
}
|
||||
|
||||
bool subghz_scene_start_on_event(void* context, SceneManagerEvent event) {
|
||||
|
||||
@@ -28,7 +28,7 @@ void subghz_scene_test_on_enter(void* context) {
|
||||
submenu_set_selected_item(
|
||||
subghz->submenu, scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneTest));
|
||||
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewMenu);
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdMenu);
|
||||
}
|
||||
|
||||
bool subghz_scene_test_on_event(void* context, SceneManagerEvent event) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "../subghz_i.h"
|
||||
#include "../views/subghz_test_carrier.h"
|
||||
|
||||
void subghz_scene_test_carrier_callback(SubghzTestCarrierEvent event, void* context) {
|
||||
void subghz_scene_test_carrier_callback(SubGhzTestCarrierEvent event, void* context) {
|
||||
furi_assert(context);
|
||||
SubGhz* subghz = context;
|
||||
view_dispatcher_send_custom_event(subghz->view_dispatcher, event);
|
||||
@@ -11,13 +11,13 @@ void subghz_scene_test_carrier_on_enter(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
subghz_test_carrier_set_callback(
|
||||
subghz->subghz_test_carrier, subghz_scene_test_carrier_callback, subghz);
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewTestCarrier);
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdTestCarrier);
|
||||
}
|
||||
|
||||
bool subghz_scene_test_carrier_on_event(void* context, SceneManagerEvent event) {
|
||||
SubGhz* subghz = context;
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubghzTestCarrierEventOnlyRx) {
|
||||
if(event.event == SubGhzTestCarrierEventOnlyRx) {
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowOnlyRx);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "../subghz_i.h"
|
||||
#include "../views/subghz_test_packet.h"
|
||||
|
||||
void subghz_scene_test_packet_callback(SubghzTestPacketEvent event, void* context) {
|
||||
void subghz_scene_test_packet_callback(SubGhzTestPacketEvent event, void* context) {
|
||||
furi_assert(context);
|
||||
SubGhz* subghz = context;
|
||||
view_dispatcher_send_custom_event(subghz->view_dispatcher, event);
|
||||
@@ -11,13 +11,13 @@ void subghz_scene_test_packet_on_enter(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
subghz_test_packet_set_callback(
|
||||
subghz->subghz_test_packet, subghz_scene_test_packet_callback, subghz);
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewTestPacket);
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdTestPacket);
|
||||
}
|
||||
|
||||
bool subghz_scene_test_packet_on_event(void* context, SceneManagerEvent event) {
|
||||
SubGhz* subghz = context;
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubghzTestPacketEventOnlyRx) {
|
||||
if(event.event == SubGhzTestPacketEventOnlyRx) {
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowOnlyRx);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "../subghz_i.h"
|
||||
#include "../views/subghz_test_static.h"
|
||||
|
||||
void subghz_scene_test_static_callback(SubghzTestStaticEvent event, void* context) {
|
||||
void subghz_scene_test_static_callback(SubGhzTestStaticEvent event, void* context) {
|
||||
furi_assert(context);
|
||||
SubGhz* subghz = context;
|
||||
view_dispatcher_send_custom_event(subghz->view_dispatcher, event);
|
||||
@@ -11,13 +11,13 @@ void subghz_scene_test_static_on_enter(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
subghz_test_static_set_callback(
|
||||
subghz->subghz_test_static, subghz_scene_test_static_callback, subghz);
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewStatic);
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdStatic);
|
||||
}
|
||||
|
||||
bool subghz_scene_test_static_on_event(void* context, SceneManagerEvent event) {
|
||||
SubGhz* subghz = context;
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubghzTestStaticEventOnlyRx) {
|
||||
if(event.event == SubGhzTestStaticEventOnlyRx) {
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowOnlyRx);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
#include "../subghz_i.h"
|
||||
#include "../views/subghz_transmitter.h"
|
||||
#include <lib/subghz/protocols/subghz_protocol_keeloq.h>
|
||||
#include "../views/transmitter.h"
|
||||
#include <dolphin/dolphin.h>
|
||||
|
||||
void subghz_scene_transmitter_callback(SubghzCustomEvent event, void* context) {
|
||||
void subghz_scene_transmitter_callback(SubGhzCustomEvent event, void* context) {
|
||||
furi_assert(context);
|
||||
SubGhz* subghz = context;
|
||||
view_dispatcher_send_custom_event(subghz->view_dispatcher, event);
|
||||
}
|
||||
|
||||
bool subghz_scene_transmitter_update_data_show(void* context) {
|
||||
//ToDo Fix
|
||||
SubGhz* subghz = context;
|
||||
|
||||
if(subghz->txrx->protocol_result && subghz->txrx->protocol_result->get_upload_protocol) {
|
||||
if(subghz->txrx->decoder_result) {
|
||||
string_t key_str;
|
||||
string_t frequency_str;
|
||||
string_t modulation_str;
|
||||
@@ -21,19 +21,18 @@ bool subghz_scene_transmitter_update_data_show(void* context) {
|
||||
string_init(frequency_str);
|
||||
string_init(modulation_str);
|
||||
uint8_t show_button = 0;
|
||||
subghz->txrx->protocol_result->to_string(subghz->txrx->protocol_result, key_str);
|
||||
|
||||
if((!strcmp(subghz->txrx->protocol_result->name, "KeeLoq")) &&
|
||||
(!strcmp(
|
||||
subghz_protocol_keeloq_get_manufacture_name(subghz->txrx->protocol_result),
|
||||
"Unknown"))) {
|
||||
show_button = 0;
|
||||
} else {
|
||||
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->txrx->decoder_result->protocol->flag & SubGhzProtocolFlag_Send) ==
|
||||
SubGhzProtocolFlag_Send) {
|
||||
show_button = 1;
|
||||
}
|
||||
|
||||
subghz_get_frequency_modulation(subghz, frequency_str, modulation_str);
|
||||
subghz_transmitter_add_data_to_show(
|
||||
subghz_view_transmitter_add_data_to_show(
|
||||
subghz->subghz_transmitter,
|
||||
string_get_cstr(key_str),
|
||||
string_get_cstr(frequency_str),
|
||||
@@ -54,27 +53,27 @@ void subghz_scene_transmitter_on_enter(void* context) {
|
||||
DOLPHIN_DEED(DolphinDeedSubGhzSend);
|
||||
if(!subghz_scene_transmitter_update_data_show(subghz)) {
|
||||
view_dispatcher_send_custom_event(
|
||||
subghz->view_dispatcher, SubghzCustomEventViewTransmitterError);
|
||||
subghz->view_dispatcher, SubGhzCustomEventViewTransmitterError);
|
||||
}
|
||||
|
||||
subghz_transmitter_set_callback(
|
||||
subghz_view_transmitter_set_callback(
|
||||
subghz->subghz_transmitter, subghz_scene_transmitter_callback, subghz);
|
||||
|
||||
subghz->state_notifications = SubGhzNotificationStateIDLE;
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewTransmitter);
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdTransmitter);
|
||||
}
|
||||
|
||||
bool subghz_scene_transmitter_on_event(void* context, SceneManagerEvent event) {
|
||||
SubGhz* subghz = context;
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubghzCustomEventViewTransmitterSendStart) {
|
||||
if(event.event == SubGhzCustomEventViewTransmitterSendStart) {
|
||||
subghz->state_notifications = SubGhzNotificationStateIDLE;
|
||||
if(subghz->txrx->txrx_state == SubGhzTxRxStateRx) {
|
||||
subghz_rx_end(subghz);
|
||||
}
|
||||
if((subghz->txrx->txrx_state == SubGhzTxRxStateIDLE) ||
|
||||
(subghz->txrx->txrx_state == SubGhzTxRxStateSleep)) {
|
||||
if(!subghz_tx_start(subghz)) {
|
||||
if(!subghz_tx_start(subghz, subghz->txrx->fff_data)) {
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowOnlyRx);
|
||||
} else {
|
||||
subghz->state_notifications = SubGhzNotificationStateTX;
|
||||
@@ -82,19 +81,19 @@ bool subghz_scene_transmitter_on_event(void* context, SceneManagerEvent event) {
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else if(event.event == SubghzCustomEventViewTransmitterSendStop) {
|
||||
} else if(event.event == SubGhzCustomEventViewTransmitterSendStop) {
|
||||
subghz->state_notifications = SubGhzNotificationStateIDLE;
|
||||
if(subghz->txrx->txrx_state == SubGhzTxRxStateTx) {
|
||||
subghz_tx_stop(subghz);
|
||||
subghz_sleep(subghz);
|
||||
}
|
||||
return true;
|
||||
} else if(event.event == SubghzCustomEventViewTransmitterBack) {
|
||||
} else if(event.event == SubGhzCustomEventViewTransmitterBack) {
|
||||
subghz->state_notifications = SubGhzNotificationStateIDLE;
|
||||
scene_manager_search_and_switch_to_previous_scene(
|
||||
subghz->scene_manager, SubGhzSceneStart);
|
||||
return true;
|
||||
} else if(event.event == SubghzCustomEventViewTransmitterError) {
|
||||
} else if(event.event == SubGhzCustomEventViewTransmitterError) {
|
||||
string_set(subghz->error_str, "Protocol not found");
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowErrorSub);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user