[FL-3242] SubGhz: refactoring app (#2554)
* SubGhz: add SubGhzThresholdRssi * SubGhz: remove direct reading of subghz-txrx-txrx_state * SubGhz: remove direct reading subghz->txrx->hopper_state * SubGhz: remove direct reading subghz->lock * SubGhz: check load type file * SubGhz: remove direct reading subghz->txrx->rx_key_state * SubGhz: remove direct reading subghz->txrx->speaker_state * SubGhz: refactoring subghz_scene_set_type.c * SubGhz: moving "txrx" entity to a separate file * SubGhz: show error tx start * SubGhz: refactoring RPC * SubGhz: value get optimizations * SubGhz: fix name file * SubGhz: add function description * SubGhz: fix double back with a blocked transmission in this region and speacker, when a transmission is blocked in this region * SubGhz: correct spelling * SubGhz: better naming * SubGhz: simplify includes Co-authored-by: SG <who.just.the.doctor@gmail.com> Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
@@ -19,7 +19,7 @@ void subghz_scene_delete_on_enter(void* context) {
|
||||
modulation_str = furi_string_alloc();
|
||||
text = furi_string_alloc();
|
||||
|
||||
subghz_get_frequency_modulation(subghz, frequency_str, modulation_str);
|
||||
subghz_txrx_get_frequency_and_modulation(subghz->txrx, frequency_str, modulation_str);
|
||||
widget_add_string_element(
|
||||
subghz->widget,
|
||||
78,
|
||||
@@ -37,7 +37,7 @@ void subghz_scene_delete_on_enter(void* context) {
|
||||
AlignTop,
|
||||
FontSecondary,
|
||||
furi_string_get_cstr(modulation_str));
|
||||
subghz_protocol_decoder_base_get_string(subghz->txrx->decoder_result, text);
|
||||
subghz_protocol_decoder_base_get_string(subghz_txrx_get_decoder(subghz->txrx), text);
|
||||
widget_add_string_multiline_element(
|
||||
subghz->widget, 0, 0, AlignLeft, AlignTop, FontSecondary, furi_string_get_cstr(text));
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ void subghz_scene_delete_raw_on_enter(void* context) {
|
||||
|
||||
widget_add_string_element(
|
||||
subghz->widget, 38, 25, AlignLeft, AlignTop, FontSecondary, "RAW signal");
|
||||
subghz_get_frequency_modulation(subghz, frequency_str, modulation_str);
|
||||
subghz_txrx_get_frequency_and_modulation(subghz->txrx, frequency_str, modulation_str);
|
||||
widget_add_string_element(
|
||||
subghz->widget,
|
||||
35,
|
||||
|
||||
@@ -37,27 +37,23 @@ void subghz_scene_need_saving_on_enter(void* context) {
|
||||
bool subghz_scene_need_saving_on_event(void* context, SceneManagerEvent event) {
|
||||
SubGhz* subghz = context;
|
||||
if(event.type == SceneManagerEventTypeBack) {
|
||||
subghz->txrx->rx_key_state = SubGhzRxKeyStateBack;
|
||||
subghz_rx_key_state_set(subghz, SubGhzRxKeyStateBack);
|
||||
scene_manager_previous_scene(subghz->scene_manager);
|
||||
return true;
|
||||
} else if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubGhzCustomEventSceneStay) {
|
||||
subghz->txrx->rx_key_state = SubGhzRxKeyStateBack;
|
||||
subghz_rx_key_state_set(subghz, SubGhzRxKeyStateBack);
|
||||
scene_manager_previous_scene(subghz->scene_manager);
|
||||
return true;
|
||||
} else if(event.event == SubGhzCustomEventSceneExit) {
|
||||
if(subghz->txrx->rx_key_state == SubGhzRxKeyStateExit) {
|
||||
subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE;
|
||||
subghz_preset_init(
|
||||
subghz,
|
||||
"AM650",
|
||||
subghz_setting_get_default_frequency(subghz->setting),
|
||||
NULL,
|
||||
0);
|
||||
SubGhzRxKeyState state = subghz_rx_key_state_get(subghz);
|
||||
subghz_rx_key_state_set(subghz, SubGhzRxKeyStateIDLE);
|
||||
|
||||
if(state == SubGhzRxKeyStateExit) {
|
||||
subghz_set_default_preset(subghz);
|
||||
scene_manager_search_and_switch_to_previous_scene(
|
||||
subghz->scene_manager, SubGhzSceneStart);
|
||||
} else {
|
||||
subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE;
|
||||
scene_manager_previous_scene(subghz->scene_manager);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,11 +3,9 @@
|
||||
#include <dolphin/dolphin.h>
|
||||
#include <lib/subghz/protocols/raw.h>
|
||||
#include <lib/toolbox/path.h>
|
||||
#include <float_tools.h>
|
||||
|
||||
#define RAW_FILE_NAME "Raw_signal_"
|
||||
#define TAG "SubGhzSceneReadRAW"
|
||||
#define RAW_THRESHOLD_RSSI_LOW_COUNT 10
|
||||
|
||||
bool subghz_scene_read_raw_update_filename(SubGhz* subghz) {
|
||||
bool ret = false;
|
||||
@@ -15,12 +13,13 @@ bool subghz_scene_read_raw_update_filename(SubGhz* subghz) {
|
||||
FuriString* temp_str;
|
||||
temp_str = furi_string_alloc();
|
||||
do {
|
||||
if(!flipper_format_rewind(subghz->txrx->fff_data)) {
|
||||
FlipperFormat* fff_data = subghz_txrx_get_fff_data(subghz->txrx);
|
||||
if(!flipper_format_rewind(fff_data)) {
|
||||
FURI_LOG_E(TAG, "Rewind error");
|
||||
break;
|
||||
}
|
||||
|
||||
if(!flipper_format_read_string(subghz->txrx->fff_data, "File_name", temp_str)) {
|
||||
if(!flipper_format_read_string(fff_data, "File_name", temp_str)) {
|
||||
FURI_LOG_E(TAG, "Missing File_name");
|
||||
break;
|
||||
}
|
||||
@@ -38,13 +37,10 @@ static void subghz_scene_read_raw_update_statusbar(void* context) {
|
||||
furi_assert(context);
|
||||
SubGhz* subghz = context;
|
||||
|
||||
FuriString* frequency_str;
|
||||
FuriString* modulation_str;
|
||||
FuriString* frequency_str = furi_string_alloc();
|
||||
FuriString* modulation_str = furi_string_alloc();
|
||||
|
||||
frequency_str = furi_string_alloc();
|
||||
modulation_str = furi_string_alloc();
|
||||
|
||||
subghz_get_frequency_modulation(subghz, frequency_str, modulation_str);
|
||||
subghz_txrx_get_frequency_and_modulation(subghz->txrx, frequency_str, modulation_str);
|
||||
subghz_read_raw_add_data_statusbar(
|
||||
subghz->subghz_read_raw,
|
||||
furi_string_get_cstr(frequency_str),
|
||||
@@ -69,13 +65,13 @@ void subghz_scene_read_raw_callback_end_tx(void* context) {
|
||||
|
||||
void subghz_scene_read_raw_on_enter(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
FuriString* file_name;
|
||||
file_name = furi_string_alloc();
|
||||
FuriString* file_name = furi_string_alloc();
|
||||
|
||||
switch(subghz->txrx->rx_key_state) {
|
||||
float threshold_rssi = subghz_threshold_rssi_get(subghz->threshold_rssi);
|
||||
switch(subghz_rx_key_state_get(subghz)) {
|
||||
case SubGhzRxKeyStateBack:
|
||||
subghz_read_raw_set_status(
|
||||
subghz->subghz_read_raw, SubGhzReadRAWStatusIDLE, "", subghz->txrx->raw_threshold_rssi);
|
||||
subghz->subghz_read_raw, SubGhzReadRAWStatusIDLE, "", threshold_rssi);
|
||||
break;
|
||||
case SubGhzRxKeyStateRAWLoad:
|
||||
path_extract_filename(subghz->file_path, file_name, true);
|
||||
@@ -83,8 +79,7 @@ void subghz_scene_read_raw_on_enter(void* context) {
|
||||
subghz->subghz_read_raw,
|
||||
SubGhzReadRAWStatusLoadKeyTX,
|
||||
furi_string_get_cstr(file_name),
|
||||
subghz->txrx->raw_threshold_rssi);
|
||||
subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE;
|
||||
threshold_rssi);
|
||||
break;
|
||||
case SubGhzRxKeyStateRAWSave:
|
||||
path_extract_filename(subghz->file_path, file_name, true);
|
||||
@@ -92,66 +87,51 @@ void subghz_scene_read_raw_on_enter(void* context) {
|
||||
subghz->subghz_read_raw,
|
||||
SubGhzReadRAWStatusSaveKey,
|
||||
furi_string_get_cstr(file_name),
|
||||
subghz->txrx->raw_threshold_rssi);
|
||||
subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE;
|
||||
threshold_rssi);
|
||||
break;
|
||||
default:
|
||||
subghz_read_raw_set_status(
|
||||
subghz->subghz_read_raw,
|
||||
SubGhzReadRAWStatusStart,
|
||||
"",
|
||||
subghz->txrx->raw_threshold_rssi);
|
||||
subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE;
|
||||
subghz->subghz_read_raw, SubGhzReadRAWStatusStart, "", threshold_rssi);
|
||||
break;
|
||||
}
|
||||
|
||||
if(subghz_rx_key_state_get(subghz) != SubGhzRxKeyStateBack) {
|
||||
subghz_rx_key_state_set(subghz, SubGhzRxKeyStateIDLE);
|
||||
}
|
||||
furi_string_free(file_name);
|
||||
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->decoder_result = subghz_receiver_search_decoder_base_by_name(
|
||||
subghz->txrx->receiver, SUBGHZ_PROTOCOL_RAW_NAME);
|
||||
furi_assert(subghz->txrx->decoder_result);
|
||||
furi_check(subghz_txrx_load_decoder_by_name_protocol(subghz->txrx, SUBGHZ_PROTOCOL_RAW_NAME));
|
||||
|
||||
//set filter RAW feed
|
||||
subghz_receiver_set_filter(subghz->txrx->receiver, SubGhzProtocolFlag_RAW);
|
||||
subghz_txrx_receiver_set_filter(subghz->txrx, 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;
|
||||
bool consumed = false;
|
||||
SubGhzProtocolDecoderRAW* decoder_raw =
|
||||
(SubGhzProtocolDecoderRAW*)subghz_txrx_get_decoder(subghz->txrx);
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
switch(event.event) {
|
||||
case SubGhzCustomEventViewReadRAWBack:
|
||||
//Stop TX
|
||||
if(subghz->txrx->txrx_state == SubGhzTxRxStateTx) {
|
||||
subghz_tx_stop(subghz);
|
||||
subghz_sleep(subghz);
|
||||
}
|
||||
//Stop RX
|
||||
if(subghz->txrx->txrx_state == SubGhzTxRxStateRx) {
|
||||
subghz_rx_end(subghz);
|
||||
subghz_sleep(subghz);
|
||||
};
|
||||
|
||||
subghz_txrx_stop(subghz->txrx);
|
||||
//Stop save file
|
||||
subghz_protocol_raw_save_to_file_stop(
|
||||
(SubGhzProtocolDecoderRAW*)subghz->txrx->decoder_result);
|
||||
subghz_protocol_raw_save_to_file_stop(decoder_raw);
|
||||
subghz->state_notifications = SubGhzNotificationStateIDLE;
|
||||
//needed save?
|
||||
if((subghz->txrx->rx_key_state == SubGhzRxKeyStateAddKey) ||
|
||||
(subghz->txrx->rx_key_state == SubGhzRxKeyStateBack)) {
|
||||
subghz->txrx->rx_key_state = SubGhzRxKeyStateExit;
|
||||
if((subghz_rx_key_state_get(subghz) == SubGhzRxKeyStateAddKey) ||
|
||||
(subghz_rx_key_state_get(subghz) == SubGhzRxKeyStateBack)) {
|
||||
subghz_rx_key_state_set(subghz, SubGhzRxKeyStateExit);
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneNeedSaving);
|
||||
} else {
|
||||
//Restore default setting
|
||||
subghz_preset_init(
|
||||
subghz,
|
||||
"AM650",
|
||||
subghz_setting_get_default_frequency(subghz->setting),
|
||||
NULL,
|
||||
0);
|
||||
subghz_set_default_preset(subghz);
|
||||
if(!scene_manager_search_and_switch_to_previous_scene(
|
||||
subghz->scene_manager, SubGhzSceneSaved)) {
|
||||
if(!scene_manager_search_and_switch_to_previous_scene(
|
||||
@@ -165,16 +145,7 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
|
||||
break;
|
||||
|
||||
case SubGhzCustomEventViewReadRAWTXRXStop:
|
||||
//Stop TX
|
||||
if(subghz->txrx->txrx_state == SubGhzTxRxStateTx) {
|
||||
subghz_tx_stop(subghz);
|
||||
subghz_sleep(subghz);
|
||||
}
|
||||
//Stop RX
|
||||
if(subghz->txrx->txrx_state == SubGhzTxRxStateRx) {
|
||||
subghz_rx_end(subghz);
|
||||
subghz_sleep(subghz);
|
||||
};
|
||||
subghz_txrx_stop(subghz->txrx);
|
||||
subghz->state_notifications = SubGhzNotificationStateIDLE;
|
||||
consumed = true;
|
||||
break;
|
||||
@@ -187,13 +158,13 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
|
||||
break;
|
||||
|
||||
case SubGhzCustomEventViewReadRAWErase:
|
||||
if(subghz->txrx->rx_key_state == SubGhzRxKeyStateAddKey) {
|
||||
if(subghz_rx_key_state_get(subghz) == SubGhzRxKeyStateAddKey) {
|
||||
if(subghz_scene_read_raw_update_filename(subghz)) {
|
||||
furi_string_set(subghz->file_path_tmp, subghz->file_path);
|
||||
subghz_delete_file(subghz);
|
||||
}
|
||||
}
|
||||
subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE;
|
||||
subghz_rx_key_state_set(subghz, SubGhzRxKeyStateIDLE);
|
||||
notification_message(subghz->notifications, &sequence_reset_rgb);
|
||||
consumed = true;
|
||||
break;
|
||||
@@ -203,7 +174,7 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
|
||||
if(subghz_scene_read_raw_update_filename(subghz)) {
|
||||
scene_manager_set_scene_state(
|
||||
subghz->scene_manager, SubGhzSceneReadRAW, SubGhzCustomEventManagerSet);
|
||||
subghz->txrx->rx_key_state = SubGhzRxKeyStateRAWLoad;
|
||||
subghz_rx_key_state_set(subghz, SubGhzRxKeyStateRAWLoad);
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneMoreRAW);
|
||||
consumed = true;
|
||||
} else {
|
||||
@@ -223,33 +194,22 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
|
||||
if(subghz_file_available(subghz) && subghz_scene_read_raw_update_filename(subghz)) {
|
||||
//start send
|
||||
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, subghz->txrx->fff_data)) {
|
||||
subghz->txrx->rx_key_state = SubGhzRxKeyStateBack;
|
||||
subghz_read_raw_set_status(
|
||||
subghz->subghz_read_raw,
|
||||
SubGhzReadRAWStatusIDLE,
|
||||
"",
|
||||
subghz->txrx->raw_threshold_rssi);
|
||||
} else {
|
||||
if(scene_manager_has_previous_scene(
|
||||
subghz->scene_manager, SubGhzSceneSaved) ||
|
||||
!scene_manager_has_previous_scene(
|
||||
subghz->scene_manager, SubGhzSceneStart)) {
|
||||
DOLPHIN_DEED(DolphinDeedSubGhzSend);
|
||||
}
|
||||
// set callback end tx
|
||||
subghz_protocol_raw_file_encoder_worker_set_callback_end(
|
||||
(SubGhzProtocolEncoderRAW*)subghz_transmitter_get_protocol_instance(
|
||||
subghz->txrx->transmitter),
|
||||
subghz_scene_read_raw_callback_end_tx,
|
||||
subghz);
|
||||
subghz->state_notifications = SubGhzNotificationStateTx;
|
||||
if(!subghz_tx_start(subghz, subghz_txrx_get_fff_data(subghz->txrx))) {
|
||||
subghz_rx_key_state_set(subghz, SubGhzRxKeyStateBack);
|
||||
subghz_read_raw_set_status(
|
||||
subghz->subghz_read_raw,
|
||||
SubGhzReadRAWStatusIDLE,
|
||||
"",
|
||||
subghz_threshold_rssi_get(subghz->threshold_rssi));
|
||||
} else {
|
||||
if(scene_manager_has_previous_scene(subghz->scene_manager, SubGhzSceneSaved) ||
|
||||
!scene_manager_has_previous_scene(subghz->scene_manager, SubGhzSceneStart)) {
|
||||
DOLPHIN_DEED(DolphinDeedSubGhzSend);
|
||||
}
|
||||
// set callback end tx
|
||||
subghz_txrx_set_raw_file_encoder_worker_callback_end(
|
||||
subghz->txrx, subghz_scene_read_raw_callback_end_tx, subghz);
|
||||
subghz->state_notifications = SubGhzNotificationStateTx;
|
||||
}
|
||||
} else {
|
||||
if(!scene_manager_search_and_switch_to_previous_scene(
|
||||
@@ -263,33 +223,22 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
|
||||
|
||||
case SubGhzCustomEventViewReadRAWSendStop:
|
||||
subghz->state_notifications = SubGhzNotificationStateIDLE;
|
||||
if(subghz->txrx->txrx_state == SubGhzTxRxStateTx) {
|
||||
subghz_speaker_unmute(subghz);
|
||||
subghz_tx_stop(subghz);
|
||||
subghz_sleep(subghz);
|
||||
}
|
||||
subghz_txrx_stop(subghz->txrx);
|
||||
subghz_read_raw_stop_send(subghz->subghz_read_raw);
|
||||
consumed = true;
|
||||
break;
|
||||
|
||||
case SubGhzCustomEventViewReadRAWIDLE:
|
||||
if(subghz->txrx->txrx_state == SubGhzTxRxStateRx) {
|
||||
subghz_rx_end(subghz);
|
||||
subghz_sleep(subghz);
|
||||
};
|
||||
subghz_txrx_stop(subghz->txrx);
|
||||
size_t spl_count = subghz_protocol_raw_get_sample_write(decoder_raw);
|
||||
|
||||
size_t spl_count = subghz_protocol_raw_get_sample_write(
|
||||
(SubGhzProtocolDecoderRAW*)subghz->txrx->decoder_result);
|
||||
subghz_protocol_raw_save_to_file_stop(decoder_raw);
|
||||
|
||||
subghz_protocol_raw_save_to_file_stop(
|
||||
(SubGhzProtocolDecoderRAW*)subghz->txrx->decoder_result);
|
||||
|
||||
FuriString* temp_str;
|
||||
temp_str = furi_string_alloc();
|
||||
FuriString* temp_str = furi_string_alloc();
|
||||
furi_string_printf(
|
||||
temp_str, "%s/%s%s", SUBGHZ_RAW_FOLDER, RAW_FILE_NAME, SUBGHZ_APP_EXTENSION);
|
||||
subghz_protocol_raw_gen_fff_data(
|
||||
subghz->txrx->fff_data, furi_string_get_cstr(temp_str));
|
||||
subghz_txrx_get_fff_data(subghz->txrx), furi_string_get_cstr(temp_str));
|
||||
furi_string_free(temp_str);
|
||||
|
||||
if(spl_count > 0) {
|
||||
@@ -299,32 +248,21 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
|
||||
}
|
||||
|
||||
subghz->state_notifications = SubGhzNotificationStateIDLE;
|
||||
subghz->txrx->rx_key_state = SubGhzRxKeyStateAddKey;
|
||||
subghz_rx_key_state_set(subghz, SubGhzRxKeyStateAddKey);
|
||||
|
||||
consumed = true;
|
||||
break;
|
||||
|
||||
case SubGhzCustomEventViewReadRAWREC:
|
||||
if(subghz->txrx->rx_key_state != SubGhzRxKeyStateIDLE) {
|
||||
if(subghz_rx_key_state_get(subghz) != SubGhzRxKeyStateIDLE) {
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneNeedSaving);
|
||||
} else {
|
||||
subghz->txrx->raw_threshold_rssi_low_count = RAW_THRESHOLD_RSSI_LOW_COUNT;
|
||||
if(subghz_protocol_raw_save_to_file_init(
|
||||
(SubGhzProtocolDecoderRAW*)subghz->txrx->decoder_result,
|
||||
RAW_FILE_NAME,
|
||||
subghz->txrx->preset)) {
|
||||
SubGhzRadioPreset preset = subghz_txrx_get_preset(subghz->txrx);
|
||||
if(subghz_protocol_raw_save_to_file_init(decoder_raw, RAW_FILE_NAME, &preset)) {
|
||||
DOLPHIN_DEED(DolphinDeedSubGhzRawRec);
|
||||
if((subghz->txrx->txrx_state == SubGhzTxRxStateIDLE) ||
|
||||
(subghz->txrx->txrx_state == SubGhzTxRxStateSleep)) {
|
||||
subghz_begin(
|
||||
subghz,
|
||||
subghz_setting_get_preset_data_by_name(
|
||||
subghz->setting,
|
||||
furi_string_get_cstr(subghz->txrx->preset->name)));
|
||||
subghz_rx(subghz, subghz->txrx->preset->frequency);
|
||||
}
|
||||
subghz_txrx_rx_start(subghz->txrx);
|
||||
subghz->state_notifications = SubGhzNotificationStateRx;
|
||||
subghz->txrx->rx_key_state = SubGhzRxKeyStateAddKey;
|
||||
subghz_rx_key_state_set(subghz, SubGhzRxKeyStateAddKey);
|
||||
} else {
|
||||
furi_string_set(subghz->error_str, "Function requires\nan SD card.");
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError);
|
||||
@@ -337,7 +275,7 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
|
||||
if(subghz_file_available(subghz) && subghz_scene_read_raw_update_filename(subghz)) {
|
||||
scene_manager_set_scene_state(
|
||||
subghz->scene_manager, SubGhzSceneReadRAW, SubGhzCustomEventManagerSetRAW);
|
||||
subghz->txrx->rx_key_state = SubGhzRxKeyStateBack;
|
||||
subghz_rx_key_state_set(subghz, SubGhzRxKeyStateBack);
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSaveName);
|
||||
} else {
|
||||
if(!scene_manager_search_and_switch_to_previous_scene(
|
||||
@@ -356,41 +294,15 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
|
||||
switch(subghz->state_notifications) {
|
||||
case SubGhzNotificationStateRx:
|
||||
notification_message(subghz->notifications, &sequence_blink_cyan_10);
|
||||
|
||||
subghz_read_raw_update_sample_write(
|
||||
subghz->subghz_read_raw,
|
||||
subghz_protocol_raw_get_sample_write(
|
||||
(SubGhzProtocolDecoderRAW*)subghz->txrx->decoder_result));
|
||||
|
||||
float rssi = furi_hal_subghz_get_rssi();
|
||||
|
||||
if(float_is_equal(subghz->txrx->raw_threshold_rssi, SUBGHZ_RAW_TRESHOLD_MIN)) {
|
||||
subghz_read_raw_add_data_rssi(subghz->subghz_read_raw, rssi, true);
|
||||
subghz_protocol_raw_save_to_file_pause(
|
||||
(SubGhzProtocolDecoderRAW*)subghz->txrx->decoder_result, false);
|
||||
} else {
|
||||
if(rssi < subghz->txrx->raw_threshold_rssi) {
|
||||
subghz->txrx->raw_threshold_rssi_low_count++;
|
||||
if(subghz->txrx->raw_threshold_rssi_low_count > RAW_THRESHOLD_RSSI_LOW_COUNT) {
|
||||
subghz->txrx->raw_threshold_rssi_low_count = RAW_THRESHOLD_RSSI_LOW_COUNT;
|
||||
}
|
||||
subghz_read_raw_add_data_rssi(subghz->subghz_read_raw, rssi, false);
|
||||
} else {
|
||||
subghz->txrx->raw_threshold_rssi_low_count = 0;
|
||||
}
|
||||
|
||||
if(subghz->txrx->raw_threshold_rssi_low_count == RAW_THRESHOLD_RSSI_LOW_COUNT) {
|
||||
subghz_read_raw_add_data_rssi(subghz->subghz_read_raw, rssi, false);
|
||||
subghz_protocol_raw_save_to_file_pause(
|
||||
(SubGhzProtocolDecoderRAW*)subghz->txrx->decoder_result, true);
|
||||
subghz_speaker_mute(subghz);
|
||||
} else {
|
||||
subghz_read_raw_add_data_rssi(subghz->subghz_read_raw, rssi, true);
|
||||
subghz_protocol_raw_save_to_file_pause(
|
||||
(SubGhzProtocolDecoderRAW*)subghz->txrx->decoder_result, false);
|
||||
subghz_speaker_unmute(subghz);
|
||||
}
|
||||
}
|
||||
subghz->subghz_read_raw, subghz_protocol_raw_get_sample_write(decoder_raw));
|
||||
|
||||
SubGhzThresholdRssiData ret_rssi =
|
||||
subghz_threshold_get_rssi_data(subghz->threshold_rssi);
|
||||
subghz_read_raw_add_data_rssi(
|
||||
subghz->subghz_read_raw, ret_rssi.rssi, ret_rssi.is_above);
|
||||
subghz_protocol_raw_save_to_file_pause(decoder_raw, !ret_rssi.is_above);
|
||||
break;
|
||||
case SubGhzNotificationStateTx:
|
||||
notification_message(subghz->notifications, &sequence_blink_magenta_10);
|
||||
@@ -407,13 +319,10 @@ void subghz_scene_read_raw_on_exit(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
|
||||
//Stop CC1101
|
||||
if(subghz->txrx->txrx_state == SubGhzTxRxStateRx) {
|
||||
subghz_rx_end(subghz);
|
||||
subghz_sleep(subghz);
|
||||
};
|
||||
subghz_txrx_stop(subghz->txrx);
|
||||
subghz->state_notifications = SubGhzNotificationStateIDLE;
|
||||
notification_message(subghz->notifications, &sequence_reset_rgb);
|
||||
|
||||
//filter restoration
|
||||
subghz_receiver_set_filter(subghz->txrx->receiver, subghz->txrx->filter);
|
||||
subghz_txrx_receiver_set_filter(subghz->txrx, subghz->filter);
|
||||
}
|
||||
|
||||
@@ -35,16 +35,12 @@ static const NotificationSequence subghs_sequence_rx_locked = {
|
||||
|
||||
static void subghz_scene_receiver_update_statusbar(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
FuriString* history_stat_str;
|
||||
history_stat_str = furi_string_alloc();
|
||||
if(!subghz_history_get_text_space_left(subghz->txrx->history, history_stat_str)) {
|
||||
FuriString* frequency_str;
|
||||
FuriString* modulation_str;
|
||||
FuriString* history_stat_str = furi_string_alloc();
|
||||
if(!subghz_history_get_text_space_left(subghz->history, history_stat_str)) {
|
||||
FuriString* frequency_str = furi_string_alloc();
|
||||
FuriString* modulation_str = furi_string_alloc();
|
||||
|
||||
frequency_str = furi_string_alloc();
|
||||
modulation_str = furi_string_alloc();
|
||||
|
||||
subghz_get_frequency_modulation(subghz, frequency_str, modulation_str);
|
||||
subghz_txrx_get_frequency_and_modulation(subghz->txrx, frequency_str, modulation_str);
|
||||
|
||||
subghz_view_receiver_add_data_statusbar(
|
||||
subghz->subghz_receiver,
|
||||
@@ -74,80 +70,68 @@ static void subghz_scene_add_to_history_callback(
|
||||
void* context) {
|
||||
furi_assert(context);
|
||||
SubGhz* subghz = context;
|
||||
FuriString* str_buff;
|
||||
str_buff = furi_string_alloc();
|
||||
SubGhzHistory* history = subghz->history;
|
||||
FuriString* str_buff = furi_string_alloc();
|
||||
|
||||
if(subghz_history_add_to_history(subghz->txrx->history, decoder_base, subghz->txrx->preset)) {
|
||||
SubGhzRadioPreset preset = subghz_txrx_get_preset(subghz->txrx);
|
||||
|
||||
if(subghz_history_add_to_history(history, decoder_base, &preset)) {
|
||||
furi_string_reset(str_buff);
|
||||
|
||||
subghz->state_notifications = SubGhzNotificationStateRxDone;
|
||||
|
||||
subghz_history_get_text_item_menu(
|
||||
subghz->txrx->history, str_buff, subghz_history_get_item(subghz->txrx->history) - 1);
|
||||
uint16_t item_history = subghz_history_get_item(history);
|
||||
subghz_history_get_text_item_menu(history, str_buff, item_history - 1);
|
||||
subghz_view_receiver_add_item_to_menu(
|
||||
subghz->subghz_receiver,
|
||||
furi_string_get_cstr(str_buff),
|
||||
subghz_history_get_type_protocol(
|
||||
subghz->txrx->history, subghz_history_get_item(subghz->txrx->history) - 1));
|
||||
subghz_history_get_type_protocol(history, item_history - 1));
|
||||
|
||||
subghz_scene_receiver_update_statusbar(subghz);
|
||||
}
|
||||
subghz_receiver_reset(receiver);
|
||||
furi_string_free(str_buff);
|
||||
subghz->txrx->rx_key_state = SubGhzRxKeyStateAddKey;
|
||||
subghz_rx_key_state_set(subghz, SubGhzRxKeyStateAddKey);
|
||||
}
|
||||
|
||||
void subghz_scene_receiver_on_enter(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
SubGhzHistory* history = subghz->history;
|
||||
|
||||
FuriString* str_buff;
|
||||
str_buff = furi_string_alloc();
|
||||
|
||||
if(subghz->txrx->rx_key_state == SubGhzRxKeyStateIDLE) {
|
||||
subghz_preset_init(
|
||||
subghz, "AM650", subghz_setting_get_default_frequency(subghz->setting), NULL, 0);
|
||||
subghz_history_reset(subghz->txrx->history);
|
||||
subghz->txrx->rx_key_state = SubGhzRxKeyStateStart;
|
||||
if(subghz_rx_key_state_get(subghz) == SubGhzRxKeyStateIDLE) {
|
||||
subghz_set_default_preset(subghz);
|
||||
subghz_history_reset(history);
|
||||
subghz_rx_key_state_set(subghz, SubGhzRxKeyStateStart);
|
||||
}
|
||||
|
||||
subghz_view_receiver_set_lock(subghz->subghz_receiver, subghz->lock);
|
||||
subghz_view_receiver_set_lock(subghz->subghz_receiver, subghz_is_locked(subghz));
|
||||
|
||||
//Load history to receiver
|
||||
subghz_view_receiver_exit(subghz->subghz_receiver);
|
||||
for(uint8_t i = 0; i < subghz_history_get_item(subghz->txrx->history); i++) {
|
||||
for(uint8_t i = 0; i < subghz_history_get_item(history); i++) {
|
||||
furi_string_reset(str_buff);
|
||||
subghz_history_get_text_item_menu(subghz->txrx->history, str_buff, i);
|
||||
subghz_history_get_text_item_menu(history, str_buff, i);
|
||||
subghz_view_receiver_add_item_to_menu(
|
||||
subghz->subghz_receiver,
|
||||
furi_string_get_cstr(str_buff),
|
||||
subghz_history_get_type_protocol(subghz->txrx->history, i));
|
||||
subghz->txrx->rx_key_state = SubGhzRxKeyStateAddKey;
|
||||
subghz_history_get_type_protocol(history, i));
|
||||
subghz_rx_key_state_set(subghz, SubGhzRxKeyStateAddKey);
|
||||
}
|
||||
furi_string_free(str_buff);
|
||||
subghz_scene_receiver_update_statusbar(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_txrx_set_rx_calback(subghz->txrx, subghz_scene_add_to_history_callback, subghz);
|
||||
|
||||
subghz->state_notifications = SubGhzNotificationStateRx;
|
||||
if(subghz->txrx->txrx_state == SubGhzTxRxStateRx) {
|
||||
subghz_rx_end(subghz);
|
||||
};
|
||||
if((subghz->txrx->txrx_state == SubGhzTxRxStateIDLE) ||
|
||||
(subghz->txrx->txrx_state == SubGhzTxRxStateSleep)) {
|
||||
subghz_begin(
|
||||
subghz,
|
||||
subghz_setting_get_preset_data_by_name(
|
||||
subghz->setting, furi_string_get_cstr(subghz->txrx->preset->name)));
|
||||
subghz_rx(subghz, subghz->txrx->preset->frequency);
|
||||
}
|
||||
subghz_view_receiver_set_idx_menu(subghz->subghz_receiver, subghz->txrx->idx_menu_chosen);
|
||||
subghz_txrx_rx_start(subghz->txrx);
|
||||
subghz_view_receiver_set_idx_menu(subghz->subghz_receiver, subghz->idx_menu_chosen);
|
||||
|
||||
//to use a universal decoder, we are looking for a link to it
|
||||
subghz->txrx->decoder_result = subghz_receiver_search_decoder_base_by_name(
|
||||
subghz->txrx->receiver, SUBGHZ_PROTOCOL_BIN_RAW_NAME);
|
||||
furi_assert(subghz->txrx->decoder_result);
|
||||
furi_check(
|
||||
subghz_txrx_load_decoder_by_name_protocol(subghz->txrx, SUBGHZ_PROTOCOL_BIN_RAW_NAME));
|
||||
|
||||
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdReceiver);
|
||||
}
|
||||
@@ -160,41 +144,31 @@ bool subghz_scene_receiver_on_event(void* context, SceneManagerEvent event) {
|
||||
case SubGhzCustomEventViewReceiverBack:
|
||||
// Stop CC1101 Rx
|
||||
subghz->state_notifications = SubGhzNotificationStateIDLE;
|
||||
if(subghz->txrx->txrx_state == SubGhzTxRxStateRx) {
|
||||
subghz_rx_end(subghz);
|
||||
subghz_sleep(subghz);
|
||||
};
|
||||
subghz->txrx->hopper_state = SubGhzHopperStateOFF;
|
||||
subghz->txrx->idx_menu_chosen = 0;
|
||||
subghz_receiver_set_rx_callback(subghz->txrx->receiver, NULL, subghz);
|
||||
subghz_txrx_stop(subghz->txrx);
|
||||
subghz_txrx_hopper_set_state(subghz->txrx, SubGhzHopperStateOFF);
|
||||
subghz->idx_menu_chosen = 0;
|
||||
subghz_txrx_set_rx_calback(subghz->txrx, NULL, subghz);
|
||||
|
||||
if(subghz->txrx->rx_key_state == SubGhzRxKeyStateAddKey) {
|
||||
subghz->txrx->rx_key_state = SubGhzRxKeyStateExit;
|
||||
if(subghz_rx_key_state_get(subghz) == SubGhzRxKeyStateAddKey) {
|
||||
subghz_rx_key_state_set(subghz, SubGhzRxKeyStateExit);
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneNeedSaving);
|
||||
} else {
|
||||
subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE;
|
||||
subghz_preset_init(
|
||||
subghz,
|
||||
"AM650",
|
||||
subghz_setting_get_default_frequency(subghz->setting),
|
||||
NULL,
|
||||
0);
|
||||
subghz_rx_key_state_set(subghz, SubGhzRxKeyStateIDLE);
|
||||
subghz_set_default_preset(subghz);
|
||||
scene_manager_search_and_switch_to_previous_scene(
|
||||
subghz->scene_manager, SubGhzSceneStart);
|
||||
}
|
||||
consumed = true;
|
||||
break;
|
||||
case SubGhzCustomEventViewReceiverOK:
|
||||
subghz->txrx->idx_menu_chosen =
|
||||
subghz_view_receiver_get_idx_menu(subghz->subghz_receiver);
|
||||
subghz->idx_menu_chosen = subghz_view_receiver_get_idx_menu(subghz->subghz_receiver);
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneReceiverInfo);
|
||||
DOLPHIN_DEED(DolphinDeedSubGhzReceiverInfo);
|
||||
consumed = true;
|
||||
break;
|
||||
case SubGhzCustomEventViewReceiverConfig:
|
||||
subghz->state_notifications = SubGhzNotificationStateIDLE;
|
||||
subghz->txrx->idx_menu_chosen =
|
||||
subghz_view_receiver_get_idx_menu(subghz->subghz_receiver);
|
||||
subghz->idx_menu_chosen = subghz_view_receiver_get_idx_menu(subghz->subghz_receiver);
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneReceiverConfig);
|
||||
consumed = true;
|
||||
break;
|
||||
@@ -203,30 +177,30 @@ bool subghz_scene_receiver_on_event(void* context, SceneManagerEvent event) {
|
||||
consumed = true;
|
||||
break;
|
||||
case SubGhzCustomEventViewReceiverUnlock:
|
||||
subghz->lock = SubGhzLockOff;
|
||||
subghz_unlock(subghz);
|
||||
consumed = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else if(event.type == SceneManagerEventTypeTick) {
|
||||
if(subghz->txrx->hopper_state != SubGhzHopperStateOFF) {
|
||||
subghz_hopper_update(subghz);
|
||||
if(subghz_txrx_hopper_get_state(subghz->txrx) != SubGhzHopperStateOFF) {
|
||||
subghz_txrx_hopper_update(subghz->txrx);
|
||||
subghz_scene_receiver_update_statusbar(subghz);
|
||||
}
|
||||
|
||||
//get RSSI
|
||||
float rssi = furi_hal_subghz_get_rssi();
|
||||
subghz_receiver_rssi(subghz->subghz_receiver, rssi);
|
||||
SubGhzThresholdRssiData ret_rssi = subghz_threshold_get_rssi_data(subghz->threshold_rssi);
|
||||
|
||||
subghz_receiver_rssi(subghz->subghz_receiver, ret_rssi.rssi);
|
||||
subghz_protocol_decoder_bin_raw_data_input_rssi(
|
||||
(SubGhzProtocolDecoderBinRAW*)subghz->txrx->decoder_result, rssi);
|
||||
(SubGhzProtocolDecoderBinRAW*)subghz_txrx_get_decoder(subghz->txrx), ret_rssi.rssi);
|
||||
|
||||
switch(subghz->state_notifications) {
|
||||
case SubGhzNotificationStateRx:
|
||||
notification_message(subghz->notifications, &sequence_blink_cyan_10);
|
||||
break;
|
||||
case SubGhzNotificationStateRxDone:
|
||||
if(subghz->lock != SubGhzLockOn) {
|
||||
if(!subghz_is_locked(subghz)) {
|
||||
notification_message(subghz->notifications, &subghs_sequence_rx);
|
||||
} else {
|
||||
notification_message(subghz->notifications, &subghs_sequence_rx_locked);
|
||||
|
||||
@@ -72,13 +72,15 @@ const uint32_t bin_raw_value[BIN_RAW_COUNT] = {
|
||||
uint8_t subghz_scene_receiver_config_next_frequency(const uint32_t value, void* context) {
|
||||
furi_assert(context);
|
||||
SubGhz* subghz = context;
|
||||
SubGhzSetting* setting = subghz_txrx_get_setting(subghz->txrx);
|
||||
|
||||
uint8_t index = 0;
|
||||
for(uint8_t i = 0; i < subghz_setting_get_frequency_count(subghz->setting); i++) {
|
||||
if(value == subghz_setting_get_frequency(subghz->setting, i)) {
|
||||
for(uint8_t i = 0; i < subghz_setting_get_frequency_count(setting); i++) {
|
||||
if(value == subghz_setting_get_frequency(setting, i)) {
|
||||
index = i;
|
||||
break;
|
||||
} else {
|
||||
index = subghz_setting_get_frequency_default_index(subghz->setting);
|
||||
index = subghz_setting_get_frequency_default_index(setting);
|
||||
}
|
||||
}
|
||||
return index;
|
||||
@@ -87,13 +89,15 @@ uint8_t subghz_scene_receiver_config_next_frequency(const uint32_t value, void*
|
||||
uint8_t subghz_scene_receiver_config_next_preset(const char* preset_name, void* context) {
|
||||
furi_assert(context);
|
||||
SubGhz* subghz = context;
|
||||
SubGhzSetting* setting = subghz_txrx_get_setting(subghz->txrx);
|
||||
|
||||
uint8_t index = 0;
|
||||
for(uint8_t i = 0; i < subghz_setting_get_preset_count(subghz->setting); i++) {
|
||||
if(!strcmp(subghz_setting_get_preset_name(subghz->setting, i), preset_name)) {
|
||||
for(uint8_t i = 0; i < subghz_setting_get_preset_count(setting); i++) {
|
||||
if(!strcmp(subghz_setting_get_preset_name(setting, i), preset_name)) {
|
||||
index = i;
|
||||
break;
|
||||
} else {
|
||||
// index = subghz_setting_get_frequency_default_index(subghz->setting);
|
||||
// index = subghz_setting_get_frequency_default_index(subghz_txrx_get_setting(subghz->txrx));
|
||||
}
|
||||
}
|
||||
return index;
|
||||
@@ -122,70 +126,84 @@ uint8_t subghz_scene_receiver_config_hopper_value_index(
|
||||
static void subghz_scene_receiver_config_set_frequency(VariableItem* item) {
|
||||
SubGhz* subghz = variable_item_get_context(item);
|
||||
uint8_t index = variable_item_get_current_value_index(item);
|
||||
SubGhzSetting* setting = subghz_txrx_get_setting(subghz->txrx);
|
||||
|
||||
if(subghz->txrx->hopper_state == SubGhzHopperStateOFF) {
|
||||
if(subghz_txrx_hopper_get_state(subghz->txrx) == SubGhzHopperStateOFF) {
|
||||
char text_buf[10] = {0};
|
||||
uint32_t frequency = subghz_setting_get_frequency(setting, index);
|
||||
SubGhzRadioPreset preset = subghz_txrx_get_preset(subghz->txrx);
|
||||
|
||||
snprintf(
|
||||
text_buf,
|
||||
sizeof(text_buf),
|
||||
"%lu.%02lu",
|
||||
subghz_setting_get_frequency(subghz->setting, index) / 1000000,
|
||||
(subghz_setting_get_frequency(subghz->setting, index) % 1000000) / 10000);
|
||||
frequency / 1000000,
|
||||
(frequency % 1000000) / 10000);
|
||||
variable_item_set_current_value_text(item, text_buf);
|
||||
subghz->txrx->preset->frequency = subghz_setting_get_frequency(subghz->setting, index);
|
||||
subghz_txrx_set_preset(
|
||||
subghz->txrx,
|
||||
furi_string_get_cstr(preset.name),
|
||||
frequency,
|
||||
preset.data,
|
||||
preset.data_size);
|
||||
} else {
|
||||
variable_item_set_current_value_index(
|
||||
item, subghz_setting_get_frequency_default_index(subghz->setting));
|
||||
item, subghz_setting_get_frequency_default_index(setting));
|
||||
}
|
||||
}
|
||||
|
||||
static void subghz_scene_receiver_config_set_preset(VariableItem* item) {
|
||||
SubGhz* subghz = variable_item_get_context(item);
|
||||
uint8_t index = variable_item_get_current_value_index(item);
|
||||
variable_item_set_current_value_text(
|
||||
item, subghz_setting_get_preset_name(subghz->setting, index));
|
||||
subghz_preset_init(
|
||||
subghz,
|
||||
subghz_setting_get_preset_name(subghz->setting, index),
|
||||
subghz->txrx->preset->frequency,
|
||||
subghz_setting_get_preset_data(subghz->setting, index),
|
||||
subghz_setting_get_preset_data_size(subghz->setting, index));
|
||||
SubGhzSetting* setting = subghz_txrx_get_setting(subghz->txrx);
|
||||
|
||||
variable_item_set_current_value_text(item, subghz_setting_get_preset_name(setting, index));
|
||||
|
||||
SubGhzRadioPreset preset = subghz_txrx_get_preset(subghz->txrx);
|
||||
subghz_txrx_set_preset(
|
||||
subghz->txrx,
|
||||
subghz_setting_get_preset_name(setting, index),
|
||||
preset.frequency,
|
||||
subghz_setting_get_preset_data(setting, index),
|
||||
subghz_setting_get_preset_data_size(setting, index));
|
||||
}
|
||||
|
||||
static void subghz_scene_receiver_config_set_hopping_running(VariableItem* item) {
|
||||
SubGhz* subghz = variable_item_get_context(item);
|
||||
uint8_t index = variable_item_get_current_value_index(item);
|
||||
SubGhzSetting* setting = subghz_txrx_get_setting(subghz->txrx);
|
||||
VariableItem* frequency_item = (VariableItem*)scene_manager_get_scene_state(
|
||||
subghz->scene_manager, SubGhzSceneReceiverConfig);
|
||||
|
||||
variable_item_set_current_value_text(item, hopping_text[index]);
|
||||
if(hopping_value[index] == SubGhzHopperStateOFF) {
|
||||
char text_buf[10] = {0};
|
||||
uint32_t frequency = subghz_setting_get_default_frequency(setting);
|
||||
SubGhzRadioPreset preset = subghz_txrx_get_preset(subghz->txrx);
|
||||
|
||||
snprintf(
|
||||
text_buf,
|
||||
sizeof(text_buf),
|
||||
"%lu.%02lu",
|
||||
subghz_setting_get_default_frequency(subghz->setting) / 1000000,
|
||||
(subghz_setting_get_default_frequency(subghz->setting) % 1000000) / 10000);
|
||||
variable_item_set_current_value_text(
|
||||
(VariableItem*)scene_manager_get_scene_state(
|
||||
subghz->scene_manager, SubGhzSceneReceiverConfig),
|
||||
text_buf);
|
||||
subghz->txrx->preset->frequency = subghz_setting_get_default_frequency(subghz->setting);
|
||||
frequency / 1000000,
|
||||
(frequency % 1000000) / 10000);
|
||||
variable_item_set_current_value_text(frequency_item, text_buf);
|
||||
|
||||
subghz_txrx_set_preset(
|
||||
subghz->txrx,
|
||||
furi_string_get_cstr(preset.name),
|
||||
frequency,
|
||||
preset.data,
|
||||
preset.data_size);
|
||||
variable_item_set_current_value_index(
|
||||
(VariableItem*)scene_manager_get_scene_state(
|
||||
subghz->scene_manager, SubGhzSceneReceiverConfig),
|
||||
subghz_setting_get_frequency_default_index(subghz->setting));
|
||||
frequency_item, subghz_setting_get_frequency_default_index(setting));
|
||||
} else {
|
||||
variable_item_set_current_value_text(
|
||||
(VariableItem*)scene_manager_get_scene_state(
|
||||
subghz->scene_manager, SubGhzSceneReceiverConfig),
|
||||
" -----");
|
||||
variable_item_set_current_value_text(frequency_item, " -----");
|
||||
variable_item_set_current_value_index(
|
||||
(VariableItem*)scene_manager_get_scene_state(
|
||||
subghz->scene_manager, SubGhzSceneReceiverConfig),
|
||||
subghz_setting_get_frequency_default_index(subghz->setting));
|
||||
frequency_item, subghz_setting_get_frequency_default_index(setting));
|
||||
}
|
||||
|
||||
subghz->txrx->hopper_state = hopping_value[index];
|
||||
subghz_txrx_hopper_set_state(subghz->txrx, hopping_value[index]);
|
||||
}
|
||||
|
||||
static void subghz_scene_receiver_config_set_speaker(VariableItem* item) {
|
||||
@@ -193,7 +211,7 @@ static void subghz_scene_receiver_config_set_speaker(VariableItem* item) {
|
||||
uint8_t index = variable_item_get_current_value_index(item);
|
||||
|
||||
variable_item_set_current_value_text(item, speaker_text[index]);
|
||||
subghz->txrx->speaker_state = speaker_value[index];
|
||||
subghz_txrx_speaker_set_state(subghz->txrx, speaker_value[index]);
|
||||
}
|
||||
|
||||
static void subghz_scene_receiver_config_set_bin_raw(VariableItem* item) {
|
||||
@@ -201,8 +219,8 @@ static void subghz_scene_receiver_config_set_bin_raw(VariableItem* item) {
|
||||
uint8_t index = variable_item_get_current_value_index(item);
|
||||
|
||||
variable_item_set_current_value_text(item, bin_raw_text[index]);
|
||||
subghz->txrx->filter = bin_raw_value[index];
|
||||
subghz_receiver_set_filter(subghz->txrx->receiver, subghz->txrx->filter);
|
||||
subghz->filter = bin_raw_value[index];
|
||||
subghz_txrx_receiver_set_filter(subghz->txrx, subghz->filter);
|
||||
}
|
||||
|
||||
static void subghz_scene_receiver_config_set_raw_threshold_rssi(VariableItem* item) {
|
||||
@@ -210,7 +228,7 @@ static void subghz_scene_receiver_config_set_raw_threshold_rssi(VariableItem* it
|
||||
uint8_t index = variable_item_get_current_value_index(item);
|
||||
|
||||
variable_item_set_current_value_text(item, raw_theshold_rssi_text[index]);
|
||||
subghz->txrx->raw_threshold_rssi = raw_theshold_rssi_value[index];
|
||||
subghz_threshold_rssi_set(subghz->threshold_rssi, raw_theshold_rssi_value[index]);
|
||||
}
|
||||
|
||||
static void subghz_scene_receiver_config_var_list_enter_callback(void* context, uint32_t index) {
|
||||
@@ -226,25 +244,27 @@ void subghz_scene_receiver_config_on_enter(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
VariableItem* item;
|
||||
uint8_t value_index;
|
||||
SubGhzSetting* setting = subghz_txrx_get_setting(subghz->txrx);
|
||||
SubGhzRadioPreset preset = subghz_txrx_get_preset(subghz->txrx);
|
||||
|
||||
item = variable_item_list_add(
|
||||
subghz->variable_item_list,
|
||||
"Frequency:",
|
||||
subghz_setting_get_frequency_count(subghz->setting),
|
||||
subghz_setting_get_frequency_count(setting),
|
||||
subghz_scene_receiver_config_set_frequency,
|
||||
subghz);
|
||||
value_index =
|
||||
subghz_scene_receiver_config_next_frequency(subghz->txrx->preset->frequency, subghz);
|
||||
value_index = subghz_scene_receiver_config_next_frequency(preset.frequency, subghz);
|
||||
scene_manager_set_scene_state(
|
||||
subghz->scene_manager, SubGhzSceneReceiverConfig, (uint32_t)item);
|
||||
variable_item_set_current_value_index(item, value_index);
|
||||
char text_buf[10] = {0};
|
||||
uint32_t frequency = subghz_setting_get_frequency(setting, value_index);
|
||||
snprintf(
|
||||
text_buf,
|
||||
sizeof(text_buf),
|
||||
"%lu.%02lu",
|
||||
subghz_setting_get_frequency(subghz->setting, value_index) / 1000000,
|
||||
(subghz_setting_get_frequency(subghz->setting, value_index) % 1000000) / 10000);
|
||||
frequency / 1000000,
|
||||
(frequency % 1000000) / 10000);
|
||||
variable_item_set_current_value_text(item, text_buf);
|
||||
|
||||
if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneReadRAW) !=
|
||||
@@ -256,7 +276,7 @@ void subghz_scene_receiver_config_on_enter(void* context) {
|
||||
subghz_scene_receiver_config_set_hopping_running,
|
||||
subghz);
|
||||
value_index = subghz_scene_receiver_config_hopper_value_index(
|
||||
subghz->txrx->hopper_state, hopping_value, HOPPING_COUNT, subghz);
|
||||
subghz_txrx_hopper_get_state(subghz->txrx), hopping_value, HOPPING_COUNT, subghz);
|
||||
variable_item_set_current_value_index(item, value_index);
|
||||
variable_item_set_current_value_text(item, hopping_text[value_index]);
|
||||
}
|
||||
@@ -264,14 +284,14 @@ void subghz_scene_receiver_config_on_enter(void* context) {
|
||||
item = variable_item_list_add(
|
||||
subghz->variable_item_list,
|
||||
"Modulation:",
|
||||
subghz_setting_get_preset_count(subghz->setting),
|
||||
subghz_setting_get_preset_count(setting),
|
||||
subghz_scene_receiver_config_set_preset,
|
||||
subghz);
|
||||
value_index = subghz_scene_receiver_config_next_preset(
|
||||
furi_string_get_cstr(subghz->txrx->preset->name), subghz);
|
||||
value_index =
|
||||
subghz_scene_receiver_config_next_preset(furi_string_get_cstr(preset.name), subghz);
|
||||
variable_item_set_current_value_index(item, value_index);
|
||||
variable_item_set_current_value_text(
|
||||
item, subghz_setting_get_preset_name(subghz->setting, value_index));
|
||||
item, subghz_setting_get_preset_name(setting, value_index));
|
||||
|
||||
if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneReadRAW) !=
|
||||
SubGhzCustomEventManagerSet) {
|
||||
@@ -281,7 +301,7 @@ void subghz_scene_receiver_config_on_enter(void* context) {
|
||||
BIN_RAW_COUNT,
|
||||
subghz_scene_receiver_config_set_bin_raw,
|
||||
subghz);
|
||||
value_index = value_index_uint32(subghz->txrx->filter, bin_raw_value, BIN_RAW_COUNT);
|
||||
value_index = value_index_uint32(subghz->filter, bin_raw_value, BIN_RAW_COUNT);
|
||||
variable_item_set_current_value_index(item, value_index);
|
||||
variable_item_set_current_value_text(item, bin_raw_text[value_index]);
|
||||
}
|
||||
@@ -292,7 +312,8 @@ void subghz_scene_receiver_config_on_enter(void* context) {
|
||||
SPEAKER_COUNT,
|
||||
subghz_scene_receiver_config_set_speaker,
|
||||
subghz);
|
||||
value_index = value_index_uint32(subghz->txrx->speaker_state, speaker_value, SPEAKER_COUNT);
|
||||
value_index = value_index_uint32(
|
||||
subghz_txrx_speaker_get_state(subghz->txrx), speaker_value, SPEAKER_COUNT);
|
||||
variable_item_set_current_value_index(item, value_index);
|
||||
variable_item_set_current_value_text(item, speaker_text[value_index]);
|
||||
|
||||
@@ -313,7 +334,9 @@ void subghz_scene_receiver_config_on_enter(void* context) {
|
||||
subghz_scene_receiver_config_set_raw_threshold_rssi,
|
||||
subghz);
|
||||
value_index = value_index_float(
|
||||
subghz->txrx->raw_threshold_rssi, raw_theshold_rssi_value, RAW_THRESHOLD_RSSI_COUNT);
|
||||
subghz_threshold_rssi_get(subghz->threshold_rssi),
|
||||
raw_theshold_rssi_value,
|
||||
RAW_THRESHOLD_RSSI_COUNT);
|
||||
variable_item_set_current_value_index(item, value_index);
|
||||
variable_item_set_current_value_text(item, raw_theshold_rssi_text[value_index]);
|
||||
}
|
||||
@@ -326,7 +349,7 @@ bool subghz_scene_receiver_config_on_event(void* context, SceneManagerEvent even
|
||||
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubGhzCustomEventSceneSettingLock) {
|
||||
subghz->lock = SubGhzLockOn;
|
||||
subghz_lock(subghz);
|
||||
scene_manager_previous_scene(subghz->scene_manager);
|
||||
consumed = true;
|
||||
}
|
||||
|
||||
@@ -19,20 +19,19 @@ void subghz_scene_receiver_info_callback(GuiButtonType result, InputType type, v
|
||||
|
||||
static bool subghz_scene_receiver_info_update_parser(void* context) {
|
||||
SubGhz* subghz = 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) {
|
||||
if(subghz_txrx_load_decoder_by_name_protocol(
|
||||
subghz->txrx,
|
||||
subghz_history_get_protocol_name(subghz->history, subghz->idx_menu_chosen))) {
|
||||
//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));
|
||||
subghz_txrx_get_decoder(subghz->txrx),
|
||||
subghz_history_get_raw_data(subghz->history, subghz->idx_menu_chosen));
|
||||
|
||||
SubGhzRadioPreset* preset =
|
||||
subghz_history_get_radio_preset(subghz->txrx->history, subghz->txrx->idx_menu_chosen);
|
||||
subghz_preset_init(
|
||||
subghz,
|
||||
subghz_history_get_radio_preset(subghz->history, subghz->idx_menu_chosen);
|
||||
subghz_txrx_set_preset(
|
||||
subghz->txrx,
|
||||
furi_string_get_cstr(preset->name),
|
||||
preset->frequency,
|
||||
preset->data,
|
||||
@@ -47,15 +46,11 @@ void subghz_scene_receiver_info_on_enter(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
|
||||
if(subghz_scene_receiver_info_update_parser(subghz)) {
|
||||
FuriString* frequency_str;
|
||||
FuriString* modulation_str;
|
||||
FuriString* text;
|
||||
FuriString* frequency_str = furi_string_alloc();
|
||||
FuriString* modulation_str = furi_string_alloc();
|
||||
FuriString* text = furi_string_alloc();
|
||||
|
||||
frequency_str = furi_string_alloc();
|
||||
modulation_str = furi_string_alloc();
|
||||
text = furi_string_alloc();
|
||||
|
||||
subghz_get_frequency_modulation(subghz, frequency_str, modulation_str);
|
||||
subghz_txrx_get_frequency_and_modulation(subghz->txrx, frequency_str, modulation_str);
|
||||
widget_add_string_element(
|
||||
subghz->widget,
|
||||
78,
|
||||
@@ -73,7 +68,7 @@ void subghz_scene_receiver_info_on_enter(void* context) {
|
||||
AlignTop,
|
||||
FontSecondary,
|
||||
furi_string_get_cstr(modulation_str));
|
||||
subghz_protocol_decoder_base_get_string(subghz->txrx->decoder_result, text);
|
||||
subghz_protocol_decoder_base_get_string(subghz_txrx_get_decoder(subghz->txrx), text);
|
||||
widget_add_string_multiline_element(
|
||||
subghz->widget, 0, 0, AlignLeft, AlignTop, FontSecondary, furi_string_get_cstr(text));
|
||||
|
||||
@@ -81,8 +76,7 @@ void subghz_scene_receiver_info_on_enter(void* context) {
|
||||
furi_string_free(modulation_str);
|
||||
furi_string_free(text);
|
||||
|
||||
if((subghz->txrx->decoder_result->protocol->flag & SubGhzProtocolFlag_Save) ==
|
||||
SubGhzProtocolFlag_Save) {
|
||||
if(subghz_txrx_protocol_is_serializable(subghz->txrx)) {
|
||||
widget_add_button_element(
|
||||
subghz->widget,
|
||||
GuiButtonTypeRight,
|
||||
@@ -90,10 +84,7 @@ void subghz_scene_receiver_info_on_enter(void* context) {
|
||||
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) {
|
||||
if(subghz_txrx_protocol_is_transmittable(subghz->txrx, true)) {
|
||||
widget_add_button_element(
|
||||
subghz->widget,
|
||||
GuiButtonTypeCenter,
|
||||
@@ -114,82 +105,49 @@ bool subghz_scene_receiver_info_on_event(void* context, SceneManagerEvent event)
|
||||
SubGhz* subghz = context;
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubGhzCustomEventSceneReceiverInfoTxStart) {
|
||||
//CC1101 Stop RX -> Start TX
|
||||
if(subghz->txrx->hopper_state != SubGhzHopperStateOFF) {
|
||||
subghz->txrx->hopper_state = SubGhzHopperStatePause;
|
||||
}
|
||||
if(subghz->txrx->txrx_state == SubGhzTxRxStateRx) {
|
||||
subghz_rx_end(subghz);
|
||||
}
|
||||
if(!subghz_scene_receiver_info_update_parser(subghz)) {
|
||||
return false;
|
||||
}
|
||||
if(subghz->txrx->txrx_state == SubGhzTxRxStateIDLE ||
|
||||
subghz->txrx->txrx_state == SubGhzTxRxStateSleep) {
|
||||
if(!subghz_tx_start(
|
||||
subghz,
|
||||
subghz_history_get_raw_data(
|
||||
subghz->txrx->history, subghz->txrx->idx_menu_chosen))) {
|
||||
if(subghz->txrx->txrx_state == SubGhzTxRxStateTx) {
|
||||
subghz_tx_stop(subghz);
|
||||
}
|
||||
if(subghz->txrx->txrx_state == SubGhzTxRxStateIDLE) {
|
||||
subghz_begin(
|
||||
subghz,
|
||||
subghz_setting_get_preset_data_by_name(
|
||||
subghz->setting,
|
||||
furi_string_get_cstr(subghz->txrx->preset->name)));
|
||||
subghz_rx(subghz, subghz->txrx->preset->frequency);
|
||||
}
|
||||
if(subghz->txrx->hopper_state == SubGhzHopperStatePause) {
|
||||
subghz->txrx->hopper_state = SubGhzHopperStateRunnig;
|
||||
}
|
||||
subghz->state_notifications = SubGhzNotificationStateRx;
|
||||
} else {
|
||||
subghz->state_notifications = SubGhzNotificationStateTx;
|
||||
}
|
||||
//CC1101 Stop RX -> Start TX
|
||||
subghz_txrx_hopper_pause(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_unpause(subghz->txrx);
|
||||
subghz->state_notifications = SubGhzNotificationStateRx;
|
||||
} else {
|
||||
subghz->state_notifications = SubGhzNotificationStateTx;
|
||||
}
|
||||
return true;
|
||||
} else if(event.event == SubGhzCustomEventSceneReceiverInfoTxStop) {
|
||||
//CC1101 Stop Tx -> Start RX
|
||||
subghz->state_notifications = SubGhzNotificationStateIDLE;
|
||||
if(subghz->txrx->txrx_state == SubGhzTxRxStateTx) {
|
||||
subghz_tx_stop(subghz);
|
||||
}
|
||||
if(subghz->txrx->txrx_state == SubGhzTxRxStateIDLE) {
|
||||
subghz_begin(
|
||||
subghz,
|
||||
subghz_setting_get_preset_data_by_name(
|
||||
subghz->setting, furi_string_get_cstr(subghz->txrx->preset->name)));
|
||||
subghz_rx(subghz, subghz->txrx->preset->frequency);
|
||||
}
|
||||
if(subghz->txrx->hopper_state == SubGhzHopperStatePause) {
|
||||
subghz->txrx->hopper_state = SubGhzHopperStateRunnig;
|
||||
}
|
||||
|
||||
subghz_txrx_rx_start(subghz->txrx);
|
||||
|
||||
subghz_txrx_hopper_unpause(subghz->txrx);
|
||||
subghz->state_notifications = SubGhzNotificationStateRx;
|
||||
return true;
|
||||
} else if(event.event == SubGhzCustomEventSceneReceiverInfoSave) {
|
||||
//CC1101 Stop RX -> Save
|
||||
subghz->state_notifications = SubGhzNotificationStateIDLE;
|
||||
subghz->txrx->hopper_state = SubGhzHopperStateOFF;
|
||||
if(subghz->txrx->txrx_state == SubGhzTxRxStateRx) {
|
||||
subghz_rx_end(subghz);
|
||||
subghz_sleep(subghz);
|
||||
}
|
||||
subghz_txrx_hopper_set_state(subghz->txrx, SubGhzHopperStateOFF);
|
||||
|
||||
subghz_txrx_stop(subghz->txrx);
|
||||
if(!subghz_scene_receiver_info_update_parser(subghz)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if((subghz->txrx->decoder_result->protocol->flag & SubGhzProtocolFlag_Save) ==
|
||||
SubGhzProtocolFlag_Save) {
|
||||
if(subghz_txrx_protocol_is_serializable(subghz->txrx)) {
|
||||
subghz_file_name_clear(subghz);
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSaveName);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} else if(event.type == SceneManagerEventTypeTick) {
|
||||
if(subghz->txrx->hopper_state != SubGhzHopperStateOFF) {
|
||||
subghz_hopper_update(subghz);
|
||||
if(subghz_txrx_hopper_get_state(subghz->txrx) != SubGhzHopperStateOFF) {
|
||||
subghz_txrx_hopper_update(subghz->txrx);
|
||||
}
|
||||
switch(subghz->state_notifications) {
|
||||
case SubGhzNotificationStateTx:
|
||||
|
||||
@@ -5,8 +5,7 @@
|
||||
void subghz_scene_region_info_on_enter(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
const FuriHalRegion* const region = furi_hal_region_get();
|
||||
FuriString* buffer;
|
||||
buffer = furi_string_alloc();
|
||||
FuriString* buffer = furi_string_alloc();
|
||||
if(region) {
|
||||
furi_string_cat_printf(buffer, "Region: %s, bands:\n", region->country_code);
|
||||
for(uint16_t i = 0; i < region->bands_count; ++i) {
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
typedef enum {
|
||||
SubGhzRpcStateIdle,
|
||||
SubGhzRpcStateLoaded,
|
||||
SubGhzRpcStateTx,
|
||||
} SubGhzRpcState;
|
||||
|
||||
void subghz_scene_rpc_on_enter(void* context) {
|
||||
@@ -38,9 +39,9 @@ bool subghz_scene_rpc_on_event(void* context, SceneManagerEvent event) {
|
||||
view_dispatcher_stop(subghz->view_dispatcher);
|
||||
} else if(event.event == SubGhzCustomEventSceneRpcButtonPress) {
|
||||
bool result = false;
|
||||
if((subghz->txrx->txrx_state == SubGhzTxRxStateSleep) &&
|
||||
(state == SubGhzRpcStateLoaded)) {
|
||||
result = subghz_tx_start(subghz, subghz->txrx->fff_data);
|
||||
if((state == SubGhzRpcStateLoaded)) {
|
||||
result = subghz_tx_start(subghz, subghz_txrx_get_fff_data(subghz->txrx));
|
||||
state = SubGhzRpcStateTx;
|
||||
if(result) subghz_blink_start(subghz);
|
||||
}
|
||||
if(!result) {
|
||||
@@ -52,10 +53,10 @@ bool subghz_scene_rpc_on_event(void* context, SceneManagerEvent event) {
|
||||
rpc_system_app_confirm(subghz->rpc_ctx, RpcAppEventButtonPress, result);
|
||||
} else if(event.event == SubGhzCustomEventSceneRpcButtonRelease) {
|
||||
bool result = false;
|
||||
if(subghz->txrx->txrx_state == SubGhzTxRxStateTx) {
|
||||
if(state == SubGhzRpcStateTx) {
|
||||
subghz_txrx_stop(subghz->txrx);
|
||||
subghz_blink_stop(subghz);
|
||||
subghz_tx_stop(subghz);
|
||||
subghz_sleep(subghz);
|
||||
state = SubGhzRpcStateIdle;
|
||||
result = true;
|
||||
}
|
||||
rpc_system_app_confirm(subghz->rpc_ctx, RpcAppEventButtonRelease, result);
|
||||
@@ -93,10 +94,9 @@ bool subghz_scene_rpc_on_event(void* context, SceneManagerEvent event) {
|
||||
|
||||
void subghz_scene_rpc_on_exit(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
|
||||
if(subghz->txrx->txrx_state == SubGhzTxRxStateTx) {
|
||||
subghz_tx_stop(subghz);
|
||||
subghz_sleep(subghz);
|
||||
SubGhzRpcState state = scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneRpc);
|
||||
if(state != SubGhzRpcStateIdle) {
|
||||
subghz_txrx_stop(subghz->txrx);
|
||||
subghz_blink_stop(subghz);
|
||||
}
|
||||
|
||||
|
||||
@@ -35,10 +35,8 @@ void subghz_scene_save_name_on_enter(void* context) {
|
||||
TextInput* text_input = subghz->text_input;
|
||||
bool dev_name_empty = false;
|
||||
|
||||
FuriString* file_name;
|
||||
FuriString* dir_name;
|
||||
file_name = furi_string_alloc();
|
||||
dir_name = furi_string_alloc();
|
||||
FuriString* file_name = furi_string_alloc();
|
||||
FuriString* dir_name = furi_string_alloc();
|
||||
|
||||
if(!subghz_path_is_file(subghz->file_path)) {
|
||||
char file_name_buf[SUBGHZ_MAX_LEN_NAME] = {0};
|
||||
@@ -69,7 +67,7 @@ void subghz_scene_save_name_on_enter(void* context) {
|
||||
subghz_scene_save_name_text_input_callback,
|
||||
subghz,
|
||||
subghz->file_name_tmp,
|
||||
MAX_TEXT_INPUT_LEN, // buffer size
|
||||
MAX_TEXT_INPUT_LEN,
|
||||
dev_name_empty);
|
||||
|
||||
ValidatorIsFile* validator_is_file = validator_is_file_alloc_init(
|
||||
@@ -106,7 +104,7 @@ bool subghz_scene_save_name_on_event(void* context, SceneManagerEvent event) {
|
||||
SubGhzCustomEventManagerNoSet) {
|
||||
subghz_save_protocol_to_file(
|
||||
subghz,
|
||||
subghz->txrx->fff_data,
|
||||
subghz_txrx_get_fff_data(subghz->txrx),
|
||||
furi_string_get_cstr(subghz->file_path));
|
||||
scene_manager_set_scene_state(
|
||||
subghz->scene_manager,
|
||||
@@ -115,8 +113,7 @@ bool subghz_scene_save_name_on_event(void* context, SceneManagerEvent event) {
|
||||
} else {
|
||||
subghz_save_protocol_to_file(
|
||||
subghz,
|
||||
subghz_history_get_raw_data(
|
||||
subghz->txrx->history, subghz->txrx->idx_menu_chosen),
|
||||
subghz_history_get_raw_data(subghz->history, subghz->idx_menu_chosen),
|
||||
furi_string_get_cstr(subghz->file_path));
|
||||
}
|
||||
}
|
||||
@@ -124,7 +121,8 @@ bool subghz_scene_save_name_on_event(void* context, SceneManagerEvent event) {
|
||||
if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneReadRAW) !=
|
||||
SubGhzCustomEventManagerNoSet) {
|
||||
subghz_protocol_raw_gen_fff_data(
|
||||
subghz->txrx->fff_data, furi_string_get_cstr(subghz->file_path));
|
||||
subghz_txrx_get_fff_data(subghz->txrx),
|
||||
furi_string_get_cstr(subghz->file_path));
|
||||
scene_manager_set_scene_state(
|
||||
subghz->scene_manager, SubGhzSceneReadRAW, SubGhzCustomEventManagerNoSet);
|
||||
} else {
|
||||
|
||||
@@ -26,10 +26,10 @@ bool subghz_scene_save_success_on_event(void* context, SceneManagerEvent event)
|
||||
if(event.event == SubGhzCustomEventSceneSaveSuccess) {
|
||||
if(!scene_manager_search_and_switch_to_previous_scene(
|
||||
subghz->scene_manager, SubGhzSceneReceiver)) {
|
||||
subghz->txrx->rx_key_state = SubGhzRxKeyStateRAWSave;
|
||||
subghz_rx_key_state_set(subghz, SubGhzRxKeyStateRAWSave);
|
||||
if(!scene_manager_search_and_switch_to_previous_scene(
|
||||
subghz->scene_manager, SubGhzSceneReadRAW)) {
|
||||
subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE;
|
||||
subghz_rx_key_state_set(subghz, SubGhzRxKeyStateIDLE);
|
||||
if(!scene_manager_search_and_switch_to_previous_scene(
|
||||
subghz->scene_manager, SubGhzSceneSaved)) {
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSaved);
|
||||
|
||||
@@ -4,8 +4,8 @@ void subghz_scene_saved_on_enter(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
|
||||
if(subghz_load_protocol_from_file(subghz)) {
|
||||
if((!strcmp(subghz->txrx->decoder_result->protocol->name, "RAW"))) {
|
||||
subghz->txrx->rx_key_state = SubGhzRxKeyStateRAWLoad;
|
||||
if(subghz_get_load_type_file(subghz) == SubGhzLoadTypeFileRaw) {
|
||||
subghz_rx_key_state_set(subghz, SubGhzRxKeyStateRAWLoad);
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneReadRAW);
|
||||
} else {
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSavedMenu);
|
||||
|
||||
@@ -1,63 +1,10 @@
|
||||
#include "../subghz_i.h"
|
||||
#include <lib/subghz/protocols/keeloq.h>
|
||||
#include <lib/subghz/protocols/secplus_v1.h>
|
||||
#include <lib/subghz/protocols/secplus_v2.h>
|
||||
#include "../helpers/subghz_txrx_create_potocol_key.h"
|
||||
#include <lib/subghz/blocks/math.h>
|
||||
#include <flipper_format/flipper_format_i.h>
|
||||
#include <lib/toolbox/stream/stream.h>
|
||||
#include <lib/subghz/protocols/protocol_items.h>
|
||||
|
||||
#define TAG "SubGhzSetType"
|
||||
|
||||
bool subghz_scene_set_type_submenu_gen_data_protocol(
|
||||
void* context,
|
||||
const char* protocol_name,
|
||||
uint64_t key,
|
||||
uint32_t bit,
|
||||
uint32_t frequency,
|
||||
const char* preset_name) {
|
||||
furi_assert(context);
|
||||
SubGhz* subghz = context;
|
||||
|
||||
bool res = false;
|
||||
|
||||
subghz_preset_init(subghz, preset_name, frequency, NULL, 0);
|
||||
subghz->txrx->decoder_result =
|
||||
subghz_receiver_search_decoder_base_by_name(subghz->txrx->receiver, protocol_name);
|
||||
|
||||
if(subghz->txrx->decoder_result == NULL) {
|
||||
furi_string_set(subghz->error_str, "Protocol not\nfound!");
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowErrorSub);
|
||||
return false;
|
||||
}
|
||||
|
||||
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) !=
|
||||
SubGhzProtocolStatusOk) {
|
||||
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) {
|
||||
SubGhz* subghz = context;
|
||||
view_dispatcher_send_custom_event(subghz->view_dispatcher, index);
|
||||
@@ -69,7 +16,13 @@ void subghz_scene_set_type_on_enter(void* context) {
|
||||
submenu_add_item(
|
||||
subghz->submenu,
|
||||
"Princeton_433",
|
||||
SubmenuIndexPricenton,
|
||||
SubmenuIndexPricenton_433,
|
||||
subghz_scene_set_type_submenu_callback,
|
||||
subghz);
|
||||
submenu_add_item(
|
||||
subghz->submenu,
|
||||
"Princeton_315",
|
||||
SubmenuIndexPricenton_315,
|
||||
subghz_scene_set_type_submenu_callback,
|
||||
subghz);
|
||||
submenu_add_item(
|
||||
@@ -108,10 +61,6 @@ void subghz_scene_set_type_on_enter(void* context) {
|
||||
SubmenuIndexCAMETwee,
|
||||
subghz_scene_set_type_submenu_callback,
|
||||
subghz);
|
||||
// submenu_add_item(
|
||||
// subghz->submenu, "Nero Sketch", SubmenuIndexNeroSketch, subghz_scene_set_type_submenu_callback, subghz);
|
||||
// submenu_add_item(
|
||||
// subghz->submenu, "Nero Radio", SubmenuIndexNeroRadio, subghz_scene_set_type_submenu_callback, subghz);
|
||||
submenu_add_item(
|
||||
subghz->submenu,
|
||||
"Gate TX_433",
|
||||
@@ -172,94 +121,59 @@ 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();
|
||||
uint32_t key = (uint32_t)rand();
|
||||
switch(event.event) {
|
||||
case SubmenuIndexPricenton:
|
||||
case SubmenuIndexPricenton_433:
|
||||
key = (key & 0x00FFFFF0) | 0x4; //btn 0x1, 0x2, 0x4, 0x8
|
||||
if(subghz_scene_set_type_submenu_gen_data_protocol(
|
||||
subghz, SUBGHZ_PROTOCOL_PRINCETON_NAME, key, 24, 433920000, "AM650")) {
|
||||
uint32_t te = 400;
|
||||
flipper_format_update_uint32(subghz->txrx->fff_data, "TE", (uint32_t*)&te, 1);
|
||||
generated_protocol = true;
|
||||
}
|
||||
generated_protocol = subghz_txrx_gen_data_protocol_and_te(
|
||||
subghz->txrx, "AM650", 433920000, SUBGHZ_PROTOCOL_PRINCETON_NAME, key, 24, 400);
|
||||
break;
|
||||
case SubmenuIndexPricenton_315:
|
||||
key = (key & 0x00FFFFF0) | 0x4; //btn 0x1, 0x2, 0x4, 0x8
|
||||
generated_protocol = subghz_txrx_gen_data_protocol_and_te(
|
||||
subghz->txrx, "AM650", 315000000, SUBGHZ_PROTOCOL_PRINCETON_NAME, key, 24, 400);
|
||||
break;
|
||||
case SubmenuIndexNiceFlo12bit:
|
||||
key = (key & 0x0000FFF0) | 0x1; //btn 0x1, 0x2, 0x4
|
||||
if(subghz_scene_set_type_submenu_gen_data_protocol(
|
||||
subghz, SUBGHZ_PROTOCOL_NICE_FLO_NAME, key, 12, 433920000, "AM650")) {
|
||||
generated_protocol = true;
|
||||
}
|
||||
generated_protocol = subghz_txrx_gen_data_protocol(
|
||||
subghz->txrx, "AM650", 433920000, SUBGHZ_PROTOCOL_NICE_FLO_NAME, key, 12);
|
||||
break;
|
||||
case SubmenuIndexNiceFlo24bit:
|
||||
key = (key & 0x00FFFFF0) | 0x4; //btn 0x1, 0x2, 0x4, 0x8
|
||||
if(subghz_scene_set_type_submenu_gen_data_protocol(
|
||||
subghz, SUBGHZ_PROTOCOL_NICE_FLO_NAME, key, 24, 433920000, "AM650")) {
|
||||
generated_protocol = true;
|
||||
}
|
||||
generated_protocol = subghz_txrx_gen_data_protocol(
|
||||
subghz->txrx, "AM650", 433920000, SUBGHZ_PROTOCOL_NICE_FLO_NAME, key, 24);
|
||||
break;
|
||||
case SubmenuIndexCAME12bit:
|
||||
key = (key & 0x0000FFF0) | 0x1; //btn 0x1, 0x2, 0x4
|
||||
if(subghz_scene_set_type_submenu_gen_data_protocol(
|
||||
subghz, SUBGHZ_PROTOCOL_CAME_NAME, key, 12, 433920000, "AM650")) {
|
||||
generated_protocol = true;
|
||||
}
|
||||
generated_protocol = subghz_txrx_gen_data_protocol(
|
||||
subghz->txrx, "AM650", 433920000, SUBGHZ_PROTOCOL_CAME_NAME, key, 12);
|
||||
break;
|
||||
case SubmenuIndexCAME24bit:
|
||||
key = (key & 0x00FFFFF0) | 0x4; //btn 0x1, 0x2, 0x4, 0x8
|
||||
if(subghz_scene_set_type_submenu_gen_data_protocol(
|
||||
subghz, SUBGHZ_PROTOCOL_CAME_NAME, key, 24, 433920000, "AM650")) {
|
||||
generated_protocol = true;
|
||||
}
|
||||
generated_protocol = subghz_txrx_gen_data_protocol(
|
||||
subghz->txrx, "AM650", 433920000, SUBGHZ_PROTOCOL_CAME_NAME, key, 24);
|
||||
break;
|
||||
case SubmenuIndexLinear_300_00:
|
||||
key = (key & 0x3FF);
|
||||
if(subghz_scene_set_type_submenu_gen_data_protocol(
|
||||
subghz, SUBGHZ_PROTOCOL_LINEAR_NAME, key, 10, 300000000, "AM650")) {
|
||||
generated_protocol = true;
|
||||
}
|
||||
generated_protocol = subghz_txrx_gen_data_protocol(
|
||||
subghz->txrx, "AM650", 300000000, SUBGHZ_PROTOCOL_LINEAR_NAME, key, 10);
|
||||
break;
|
||||
case SubmenuIndexCAMETwee:
|
||||
key = (key & 0x0FFFFFF0);
|
||||
key = 0x003FFF7200000000 | (key ^ 0xE0E0E0EE);
|
||||
if(subghz_scene_set_type_submenu_gen_data_protocol(
|
||||
subghz, SUBGHZ_PROTOCOL_CAME_TWEE_NAME, key, 54, 433920000, "AM650")) {
|
||||
generated_protocol = true;
|
||||
}
|
||||
|
||||
generated_protocol = subghz_txrx_gen_data_protocol(
|
||||
subghz->txrx, "AM650", 433920000, SUBGHZ_PROTOCOL_CAME_TWEE_NAME, key, 54);
|
||||
break;
|
||||
// case SubmenuIndexNeroSketch:
|
||||
// /* code */
|
||||
// break;
|
||||
// case SubmenuIndexNeroRadio:
|
||||
// /* code */
|
||||
// break;
|
||||
case SubmenuIndexGateTX:
|
||||
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, SUBGHZ_PROTOCOL_GATE_TX_NAME, rev_key, 24, 433920000, "AM650")) {
|
||||
generated_protocol = true;
|
||||
}
|
||||
generated_protocol = subghz_txrx_gen_data_protocol(
|
||||
subghz->txrx, "AM650", 433920000, SUBGHZ_PROTOCOL_GATE_TX_NAME, rev_key, 24);
|
||||
break;
|
||||
case SubmenuIndexDoorHan_433_92:
|
||||
subghz->txrx->transmitter = subghz_transmitter_alloc_init(
|
||||
subghz->txrx->environment, SUBGHZ_PROTOCOL_KEELOQ_NAME);
|
||||
subghz_preset_init(
|
||||
subghz, "AM650", subghz_setting_get_default_frequency(subghz->setting), NULL, 0);
|
||||
if(subghz->txrx->transmitter) {
|
||||
subghz_protocol_keeloq_create_data(
|
||||
subghz_transmitter_get_protocol_instance(subghz->txrx->transmitter),
|
||||
subghz->txrx->fff_data,
|
||||
key & 0x0FFFFFFF,
|
||||
0x2,
|
||||
0x0003,
|
||||
"DoorHan",
|
||||
subghz->txrx->preset);
|
||||
generated_protocol = true;
|
||||
} else {
|
||||
generated_protocol = false;
|
||||
}
|
||||
subghz_transmitter_free(subghz->txrx->transmitter);
|
||||
generated_protocol = subghz_txrx_gen_keelog_protocol(
|
||||
subghz->txrx, "AM650", 433920000, "DoorHan", key, 0x2, 0x0003);
|
||||
if(!generated_protocol) {
|
||||
furi_string_set(
|
||||
subghz->error_str, "Function requires\nan SD card with\nfresh databases.");
|
||||
@@ -267,23 +181,8 @@ bool subghz_scene_set_type_on_event(void* context, SceneManagerEvent event) {
|
||||
}
|
||||
break;
|
||||
case SubmenuIndexDoorHan_315_00:
|
||||
subghz->txrx->transmitter = subghz_transmitter_alloc_init(
|
||||
subghz->txrx->environment, SUBGHZ_PROTOCOL_KEELOQ_NAME);
|
||||
subghz_preset_init(subghz, "AM650", 315000000, NULL, 0);
|
||||
if(subghz->txrx->transmitter) {
|
||||
subghz_protocol_keeloq_create_data(
|
||||
subghz_transmitter_get_protocol_instance(subghz->txrx->transmitter),
|
||||
subghz->txrx->fff_data,
|
||||
key & 0x0FFFFFFF,
|
||||
0x2,
|
||||
0x0003,
|
||||
"DoorHan",
|
||||
subghz->txrx->preset);
|
||||
generated_protocol = true;
|
||||
} else {
|
||||
generated_protocol = false;
|
||||
}
|
||||
subghz_transmitter_free(subghz->txrx->transmitter);
|
||||
generated_protocol = subghz_txrx_gen_keelog_protocol(
|
||||
subghz->txrx, "AM650", 315000000, "DoorHan", key, 0x2, 0x0003);
|
||||
if(!generated_protocol) {
|
||||
furi_string_set(
|
||||
subghz->error_str, "Function requires\nan SD card with\nfresh databases.");
|
||||
@@ -291,86 +190,24 @@ bool subghz_scene_set_type_on_event(void* context, SceneManagerEvent event) {
|
||||
}
|
||||
break;
|
||||
case SubmenuIndexLiftMaster_315_00:
|
||||
while(!subghz_protocol_secplus_v1_check_fixed(key)) {
|
||||
key = subghz_random_serial();
|
||||
}
|
||||
if(subghz_scene_set_type_submenu_gen_data_protocol(
|
||||
subghz,
|
||||
SUBGHZ_PROTOCOL_SECPLUS_V1_NAME,
|
||||
(uint64_t)key << 32 | 0xE6000000,
|
||||
42,
|
||||
315000000,
|
||||
"AM650")) {
|
||||
generated_protocol = true;
|
||||
}
|
||||
generated_protocol =
|
||||
subghz_txrx_gen_secplus_v1_protocol(subghz->txrx, "AM650", 315000000);
|
||||
break;
|
||||
case SubmenuIndexLiftMaster_390_00:
|
||||
while(!subghz_protocol_secplus_v1_check_fixed(key)) {
|
||||
key = subghz_random_serial();
|
||||
}
|
||||
if(subghz_scene_set_type_submenu_gen_data_protocol(
|
||||
subghz,
|
||||
SUBGHZ_PROTOCOL_SECPLUS_V1_NAME,
|
||||
(uint64_t)key << 32 | 0xE6000000,
|
||||
42,
|
||||
390000000,
|
||||
"AM650")) {
|
||||
generated_protocol = true;
|
||||
}
|
||||
generated_protocol =
|
||||
subghz_txrx_gen_secplus_v1_protocol(subghz->txrx, "AM650", 390000000);
|
||||
break;
|
||||
case SubmenuIndexSecPlus_v2_310_00:
|
||||
subghz->txrx->transmitter = subghz_transmitter_alloc_init(
|
||||
subghz->txrx->environment, SUBGHZ_PROTOCOL_SECPLUS_V2_NAME);
|
||||
subghz_preset_init(subghz, "AM650", 310000000, NULL, 0);
|
||||
if(subghz->txrx->transmitter) {
|
||||
subghz_protocol_secplus_v2_create_data(
|
||||
subghz_transmitter_get_protocol_instance(subghz->txrx->transmitter),
|
||||
subghz->txrx->fff_data,
|
||||
key,
|
||||
0x68,
|
||||
0xE500000,
|
||||
subghz->txrx->preset);
|
||||
generated_protocol = true;
|
||||
} else {
|
||||
generated_protocol = false;
|
||||
}
|
||||
subghz_transmitter_free(subghz->txrx->transmitter);
|
||||
generated_protocol = subghz_txrx_gen_secplus_v2_protocol(
|
||||
subghz->txrx, "AM650", 310000000, key, 0x68, 0xE500000);
|
||||
break;
|
||||
case SubmenuIndexSecPlus_v2_315_00:
|
||||
subghz->txrx->transmitter = subghz_transmitter_alloc_init(
|
||||
subghz->txrx->environment, SUBGHZ_PROTOCOL_SECPLUS_V2_NAME);
|
||||
subghz_preset_init(subghz, "AM650", 315000000, NULL, 0);
|
||||
if(subghz->txrx->transmitter) {
|
||||
subghz_protocol_secplus_v2_create_data(
|
||||
subghz_transmitter_get_protocol_instance(subghz->txrx->transmitter),
|
||||
subghz->txrx->fff_data,
|
||||
key,
|
||||
0x68,
|
||||
0xE500000,
|
||||
subghz->txrx->preset);
|
||||
generated_protocol = true;
|
||||
} else {
|
||||
generated_protocol = false;
|
||||
}
|
||||
subghz_transmitter_free(subghz->txrx->transmitter);
|
||||
generated_protocol = subghz_txrx_gen_secplus_v2_protocol(
|
||||
subghz->txrx, "AM650", 315000000, key, 0x68, 0xE500000);
|
||||
break;
|
||||
case SubmenuIndexSecPlus_v2_390_00:
|
||||
subghz->txrx->transmitter = subghz_transmitter_alloc_init(
|
||||
subghz->txrx->environment, SUBGHZ_PROTOCOL_SECPLUS_V2_NAME);
|
||||
subghz_preset_init(subghz, "AM650", 390000000, NULL, 0);
|
||||
if(subghz->txrx->transmitter) {
|
||||
subghz_protocol_secplus_v2_create_data(
|
||||
subghz_transmitter_get_protocol_instance(subghz->txrx->transmitter),
|
||||
subghz->txrx->fff_data,
|
||||
key,
|
||||
0x68,
|
||||
0xE500000,
|
||||
subghz->txrx->preset);
|
||||
generated_protocol = true;
|
||||
} else {
|
||||
generated_protocol = false;
|
||||
}
|
||||
subghz_transmitter_free(subghz->txrx->transmitter);
|
||||
generated_protocol = subghz_txrx_gen_secplus_v2_protocol(
|
||||
subghz->txrx, "AM650", 390000000, key, 0x68, 0xE500000);
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
|
||||
@@ -50,9 +50,10 @@ void subghz_scene_show_error_on_enter(void* context) {
|
||||
|
||||
bool subghz_scene_show_error_on_event(void* context, SceneManagerEvent event) {
|
||||
SubGhz* subghz = context;
|
||||
SubGhzCustomEvent scene_state =
|
||||
scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneShowError);
|
||||
if(event.type == SceneManagerEventTypeBack) {
|
||||
if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneShowError) ==
|
||||
SubGhzCustomEventManagerSet) {
|
||||
if(scene_state == SubGhzCustomEventManagerSet) {
|
||||
return false;
|
||||
} else {
|
||||
scene_manager_search_and_switch_to_previous_scene(
|
||||
@@ -61,14 +62,12 @@ bool subghz_scene_show_error_on_event(void* context, SceneManagerEvent event) {
|
||||
return true;
|
||||
} else if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubGhzCustomEventSceneShowErrorOk) {
|
||||
if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneShowError) ==
|
||||
SubGhzCustomEventManagerSet) {
|
||||
if(scene_state == SubGhzCustomEventManagerSet) {
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneStart);
|
||||
}
|
||||
return true;
|
||||
} else if(event.event == SubGhzCustomEventSceneShowErrorBack) {
|
||||
if(scene_manager_get_scene_state(subghz->scene_manager, SubGhzSceneShowError) ==
|
||||
SubGhzCustomEventManagerSet) {
|
||||
if(scene_state == SubGhzCustomEventManagerSet) {
|
||||
//exit app
|
||||
if(!scene_manager_previous_scene(subghz->scene_manager)) {
|
||||
scene_manager_stop(subghz->scene_manager);
|
||||
|
||||
@@ -70,7 +70,7 @@ bool subghz_scene_start_on_event(void* context, SceneManagerEvent event) {
|
||||
if(event.event == SubmenuIndexReadRAW) {
|
||||
scene_manager_set_scene_state(
|
||||
subghz->scene_manager, SubGhzSceneStart, SubmenuIndexReadRAW);
|
||||
subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE;
|
||||
subghz_rx_key_state_set(subghz, SubGhzRxKeyStateIDLE);
|
||||
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneReadRAW);
|
||||
return true;
|
||||
} else if(event.event == SubmenuIndexRead) {
|
||||
|
||||
@@ -11,32 +11,24 @@ void subghz_scene_transmitter_callback(SubGhzCustomEvent event, void* context) {
|
||||
bool subghz_scene_transmitter_update_data_show(void* context) {
|
||||
SubGhz* subghz = context;
|
||||
bool ret = false;
|
||||
if(subghz->txrx->decoder_result) {
|
||||
FuriString* key_str;
|
||||
FuriString* frequency_str;
|
||||
FuriString* modulation_str;
|
||||
SubGhzProtocolDecoderBase* decoder = subghz_txrx_get_decoder(subghz->txrx);
|
||||
|
||||
key_str = furi_string_alloc();
|
||||
frequency_str = furi_string_alloc();
|
||||
modulation_str = furi_string_alloc();
|
||||
uint8_t show_button = 0;
|
||||
if(decoder) {
|
||||
FuriString* key_str = furi_string_alloc();
|
||||
FuriString* frequency_str = furi_string_alloc();
|
||||
FuriString* modulation_str = furi_string_alloc();
|
||||
|
||||
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);
|
||||
decoder, subghz_txrx_get_fff_data(subghz->txrx)) == SubGhzProtocolStatusOk) {
|
||||
subghz_protocol_decoder_base_get_string(decoder, 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_txrx_get_frequency_and_modulation(subghz->txrx, 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);
|
||||
subghz_txrx_protocol_is_transmittable(subghz->txrx, false));
|
||||
ret = true;
|
||||
}
|
||||
furi_string_free(frequency_str);
|
||||
@@ -65,24 +57,16 @@ bool subghz_scene_transmitter_on_event(void* context, SceneManagerEvent event) {
|
||||
if(event.type == SceneManagerEventTypeCustom) {
|
||||
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, subghz->txrx->fff_data)) {
|
||||
subghz->state_notifications = SubGhzNotificationStateTx;
|
||||
subghz_scene_transmitter_update_data_show(subghz);
|
||||
DOLPHIN_DEED(DolphinDeedSubGhzSend);
|
||||
}
|
||||
|
||||
if(subghz_tx_start(subghz, subghz_txrx_get_fff_data(subghz->txrx))) {
|
||||
subghz->state_notifications = SubGhzNotificationStateTx;
|
||||
subghz_scene_transmitter_update_data_show(subghz);
|
||||
DOLPHIN_DEED(DolphinDeedSubGhzSend);
|
||||
}
|
||||
return true;
|
||||
} else if(event.event == SubGhzCustomEventViewTransmitterSendStop) {
|
||||
subghz->state_notifications = SubGhzNotificationStateIDLE;
|
||||
if(subghz->txrx->txrx_state == SubGhzTxRxStateTx) {
|
||||
subghz_tx_stop(subghz);
|
||||
subghz_sleep(subghz);
|
||||
}
|
||||
subghz_txrx_stop(subghz->txrx);
|
||||
return true;
|
||||
} else if(event.event == SubGhzCustomEventViewTransmitterBack) {
|
||||
subghz->state_notifications = SubGhzNotificationStateIDLE;
|
||||
|
||||
Reference in New Issue
Block a user