2021-10-25 14:37:14 +00:00
|
|
|
#include "../subghz_i.h"
|
2021-10-27 17:37:11 +00:00
|
|
|
#include "../views/subghz_read_raw.h"
|
[FL-2183] [FL-2209] Dolphin Deeds, Level up, assets generation, refactoring (#965)
* Desktop: cleanup headers
* Get loader pubsub via record
* [FL-2183] Dolphin refactoring 2022.01
* Restruct animations assets structure
* Rename assets
* Cleanup headers
* Update Recording animation
* Add BadBattery animation
* Provide loader's pubsub via record
* Fix load/unload animations
* Scripts: add flipper format support, initial dolphin packager rework. Assets: internal and external dolphin.
* Sync internal meta.txt and manifest.txt
* Reorder, rename dolphin assets
* Split essential generated assets
* Add ReadMe for dolphin assets
* Separate essential blocking animations
* Scripts: full dolphin validation before packaging
* Assets, Scripts: dolphin external resources packer
* Github: update codeowners
* Scripts: proper slots handling in dolphin animation meta
* Scripts: correct frames enumeration and fix compiled assets.
* [FL-2209] Add Dolphin Deeds points and many more
* Remove excess frame_rate
* Change dolphin assets directory
* Scripts: add internal resource support to dolphin compiler
* Scripts: add internal assets generation, renaming
* Scripts: correct assert, renaming
* Code cleanup, documentation, fixes
* Update Levelup animations
* Rename essential -> blocking
* Fix Unlocked hint
* Scripts: rewrite Templite compiller, replace regexps with token parser, split block types into code and variable blocks. Update dolphin templates.
* Documentation: add key combos description and use information
* Scripts: cleanup templit, more debug info and add dev comment
Co-authored-by: あく <alleteam@gmail.com>
2022-01-29 09:20:41 +00:00
|
|
|
#include <dolphin/dolphin.h>
|
2022-03-03 09:48:56 +00:00
|
|
|
#include <lib/subghz/protocols/raw.h>
|
2021-11-24 13:59:45 +00:00
|
|
|
#include <lib/toolbox/path.h>
|
|
|
|
|
2022-01-27 16:38:47 +00:00
|
|
|
#define RAW_FILE_NAME "Raw_signal_"
|
2022-03-03 09:48:56 +00:00
|
|
|
#define TAG "SubGhzSceneReadRAW"
|
2021-10-25 14:37:14 +00:00
|
|
|
|
2021-12-22 13:01:20 +00:00
|
|
|
bool subghz_scene_read_raw_update_filename(SubGhz* subghz) {
|
|
|
|
bool ret = false;
|
|
|
|
//set the path to read the file
|
2022-10-05 15:15:23 +00:00
|
|
|
FuriString* temp_str;
|
|
|
|
temp_str = furi_string_alloc();
|
2022-03-03 09:48:56 +00:00
|
|
|
do {
|
2023-05-04 03:04:26 +00:00
|
|
|
FlipperFormat* fff_data = subghz_txrx_get_fff_data(subghz->txrx);
|
|
|
|
if(!flipper_format_rewind(fff_data)) {
|
2022-03-03 09:48:56 +00:00
|
|
|
FURI_LOG_E(TAG, "Rewind error");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2023-05-04 03:04:26 +00:00
|
|
|
if(!flipper_format_read_string(fff_data, "File_name", temp_str)) {
|
2022-03-03 09:48:56 +00:00
|
|
|
FURI_LOG_E(TAG, "Missing File_name");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2022-10-05 15:15:23 +00:00
|
|
|
furi_string_set(subghz->file_path, temp_str);
|
2021-12-22 13:01:20 +00:00
|
|
|
|
|
|
|
ret = true;
|
2022-03-03 09:48:56 +00:00
|
|
|
} while(false);
|
|
|
|
|
2022-10-05 15:15:23 +00:00
|
|
|
furi_string_free(temp_str);
|
2021-12-22 13:01:20 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2021-10-27 17:37:11 +00:00
|
|
|
static void subghz_scene_read_raw_update_statusbar(void* context) {
|
2021-10-25 14:37:14 +00:00
|
|
|
furi_assert(context);
|
|
|
|
SubGhz* subghz = context;
|
2021-10-27 17:37:11 +00:00
|
|
|
|
2023-05-04 03:04:26 +00:00
|
|
|
FuriString* frequency_str = furi_string_alloc();
|
|
|
|
FuriString* modulation_str = furi_string_alloc();
|
2021-11-11 12:49:19 +00:00
|
|
|
|
2023-05-04 03:04:26 +00:00
|
|
|
subghz_txrx_get_frequency_and_modulation(subghz->txrx, frequency_str, modulation_str);
|
2021-11-11 12:49:19 +00:00
|
|
|
subghz_read_raw_add_data_statusbar(
|
2022-10-05 15:15:23 +00:00
|
|
|
subghz->subghz_read_raw,
|
|
|
|
furi_string_get_cstr(frequency_str),
|
|
|
|
furi_string_get_cstr(modulation_str));
|
2021-11-11 12:49:19 +00:00
|
|
|
|
2022-10-05 15:15:23 +00:00
|
|
|
furi_string_free(frequency_str);
|
|
|
|
furi_string_free(modulation_str);
|
2023-06-30 14:03:36 +00:00
|
|
|
|
|
|
|
subghz_read_raw_set_radio_device_type(
|
|
|
|
subghz->subghz_read_raw, subghz_txrx_radio_device_get(subghz->txrx));
|
2021-10-25 14:37:14 +00:00
|
|
|
}
|
|
|
|
|
2022-03-03 09:48:56 +00:00
|
|
|
void subghz_scene_read_raw_callback(SubGhzCustomEvent event, void* context) {
|
2021-10-25 14:37:14 +00:00
|
|
|
furi_assert(context);
|
|
|
|
SubGhz* subghz = context;
|
|
|
|
view_dispatcher_send_custom_event(subghz->view_dispatcher, event);
|
|
|
|
}
|
|
|
|
|
2021-11-24 13:59:45 +00:00
|
|
|
void subghz_scene_read_raw_callback_end_tx(void* context) {
|
|
|
|
furi_assert(context);
|
|
|
|
SubGhz* subghz = context;
|
|
|
|
view_dispatcher_send_custom_event(
|
2022-03-03 09:48:56 +00:00
|
|
|
subghz->view_dispatcher, SubGhzCustomEventViewReadRAWSendStop);
|
2021-11-24 13:59:45 +00:00
|
|
|
}
|
|
|
|
|
2021-10-27 17:37:11 +00:00
|
|
|
void subghz_scene_read_raw_on_enter(void* context) {
|
2021-10-25 14:37:14 +00:00
|
|
|
SubGhz* subghz = context;
|
2023-05-04 03:04:26 +00:00
|
|
|
FuriString* file_name = furi_string_alloc();
|
2021-10-27 17:37:11 +00:00
|
|
|
|
2023-05-04 03:04:26 +00:00
|
|
|
float threshold_rssi = subghz_threshold_rssi_get(subghz->threshold_rssi);
|
|
|
|
switch(subghz_rx_key_state_get(subghz)) {
|
2021-12-22 13:01:20 +00:00
|
|
|
case SubGhzRxKeyStateBack:
|
2022-10-26 15:13:00 +00:00
|
|
|
subghz_read_raw_set_status(
|
2023-05-04 03:04:26 +00:00
|
|
|
subghz->subghz_read_raw, SubGhzReadRAWStatusIDLE, "", threshold_rssi);
|
2021-12-22 13:01:20 +00:00
|
|
|
break;
|
|
|
|
case SubGhzRxKeyStateRAWLoad:
|
2022-05-27 11:19:21 +00:00
|
|
|
path_extract_filename(subghz->file_path, file_name, true);
|
2021-12-22 13:01:20 +00:00
|
|
|
subghz_read_raw_set_status(
|
2022-10-05 15:15:23 +00:00
|
|
|
subghz->subghz_read_raw,
|
|
|
|
SubGhzReadRAWStatusLoadKeyTX,
|
2022-10-26 15:13:00 +00:00
|
|
|
furi_string_get_cstr(file_name),
|
2023-05-04 03:04:26 +00:00
|
|
|
threshold_rssi);
|
2021-12-22 13:01:20 +00:00
|
|
|
break;
|
|
|
|
case SubGhzRxKeyStateRAWSave:
|
2022-05-27 11:19:21 +00:00
|
|
|
path_extract_filename(subghz->file_path, file_name, true);
|
2021-12-08 15:00:54 +00:00
|
|
|
subghz_read_raw_set_status(
|
2022-10-26 15:13:00 +00:00
|
|
|
subghz->subghz_read_raw,
|
|
|
|
SubGhzReadRAWStatusSaveKey,
|
|
|
|
furi_string_get_cstr(file_name),
|
2023-05-04 03:04:26 +00:00
|
|
|
threshold_rssi);
|
2021-12-22 13:01:20 +00:00
|
|
|
break;
|
|
|
|
default:
|
2022-10-26 15:13:00 +00:00
|
|
|
subghz_read_raw_set_status(
|
2023-05-04 03:04:26 +00:00
|
|
|
subghz->subghz_read_raw, SubGhzReadRAWStatusStart, "", threshold_rssi);
|
2021-12-22 13:01:20 +00:00
|
|
|
break;
|
2021-10-27 17:37:11 +00:00
|
|
|
}
|
2023-05-04 03:04:26 +00:00
|
|
|
|
|
|
|
if(subghz_rx_key_state_get(subghz) != SubGhzRxKeyStateBack) {
|
|
|
|
subghz_rx_key_state_set(subghz, SubGhzRxKeyStateIDLE);
|
|
|
|
}
|
2022-10-05 15:15:23 +00:00
|
|
|
furi_string_free(file_name);
|
2021-10-27 17:37:11 +00:00
|
|
|
subghz_scene_read_raw_update_statusbar(subghz);
|
2021-10-25 14:37:14 +00:00
|
|
|
|
2022-03-03 09:48:56 +00:00
|
|
|
//set callback view raw
|
|
|
|
subghz_read_raw_set_callback(subghz->subghz_read_raw, subghz_scene_read_raw_callback, subghz);
|
2021-10-25 14:37:14 +00:00
|
|
|
|
2023-05-04 03:04:26 +00:00
|
|
|
furi_check(subghz_txrx_load_decoder_by_name_protocol(subghz->txrx, SUBGHZ_PROTOCOL_RAW_NAME));
|
2021-11-24 13:59:45 +00:00
|
|
|
|
2022-03-03 09:48:56 +00:00
|
|
|
//set filter RAW feed
|
2023-05-04 03:04:26 +00:00
|
|
|
subghz_txrx_receiver_set_filter(subghz->txrx, SubGhzProtocolFlag_RAW);
|
2022-03-03 09:48:56 +00:00
|
|
|
view_dispatcher_switch_to_view(subghz->view_dispatcher, SubGhzViewIdReadRAW);
|
2021-10-25 14:37:14 +00:00
|
|
|
}
|
|
|
|
|
2021-10-27 17:37:11 +00:00
|
|
|
bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
|
2021-10-25 14:37:14 +00:00
|
|
|
SubGhz* subghz = context;
|
2022-07-03 16:03:36 +00:00
|
|
|
bool consumed = false;
|
2023-05-04 03:04:26 +00:00
|
|
|
SubGhzProtocolDecoderRAW* decoder_raw =
|
|
|
|
(SubGhzProtocolDecoderRAW*)subghz_txrx_get_decoder(subghz->txrx);
|
2021-10-25 14:37:14 +00:00
|
|
|
if(event.type == SceneManagerEventTypeCustom) {
|
|
|
|
switch(event.event) {
|
2022-03-03 09:48:56 +00:00
|
|
|
case SubGhzCustomEventViewReadRAWBack:
|
2023-05-04 03:04:26 +00:00
|
|
|
|
|
|
|
subghz_txrx_stop(subghz->txrx);
|
2021-11-24 13:59:45 +00:00
|
|
|
//Stop save file
|
2023-05-04 03:04:26 +00:00
|
|
|
subghz_protocol_raw_save_to_file_stop(decoder_raw);
|
2021-11-11 12:49:19 +00:00
|
|
|
subghz->state_notifications = SubGhzNotificationStateIDLE;
|
2021-11-24 13:59:45 +00:00
|
|
|
//needed save?
|
2023-05-04 03:04:26 +00:00
|
|
|
if((subghz_rx_key_state_get(subghz) == SubGhzRxKeyStateAddKey) ||
|
|
|
|
(subghz_rx_key_state_get(subghz) == SubGhzRxKeyStateBack)) {
|
|
|
|
subghz_rx_key_state_set(subghz, SubGhzRxKeyStateExit);
|
2021-10-27 17:37:11 +00:00
|
|
|
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneNeedSaving);
|
|
|
|
} else {
|
2021-11-24 13:59:45 +00:00
|
|
|
//Restore default setting
|
2023-05-04 03:04:26 +00:00
|
|
|
subghz_set_default_preset(subghz);
|
2021-12-22 13:01:20 +00:00
|
|
|
if(!scene_manager_search_and_switch_to_previous_scene(
|
|
|
|
subghz->scene_manager, SubGhzSceneSaved)) {
|
|
|
|
if(!scene_manager_search_and_switch_to_previous_scene(
|
|
|
|
subghz->scene_manager, SubGhzSceneStart)) {
|
|
|
|
scene_manager_stop(subghz->scene_manager);
|
|
|
|
view_dispatcher_stop(subghz->view_dispatcher);
|
|
|
|
}
|
|
|
|
}
|
2021-10-27 17:37:11 +00:00
|
|
|
}
|
2022-07-03 16:03:36 +00:00
|
|
|
consumed = true;
|
2021-12-22 13:01:20 +00:00
|
|
|
break;
|
2021-10-27 17:37:11 +00:00
|
|
|
|
2022-03-03 09:48:56 +00:00
|
|
|
case SubGhzCustomEventViewReadRAWTXRXStop:
|
2023-05-04 03:04:26 +00:00
|
|
|
subghz_txrx_stop(subghz->txrx);
|
2021-12-22 13:01:20 +00:00
|
|
|
subghz->state_notifications = SubGhzNotificationStateIDLE;
|
2022-07-03 16:03:36 +00:00
|
|
|
consumed = true;
|
2021-10-25 14:37:14 +00:00
|
|
|
break;
|
2021-12-22 13:01:20 +00:00
|
|
|
|
2022-03-03 09:48:56 +00:00
|
|
|
case SubGhzCustomEventViewReadRAWConfig:
|
2021-10-27 17:37:11 +00:00
|
|
|
scene_manager_set_scene_state(
|
2022-03-03 09:48:56 +00:00
|
|
|
subghz->scene_manager, SubGhzSceneReadRAW, SubGhzCustomEventManagerSet);
|
2021-10-25 14:37:14 +00:00
|
|
|
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneReceiverConfig);
|
2022-07-03 16:03:36 +00:00
|
|
|
consumed = true;
|
2021-10-25 14:37:14 +00:00
|
|
|
break;
|
2021-12-22 13:01:20 +00:00
|
|
|
|
2022-03-03 09:48:56 +00:00
|
|
|
case SubGhzCustomEventViewReadRAWErase:
|
2023-05-04 03:04:26 +00:00
|
|
|
if(subghz_rx_key_state_get(subghz) == SubGhzRxKeyStateAddKey) {
|
2022-06-03 07:46:25 +00:00
|
|
|
if(subghz_scene_read_raw_update_filename(subghz)) {
|
2022-10-05 15:15:23 +00:00
|
|
|
furi_string_set(subghz->file_path_tmp, subghz->file_path);
|
2022-06-03 07:46:25 +00:00
|
|
|
subghz_delete_file(subghz);
|
|
|
|
}
|
2022-05-31 15:50:50 +00:00
|
|
|
}
|
2023-05-04 03:04:26 +00:00
|
|
|
subghz_rx_key_state_set(subghz, SubGhzRxKeyStateIDLE);
|
2022-04-28 17:20:59 +00:00
|
|
|
notification_message(subghz->notifications, &sequence_reset_rgb);
|
2022-07-03 16:03:36 +00:00
|
|
|
consumed = true;
|
2021-11-26 14:01:03 +00:00
|
|
|
break;
|
2021-12-22 13:01:20 +00:00
|
|
|
|
2022-03-03 09:48:56 +00:00
|
|
|
case SubGhzCustomEventViewReadRAWMore:
|
2022-11-10 17:14:44 +00:00
|
|
|
if(subghz_file_available(subghz)) {
|
|
|
|
if(subghz_scene_read_raw_update_filename(subghz)) {
|
|
|
|
scene_manager_set_scene_state(
|
|
|
|
subghz->scene_manager, SubGhzSceneReadRAW, SubGhzCustomEventManagerSet);
|
2023-05-04 03:04:26 +00:00
|
|
|
subghz_rx_key_state_set(subghz, SubGhzRxKeyStateRAWLoad);
|
2022-11-10 17:14:44 +00:00
|
|
|
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneMoreRAW);
|
|
|
|
consumed = true;
|
|
|
|
} else {
|
|
|
|
furi_crash("SubGhz: RAW file name update error.");
|
|
|
|
}
|
2021-12-22 13:01:20 +00:00
|
|
|
} else {
|
2022-11-10 17:14:44 +00:00
|
|
|
if(!scene_manager_search_and_switch_to_previous_scene(
|
|
|
|
subghz->scene_manager, SubGhzSceneStart)) {
|
|
|
|
scene_manager_stop(subghz->scene_manager);
|
|
|
|
view_dispatcher_stop(subghz->view_dispatcher);
|
|
|
|
}
|
2021-12-22 13:01:20 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2022-03-03 09:48:56 +00:00
|
|
|
case SubGhzCustomEventViewReadRAWSendStart:
|
|
|
|
|
2022-11-10 17:14:44 +00:00
|
|
|
if(subghz_file_available(subghz) && subghz_scene_read_raw_update_filename(subghz)) {
|
2021-11-24 13:59:45 +00:00
|
|
|
//start send
|
|
|
|
subghz->state_notifications = SubGhzNotificationStateIDLE;
|
2023-05-04 03:04:26 +00:00
|
|
|
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)) {
|
2023-06-09 11:02:47 +00:00
|
|
|
dolphin_deed(DolphinDeedSubGhzSend);
|
2021-11-24 13:59:45 +00:00
|
|
|
}
|
2023-05-04 03:04:26 +00:00
|
|
|
// 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;
|
2021-11-24 13:59:45 +00:00
|
|
|
}
|
2022-11-10 17:14:44 +00:00
|
|
|
} else {
|
|
|
|
if(!scene_manager_search_and_switch_to_previous_scene(
|
|
|
|
subghz->scene_manager, SubGhzSceneStart)) {
|
|
|
|
scene_manager_stop(subghz->scene_manager);
|
|
|
|
view_dispatcher_stop(subghz->view_dispatcher);
|
|
|
|
}
|
2021-11-24 13:59:45 +00:00
|
|
|
}
|
2022-07-03 16:03:36 +00:00
|
|
|
consumed = true;
|
2021-11-24 13:59:45 +00:00
|
|
|
break;
|
2021-12-22 13:01:20 +00:00
|
|
|
|
2022-03-03 09:48:56 +00:00
|
|
|
case SubGhzCustomEventViewReadRAWSendStop:
|
2021-11-24 13:59:45 +00:00
|
|
|
subghz->state_notifications = SubGhzNotificationStateIDLE;
|
2023-05-04 03:04:26 +00:00
|
|
|
subghz_txrx_stop(subghz->txrx);
|
2021-11-24 13:59:45 +00:00
|
|
|
subghz_read_raw_stop_send(subghz->subghz_read_raw);
|
2022-07-03 16:03:36 +00:00
|
|
|
consumed = true;
|
2021-11-24 13:59:45 +00:00
|
|
|
break;
|
2021-12-22 13:01:20 +00:00
|
|
|
|
2022-03-03 09:48:56 +00:00
|
|
|
case SubGhzCustomEventViewReadRAWIDLE:
|
2023-05-04 03:04:26 +00:00
|
|
|
subghz_txrx_stop(subghz->txrx);
|
|
|
|
size_t spl_count = subghz_protocol_raw_get_sample_write(decoder_raw);
|
2022-04-28 17:20:59 +00:00
|
|
|
|
2023-05-04 03:04:26 +00:00
|
|
|
subghz_protocol_raw_save_to_file_stop(decoder_raw);
|
2021-10-27 17:37:11 +00:00
|
|
|
|
2023-05-04 03:04:26 +00:00
|
|
|
FuriString* temp_str = furi_string_alloc();
|
2022-10-05 15:15:23 +00:00
|
|
|
furi_string_printf(
|
2022-04-21 16:10:50 +00:00
|
|
|
temp_str, "%s/%s%s", SUBGHZ_RAW_FOLDER, RAW_FILE_NAME, SUBGHZ_APP_EXTENSION);
|
2022-10-05 15:15:23 +00:00
|
|
|
subghz_protocol_raw_gen_fff_data(
|
2023-06-30 14:03:36 +00:00
|
|
|
subghz_txrx_get_fff_data(subghz->txrx),
|
|
|
|
furi_string_get_cstr(temp_str),
|
|
|
|
subghz_txrx_radio_device_get_name(subghz->txrx));
|
2022-10-05 15:15:23 +00:00
|
|
|
furi_string_free(temp_str);
|
2022-04-21 16:10:50 +00:00
|
|
|
|
2022-04-28 17:20:59 +00:00
|
|
|
if(spl_count > 0) {
|
|
|
|
notification_message(subghz->notifications, &sequence_set_green_255);
|
|
|
|
} else {
|
|
|
|
notification_message(subghz->notifications, &sequence_reset_rgb);
|
|
|
|
}
|
|
|
|
|
2022-04-21 16:10:50 +00:00
|
|
|
subghz->state_notifications = SubGhzNotificationStateIDLE;
|
2023-05-04 03:04:26 +00:00
|
|
|
subghz_rx_key_state_set(subghz, SubGhzRxKeyStateAddKey);
|
2021-10-27 17:37:11 +00:00
|
|
|
|
2022-07-03 16:03:36 +00:00
|
|
|
consumed = true;
|
2021-10-25 14:37:14 +00:00
|
|
|
break;
|
2021-10-27 17:37:11 +00:00
|
|
|
|
2022-03-03 09:48:56 +00:00
|
|
|
case SubGhzCustomEventViewReadRAWREC:
|
2023-05-04 03:04:26 +00:00
|
|
|
if(subghz_rx_key_state_get(subghz) != SubGhzRxKeyStateIDLE) {
|
2021-10-27 17:37:11 +00:00
|
|
|
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneNeedSaving);
|
2021-10-25 14:37:14 +00:00
|
|
|
} else {
|
2023-05-04 03:04:26 +00:00
|
|
|
SubGhzRadioPreset preset = subghz_txrx_get_preset(subghz->txrx);
|
|
|
|
if(subghz_protocol_raw_save_to_file_init(decoder_raw, RAW_FILE_NAME, &preset)) {
|
2023-06-09 11:02:47 +00:00
|
|
|
dolphin_deed(DolphinDeedSubGhzRawRec);
|
2023-05-04 03:04:26 +00:00
|
|
|
subghz_txrx_rx_start(subghz->txrx);
|
2022-04-28 17:20:59 +00:00
|
|
|
subghz->state_notifications = SubGhzNotificationStateRx;
|
2023-05-04 03:04:26 +00:00
|
|
|
subghz_rx_key_state_set(subghz, SubGhzRxKeyStateAddKey);
|
2021-10-27 17:37:11 +00:00
|
|
|
} else {
|
2022-10-05 15:15:23 +00:00
|
|
|
furi_string_set(subghz->error_str, "Function requires\nan SD card.");
|
2021-10-27 17:37:11 +00:00
|
|
|
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowError);
|
|
|
|
}
|
2021-10-25 14:37:14 +00:00
|
|
|
}
|
2022-07-03 16:03:36 +00:00
|
|
|
consumed = true;
|
2021-10-25 14:37:14 +00:00
|
|
|
break;
|
|
|
|
|
2022-03-03 09:48:56 +00:00
|
|
|
case SubGhzCustomEventViewReadRAWSave:
|
2022-11-10 17:14:44 +00:00
|
|
|
if(subghz_file_available(subghz) && subghz_scene_read_raw_update_filename(subghz)) {
|
2021-11-24 13:59:45 +00:00
|
|
|
scene_manager_set_scene_state(
|
2022-03-03 09:48:56 +00:00
|
|
|
subghz->scene_manager, SubGhzSceneReadRAW, SubGhzCustomEventManagerSetRAW);
|
2023-05-04 03:04:26 +00:00
|
|
|
subghz_rx_key_state_set(subghz, SubGhzRxKeyStateBack);
|
2021-11-24 13:59:45 +00:00
|
|
|
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneSaveName);
|
2022-11-10 17:14:44 +00:00
|
|
|
} else {
|
|
|
|
if(!scene_manager_search_and_switch_to_previous_scene(
|
|
|
|
subghz->scene_manager, SubGhzSceneStart)) {
|
|
|
|
scene_manager_stop(subghz->scene_manager);
|
|
|
|
view_dispatcher_stop(subghz->view_dispatcher);
|
|
|
|
}
|
2021-10-25 14:37:14 +00:00
|
|
|
}
|
2022-07-03 16:03:36 +00:00
|
|
|
consumed = true;
|
2021-10-25 14:37:14 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else if(event.type == SceneManagerEventTypeTick) {
|
|
|
|
switch(subghz->state_notifications) {
|
2022-04-28 17:20:59 +00:00
|
|
|
case SubGhzNotificationStateRx:
|
|
|
|
notification_message(subghz->notifications, &sequence_blink_cyan_10);
|
2022-10-26 15:13:00 +00:00
|
|
|
|
2023-05-04 03:04:26 +00:00
|
|
|
subghz_read_raw_update_sample_write(
|
|
|
|
subghz->subghz_read_raw, subghz_protocol_raw_get_sample_write(decoder_raw));
|
2022-10-26 15:13:00 +00:00
|
|
|
|
2023-06-30 14:03:36 +00:00
|
|
|
SubGhzThresholdRssiData ret_rssi = subghz_threshold_get_rssi_data(
|
|
|
|
subghz->threshold_rssi, subghz_txrx_radio_device_get_rssi(subghz->txrx));
|
2023-05-04 03:04:26 +00:00
|
|
|
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);
|
2021-10-25 14:37:14 +00:00
|
|
|
break;
|
2022-04-28 17:20:59 +00:00
|
|
|
case SubGhzNotificationStateTx:
|
|
|
|
notification_message(subghz->notifications, &sequence_blink_magenta_10);
|
2021-11-24 13:59:45 +00:00
|
|
|
subghz_read_raw_update_sin(subghz->subghz_read_raw);
|
|
|
|
break;
|
2021-10-25 14:37:14 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2022-07-03 16:03:36 +00:00
|
|
|
return consumed;
|
2021-10-25 14:37:14 +00:00
|
|
|
}
|
|
|
|
|
2021-10-27 17:37:11 +00:00
|
|
|
void subghz_scene_read_raw_on_exit(void* context) {
|
2021-10-25 14:37:14 +00:00
|
|
|
SubGhz* subghz = context;
|
|
|
|
|
|
|
|
//Stop CC1101
|
2023-05-04 03:04:26 +00:00
|
|
|
subghz_txrx_stop(subghz->txrx);
|
2021-11-11 12:49:19 +00:00
|
|
|
subghz->state_notifications = SubGhzNotificationStateIDLE;
|
2022-04-28 17:20:59 +00:00
|
|
|
notification_message(subghz->notifications, &sequence_reset_rgb);
|
2021-10-25 14:37:14 +00:00
|
|
|
|
2022-03-03 09:48:56 +00:00
|
|
|
//filter restoration
|
2023-05-04 03:04:26 +00:00
|
|
|
subghz_txrx_receiver_set_filter(subghz->txrx, subghz->filter);
|
2021-10-25 14:37:14 +00:00
|
|
|
}
|