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-12-26 12:13:30 +00:00
|
|
|
#include <float_tools.h>
|
2021-11-24 13:59:45 +00:00
|
|
|
|
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"
|
2022-10-26 15:13:00 +00:00
|
|
|
#define RAW_THRESHOLD_RSSI_LOW_COUNT 10
|
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 {
|
|
|
|
if(!flipper_format_rewind(subghz->txrx->fff_data)) {
|
|
|
|
FURI_LOG_E(TAG, "Rewind error");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!flipper_format_read_string(subghz->txrx->fff_data, "File_name", temp_str)) {
|
|
|
|
FURI_LOG_E(TAG, "Missing File_name");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2022-10-05 15:15:23 +00:00
|
|
|
FuriString* frequency_str;
|
|
|
|
FuriString* modulation_str;
|
2021-11-11 12:49:19 +00:00
|
|
|
|
2022-10-05 15:15:23 +00:00
|
|
|
frequency_str = furi_string_alloc();
|
|
|
|
modulation_str = furi_string_alloc();
|
2021-11-11 12:49:19 +00:00
|
|
|
|
|
|
|
subghz_get_frequency_modulation(subghz, frequency_str, modulation_str);
|
|
|
|
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);
|
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;
|
2022-10-05 15:15:23 +00:00
|
|
|
FuriString* file_name;
|
|
|
|
file_name = furi_string_alloc();
|
2021-10-27 17:37:11 +00:00
|
|
|
|
2021-12-22 13:01:20 +00:00
|
|
|
switch(subghz->txrx->rx_key_state) {
|
|
|
|
case SubGhzRxKeyStateBack:
|
2022-10-26 15:13:00 +00:00
|
|
|
subghz_read_raw_set_status(
|
|
|
|
subghz->subghz_read_raw, SubGhzReadRAWStatusIDLE, "", subghz->txrx->raw_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),
|
|
|
|
subghz->txrx->raw_threshold_rssi);
|
2021-12-22 13:01:20 +00:00
|
|
|
subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE;
|
|
|
|
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),
|
|
|
|
subghz->txrx->raw_threshold_rssi);
|
2021-12-22 13:01:20 +00:00
|
|
|
subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE;
|
|
|
|
break;
|
|
|
|
default:
|
2022-10-26 15:13:00 +00:00
|
|
|
subghz_read_raw_set_status(
|
|
|
|
subghz->subghz_read_raw,
|
|
|
|
SubGhzReadRAWStatusStart,
|
|
|
|
"",
|
|
|
|
subghz->txrx->raw_threshold_rssi);
|
2021-10-27 17:37:11 +00:00
|
|
|
subghz->txrx->rx_key_state = SubGhzRxKeyStateIDLE;
|
2021-12-22 13:01:20 +00:00
|
|
|
break;
|
2021-10-27 17:37:11 +00:00
|
|
|
}
|
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
|
|
|
|
2022-04-21 16:10:50 +00:00
|
|
|
subghz->txrx->decoder_result = subghz_receiver_search_decoder_base_by_name(
|
|
|
|
subghz->txrx->receiver, SUBGHZ_PROTOCOL_RAW_NAME);
|
2022-03-03 09:48:56 +00:00
|
|
|
furi_assert(subghz->txrx->decoder_result);
|
2021-11-24 13:59:45 +00:00
|
|
|
|
2022-03-03 09:48:56 +00:00
|
|
|
//set filter RAW feed
|
|
|
|
subghz_receiver_set_filter(subghz->txrx->receiver, SubGhzProtocolFlag_RAW);
|
|
|
|
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;
|
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:
|
2021-11-24 13:59:45 +00:00
|
|
|
//Stop TX
|
|
|
|
if(subghz->txrx->txrx_state == SubGhzTxRxStateTx) {
|
|
|
|
subghz_tx_stop(subghz);
|
|
|
|
subghz_sleep(subghz);
|
|
|
|
}
|
|
|
|
//Stop RX
|
2021-10-25 14:37:14 +00:00
|
|
|
if(subghz->txrx->txrx_state == SubGhzTxRxStateRx) {
|
|
|
|
subghz_rx_end(subghz);
|
|
|
|
subghz_sleep(subghz);
|
|
|
|
};
|
2021-11-24 13:59:45 +00:00
|
|
|
//Stop save file
|
2021-10-27 17:37:11 +00:00
|
|
|
subghz_protocol_raw_save_to_file_stop(
|
2022-03-03 09:48:56 +00:00
|
|
|
(SubGhzProtocolDecoderRAW*)subghz->txrx->decoder_result);
|
2021-11-11 12:49:19 +00:00
|
|
|
subghz->state_notifications = SubGhzNotificationStateIDLE;
|
2021-11-24 13:59:45 +00:00
|
|
|
//needed save?
|
|
|
|
if((subghz->txrx->rx_key_state == SubGhzRxKeyStateAddKey) ||
|
|
|
|
(subghz->txrx->rx_key_state == SubGhzRxKeyStateBack)) {
|
2021-10-27 17:37:11 +00:00
|
|
|
subghz->txrx->rx_key_state = SubGhzRxKeyStateExit;
|
|
|
|
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneNeedSaving);
|
|
|
|
} else {
|
2021-11-24 13:59:45 +00:00
|
|
|
//Restore default setting
|
2022-07-26 14:16:59 +00:00
|
|
|
subghz_preset_init(
|
|
|
|
subghz,
|
|
|
|
"AM650",
|
|
|
|
subghz_setting_get_default_frequency(subghz->setting),
|
|
|
|
NULL,
|
|
|
|
0);
|
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:
|
2021-12-22 13:01:20 +00:00
|
|
|
//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->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:
|
2022-06-03 07:46:25 +00:00
|
|
|
if(subghz->txrx->rx_key_state == SubGhzRxKeyStateAddKey) {
|
|
|
|
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
|
|
|
}
|
2022-06-03 07:46:25 +00:00
|
|
|
subghz->txrx->rx_key_state = 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);
|
|
|
|
subghz->txrx->rx_key_state = SubGhzRxKeyStateRAWLoad;
|
|
|
|
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;
|
|
|
|
if(subghz->txrx->txrx_state == SubGhzTxRxStateRx) {
|
|
|
|
subghz_rx_end(subghz);
|
|
|
|
}
|
|
|
|
if((subghz->txrx->txrx_state == SubGhzTxRxStateIDLE) ||
|
|
|
|
(subghz->txrx->txrx_state == SubGhzTxRxStateSleep)) {
|
2022-03-03 09:48:56 +00:00
|
|
|
if(!subghz_tx_start(subghz, subghz->txrx->fff_data)) {
|
2022-07-26 12:58:07 +00:00
|
|
|
subghz->txrx->rx_key_state = SubGhzRxKeyStateBack;
|
2021-11-24 13:59:45 +00:00
|
|
|
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneShowOnlyRx);
|
|
|
|
} else {
|
2022-10-28 07:18:41 +00:00
|
|
|
if(scene_manager_has_previous_scene(
|
|
|
|
subghz->scene_manager, SubGhzSceneSaved) ||
|
|
|
|
!scene_manager_has_previous_scene(
|
|
|
|
subghz->scene_manager, SubGhzSceneStart)) {
|
|
|
|
DOLPHIN_DEED(DolphinDeedSubGhzSend);
|
|
|
|
}
|
2022-03-03 09:48:56 +00:00
|
|
|
// set callback end tx
|
|
|
|
subghz_protocol_raw_file_encoder_worker_set_callback_end(
|
2022-05-08 17:50:20 +00:00
|
|
|
(SubGhzProtocolEncoderRAW*)subghz_transmitter_get_protocol_instance(
|
|
|
|
subghz->txrx->transmitter),
|
2022-03-03 09:48:56 +00:00
|
|
|
subghz_scene_read_raw_callback_end_tx,
|
|
|
|
subghz);
|
2022-04-28 17:20:59 +00:00
|
|
|
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;
|
|
|
|
if(subghz->txrx->txrx_state == SubGhzTxRxStateTx) {
|
2022-12-16 22:20:10 +00:00
|
|
|
subghz_speaker_unmute(subghz);
|
2021-11-24 13:59:45 +00:00
|
|
|
subghz_tx_stop(subghz);
|
|
|
|
subghz_sleep(subghz);
|
|
|
|
}
|
|
|
|
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:
|
2021-10-25 14:37:14 +00:00
|
|
|
if(subghz->txrx->txrx_state == SubGhzTxRxStateRx) {
|
|
|
|
subghz_rx_end(subghz);
|
|
|
|
subghz_sleep(subghz);
|
|
|
|
};
|
2022-04-28 17:20:59 +00:00
|
|
|
|
|
|
|
size_t spl_count = subghz_protocol_raw_get_sample_write(
|
|
|
|
(SubGhzProtocolDecoderRAW*)subghz->txrx->decoder_result);
|
|
|
|
|
2021-10-27 17:37:11 +00:00
|
|
|
subghz_protocol_raw_save_to_file_stop(
|
2022-03-03 09:48:56 +00:00
|
|
|
(SubGhzProtocolDecoderRAW*)subghz->txrx->decoder_result);
|
2021-10-27 17:37:11 +00:00
|
|
|
|
2022-10-05 15:15:23 +00:00
|
|
|
FuriString* temp_str;
|
|
|
|
temp_str = furi_string_alloc();
|
|
|
|
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(
|
|
|
|
subghz->txrx->fff_data, furi_string_get_cstr(temp_str));
|
|
|
|
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;
|
2021-10-27 17:37:11 +00:00
|
|
|
subghz->txrx->rx_key_state = SubGhzRxKeyStateAddKey;
|
|
|
|
|
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:
|
2021-10-27 17:37:11 +00:00
|
|
|
if(subghz->txrx->rx_key_state != SubGhzRxKeyStateIDLE) {
|
|
|
|
scene_manager_next_scene(subghz->scene_manager, SubGhzSceneNeedSaving);
|
2021-10-25 14:37:14 +00:00
|
|
|
} else {
|
2022-10-26 15:13:00 +00:00
|
|
|
subghz->txrx->raw_threshold_rssi_low_count = RAW_THRESHOLD_RSSI_LOW_COUNT;
|
2021-10-27 17:37:11 +00:00
|
|
|
if(subghz_protocol_raw_save_to_file_init(
|
2022-03-03 09:48:56 +00:00
|
|
|
(SubGhzProtocolDecoderRAW*)subghz->txrx->decoder_result,
|
2021-11-24 13:59:45 +00:00
|
|
|
RAW_FILE_NAME,
|
2022-03-03 09:48:56 +00:00
|
|
|
subghz->txrx->preset)) {
|
[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
|
|
|
DOLPHIN_DEED(DolphinDeedSubGhzRawRec);
|
2021-10-27 17:37:11 +00:00
|
|
|
if((subghz->txrx->txrx_state == SubGhzTxRxStateIDLE) ||
|
|
|
|
(subghz->txrx->txrx_state == SubGhzTxRxStateSleep)) {
|
2022-07-26 14:16:59 +00:00
|
|
|
subghz_begin(
|
|
|
|
subghz,
|
|
|
|
subghz_setting_get_preset_data_by_name(
|
2022-10-05 15:15:23 +00:00
|
|
|
subghz->setting,
|
|
|
|
furi_string_get_cstr(subghz->txrx->preset->name)));
|
2022-07-26 14:16:59 +00:00
|
|
|
subghz_rx(subghz, subghz->txrx->preset->frequency);
|
2021-10-27 17:37:11 +00:00
|
|
|
}
|
2022-04-28 17:20:59 +00:00
|
|
|
subghz->state_notifications = SubGhzNotificationStateRx;
|
2021-12-22 13:01:20 +00:00
|
|
|
subghz->txrx->rx_key_state = 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);
|
2021-11-24 13:59:45 +00:00
|
|
|
subghz->txrx->rx_key_state = SubGhzRxKeyStateBack;
|
|
|
|
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);
|
2021-10-27 17:37:11 +00:00
|
|
|
subghz_read_raw_update_sample_write(
|
|
|
|
subghz->subghz_read_raw,
|
|
|
|
subghz_protocol_raw_get_sample_write(
|
2022-03-03 09:48:56 +00:00
|
|
|
(SubGhzProtocolDecoderRAW*)subghz->txrx->decoder_result));
|
2022-10-26 15:13:00 +00:00
|
|
|
|
|
|
|
float rssi = furi_hal_subghz_get_rssi();
|
|
|
|
|
2022-12-26 12:13:30 +00:00
|
|
|
if(float_is_equal(subghz->txrx->raw_threshold_rssi, SUBGHZ_RAW_TRESHOLD_MIN)) {
|
2022-10-26 15:13:00 +00:00
|
|
|
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);
|
2022-12-16 22:20:10 +00:00
|
|
|
subghz_speaker_mute(subghz);
|
2022-10-26 15:13:00 +00:00
|
|
|
} 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);
|
2022-12-16 22:20:10 +00:00
|
|
|
subghz_speaker_unmute(subghz);
|
2022-10-26 15:13:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
if(subghz->txrx->txrx_state == SubGhzTxRxStateRx) {
|
|
|
|
subghz_rx_end(subghz);
|
|
|
|
subghz_sleep(subghz);
|
|
|
|
};
|
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
|
|
|
|
subghz_receiver_set_filter(subghz->txrx->receiver, SubGhzProtocolFlag_Decodable);
|
2021-10-25 14:37:14 +00:00
|
|
|
}
|