mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2025-12-12 20:49:49 +04:00
SubGhz - Temp Fix RAW recording and reading
and remove unused file
This commit is contained in:
@@ -1,163 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "subghz_history.h"
|
|
||||||
#include <toolbox/stream/stream.h>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Generate filename like 000.tmp
|
|
||||||
*
|
|
||||||
* @param index - index of file, timestamp doesn't accepted!
|
|
||||||
*/
|
|
||||||
FuriString* subghz_history_generate_temp_filename(uint32_t index);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Check if directory for temporary files is exists
|
|
||||||
*
|
|
||||||
* @param instance SubGhzHistory*
|
|
||||||
* @return true
|
|
||||||
* @return false
|
|
||||||
*/
|
|
||||||
bool subghz_history_is_tmp_dir_exists(SubGhzHistory* instance);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Check SD card and create temporary dir if not exists,
|
|
||||||
* Result write_tmp_files without this unstable work is GUARANTEED
|
|
||||||
*
|
|
||||||
* @param instance - SubGhzHistory*
|
|
||||||
* @return - true all ok
|
|
||||||
* @return - false we have a problems
|
|
||||||
*/
|
|
||||||
bool subghz_history_check_sdcard(SubGhzHistory* instance);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Recursive delete dir and files and create new temp dir
|
|
||||||
*
|
|
||||||
* @param instance - SubGhzHistory*
|
|
||||||
* @return true - if all ok
|
|
||||||
* @return false - if something failed
|
|
||||||
*/
|
|
||||||
void subghz_history_clear_tmp_dir(SubGhzHistory* instance);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Free item and free all resources
|
|
||||||
*
|
|
||||||
* @param current_item - SubGhzHistoryItem*
|
|
||||||
*/
|
|
||||||
void subghz_history_item_free(void* current_item);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief free all items in array
|
|
||||||
*
|
|
||||||
* @param instance
|
|
||||||
*/
|
|
||||||
void subghz_history_clean_item_array(SubGhzHistory* instance);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Write temp file fully, without splitting
|
|
||||||
*
|
|
||||||
* @param instance - SubGhzHistory*
|
|
||||||
* @param current_item - SubGhzHistoryItem*
|
|
||||||
* @param dir_path - full path to file
|
|
||||||
*/
|
|
||||||
void subghz_history_tmp_write_file_full(
|
|
||||||
SubGhzHistory* instance,
|
|
||||||
void* current_item,
|
|
||||||
FuriString* dir_path);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Write temp spited to lines
|
|
||||||
*
|
|
||||||
* @param instance - SubGhzHistory*
|
|
||||||
* @param current_item - SubGhzHistoryItem*
|
|
||||||
* @param dir_path - full path to file
|
|
||||||
* @return true - file saved
|
|
||||||
* @return false - error occurred
|
|
||||||
*/
|
|
||||||
bool subghz_history_tmp_write_file_split(
|
|
||||||
SubGhzHistory* instance,
|
|
||||||
void* current_item,
|
|
||||||
const char* dir_path);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief generate random value
|
|
||||||
*
|
|
||||||
* @param min - min value
|
|
||||||
* @param max - max value
|
|
||||||
* @return uint32_t
|
|
||||||
*/
|
|
||||||
uint32_t subghz_history_rand_range(uint32_t min, uint32_t max);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief write random noise signals to file applying to max line value
|
|
||||||
*
|
|
||||||
* @param file - Stream*
|
|
||||||
* @param is_negative_start - first value is negative or positive?
|
|
||||||
* @param current_position - 0 if started from beginning
|
|
||||||
* @param empty_line - add RAW_Data to this line
|
|
||||||
* @return true
|
|
||||||
* @return false
|
|
||||||
*/
|
|
||||||
bool subghz_history_write_file_noise(
|
|
||||||
Stream* file,
|
|
||||||
bool is_negative_start,
|
|
||||||
size_t current_position,
|
|
||||||
bool empty_line);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief taken from flipper_format_stream_read_value_line but takes only one int32 value
|
|
||||||
*
|
|
||||||
* @param stream - Stream*
|
|
||||||
* @param _data - int32_t* output data
|
|
||||||
* @param data_size - size of data
|
|
||||||
* @return true
|
|
||||||
* @return false
|
|
||||||
*/
|
|
||||||
bool subghz_history_read_int32(Stream* stream, int32_t* _data, const uint16_t data_size);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief write payload to file spliting by lines
|
|
||||||
*
|
|
||||||
* @param src - Stream* of source
|
|
||||||
* @param file - Stream* of file
|
|
||||||
* @param is_negative_start - first value is negative or positive?
|
|
||||||
* @param current_position - by default is 0 but in this value returned last position of payload
|
|
||||||
* @return true
|
|
||||||
* @return false
|
|
||||||
*/
|
|
||||||
bool subghz_history_write_file_data(
|
|
||||||
Stream* src,
|
|
||||||
Stream* file,
|
|
||||||
bool* is_negative_start,
|
|
||||||
size_t* current_position);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief taken from flipper_format_stream_read_valid_key
|
|
||||||
*
|
|
||||||
* @param stream - Stream*
|
|
||||||
* @param key - FuriString* output value
|
|
||||||
* @return true
|
|
||||||
* @return false
|
|
||||||
*/
|
|
||||||
bool subghz_history_stream_read_valid_key(Stream* stream, FuriString* key);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief taken from flipper_format_stream_seek_to_key
|
|
||||||
*
|
|
||||||
* @param stream - Stream*
|
|
||||||
* @param key - key
|
|
||||||
* @param strict_mode - false
|
|
||||||
* @return true
|
|
||||||
* @return false
|
|
||||||
*/
|
|
||||||
bool subghz_history_stream_seek_to_key(Stream* stream, const char* key, bool strict_mode);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief taken from flipper_format_stream_read_value
|
|
||||||
*
|
|
||||||
* @param stream - Stream*
|
|
||||||
* @param value - FuriString* output value
|
|
||||||
* @param last - return position is last flag
|
|
||||||
* @return true
|
|
||||||
* @return false
|
|
||||||
*/
|
|
||||||
bool subghz_history_stream_read_value(Stream* stream, FuriString* value, bool* last);
|
|
||||||
@@ -244,8 +244,8 @@ void subghz_protocol_decoder_raw_reset(void* context) {
|
|||||||
void subghz_protocol_decoder_raw_feed(void* context, bool level, uint32_t duration) {
|
void subghz_protocol_decoder_raw_feed(void* context, bool level, uint32_t duration) {
|
||||||
furi_assert(context);
|
furi_assert(context);
|
||||||
SubGhzProtocolDecoderRAW* instance = context;
|
SubGhzProtocolDecoderRAW* instance = context;
|
||||||
|
// Add check if we got duration higher than 1 second, we skipping it, temp fix
|
||||||
if(!instance->pause && (instance->upload_raw != NULL)) {
|
if((!instance->pause && (instance->upload_raw != NULL)) && (duration < ((uint32_t)1000000))) {
|
||||||
if(duration > subghz_protocol_raw_const.te_short) {
|
if(duration > subghz_protocol_raw_const.te_short) {
|
||||||
if(instance->last_level != level) {
|
if(instance->last_level != level) {
|
||||||
instance->last_level = (level ? true : false);
|
instance->last_level = (level ? true : false);
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ void subghz_file_encoder_worker_add_level_duration(
|
|||||||
|
|
||||||
bool subghz_file_encoder_worker_data_parse(SubGhzFileEncoderWorker* instance, const char* strStart) {
|
bool subghz_file_encoder_worker_data_parse(SubGhzFileEncoderWorker* instance, const char* strStart) {
|
||||||
char* str1;
|
char* str1;
|
||||||
|
int32_t temp_ds = 0;
|
||||||
bool res = false;
|
bool res = false;
|
||||||
// Line sample: "RAW_Data: -1, 2, -2..."
|
// Line sample: "RAW_Data: -1, 2, -2..."
|
||||||
|
|
||||||
@@ -72,7 +73,13 @@ bool subghz_file_encoder_worker_data_parse(SubGhzFileEncoderWorker* instance, co
|
|||||||
|
|
||||||
// Skip space
|
// Skip space
|
||||||
str1 += 1;
|
str1 += 1;
|
||||||
subghz_file_encoder_worker_add_level_duration(instance, atoi(str1));
|
//
|
||||||
|
temp_ds = atoi(str1);
|
||||||
|
if((temp_ds < -1000000) || (temp_ds > 1000000)) {
|
||||||
|
//FURI_LOG_I("PARSE", "Number overflow - %d", atoi(str1));
|
||||||
|
} else {
|
||||||
|
subghz_file_encoder_worker_add_level_duration(instance, temp_ds);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
res = true;
|
res = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user