[FL-2047] SubGhz: New GUI ReadRAW view (#832)
* SubGhz: GUI RAW Read view * SubGhz: GUI Read RAW refactoring * SubGhz: fix bug wrong frequency of the allowed transmission * GUI Read RAW refactoring * SubGhz: fix set the default frequency * SubGhz: fix save filename when returning from another menu * SubGhz: fix Send and Back button behavior Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
@@ -17,6 +17,8 @@ struct SubGhzProtocolRAW {
|
||||
string_t file_name;
|
||||
size_t sample_write;
|
||||
bool last_level;
|
||||
SubGhzProtocolRAWCallbackEnd callback_end;
|
||||
void* context_end;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
@@ -65,6 +67,22 @@ void subghz_protocol_raw_free(SubGhzProtocolRAW* instance) {
|
||||
free(instance);
|
||||
}
|
||||
|
||||
void subghz_protocol_raw_file_encoder_worker_callback_end(void* context) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolRAW* instance = context;
|
||||
if(instance->callback_end) instance->callback_end(instance->context_end);
|
||||
}
|
||||
|
||||
void subghz_protocol_raw_file_encoder_worker_set_callback_end(
|
||||
SubGhzProtocolRAW* instance,
|
||||
SubGhzProtocolRAWCallbackEnd callback_end,
|
||||
void* context_end) {
|
||||
furi_assert(instance);
|
||||
furi_assert(callback_end);
|
||||
instance->callback_end = callback_end;
|
||||
instance->context_end = context_end;
|
||||
}
|
||||
|
||||
void subghz_protocol_raw_file_encoder_worker_stop(void* context) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolRAW* instance = context;
|
||||
@@ -90,10 +108,17 @@ bool subghz_protocol_raw_send_key(
|
||||
//the worker needs a file in order to open and read part of the file
|
||||
osDelay(100);
|
||||
instance->file_is_open = RAWFileIsOpenRead;
|
||||
//Forwarding UPLOAD to common encoder
|
||||
subghz_protocol_encoder_common_set_callback(
|
||||
encoder, subghz_file_encoder_worker_get_level_duration, instance->file_worker_encoder);
|
||||
//forced stop of transmission
|
||||
subghz_protocol_encoder_common_set_callback_end(
|
||||
encoder, subghz_protocol_raw_file_encoder_worker_stop, instance);
|
||||
//file transfer complete callback
|
||||
subghz_file_encoder_worker_callback_end(
|
||||
instance->file_worker_encoder,
|
||||
subghz_protocol_raw_file_encoder_worker_callback_end,
|
||||
instance);
|
||||
|
||||
loaded = true;
|
||||
} else {
|
||||
@@ -187,7 +212,8 @@ bool subghz_protocol_raw_save_to_file_init(
|
||||
break;
|
||||
}
|
||||
|
||||
if(!flipper_file_write_string_cstr(instance->flipper_file, "Protocol", instance->common.name)) {
|
||||
if(!flipper_file_write_string_cstr(
|
||||
instance->flipper_file, "Protocol", instance->common.name)) {
|
||||
FURI_LOG_E(TAG, "Unable to add Protocol");
|
||||
break;
|
||||
}
|
||||
|
@@ -2,6 +2,8 @@
|
||||
|
||||
#include "subghz_protocol_common.h"
|
||||
|
||||
typedef void (*SubGhzProtocolRAWCallbackEnd)(void* context);
|
||||
|
||||
typedef struct SubGhzProtocolRAW SubGhzProtocolRAW;
|
||||
|
||||
/** Allocate SubGhzProtocolRAW
|
||||
@@ -16,6 +18,11 @@ SubGhzProtocolRAW* subghz_protocol_raw_alloc();
|
||||
*/
|
||||
void subghz_protocol_raw_free(SubGhzProtocolRAW* instance);
|
||||
|
||||
void subghz_protocol_raw_file_encoder_worker_set_callback_end(
|
||||
SubGhzProtocolRAW* instance,
|
||||
SubGhzProtocolRAWCallbackEnd callback_end,
|
||||
void* context_end);
|
||||
|
||||
/** Reset internal state
|
||||
* @param instance - SubGhzProtocolRAW instance
|
||||
*/
|
||||
|
@@ -16,12 +16,26 @@ struct SubGhzFileEncoderWorker {
|
||||
FlipperFile* flipper_file;
|
||||
|
||||
volatile bool worker_running;
|
||||
volatile bool worker_stoping;
|
||||
bool level;
|
||||
int32_t duration;
|
||||
string_t str_data;
|
||||
string_t file_path;
|
||||
|
||||
SubGhzFileEncoderWorkerCallbackEnd callback_end;
|
||||
void* context_end;
|
||||
};
|
||||
|
||||
void subghz_file_encoder_worker_callback_end(
|
||||
SubGhzFileEncoderWorker* instance,
|
||||
SubGhzFileEncoderWorkerCallbackEnd callback_end,
|
||||
void* context_end) {
|
||||
furi_assert(instance);
|
||||
furi_assert(callback_end);
|
||||
instance->callback_end = callback_end;
|
||||
instance->context_end = context_end;
|
||||
}
|
||||
|
||||
void subghz_file_encoder_worker_add_livel_duration(
|
||||
SubGhzFileEncoderWorker* instance,
|
||||
int32_t duration) {
|
||||
@@ -89,6 +103,7 @@ LevelDuration subghz_file_encoder_worker_get_level_duration(void* context) {
|
||||
} else if(duration == 0) {
|
||||
level_duration = level_duration_reset();
|
||||
FURI_LOG_I(TAG, "Stop transmission");
|
||||
instance->worker_stoping = true;
|
||||
}
|
||||
return level_duration;
|
||||
} else {
|
||||
@@ -111,9 +126,7 @@ static int32_t subghz_file_encoder_worker_thread(void* context) {
|
||||
if(!flipper_file_open_existing(
|
||||
instance->flipper_file, string_get_cstr(instance->file_path))) {
|
||||
FURI_LOG_E(
|
||||
TAG,
|
||||
"Unable to open file for read: %s",
|
||||
string_get_cstr(instance->file_path));
|
||||
TAG, "Unable to open file for read: %s", string_get_cstr(instance->file_path));
|
||||
break;
|
||||
}
|
||||
if(!flipper_file_read_string(instance->flipper_file, "Protocol", instance->str_data)) {
|
||||
@@ -124,6 +137,7 @@ static int32_t subghz_file_encoder_worker_thread(void* context) {
|
||||
//skip the end of the previous line "\n"
|
||||
storage_file_seek(file, 1, false);
|
||||
res = true;
|
||||
instance->worker_stoping = false;
|
||||
FURI_LOG_I(TAG, "Start transmission");
|
||||
} while(0);
|
||||
|
||||
@@ -152,7 +166,11 @@ static int32_t subghz_file_encoder_worker_thread(void* context) {
|
||||
}
|
||||
//waiting for the end of the transfer
|
||||
FURI_LOG_I(TAG, "End read file");
|
||||
|
||||
while(instance->worker_running) {
|
||||
if(instance->worker_stoping) {
|
||||
if(instance->callback_end) instance->callback_end(instance->context_end);
|
||||
}
|
||||
osDelay(50);
|
||||
}
|
||||
flipper_file_close(instance->flipper_file);
|
||||
@@ -177,6 +195,7 @@ SubGhzFileEncoderWorker* subghz_file_encoder_worker_alloc() {
|
||||
string_init(instance->str_data);
|
||||
string_init(instance->file_path);
|
||||
instance->level = false;
|
||||
instance->worker_stoping = true;
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
@@ -2,8 +2,20 @@
|
||||
|
||||
#include <furi-hal.h>
|
||||
|
||||
typedef void (*SubGhzFileEncoderWorkerCallbackEnd)(void* context);
|
||||
|
||||
typedef struct SubGhzFileEncoderWorker SubGhzFileEncoderWorker;
|
||||
|
||||
/** End callback SubGhzWorker
|
||||
*
|
||||
* @param instance SubGhzFileEncoderWorker instance
|
||||
* @param callback SubGhzFileEncoderWorkerCallbackEnd callback
|
||||
*/
|
||||
void subghz_file_encoder_worker_callback_end(
|
||||
SubGhzFileEncoderWorker* instance,
|
||||
SubGhzFileEncoderWorkerCallbackEnd callback_end,
|
||||
void* context_end);
|
||||
|
||||
/** Allocate SubGhzFileEncoderWorker
|
||||
*
|
||||
* @return SubGhzFileEncoderWorker*
|
||||
|
Reference in New Issue
Block a user