[FL-1931, FL-2005] SubGhz: migration in flipper file format (#807)
* SubGhz: add save key in flipper file format * [FL-2005] SubGhz: fix stored signals cannot be deleted * SubGhz: add load key in flipper file format * SubGhz: fix syntax * SubGhz: fix bad file upload * Storage: add function to get the next free filename * SubGhz: add save RAW in flipper file format * SubGhz: add load RAW in flipper file format * SubGhz: refactoring protocol * SubGhz: refactoring scene * SubGhz: fix SubGhzNotificationState define * Makefile: proper comapre for FORCE Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
@@ -28,8 +28,8 @@ SubGhzProtocolCame* subghz_protocol_came_alloc() {
|
||||
instance->common.te_delta = 150;
|
||||
instance->common.type_protocol = SubGhzProtocolCommonTypeStatic;
|
||||
instance->common.to_string = (SubGhzProtocolCommonToStr)subghz_protocol_came_to_str;
|
||||
instance->common.to_save_string =
|
||||
(SubGhzProtocolCommonGetStrSave)subghz_protocol_came_to_save_str;
|
||||
instance->common.to_save_file =
|
||||
(SubGhzProtocolCommonSaveFile)subghz_protocol_came_to_save_file;
|
||||
instance->common.to_load_protocol_from_file =
|
||||
(SubGhzProtocolCommonLoadFromFile)subghz_protocol_came_to_load_protocol_from_file;
|
||||
instance->common.to_load_protocol =
|
||||
@@ -88,8 +88,6 @@ void subghz_protocol_came_parse(SubGhzProtocolCame* instance, bool level, uint32
|
||||
instance->common.te_delta * 51)) { //Need protocol 36 te_short
|
||||
//Found header CAME
|
||||
instance->common.parser_step = CameDecoderStepFoundStartBit;
|
||||
} else {
|
||||
instance->common.parser_step = CameDecoderStepReset;
|
||||
}
|
||||
break;
|
||||
case CameDecoderStepFoundStartBit:
|
||||
@@ -169,55 +167,16 @@ void subghz_protocol_came_to_str(SubGhzProtocolCame* instance, string_t output)
|
||||
code_found_reverse_lo);
|
||||
}
|
||||
|
||||
void subghz_protocol_came_to_save_str(SubGhzProtocolCame* instance, string_t output) {
|
||||
string_printf(
|
||||
output,
|
||||
"Protocol: %s\n"
|
||||
"Bit: %d\n"
|
||||
"Key: %08lX\n",
|
||||
instance->common.name,
|
||||
instance->common.code_last_count_bit,
|
||||
(uint32_t)(instance->common.code_last_found & 0x00000000ffffffff));
|
||||
bool subghz_protocol_came_to_save_file(SubGhzProtocolCame* instance, FlipperFile* flipper_file) {
|
||||
return subghz_protocol_common_to_save_file((SubGhzProtocolCommon*)instance, flipper_file);
|
||||
}
|
||||
|
||||
bool subghz_protocol_came_to_load_protocol_from_file(
|
||||
FileWorker* file_worker,
|
||||
FlipperFile* flipper_file,
|
||||
SubGhzProtocolCame* instance,
|
||||
const char* file_path) {
|
||||
bool loaded = false;
|
||||
string_t temp_str;
|
||||
string_init(temp_str);
|
||||
int res = 0;
|
||||
int data = 0;
|
||||
|
||||
do {
|
||||
// Read and parse bit data from 2nd line
|
||||
if(!file_worker_read_until(file_worker, temp_str, '\n')) {
|
||||
break;
|
||||
}
|
||||
res = sscanf(string_get_cstr(temp_str), "Bit: %d\n", &data);
|
||||
if(res != 1) {
|
||||
break;
|
||||
}
|
||||
instance->common.code_last_count_bit = (uint8_t)data;
|
||||
|
||||
// Read and parse key data from 3nd line
|
||||
if(!file_worker_read_until(file_worker, temp_str, '\n')) {
|
||||
break;
|
||||
}
|
||||
uint32_t temp_key = 0;
|
||||
res = sscanf(string_get_cstr(temp_str), "Key: %08lX\n", &temp_key);
|
||||
if(res != 1) {
|
||||
break;
|
||||
}
|
||||
instance->common.code_last_found = (uint64_t)temp_key;
|
||||
|
||||
loaded = true;
|
||||
} while(0);
|
||||
|
||||
string_clear(temp_str);
|
||||
|
||||
return loaded;
|
||||
return subghz_protocol_common_to_load_protocol_from_file(
|
||||
(SubGhzProtocolCommon*)instance, flipper_file);
|
||||
}
|
||||
|
||||
void subghz_decoder_came_to_load_protocol(SubGhzProtocolCame* instance, void* context) {
|
||||
|
||||
@@ -45,22 +45,23 @@ void subghz_protocol_came_parse(SubGhzProtocolCame* instance, bool level, uint32
|
||||
*/
|
||||
void subghz_protocol_came_to_str(SubGhzProtocolCame* instance, string_t output);
|
||||
|
||||
/** Get a string to save the protocol
|
||||
/** Adding data to a file
|
||||
*
|
||||
* @param instance - SubGhzProtocolCame instance
|
||||
* @param output - the resulting string
|
||||
* @param flipper_file - FlipperFile
|
||||
* @return bool
|
||||
*/
|
||||
void subghz_protocol_came_to_save_str(SubGhzProtocolCame* instance, string_t output);
|
||||
bool subghz_protocol_came_to_save_file(SubGhzProtocolCame* instance, FlipperFile* flipper_file);
|
||||
|
||||
/** Loading protocol from file
|
||||
*
|
||||
* @param file_worker - FileWorker file_worker
|
||||
* @param flipper_file - FlipperFile
|
||||
* @param instance - SubGhzProtocolCame instance
|
||||
* @param file_path - file path
|
||||
* @return bool
|
||||
*/
|
||||
bool subghz_protocol_came_to_load_protocol_from_file(
|
||||
FileWorker* file_worker,
|
||||
FlipperFile* flipper_file,
|
||||
SubGhzProtocolCame* instance,
|
||||
const char* file_path);
|
||||
|
||||
|
||||
@@ -177,8 +177,6 @@ void subghz_protocol_came_atomo_parse(
|
||||
ManchesterEventShortLow,
|
||||
&instance->manchester_saved_state,
|
||||
NULL);
|
||||
} else {
|
||||
instance->common.parser_step = CameAtomoDecoderStepReset;
|
||||
}
|
||||
break;
|
||||
case CameAtomoDecoderStepDecoderData:
|
||||
|
||||
@@ -36,8 +36,8 @@ SubGhzProtocolCameTwee* subghz_protocol_came_twee_alloc() {
|
||||
instance->common.te_delta = 250;
|
||||
instance->common.type_protocol = SubGhzProtocolCommonTypeStatic;
|
||||
instance->common.to_string = (SubGhzProtocolCommonToStr)subghz_protocol_came_twee_to_str;
|
||||
instance->common.to_save_string =
|
||||
(SubGhzProtocolCommonGetStrSave)subghz_protocol_came_twee_to_save_str;
|
||||
instance->common.to_save_file =
|
||||
(SubGhzProtocolCommonSaveFile)subghz_protocol_came_twee_to_save_file;
|
||||
instance->common.to_load_protocol_from_file =
|
||||
(SubGhzProtocolCommonLoadFromFile)subghz_protocol_came_twee_to_load_protocol_from_file;
|
||||
instance->common.to_load_protocol =
|
||||
@@ -247,8 +247,6 @@ void subghz_protocol_came_twee_parse(
|
||||
ManchesterEventShortLow,
|
||||
&instance->manchester_saved_state,
|
||||
NULL);
|
||||
} else {
|
||||
instance->common.parser_step = CameTweeDecoderStepReset;
|
||||
}
|
||||
break;
|
||||
case CameTweeDecoderStepDecoderData:
|
||||
@@ -327,62 +325,22 @@ void subghz_protocol_came_twee_to_str(SubGhzProtocolCameTwee* instance, string_t
|
||||
CNT_TO_DIP(instance->common.cnt));
|
||||
}
|
||||
|
||||
void subghz_protocol_came_twee_to_save_str(SubGhzProtocolCameTwee* instance, string_t output) {
|
||||
string_printf(
|
||||
output,
|
||||
"Protocol: %s\n"
|
||||
"Bit: %d\n"
|
||||
"Key: %08lX%08lX\r\n",
|
||||
instance->common.name,
|
||||
instance->common.code_last_count_bit,
|
||||
(uint32_t)(instance->common.code_last_found >> 32),
|
||||
(uint32_t)(instance->common.code_last_found & 0xFFFFFFFF));
|
||||
bool subghz_protocol_came_twee_to_save_file(
|
||||
SubGhzProtocolCameTwee* instance,
|
||||
FlipperFile* flipper_file) {
|
||||
return subghz_protocol_common_to_save_file((SubGhzProtocolCommon*)instance, flipper_file);
|
||||
}
|
||||
|
||||
bool subghz_protocol_came_twee_to_load_protocol_from_file(
|
||||
FileWorker* file_worker,
|
||||
FlipperFile* flipper_file,
|
||||
SubGhzProtocolCameTwee* instance,
|
||||
const char* file_path) {
|
||||
bool loaded = false;
|
||||
string_t temp_str;
|
||||
string_init(temp_str);
|
||||
int res = 0;
|
||||
int data = 0;
|
||||
|
||||
do {
|
||||
// Read and parse bit data from 2nd line
|
||||
if(!file_worker_read_until(file_worker, temp_str, '\n')) {
|
||||
break;
|
||||
}
|
||||
res = sscanf(string_get_cstr(temp_str), "Bit: %d\n", &data);
|
||||
if(res != 1) {
|
||||
break;
|
||||
}
|
||||
instance->common.code_last_count_bit = (uint8_t)data;
|
||||
|
||||
// Read and parse key data from 3nd line
|
||||
if(!file_worker_read_until(file_worker, temp_str, '\n')) {
|
||||
break;
|
||||
}
|
||||
// strlen("Key: ") = 5
|
||||
string_right(temp_str, 5);
|
||||
|
||||
uint8_t buf_key[8] = {0};
|
||||
if(!subghz_protocol_common_read_hex(temp_str, buf_key, 8)) {
|
||||
break;
|
||||
}
|
||||
|
||||
for(uint8_t i = 0; i < 8; i++) {
|
||||
instance->common.code_last_found = instance->common.code_last_found << 8 | buf_key[i];
|
||||
}
|
||||
|
||||
loaded = true;
|
||||
} while(0);
|
||||
|
||||
string_clear(temp_str);
|
||||
|
||||
subghz_protocol_came_twee_remote_controller(instance);
|
||||
return loaded;
|
||||
if(subghz_protocol_common_to_load_protocol_from_file(
|
||||
(SubGhzProtocolCommon*)instance, flipper_file)) {
|
||||
subghz_protocol_came_twee_remote_controller(instance);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void subghz_decoder_came_twee_to_load_protocol(SubGhzProtocolCameTwee* instance, void* context) {
|
||||
|
||||
@@ -48,22 +48,25 @@ void subghz_protocol_came_twee_parse(
|
||||
*/
|
||||
void subghz_protocol_came_twee_to_str(SubGhzProtocolCameTwee* instance, string_t output);
|
||||
|
||||
/** Get a string to save the protocol
|
||||
/** Adding data to a file
|
||||
*
|
||||
* @param instance - SubGhzProtocolCameTwee instance
|
||||
* @param output - the resulting string
|
||||
* @param flipper_file - FlipperFile
|
||||
* @return bool
|
||||
*/
|
||||
void subghz_protocol_came_twee_to_save_str(SubGhzProtocolCameTwee* instance, string_t output);
|
||||
bool subghz_protocol_came_twee_to_save_file(
|
||||
SubGhzProtocolCameTwee* instance,
|
||||
FlipperFile* flipper_file);
|
||||
|
||||
/** Loading protocol from file
|
||||
*
|
||||
* @param file_worker - FileWorker file_worker
|
||||
* @param flipper_file - FlipperFile
|
||||
* @param instance - SubGhzProtocolCameTwee instance
|
||||
* @param file_path - file path
|
||||
* @return bool
|
||||
*/
|
||||
bool subghz_protocol_came_twee_to_load_protocol_from_file(
|
||||
FileWorker* file_worker,
|
||||
FlipperFile* flipper_file,
|
||||
SubGhzProtocolCameTwee* instance,
|
||||
const char* file_path);
|
||||
|
||||
|
||||
@@ -168,3 +168,67 @@ bool subghz_protocol_common_read_hex(string_t str, uint8_t* buff, uint16_t len)
|
||||
}
|
||||
return parsed;
|
||||
}
|
||||
|
||||
bool subghz_protocol_common_to_save_file(SubGhzProtocolCommon* instance, FlipperFile* flipper_file) {
|
||||
furi_assert(instance);
|
||||
furi_assert(flipper_file);
|
||||
bool res = false;
|
||||
do {
|
||||
if(!flipper_file_write_string_cstr(flipper_file, "Protocol", instance->name)) {
|
||||
FURI_LOG_E(SUBGHZ_KEY_TAG, "Unable to add Protocol");
|
||||
break;
|
||||
}
|
||||
if(!flipper_file_write_uint32(
|
||||
flipper_file, "Bit", (uint32_t*)&instance->code_last_count_bit, 1)) {
|
||||
FURI_LOG_E(SUBGHZ_KEY_TAG, "Unable to add 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] = (instance->code_last_found >> i * 8) & 0xFF;
|
||||
}
|
||||
|
||||
if(!flipper_file_write_hex(flipper_file, "Key", key_data, sizeof(uint64_t))) {
|
||||
FURI_LOG_E(SUBGHZ_KEY_TAG, "Unable to add Key");
|
||||
break;
|
||||
}
|
||||
res = true;
|
||||
} while(false);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
bool subghz_protocol_common_to_load_protocol_from_file(
|
||||
SubGhzProtocolCommon* instance,
|
||||
FlipperFile* flipper_file) {
|
||||
furi_assert(instance);
|
||||
furi_assert(flipper_file);
|
||||
bool loaded = false;
|
||||
string_t temp_str;
|
||||
string_init(temp_str);
|
||||
uint32_t temp_data = 0;
|
||||
|
||||
do {
|
||||
if(!flipper_file_read_uint32(flipper_file, "Bit", (uint32_t*)&temp_data, 1)) {
|
||||
FURI_LOG_E(SUBGHZ_KEY_TAG, "Missing Bit");
|
||||
break;
|
||||
}
|
||||
instance->code_last_count_bit = (uint8_t)temp_data;
|
||||
|
||||
uint8_t key_data[sizeof(uint64_t)] = {0};
|
||||
if(!flipper_file_read_hex(flipper_file, "Key", key_data, sizeof(uint64_t))) {
|
||||
FURI_LOG_E(SUBGHZ_KEY_TAG, "Missing Key");
|
||||
break;
|
||||
}
|
||||
for(uint8_t i = 0; i < sizeof(uint64_t); i++) {
|
||||
instance->code_last_found = instance->code_last_found << 8 | key_data[i];
|
||||
}
|
||||
|
||||
loaded = true;
|
||||
} while(0);
|
||||
|
||||
string_clear(temp_str);
|
||||
|
||||
return loaded;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <m-string.h>
|
||||
#include <furi-hal.h>
|
||||
#include <stdint.h>
|
||||
#include "file-worker.h"
|
||||
#include <lib/flipper_file/flipper_file.h>
|
||||
|
||||
#define bit_read(value, bit) (((value) >> (bit)) & 0x01)
|
||||
#define bit_set(value, bit) ((value) |= (1UL << (bit)))
|
||||
@@ -21,6 +21,15 @@
|
||||
#define SUBGHZ_APP_EXTENSION ".sub"
|
||||
#define SUBGHZ_ENCODER_UPLOAD_MAX_SIZE 2048
|
||||
|
||||
#define SUBGHZ_KEY_TAG "SubGhzParser"
|
||||
#define SUBGHZ_KEY_FILE_VERSION 1
|
||||
#define SUBGHZ_KEY_FILE_TYPE "Flipper SubGhz Key File"
|
||||
|
||||
#define SUBGHZ_RAW_TAG "SubGhzRAW"
|
||||
#define SUBGHZ_RAW_FILE_VERSION 1
|
||||
#define SUBGHZ_RAW_FILE_TYPE "Flipper SubGhz RAW File"
|
||||
|
||||
|
||||
typedef enum {
|
||||
SubGhzProtocolCommonTypeUnknown,
|
||||
SubGhzProtocolCommonTypeStatic,
|
||||
@@ -37,11 +46,14 @@ typedef void (*SubGhzProtocolCommonCallback)(SubGhzProtocolCommon* parser, void*
|
||||
typedef void (*SubGhzProtocolCommonToStr)(SubGhzProtocolCommon* instance, string_t output);
|
||||
|
||||
//Get string to save
|
||||
typedef void (*SubGhzProtocolCommonGetStrSave)(SubGhzProtocolCommon* instance, string_t output);
|
||||
typedef bool (
|
||||
*SubGhzProtocolCommonSaveFile)(SubGhzProtocolCommon* instance, FlipperFile* flipper_file);
|
||||
|
||||
//Load protocol from file
|
||||
typedef bool (
|
||||
*SubGhzProtocolCommonLoadFromFile)(FileWorker* file_worker, SubGhzProtocolCommon* instance, const char* file_path);
|
||||
typedef bool (*SubGhzProtocolCommonLoadFromFile)(
|
||||
FlipperFile* flipper_file,
|
||||
SubGhzProtocolCommon* instance,
|
||||
const char* file_path);
|
||||
//Load protocol
|
||||
typedef void (*SubGhzProtocolCommonLoadFromRAW)(SubGhzProtocolCommon* instance, void* context);
|
||||
//Get upload encoder protocol
|
||||
@@ -77,7 +89,7 @@ struct SubGhzProtocolCommon {
|
||||
/* Dump To String */
|
||||
SubGhzProtocolCommonToStr to_string;
|
||||
/* Get string to save */
|
||||
SubGhzProtocolCommonGetStrSave to_save_string;
|
||||
SubGhzProtocolCommonSaveFile to_save_file;
|
||||
/* Load protocol from file */
|
||||
SubGhzProtocolCommonLoadFromFile to_load_protocol_from_file;
|
||||
/* Load protocol from RAW data */
|
||||
@@ -196,3 +208,21 @@ void subghz_protocol_common_to_str(SubGhzProtocolCommon* instance, string_t outp
|
||||
* @return bool
|
||||
*/
|
||||
bool subghz_protocol_common_read_hex(string_t str, uint8_t* buff, uint16_t len);
|
||||
|
||||
/** Adding data to a file
|
||||
*
|
||||
* @param instance - SubGhzProtocolCommon instance
|
||||
* @param flipper_file - FlipperFile
|
||||
* @return bool
|
||||
*/
|
||||
bool subghz_protocol_common_to_save_file(SubGhzProtocolCommon* instance, FlipperFile* flipper_file);
|
||||
|
||||
/** Loading data to a file
|
||||
*
|
||||
* @param instance - SubGhzProtocolCommon instance
|
||||
* @param flipper_file - FlipperFile
|
||||
* @return bool
|
||||
*/
|
||||
bool subghz_protocol_common_to_load_protocol_from_file(
|
||||
SubGhzProtocolCommon* instance,
|
||||
FlipperFile* flipper_file);
|
||||
|
||||
@@ -95,8 +95,6 @@ void subghz_protocol_faac_slh_parse(SubGhzProtocolFaacSLH* instance, bool level,
|
||||
if((level) && (DURATION_DIFF(duration, instance->common.te_long * 2) <
|
||||
instance->common.te_delta * 3)) {
|
||||
instance->common.parser_step = FaacSLHDecoderStepFoundPreambula;
|
||||
} else {
|
||||
instance->common.parser_step = FaacSLHDecoderStepReset;
|
||||
}
|
||||
break;
|
||||
case FaacSLHDecoderStepFoundPreambula:
|
||||
|
||||
@@ -21,8 +21,8 @@ SubGhzProtocolGateTX* subghz_protocol_gate_tx_alloc(void) {
|
||||
instance->common.te_delta = 100;
|
||||
instance->common.type_protocol = SubGhzProtocolCommonTypeStatic;
|
||||
instance->common.to_string = (SubGhzProtocolCommonToStr)subghz_protocol_gate_tx_to_str;
|
||||
instance->common.to_save_string =
|
||||
(SubGhzProtocolCommonGetStrSave)subghz_protocol_gate_tx_to_save_str;
|
||||
instance->common.to_save_file =
|
||||
(SubGhzProtocolCommonSaveFile)subghz_protocol_gate_tx_to_save_file;
|
||||
instance->common.to_load_protocol_from_file =
|
||||
(SubGhzProtocolCommonLoadFromFile)subghz_protocol_gate_tx_to_load_protocol_from_file;
|
||||
instance->common.to_load_protocol =
|
||||
@@ -94,8 +94,6 @@ void subghz_protocol_gate_tx_parse(SubGhzProtocolGateTX* instance, bool level, u
|
||||
instance->common.te_delta * 47)) {
|
||||
//Found Preambula
|
||||
instance->common.parser_step = GateTXDecoderStepFoundStartBit;
|
||||
} else {
|
||||
instance->common.parser_step = GateTXDecoderStepReset;
|
||||
}
|
||||
break;
|
||||
case GateTXDecoderStepFoundStartBit:
|
||||
@@ -169,56 +167,22 @@ void subghz_protocol_gate_tx_to_str(SubGhzProtocolGateTX* instance, string_t out
|
||||
instance->common.btn);
|
||||
}
|
||||
|
||||
void subghz_protocol_gate_tx_to_save_str(SubGhzProtocolGateTX* instance, string_t output) {
|
||||
string_printf(
|
||||
output,
|
||||
"Protocol: %s\n"
|
||||
"Bit: %d\n"
|
||||
"Key: %08lX\n",
|
||||
instance->common.name,
|
||||
instance->common.code_last_count_bit,
|
||||
(uint32_t)(instance->common.code_last_found & 0x00000000ffffffff));
|
||||
bool subghz_protocol_gate_tx_to_save_file(
|
||||
SubGhzProtocolGateTX* instance,
|
||||
FlipperFile* flipper_file) {
|
||||
return subghz_protocol_common_to_save_file((SubGhzProtocolCommon*)instance, flipper_file);
|
||||
}
|
||||
|
||||
bool subghz_protocol_gate_tx_to_load_protocol_from_file(
|
||||
FileWorker* file_worker,
|
||||
FlipperFile* flipper_file,
|
||||
SubGhzProtocolGateTX* instance,
|
||||
const char* file_path) {
|
||||
bool loaded = false;
|
||||
string_t temp_str;
|
||||
string_init(temp_str);
|
||||
int res = 0;
|
||||
int data = 0;
|
||||
|
||||
do {
|
||||
// Read and parse bit data from 2nd line
|
||||
if(!file_worker_read_until(file_worker, temp_str, '\n')) {
|
||||
break;
|
||||
}
|
||||
res = sscanf(string_get_cstr(temp_str), "Bit: %d\n", &data);
|
||||
if(res != 1) {
|
||||
break;
|
||||
}
|
||||
instance->common.code_last_count_bit = (uint8_t)data;
|
||||
|
||||
// Read and parse key data from 3nd line
|
||||
if(!file_worker_read_until(file_worker, temp_str, '\n')) {
|
||||
break;
|
||||
}
|
||||
uint32_t temp_key = 0;
|
||||
res = sscanf(string_get_cstr(temp_str), "Key: %08lX\n", &temp_key);
|
||||
if(res != 1) {
|
||||
break;
|
||||
}
|
||||
instance->common.code_last_found = (uint64_t)temp_key;
|
||||
if(subghz_protocol_common_to_load_protocol_from_file(
|
||||
(SubGhzProtocolCommon*)instance, flipper_file)) {
|
||||
subghz_protocol_gate_tx_check_remote_controller(instance);
|
||||
|
||||
loaded = true;
|
||||
} while(0);
|
||||
|
||||
string_clear(temp_str);
|
||||
|
||||
return loaded;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void subghz_decoder_gate_tx_to_load_protocol(SubGhzProtocolGateTX* instance, void* context) {
|
||||
|
||||
@@ -45,22 +45,25 @@ void subghz_protocol_gate_tx_parse(SubGhzProtocolGateTX* instance, bool level, u
|
||||
*/
|
||||
void subghz_protocol_gate_tx_to_str(SubGhzProtocolGateTX* instance, string_t output);
|
||||
|
||||
/** Get a string to save the protocol
|
||||
/** Adding data to a file
|
||||
*
|
||||
* @param instance - SubGhzProtocolGateTX instance
|
||||
* @param output - the resulting string
|
||||
* @param flipper_file - FlipperFile
|
||||
* @return bool
|
||||
*/
|
||||
void subghz_protocol_gate_tx_to_save_str(SubGhzProtocolGateTX* instance, string_t output);
|
||||
bool subghz_protocol_gate_tx_to_save_file(
|
||||
SubGhzProtocolGateTX* instance,
|
||||
FlipperFile* flipper_file);
|
||||
|
||||
/** Loading protocol from file
|
||||
*
|
||||
* @param file_worker - FileWorker file_worker
|
||||
* @param flipper_file - FlipperFile
|
||||
* @param instance - SubGhzProtocolGateTX instance
|
||||
* @param file_path - file path
|
||||
* @return bool
|
||||
*/
|
||||
bool subghz_protocol_gate_tx_to_load_protocol_from_file(
|
||||
FileWorker* file_worker,
|
||||
FlipperFile* flipper_file,
|
||||
SubGhzProtocolGateTX* instance,
|
||||
const char* file_path);
|
||||
|
||||
|
||||
@@ -24,8 +24,8 @@ SubGhzProtocolHormann* subghz_protocol_hormann_alloc() {
|
||||
instance->common.te_delta = 200;
|
||||
instance->common.type_protocol = SubGhzProtocolCommonTypeStatic;
|
||||
instance->common.to_string = (SubGhzProtocolCommonToStr)subghz_protocol_hormann_to_str;
|
||||
instance->common.to_save_string =
|
||||
(SubGhzProtocolCommonGetStrSave)subghz_protocol_hormann_to_save_str;
|
||||
instance->common.to_save_file =
|
||||
(SubGhzProtocolCommonSaveFile)subghz_protocol_hormann_to_save_file;
|
||||
instance->common.to_load_protocol_from_file =
|
||||
(SubGhzProtocolCommonLoadFromFile)subghz_protocol_hormann_to_load_protocol_from_file;
|
||||
instance->common.to_load_protocol =
|
||||
@@ -94,8 +94,6 @@ void subghz_protocol_hormann_parse(SubGhzProtocolHormann* instance, bool level,
|
||||
if((level) && (DURATION_DIFF(duration, instance->common.te_short * 64) <
|
||||
instance->common.te_delta * 64)) {
|
||||
instance->common.parser_step = HormannDecoderStepFoundStartHeader;
|
||||
} else {
|
||||
instance->common.parser_step = HormannDecoderStepReset;
|
||||
}
|
||||
break;
|
||||
case HormannDecoderStepFoundStartHeader:
|
||||
@@ -188,61 +186,18 @@ void subghz_protocol_hormann_to_str(SubGhzProtocolHormann* instance, string_t ou
|
||||
instance->common.btn);
|
||||
}
|
||||
|
||||
void subghz_protocol_hormann_to_save_str(SubGhzProtocolHormann* instance, string_t output) {
|
||||
string_printf(
|
||||
output,
|
||||
"Protocol: %s\n"
|
||||
"Bit: %d\n"
|
||||
"Key: %08lX%08lX\n",
|
||||
instance->common.name,
|
||||
instance->common.code_last_count_bit,
|
||||
(uint32_t)(instance->common.code_last_found >> 32),
|
||||
(uint32_t)(instance->common.code_last_found & 0x00000000ffffffff));
|
||||
bool subghz_protocol_hormann_to_save_file(
|
||||
SubGhzProtocolHormann* instance,
|
||||
FlipperFile* flipper_file) {
|
||||
return subghz_protocol_common_to_save_file((SubGhzProtocolCommon*)instance, flipper_file);
|
||||
}
|
||||
|
||||
bool subghz_protocol_hormann_to_load_protocol_from_file(
|
||||
FileWorker* file_worker,
|
||||
FlipperFile* flipper_file,
|
||||
SubGhzProtocolHormann* instance,
|
||||
const char* file_path) {
|
||||
bool loaded = false;
|
||||
string_t temp_str;
|
||||
string_init(temp_str);
|
||||
int res = 0;
|
||||
int data = 0;
|
||||
|
||||
do {
|
||||
// Read and parse bit data from 2nd line
|
||||
if(!file_worker_read_until(file_worker, temp_str, '\n')) {
|
||||
break;
|
||||
}
|
||||
res = sscanf(string_get_cstr(temp_str), "Bit: %d\n", &data);
|
||||
if(res != 1) {
|
||||
break;
|
||||
}
|
||||
instance->common.code_last_count_bit = (uint8_t)data;
|
||||
|
||||
// Read and parse key data from 3nd line
|
||||
if(!file_worker_read_until(file_worker, temp_str, '\n')) {
|
||||
break;
|
||||
}
|
||||
// strlen("Key: ") = 5
|
||||
string_right(temp_str, 5);
|
||||
|
||||
uint8_t buf_key[8] = {0};
|
||||
if(!subghz_protocol_common_read_hex(temp_str, buf_key, 8)) {
|
||||
break;
|
||||
}
|
||||
|
||||
for(uint8_t i = 0; i < 8; i++) {
|
||||
instance->common.code_last_found = instance->common.code_last_found << 8 | buf_key[i];
|
||||
}
|
||||
|
||||
loaded = true;
|
||||
} while(0);
|
||||
|
||||
string_clear(temp_str);
|
||||
|
||||
return loaded;
|
||||
return subghz_protocol_common_to_load_protocol_from_file(
|
||||
(SubGhzProtocolCommon*)instance, flipper_file);
|
||||
}
|
||||
|
||||
void subghz_decoder_hormann_to_load_protocol(SubGhzProtocolHormann* instance, void* context) {
|
||||
|
||||
@@ -45,22 +45,25 @@ void subghz_protocol_hormann_parse(SubGhzProtocolHormann* instance, bool level,
|
||||
*/
|
||||
void subghz_protocol_hormann_to_str(SubGhzProtocolHormann* instance, string_t output);
|
||||
|
||||
/** Get a string to save the protocol
|
||||
/** Adding data to a file
|
||||
*
|
||||
* @param instance - SubGhzProtocolHormann instance
|
||||
* @param output - the resulting string
|
||||
* @param flipper_file - FlipperFile
|
||||
* @return bool
|
||||
*/
|
||||
void subghz_protocol_hormann_to_save_str(SubGhzProtocolHormann* instance, string_t output);
|
||||
bool subghz_protocol_hormann_to_save_file(
|
||||
SubGhzProtocolHormann* instance,
|
||||
FlipperFile* flipper_file);
|
||||
|
||||
/** Loading protocol from file
|
||||
*
|
||||
* @param file_worker - FileWorker file_worker
|
||||
* @param flipper_file - FlipperFile
|
||||
* @param instance - SubGhzProtocolHormann instance
|
||||
* @param file_path - file path
|
||||
* @return bool
|
||||
*/
|
||||
bool subghz_protocol_hormann_to_load_protocol_from_file(
|
||||
FileWorker* file_worker,
|
||||
FlipperFile* flipper_file,
|
||||
SubGhzProtocolHormann* instance,
|
||||
const char* file_path);
|
||||
|
||||
|
||||
@@ -94,8 +94,6 @@ void subghz_protocol_ido_parse(SubGhzProtocolIDo* instance, bool level, uint32_t
|
||||
if((level) && (DURATION_DIFF(duration, instance->common.te_short * 10) <
|
||||
instance->common.te_delta * 5)) {
|
||||
instance->common.parser_step = IDoDecoderStepFoundPreambula;
|
||||
} else {
|
||||
instance->common.parser_step = IDoDecoderStepReset;
|
||||
}
|
||||
break;
|
||||
case IDoDecoderStepFoundPreambula:
|
||||
|
||||
@@ -32,8 +32,8 @@ SubGhzProtocolKeeloq* subghz_protocol_keeloq_alloc(SubGhzKeystore* keystore) {
|
||||
instance->common.te_delta = 140;
|
||||
instance->common.type_protocol = SubGhzProtocolCommonTypeDynamic;
|
||||
instance->common.to_string = (SubGhzProtocolCommonToStr)subghz_protocol_keeloq_to_str;
|
||||
instance->common.to_save_string =
|
||||
(SubGhzProtocolCommonGetStrSave)subghz_protocol_keeloq_to_save_str;
|
||||
instance->common.to_save_file =
|
||||
(SubGhzProtocolCommonSaveFile)subghz_protocol_keeloq_to_save_file;
|
||||
instance->common.to_load_protocol_from_file =
|
||||
(SubGhzProtocolCommonLoadFromFile)subghz_protocol_keeloq_to_load_protocol_from_file;
|
||||
instance->common.to_load_protocol =
|
||||
@@ -314,10 +314,7 @@ void subghz_protocol_keeloq_parse(SubGhzProtocolKeeloq* instance, bool level, ui
|
||||
DURATION_DIFF(duration, instance->common.te_short) < instance->common.te_delta) {
|
||||
instance->common.parser_step = KeeloqDecoderStepCheckPreambula;
|
||||
instance->common.header_count++;
|
||||
} else {
|
||||
instance->common.parser_step = KeeloqDecoderStepReset;
|
||||
}
|
||||
|
||||
break;
|
||||
case KeeloqDecoderStepCheckPreambula:
|
||||
if((!level) &&
|
||||
@@ -422,59 +419,16 @@ void subghz_protocol_keeloq_to_str(SubGhzProtocolKeeloq* instance, string_t outp
|
||||
instance->common.serial);
|
||||
}
|
||||
|
||||
void subghz_protocol_keeloq_to_save_str(SubGhzProtocolKeeloq* instance, string_t output) {
|
||||
string_printf(
|
||||
output,
|
||||
"Protocol: %s\n"
|
||||
"Bit: %d\n"
|
||||
"Key: %08lX%08lX\n",
|
||||
instance->common.name,
|
||||
instance->common.code_last_count_bit,
|
||||
(uint32_t)(instance->common.code_last_found >> 32),
|
||||
(uint32_t)(instance->common.code_last_found & 0xFFFFFFFF));
|
||||
bool subghz_protocol_keeloq_to_save_file(SubGhzProtocolKeeloq* instance, FlipperFile* flipper_file) {
|
||||
return subghz_protocol_common_to_save_file((SubGhzProtocolCommon*)instance, flipper_file);
|
||||
}
|
||||
|
||||
bool subghz_protocol_keeloq_to_load_protocol_from_file(
|
||||
FileWorker* file_worker,
|
||||
FlipperFile* flipper_file,
|
||||
SubGhzProtocolKeeloq* instance,
|
||||
const char* file_path) {
|
||||
bool loaded = false;
|
||||
string_t temp_str;
|
||||
string_init(temp_str);
|
||||
int res = 0;
|
||||
int data = 0;
|
||||
|
||||
do {
|
||||
// Read and parse bit data from 2nd line
|
||||
if(!file_worker_read_until(file_worker, temp_str, '\n')) {
|
||||
break;
|
||||
}
|
||||
res = sscanf(string_get_cstr(temp_str), "Bit: %d\n", &data);
|
||||
if(res != 1) {
|
||||
break;
|
||||
}
|
||||
instance->common.code_last_count_bit = (uint8_t)data;
|
||||
|
||||
// Read and parse key data from 3nd line
|
||||
if(!file_worker_read_until(file_worker, temp_str, '\n')) {
|
||||
break;
|
||||
}
|
||||
// strlen("Key: ") = 5
|
||||
string_right(temp_str, 5);
|
||||
|
||||
uint8_t buf_key[8] = {0};
|
||||
if(!subghz_protocol_common_read_hex(temp_str, buf_key, 8)) {
|
||||
break;
|
||||
}
|
||||
|
||||
for(uint8_t i = 0; i < 8; i++) {
|
||||
instance->common.code_last_found = instance->common.code_last_found << 8 | buf_key[i];
|
||||
}
|
||||
loaded = true;
|
||||
} while(0);
|
||||
string_clear(temp_str);
|
||||
|
||||
return loaded;
|
||||
return subghz_protocol_common_to_load_protocol_from_file(
|
||||
(SubGhzProtocolCommon*)instance, flipper_file);
|
||||
}
|
||||
|
||||
void subghz_decoder_keeloq_to_load_protocol(SubGhzProtocolKeeloq* instance, void* context) {
|
||||
|
||||
@@ -76,22 +76,23 @@ void subghz_protocol_keeloq_parse(SubGhzProtocolKeeloq* instance, bool level, ui
|
||||
*/
|
||||
void subghz_protocol_keeloq_to_str(SubGhzProtocolKeeloq* instance, string_t output);
|
||||
|
||||
/** Get a string to save the protocol
|
||||
/** Adding data to a file
|
||||
*
|
||||
* @param instance - SubGhzProtocolKeeloq instance
|
||||
* @param output - the resulting string
|
||||
* @param flipper_file - FlipperFile
|
||||
* @return bool
|
||||
*/
|
||||
void subghz_protocol_keeloq_to_save_str(SubGhzProtocolKeeloq* instance, string_t output);
|
||||
bool subghz_protocol_keeloq_to_save_file(SubGhzProtocolKeeloq* instance, FlipperFile* flipper_file);
|
||||
|
||||
/** Loading protocol from file
|
||||
*
|
||||
* @param file_worker - FileWorker file_worker
|
||||
* @param flipper_file - FlipperFile
|
||||
* @param instance - SubGhzProtocolKeeloq instance
|
||||
* @param file_path - file path
|
||||
* @return bool
|
||||
*/
|
||||
bool subghz_protocol_keeloq_to_load_protocol_from_file(
|
||||
FileWorker* file_worker,
|
||||
FlipperFile* flipper_file,
|
||||
SubGhzProtocolKeeloq* instance,
|
||||
const char* file_path);
|
||||
|
||||
|
||||
@@ -78,8 +78,6 @@ void subghz_protocol_kia_parse(SubGhzProtocolKIA* instance, bool level, uint32_t
|
||||
instance->common.parser_step = KIADecoderStepCheckPreambula;
|
||||
instance->common.te_last = duration;
|
||||
instance->common.header_count = 0;
|
||||
} else {
|
||||
instance->common.parser_step = KIADecoderStepReset;
|
||||
}
|
||||
break;
|
||||
case KIADecoderStepCheckPreambula:
|
||||
|
||||
@@ -21,8 +21,8 @@ SubGhzProtocolNeroRadio* subghz_protocol_nero_radio_alloc(void) {
|
||||
instance->common.te_delta = 80;
|
||||
instance->common.type_protocol = SubGhzProtocolCommonTypeStatic;
|
||||
instance->common.to_string = (SubGhzProtocolCommonToStr)subghz_protocol_nero_radio_to_str;
|
||||
instance->common.to_save_string =
|
||||
(SubGhzProtocolCommonGetStrSave)subghz_protocol_nero_radio_to_save_str;
|
||||
instance->common.to_save_file =
|
||||
(SubGhzProtocolCommonSaveFile)subghz_protocol_nero_radio_to_save_file;
|
||||
instance->common.to_load_protocol_from_file =
|
||||
(SubGhzProtocolCommonLoadFromFile)subghz_protocol_nero_radio_to_load_protocol_from_file;
|
||||
instance->common.to_load_protocol =
|
||||
@@ -84,23 +84,6 @@ void subghz_protocol_nero_radio_reset(SubGhzProtocolNeroRadio* instance) {
|
||||
instance->common.parser_step = NeroRadioDecoderStepReset;
|
||||
}
|
||||
|
||||
/** Analysis of received data
|
||||
*
|
||||
* @param instance SubGhzProtocolNeroRadio instance
|
||||
*/
|
||||
// void subghz_protocol_nero_radio_check_remote_controller(SubGhzProtocolNeroRadio* instance) {
|
||||
// //пока не понятно с серийником, но код статический
|
||||
// // uint64_t code_found_reverse = subghz_protocol_common_reverse_key(instance->common.code_found, instance->common.code_count_bit);
|
||||
// // uint32_t code_fix = code_found_reverse & 0xFFFFFFFF;
|
||||
// // //uint32_t code_hop = (code_found_reverse >> 24) & 0xFFFFF;
|
||||
|
||||
// // instance->common.serial = code_fix & 0xFFFFFFF;
|
||||
// // instance->common.btn = (code_fix >> 28) & 0x0F;
|
||||
|
||||
// //if (instance->common.callback) instance->common.callback((SubGhzProtocolCommon*)instance, instance->common.context);
|
||||
|
||||
// }
|
||||
|
||||
void subghz_protocol_nero_radio_parse(
|
||||
SubGhzProtocolNeroRadio* instance,
|
||||
bool level,
|
||||
@@ -112,8 +95,6 @@ void subghz_protocol_nero_radio_parse(
|
||||
instance->common.parser_step = NeroRadioDecoderStepCheckPreambula;
|
||||
instance->common.te_last = duration;
|
||||
instance->common.header_count = 0;
|
||||
} else {
|
||||
instance->common.parser_step = NeroRadioDecoderStepReset;
|
||||
}
|
||||
break;
|
||||
case NeroRadioDecoderStepCheckPreambula:
|
||||
@@ -228,64 +209,18 @@ void subghz_protocol_nero_radio_to_str(SubGhzProtocolNeroRadio* instance, string
|
||||
code_found_reverse_lo);
|
||||
}
|
||||
|
||||
void subghz_protocol_nero_radio_to_save_str(SubGhzProtocolNeroRadio* instance, string_t output) {
|
||||
uint32_t code_found_hi = instance->common.code_last_found >> 32;
|
||||
uint32_t code_found_lo = instance->common.code_last_found & 0x00000000ffffffff;
|
||||
|
||||
string_printf(
|
||||
output,
|
||||
"Protocol: %s\n"
|
||||
"Bit: %d\n"
|
||||
"Key: %08lX%08lX\n",
|
||||
instance->common.name,
|
||||
instance->common.code_last_count_bit,
|
||||
code_found_hi,
|
||||
code_found_lo);
|
||||
bool subghz_protocol_nero_radio_to_save_file(
|
||||
SubGhzProtocolNeroRadio* instance,
|
||||
FlipperFile* flipper_file) {
|
||||
return subghz_protocol_common_to_save_file((SubGhzProtocolCommon*)instance, flipper_file);
|
||||
}
|
||||
|
||||
bool subghz_protocol_nero_radio_to_load_protocol_from_file(
|
||||
FileWorker* file_worker,
|
||||
FlipperFile* flipper_file,
|
||||
SubGhzProtocolNeroRadio* instance,
|
||||
const char* file_path) {
|
||||
bool loaded = false;
|
||||
string_t temp_str;
|
||||
string_init(temp_str);
|
||||
int res = 0;
|
||||
int data = 0;
|
||||
|
||||
do {
|
||||
// Read and parse bit data from 2nd line
|
||||
if(!file_worker_read_until(file_worker, temp_str, '\n')) {
|
||||
break;
|
||||
}
|
||||
res = sscanf(string_get_cstr(temp_str), "Bit: %d\n", &data);
|
||||
if(res != 1) {
|
||||
break;
|
||||
}
|
||||
instance->common.code_last_count_bit = (uint8_t)data;
|
||||
|
||||
// Read and parse key data from 3nd line
|
||||
if(!file_worker_read_until(file_worker, temp_str, '\n')) {
|
||||
break;
|
||||
}
|
||||
// strlen("Key: ") = 5
|
||||
string_right(temp_str, 5);
|
||||
|
||||
uint8_t buf_key[8] = {0};
|
||||
if(!subghz_protocol_common_read_hex(temp_str, buf_key, 8)) {
|
||||
break;
|
||||
}
|
||||
|
||||
for(uint8_t i = 0; i < 8; i++) {
|
||||
instance->common.code_last_found = instance->common.code_last_found << 8 | buf_key[i];
|
||||
}
|
||||
|
||||
loaded = true;
|
||||
} while(0);
|
||||
|
||||
string_clear(temp_str);
|
||||
|
||||
return loaded;
|
||||
return subghz_protocol_common_to_load_protocol_from_file(
|
||||
(SubGhzProtocolCommon*)instance, flipper_file);
|
||||
}
|
||||
|
||||
void subghz_decoder_nero_radio_to_load_protocol(SubGhzProtocolNeroRadio* instance, void* context) {
|
||||
|
||||
@@ -54,22 +54,25 @@ void subghz_protocol_nero_radio_parse(
|
||||
*/
|
||||
void subghz_protocol_nero_radio_to_str(SubGhzProtocolNeroRadio* instance, string_t output);
|
||||
|
||||
/** Get a string to save the protocol
|
||||
/** Adding data to a file
|
||||
*
|
||||
* @param instance - SubGhzProtocolNeroRadio instance
|
||||
* @param output - the resulting string
|
||||
* @param flipper_file - FlipperFile
|
||||
* @return bool
|
||||
*/
|
||||
void subghz_protocol_nero_radio_to_save_str(SubGhzProtocolNeroRadio* instance, string_t output);
|
||||
bool subghz_protocol_nero_radio_to_save_file(
|
||||
SubGhzProtocolNeroRadio* instance,
|
||||
FlipperFile* flipper_file);
|
||||
|
||||
/** Loading protocol from file
|
||||
*
|
||||
* @param file_worker - FileWorker file_worker
|
||||
* @param flipper_file - FlipperFile
|
||||
* @param instance - SubGhzProtocolNeroRadio instance
|
||||
* @param file_path - file path
|
||||
* @return bool
|
||||
*/
|
||||
bool subghz_protocol_nero_radio_to_load_protocol_from_file(
|
||||
FileWorker* file_worker,
|
||||
FlipperFile* flipper_file,
|
||||
SubGhzProtocolNeroRadio* instance,
|
||||
const char* file_path);
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@ SubGhzProtocolNeroSketch* subghz_protocol_nero_sketch_alloc(void) {
|
||||
instance->common.te_delta = 150;
|
||||
instance->common.type_protocol = SubGhzProtocolCommonTypeStatic;
|
||||
instance->common.to_string = (SubGhzProtocolCommonToStr)subghz_protocol_nero_sketch_to_str;
|
||||
instance->common.to_save_string =
|
||||
(SubGhzProtocolCommonGetStrSave)subghz_protocol_nero_sketch_to_save_str;
|
||||
instance->common.to_save_file =
|
||||
(SubGhzProtocolCommonSaveFile)subghz_protocol_nero_sketch_to_save_file;
|
||||
instance->common.to_load_protocol_from_file =
|
||||
(SubGhzProtocolCommonLoadFromFile)subghz_protocol_nero_sketch_to_load_protocol_from_file;
|
||||
instance->common.to_load_protocol =
|
||||
@@ -85,23 +85,6 @@ void subghz_protocol_nero_sketch_reset(SubGhzProtocolNeroSketch* instance) {
|
||||
instance->common.parser_step = NeroSketchDecoderStepReset;
|
||||
}
|
||||
|
||||
/** Analysis of received data
|
||||
*
|
||||
* @param instance SubGhzProtocolNeroSketch instance
|
||||
*/
|
||||
// void subghz_protocol_nero_sketch_check_remote_controller(SubGhzProtocolNeroSketch* instance) {
|
||||
// //пока не понятно с серийником, но код статический
|
||||
// // uint64_t code_found_reverse = subghz_protocol_common_reverse_key(instance->common.code_found, instance->common.code_count_bit);
|
||||
// // uint32_t code_fix = code_found_reverse & 0xFFFFFFFF;
|
||||
// // //uint32_t code_hop = (code_found_reverse >> 24) & 0xFFFFF;
|
||||
|
||||
// // instance->common.serial = code_fix & 0xFFFFFFF;
|
||||
// // instance->common.btn = (code_fix >> 28) & 0x0F;
|
||||
|
||||
// //if (instance->common.callback) instance->common.callback((SubGhzProtocolCommon*)instance, instance->common.context);
|
||||
|
||||
// }
|
||||
|
||||
void subghz_protocol_nero_sketch_parse(
|
||||
SubGhzProtocolNeroSketch* instance,
|
||||
bool level,
|
||||
@@ -113,8 +96,6 @@ void subghz_protocol_nero_sketch_parse(
|
||||
instance->common.parser_step = NeroSketchDecoderStepCheckPreambula;
|
||||
instance->common.te_last = duration;
|
||||
instance->common.header_count = 0;
|
||||
} else {
|
||||
instance->common.parser_step = NeroSketchDecoderStepReset;
|
||||
}
|
||||
break;
|
||||
case NeroSketchDecoderStepCheckPreambula:
|
||||
@@ -221,60 +202,18 @@ void subghz_protocol_nero_sketch_to_str(SubGhzProtocolNeroSketch* instance, stri
|
||||
code_found_reverse_lo);
|
||||
}
|
||||
|
||||
void subghz_protocol_nero_sketch_to_save_str(SubGhzProtocolNeroSketch* instance, string_t output) {
|
||||
uint32_t code_found_hi = instance->common.code_last_found >> 32;
|
||||
uint32_t code_found_lo = instance->common.code_last_found & 0x00000000ffffffff;
|
||||
|
||||
string_printf(
|
||||
output,
|
||||
"Protocol: %s\n"
|
||||
"Bit: %d\n"
|
||||
"Key: %08lX%08lX\n",
|
||||
instance->common.name,
|
||||
instance->common.code_last_count_bit,
|
||||
code_found_hi,
|
||||
code_found_lo);
|
||||
bool subghz_protocol_nero_sketch_to_save_file(
|
||||
SubGhzProtocolNeroSketch* instance,
|
||||
FlipperFile* flipper_file) {
|
||||
return subghz_protocol_common_to_save_file((SubGhzProtocolCommon*)instance, flipper_file);
|
||||
}
|
||||
|
||||
bool subghz_protocol_nero_sketch_to_load_protocol_from_file(
|
||||
FileWorker* file_worker,
|
||||
FlipperFile* flipper_file,
|
||||
SubGhzProtocolNeroSketch* instance,
|
||||
const char* file_path) {
|
||||
bool loaded = false;
|
||||
string_t temp_str;
|
||||
string_init(temp_str);
|
||||
int res = 0;
|
||||
int data = 0;
|
||||
|
||||
do {
|
||||
// Read and parse bit data from 2nd line
|
||||
if(!file_worker_read_until(file_worker, temp_str, '\n')) {
|
||||
break;
|
||||
}
|
||||
res = sscanf(string_get_cstr(temp_str), "Bit: %d\n", &data);
|
||||
if(res != 1) {
|
||||
break;
|
||||
}
|
||||
instance->common.code_last_count_bit = (uint8_t)data;
|
||||
|
||||
// Read and parse key data from 3nd line
|
||||
if(!file_worker_read_until(file_worker, temp_str, '\n')) {
|
||||
break;
|
||||
}
|
||||
uint32_t temp_key_hi = 0;
|
||||
uint32_t temp_key_lo = 0;
|
||||
res = sscanf(string_get_cstr(temp_str), "Key: %08lX%08lX\n", &temp_key_hi, &temp_key_lo);
|
||||
if(res != 2) {
|
||||
break;
|
||||
}
|
||||
instance->common.code_last_found = (uint64_t)temp_key_hi << 32 | temp_key_lo;
|
||||
|
||||
loaded = true;
|
||||
} while(0);
|
||||
|
||||
string_clear(temp_str);
|
||||
|
||||
return loaded;
|
||||
return subghz_protocol_common_to_load_protocol_from_file(
|
||||
(SubGhzProtocolCommon*)instance, flipper_file);
|
||||
}
|
||||
|
||||
void subghz_decoder_nero_sketch_to_load_protocol(SubGhzProtocolNeroSketch* instance, void* context) {
|
||||
|
||||
@@ -54,22 +54,25 @@ void subghz_protocol_nero_sketch_parse(
|
||||
*/
|
||||
void subghz_protocol_nero_sketch_to_str(SubGhzProtocolNeroSketch* instance, string_t output);
|
||||
|
||||
/** Get a string to save the protocol
|
||||
/** Adding data to a file
|
||||
*
|
||||
* @param instance - SubGhzProtocolNeroSketch instance
|
||||
* @param output - the resulting string
|
||||
* @param flipper_file - FlipperFile
|
||||
* @return bool
|
||||
*/
|
||||
void subghz_protocol_nero_sketch_to_save_str(SubGhzProtocolNeroSketch* instance, string_t output);
|
||||
bool subghz_protocol_nero_sketch_to_save_file(
|
||||
SubGhzProtocolNeroSketch* instance,
|
||||
FlipperFile* flipper_file);
|
||||
|
||||
/** Loading protocol from file
|
||||
*
|
||||
* @param file_worker - FileWorker file_worker
|
||||
* @param flipper_file - FlipperFile
|
||||
* @param instance - SubGhzProtocolNeroSketch instance
|
||||
* @param file_path - file path
|
||||
* @return bool
|
||||
*/
|
||||
bool subghz_protocol_nero_sketch_to_load_protocol_from_file(
|
||||
FileWorker* file_worker,
|
||||
FlipperFile* flipper_file,
|
||||
SubGhzProtocolNeroSketch* instance,
|
||||
const char* file_path);
|
||||
|
||||
|
||||
@@ -27,8 +27,8 @@ SubGhzProtocolNiceFlo* subghz_protocol_nice_flo_alloc() {
|
||||
instance->common.te_delta = 200;
|
||||
instance->common.type_protocol = SubGhzProtocolCommonTypeStatic;
|
||||
instance->common.to_string = (SubGhzProtocolCommonToStr)subghz_protocol_nice_flo_to_str;
|
||||
instance->common.to_save_string =
|
||||
(SubGhzProtocolCommonGetStrSave)subghz_protocol_nice_flo_to_save_str;
|
||||
instance->common.to_save_file =
|
||||
(SubGhzProtocolCommonSaveFile)subghz_protocol_nice_flo_to_save_file;
|
||||
instance->common.to_load_protocol_from_file =
|
||||
(SubGhzProtocolCommonLoadFromFile)subghz_protocol_nice_flo_to_load_protocol_from_file;
|
||||
instance->common.to_load_protocol =
|
||||
@@ -86,8 +86,6 @@ void subghz_protocol_nice_flo_parse(SubGhzProtocolNiceFlo* instance, bool level,
|
||||
instance->common.te_delta * 36)) {
|
||||
//Found header Nice Flo
|
||||
instance->common.parser_step = NiceFloDecoderStepFoundStartBit;
|
||||
} else {
|
||||
instance->common.parser_step = NiceFloDecoderStepReset;
|
||||
}
|
||||
break;
|
||||
case NiceFloDecoderStepFoundStartBit:
|
||||
@@ -166,55 +164,18 @@ void subghz_protocol_nice_flo_to_str(SubGhzProtocolNiceFlo* instance, string_t o
|
||||
code_found_reverse_lo);
|
||||
}
|
||||
|
||||
void subghz_protocol_nice_flo_to_save_str(SubGhzProtocolNiceFlo* instance, string_t output) {
|
||||
string_printf(
|
||||
output,
|
||||
"Protocol: %s\n"
|
||||
"Bit: %d\n"
|
||||
"Key: %08lX\n",
|
||||
instance->common.name,
|
||||
instance->common.code_last_count_bit,
|
||||
(uint32_t)(instance->common.code_last_found & 0x00000000ffffffff));
|
||||
bool subghz_protocol_nice_flo_to_save_file(
|
||||
SubGhzProtocolNiceFlo* instance,
|
||||
FlipperFile* flipper_file) {
|
||||
return subghz_protocol_common_to_save_file((SubGhzProtocolCommon*)instance, flipper_file);
|
||||
}
|
||||
|
||||
bool subghz_protocol_nice_flo_to_load_protocol_from_file(
|
||||
FileWorker* file_worker,
|
||||
FlipperFile* flipper_file,
|
||||
SubGhzProtocolNiceFlo* instance,
|
||||
const char* file_path) {
|
||||
bool loaded = false;
|
||||
string_t temp_str;
|
||||
string_init(temp_str);
|
||||
int res = 0;
|
||||
int data = 0;
|
||||
|
||||
do {
|
||||
// Read and parse bit data from 2nd line
|
||||
if(!file_worker_read_until(file_worker, temp_str, '\n')) {
|
||||
break;
|
||||
}
|
||||
res = sscanf(string_get_cstr(temp_str), "Bit: %d\n", &data);
|
||||
if(res != 1) {
|
||||
break;
|
||||
}
|
||||
instance->common.code_last_count_bit = (uint8_t)data;
|
||||
|
||||
// Read and parse key data from 3nd line
|
||||
if(!file_worker_read_until(file_worker, temp_str, '\n')) {
|
||||
break;
|
||||
}
|
||||
uint32_t temp_key = 0;
|
||||
res = sscanf(string_get_cstr(temp_str), "Key: %08lX\n", &temp_key);
|
||||
if(res != 1) {
|
||||
break;
|
||||
}
|
||||
instance->common.code_last_found = (uint64_t)temp_key;
|
||||
|
||||
loaded = true;
|
||||
} while(0);
|
||||
|
||||
string_clear(temp_str);
|
||||
|
||||
return loaded;
|
||||
return subghz_protocol_common_to_load_protocol_from_file(
|
||||
(SubGhzProtocolCommon*)instance, flipper_file);
|
||||
}
|
||||
|
||||
void subghz_decoder_nice_flo_to_load_protocol(SubGhzProtocolNiceFlo* instance, void* context) {
|
||||
|
||||
@@ -45,22 +45,25 @@ void subghz_protocol_nice_flo_parse(SubGhzProtocolNiceFlo* instance, bool level,
|
||||
*/
|
||||
void subghz_protocol_nice_flo_to_str(SubGhzProtocolNiceFlo* instance, string_t output);
|
||||
|
||||
/** Get a string to save the protocol
|
||||
/** Adding data to a file
|
||||
*
|
||||
* @param instance - SubGhzProtocolNiceFlo instance
|
||||
* @param output - the resulting string
|
||||
* @param flipper_file - FlipperFile
|
||||
* @return bool
|
||||
*/
|
||||
void subghz_protocol_nice_flo_to_save_str(SubGhzProtocolNiceFlo* instance, string_t output);
|
||||
bool subghz_protocol_nice_flo_to_save_file(
|
||||
SubGhzProtocolNiceFlo* instance,
|
||||
FlipperFile* flipper_file);
|
||||
|
||||
/** Loading protocol from file
|
||||
*
|
||||
* @param file_worker - FileWorker file_worker
|
||||
* @param flipper_file - FlipperFile
|
||||
* @param instance - SubGhzProtocolNiceFlo instance
|
||||
* @param file_path - file path
|
||||
* @return bool
|
||||
*/
|
||||
bool subghz_protocol_nice_flo_to_load_protocol_from_file(
|
||||
FileWorker* file_worker,
|
||||
FlipperFile* flipper_file,
|
||||
SubGhzProtocolNiceFlo* instance,
|
||||
const char* file_path);
|
||||
|
||||
|
||||
@@ -166,8 +166,6 @@ void subghz_protocol_nice_flor_s_parse(
|
||||
instance->common.te_delta * 38)) {
|
||||
//Found start header Nice Flor-S
|
||||
instance->common.parser_step = NiceFlorSDecoderStepCheckHeader;
|
||||
} else {
|
||||
instance->common.parser_step = NiceFlorSDecoderStepReset;
|
||||
}
|
||||
break;
|
||||
case NiceFlorSDecoderStepCheckHeader:
|
||||
|
||||
@@ -141,8 +141,8 @@ SubGhzDecoderPrinceton* subghz_decoder_princeton_alloc(void) {
|
||||
instance->common.te_delta = 250; //50;
|
||||
instance->common.type_protocol = SubGhzProtocolCommonTypeStatic;
|
||||
instance->common.to_string = (SubGhzProtocolCommonToStr)subghz_decoder_princeton_to_str;
|
||||
instance->common.to_save_string =
|
||||
(SubGhzProtocolCommonGetStrSave)subghz_decoder_princeton_to_save_str;
|
||||
instance->common.to_save_file =
|
||||
(SubGhzProtocolCommonSaveFile)subghz_decoder_princeton_to_save_file;
|
||||
instance->common.to_load_protocol_from_file =
|
||||
(SubGhzProtocolCommonLoadFromFile)subghz_decoder_princeton_to_load_protocol_from_file;
|
||||
instance->common.to_load_protocol =
|
||||
@@ -210,8 +210,6 @@ void subghz_decoder_princeton_parse(
|
||||
instance->common.code_found = 0;
|
||||
instance->common.code_count_bit = 0;
|
||||
instance->te = 0;
|
||||
} else {
|
||||
instance->common.parser_step = PrincetonDecoderStepReset;
|
||||
}
|
||||
break;
|
||||
case PrincetonDecoderStepSaveDuration:
|
||||
@@ -293,68 +291,27 @@ void subghz_decoder_princeton_to_str(SubGhzDecoderPrinceton* instance, string_t
|
||||
instance->te);
|
||||
}
|
||||
|
||||
void subghz_decoder_princeton_to_save_str(SubGhzDecoderPrinceton* instance, string_t output) {
|
||||
string_printf(
|
||||
output,
|
||||
"Protocol: %s\n"
|
||||
"Bit: %d\n"
|
||||
"Te: %d\n"
|
||||
"Key: %08lX\n",
|
||||
instance->common.name,
|
||||
instance->common.code_last_count_bit,
|
||||
instance->te,
|
||||
(uint32_t)(instance->common.code_last_found & 0x00000000ffffffff));
|
||||
bool subghz_decoder_princeton_to_save_file(
|
||||
SubGhzDecoderPrinceton* instance,
|
||||
FlipperFile* flipper_file) {
|
||||
bool res = subghz_protocol_common_to_save_file((SubGhzProtocolCommon*)instance, flipper_file);
|
||||
if(res) {
|
||||
res = flipper_file_write_uint32(flipper_file, "TE", (uint32_t*)&instance->te, 1);
|
||||
if(!res) FURI_LOG_E(SUBGHZ_KEY_TAG, "Unable to add Te");
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
bool subghz_decoder_princeton_to_load_protocol_from_file(
|
||||
FileWorker* file_worker,
|
||||
FlipperFile* flipper_file,
|
||||
SubGhzDecoderPrinceton* instance,
|
||||
const char* file_path) {
|
||||
bool loaded = false;
|
||||
string_t temp_str;
|
||||
string_init(temp_str);
|
||||
int res = 0;
|
||||
int data = 0;
|
||||
|
||||
do {
|
||||
// Read and parse bit data from 2nd line
|
||||
if(!file_worker_read_until(file_worker, temp_str, '\n')) {
|
||||
break;
|
||||
}
|
||||
res = sscanf(string_get_cstr(temp_str), "Bit: %d\n", &data);
|
||||
if(res != 1) {
|
||||
break;
|
||||
}
|
||||
instance->common.code_last_count_bit = (uint8_t)data;
|
||||
|
||||
// Read and parse te data from 3nd line
|
||||
if(!file_worker_read_until(file_worker, temp_str, '\n')) {
|
||||
break;
|
||||
}
|
||||
res = sscanf(string_get_cstr(temp_str), "Te: %d\n", &data);
|
||||
if(res != 1) {
|
||||
break;
|
||||
}
|
||||
instance->te = (uint16_t)data;
|
||||
|
||||
// Read and parse key data from 4nd line
|
||||
if(!file_worker_read_until(file_worker, temp_str, '\n')) {
|
||||
break;
|
||||
}
|
||||
uint32_t temp_key = 0;
|
||||
res = sscanf(string_get_cstr(temp_str), "Key: %08lX\n", &temp_key);
|
||||
if(res != 1) {
|
||||
break;
|
||||
}
|
||||
instance->common.code_last_found = (uint64_t)temp_key;
|
||||
instance->common.serial = instance->common.code_last_found >> 4;
|
||||
instance->common.btn = (uint8_t)instance->common.code_last_found & 0x00000F;
|
||||
|
||||
loaded = true;
|
||||
} while(0);
|
||||
|
||||
string_clear(temp_str);
|
||||
|
||||
bool loaded = subghz_protocol_common_to_load_protocol_from_file(
|
||||
(SubGhzProtocolCommon*)instance, flipper_file);
|
||||
if(loaded) {
|
||||
loaded = flipper_file_read_uint32(flipper_file, "TE", (uint32_t*)&instance->te, 1);
|
||||
if(!loaded) FURI_LOG_E(SUBGHZ_KEY_TAG, "Missing TE");
|
||||
}
|
||||
return loaded;
|
||||
}
|
||||
|
||||
|
||||
@@ -100,22 +100,25 @@ void subghz_decoder_princeton_parse(
|
||||
*/
|
||||
void subghz_decoder_princeton_to_str(SubGhzDecoderPrinceton* instance, string_t output);
|
||||
|
||||
/** Get a string to save the protocol
|
||||
/** Adding data to a file
|
||||
*
|
||||
* @param instance - SubGhzDecoderPrinceton instance
|
||||
* @param output - the resulting string
|
||||
* @param flipper_file - FlipperFile
|
||||
* @return bool
|
||||
*/
|
||||
void subghz_decoder_princeton_to_save_str(SubGhzDecoderPrinceton* instance, string_t output);
|
||||
bool subghz_decoder_princeton_to_save_file(
|
||||
SubGhzDecoderPrinceton* instance,
|
||||
FlipperFile* flipper_file);
|
||||
|
||||
/** Loading protocol from file
|
||||
*
|
||||
* @param file_worker - FileWorker file_worker
|
||||
* @param flipper_file - FlipperFile
|
||||
* @param instance - SubGhzDecoderPrinceton instance
|
||||
* @param file_path - file path
|
||||
* @return bool
|
||||
*/
|
||||
bool subghz_decoder_princeton_to_load_protocol_from_file(
|
||||
FileWorker* file_worker,
|
||||
FlipperFile* flipper_file,
|
||||
SubGhzDecoderPrinceton* instance,
|
||||
const char* file_path);
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#include "subghz_protocol_raw.h"
|
||||
#include "file-worker.h"
|
||||
#include "../subghz_file_encoder_worker.h"
|
||||
|
||||
#define SUBGHZ_DOWNLOAD_MAX_SIZE 512
|
||||
@@ -7,9 +6,10 @@
|
||||
struct SubGhzProtocolRAW {
|
||||
SubGhzProtocolCommon common;
|
||||
|
||||
int16_t* upload_raw;
|
||||
int32_t* upload_raw;
|
||||
uint16_t ind_write;
|
||||
FileWorker* file_worker;
|
||||
Storage* storage;
|
||||
FlipperFile* flipper_file;
|
||||
SubGhzFileEncoderWorker* file_worker_encoder;
|
||||
uint32_t file_is_open;
|
||||
string_t file_name;
|
||||
@@ -31,7 +31,8 @@ SubGhzProtocolRAW* subghz_protocol_raw_alloc(void) {
|
||||
|
||||
instance->last_level = false;
|
||||
|
||||
instance->file_worker = file_worker_alloc(false);
|
||||
instance->storage = furi_record_open("storage");
|
||||
instance->flipper_file = flipper_file_alloc(instance->storage);
|
||||
instance->file_is_open = RAWFileIsOpenClose;
|
||||
string_init(instance->file_name);
|
||||
|
||||
@@ -55,7 +56,10 @@ SubGhzProtocolRAW* subghz_protocol_raw_alloc(void) {
|
||||
void subghz_protocol_raw_free(SubGhzProtocolRAW* instance) {
|
||||
furi_assert(instance);
|
||||
string_clear(instance->file_name);
|
||||
file_worker_free(instance->file_worker);
|
||||
|
||||
flipper_file_free(instance->flipper_file);
|
||||
furi_record_close("storage");
|
||||
|
||||
free(instance);
|
||||
}
|
||||
|
||||
@@ -120,11 +124,11 @@ void subghz_protocol_raw_to_str(SubGhzProtocolRAW* instance, string_t output) {
|
||||
string_cat_printf(output, "RAW Date");
|
||||
}
|
||||
|
||||
const char* subghz_protocol_get_last_file_name(SubGhzProtocolRAW* instance) {
|
||||
const char* subghz_protocol_raw_get_last_file_name(SubGhzProtocolRAW* instance) {
|
||||
return string_get_cstr(instance->file_name);
|
||||
}
|
||||
|
||||
void subghz_protocol_set_last_file_name(SubGhzProtocolRAW* instance, const char* name) {
|
||||
void subghz_protocol_raw_set_last_file_name(SubGhzProtocolRAW* instance, const char* name) {
|
||||
string_printf(instance->file_name, "%s", name);
|
||||
}
|
||||
|
||||
@@ -132,22 +136,21 @@ bool subghz_protocol_raw_save_to_file_init(
|
||||
SubGhzProtocolRAW* instance,
|
||||
const char* dev_name,
|
||||
uint32_t frequency,
|
||||
FuriHalSubGhzPreset preset) {
|
||||
const char* preset) {
|
||||
furi_assert(instance);
|
||||
|
||||
//instance->flipper_file = flipper_file_alloc(instance->storage);
|
||||
string_t dev_file_name;
|
||||
string_init(dev_file_name);
|
||||
string_t temp_str;
|
||||
string_init(temp_str);
|
||||
bool init = false;
|
||||
|
||||
do {
|
||||
// Create subghz folder directory if necessary
|
||||
if(!file_worker_mkdir(instance->file_worker, SUBGHZ_RAW_FOLDER)) {
|
||||
if(!storage_simply_mkdir(instance->storage, SUBGHZ_RAW_FOLDER)) {
|
||||
break;
|
||||
}
|
||||
// Create saved directory if necessary
|
||||
if(!file_worker_mkdir(instance->file_worker, SUBGHZ_RAW_PATH_FOLDER)) {
|
||||
if(!storage_simply_mkdir(instance->storage, SUBGHZ_RAW_PATH_FOLDER)) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -155,61 +158,44 @@ bool subghz_protocol_raw_save_to_file_init(
|
||||
// First remove subghz device file if it was saved
|
||||
string_printf(
|
||||
dev_file_name, "%s/%s%s", SUBGHZ_APP_PATH_FOLDER, dev_name, SUBGHZ_APP_EXTENSION);
|
||||
if(!file_worker_remove(instance->file_worker, string_get_cstr(dev_file_name))) {
|
||||
|
||||
if(!storage_simply_remove(instance->storage, string_get_cstr(dev_file_name))) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Open file
|
||||
if(!file_worker_open(
|
||||
instance->file_worker, string_get_cstr(dev_file_name), FSAM_WRITE, FSOM_CREATE_ALWAYS)) {
|
||||
if(!flipper_file_open_always(instance->flipper_file, string_get_cstr(dev_file_name))) {
|
||||
FURI_LOG_E(SUBGHZ_RAW_TAG, "Unable to open file for write: %s", dev_file_name);
|
||||
break;
|
||||
}
|
||||
|
||||
// //get the name of the next free file
|
||||
// file_worker_get_next_filename(
|
||||
// instance->file_worker,
|
||||
// SUBGHZ_RAW_PATH_FOLDER,
|
||||
// dev_name,
|
||||
// SUBGHZ_APP_EXTENSION,
|
||||
// temp_str);
|
||||
|
||||
// string_set(instance->file_name, temp_str);
|
||||
|
||||
// string_printf(
|
||||
// dev_file_name,
|
||||
// "%s/%s%s",
|
||||
// SUBGHZ_RAW_PATH_FOLDER,
|
||||
// string_get_cstr(temp_str),
|
||||
// SUBGHZ_APP_EXTENSION);
|
||||
// // Open file
|
||||
// if(!file_worker_open(
|
||||
// instance->file_worker,
|
||||
// string_get_cstr(dev_file_name),
|
||||
// FSAM_WRITE,
|
||||
// FSOM_CREATE_ALWAYS)) {
|
||||
// break;
|
||||
// }
|
||||
|
||||
//Get string frequency preset protocol
|
||||
string_printf(
|
||||
temp_str,
|
||||
"Frequency: %d\n"
|
||||
"Preset: %d\n"
|
||||
"Protocol: RAW\n",
|
||||
(int)frequency,
|
||||
(int)preset);
|
||||
|
||||
if(!file_worker_write(
|
||||
instance->file_worker, string_get_cstr(temp_str), string_size(temp_str))) {
|
||||
if(!flipper_file_write_header_cstr(
|
||||
instance->flipper_file, SUBGHZ_RAW_FILE_TYPE, SUBGHZ_RAW_FILE_VERSION)) {
|
||||
FURI_LOG_E(SUBGHZ_RAW_TAG, "Unable to add header");
|
||||
break;
|
||||
}
|
||||
|
||||
instance->upload_raw = furi_alloc(SUBGHZ_DOWNLOAD_MAX_SIZE * sizeof(uint16_t));
|
||||
if(!flipper_file_write_uint32(instance->flipper_file, "Frequency", (uint32_t*)&frequency, 1)) {
|
||||
FURI_LOG_E(SUBGHZ_RAW_TAG, "Unable to add Frequency");
|
||||
break;
|
||||
}
|
||||
|
||||
if(!flipper_file_write_string_cstr(instance->flipper_file, "Preset", preset)) {
|
||||
FURI_LOG_E(SUBGHZ_RAW_TAG, "Unable to add Preset");
|
||||
break;
|
||||
}
|
||||
|
||||
if(!flipper_file_write_string_cstr(instance->flipper_file, "Protocol", instance->common.name)) {
|
||||
FURI_LOG_E(SUBGHZ_RAW_TAG, "Unable to add Protocol");
|
||||
break;
|
||||
}
|
||||
|
||||
instance->upload_raw = furi_alloc(SUBGHZ_DOWNLOAD_MAX_SIZE * sizeof(int32_t));
|
||||
instance->file_is_open = RAWFileIsOpenWrite;
|
||||
instance->sample_write = 0;
|
||||
init = true;
|
||||
} while(0);
|
||||
|
||||
string_clear(temp_str);
|
||||
string_clear(dev_file_name);
|
||||
|
||||
return init;
|
||||
@@ -225,44 +211,23 @@ void subghz_protocol_raw_save_to_file_stop(SubGhzProtocolRAW* instance) {
|
||||
instance->upload_raw = NULL;
|
||||
}
|
||||
|
||||
file_worker_close(instance->file_worker);
|
||||
flipper_file_close(instance->flipper_file);
|
||||
instance->file_is_open = RAWFileIsOpenClose;
|
||||
}
|
||||
|
||||
bool subghz_protocol_raw_save_to_file_write(SubGhzProtocolRAW* instance) {
|
||||
furi_assert(instance);
|
||||
|
||||
string_t temp_str;
|
||||
string_init(temp_str);
|
||||
bool is_write = false;
|
||||
if(instance->file_is_open == RAWFileIsOpenWrite) {
|
||||
do {
|
||||
string_printf(temp_str, "RAW_Data: ");
|
||||
|
||||
if(!file_worker_write(
|
||||
instance->file_worker, string_get_cstr(temp_str), string_size(temp_str))) {
|
||||
break;
|
||||
}
|
||||
|
||||
for(size_t i = 0; i < instance->ind_write - 1; i++) {
|
||||
string_printf(temp_str, "%d, ", instance->upload_raw[i]);
|
||||
if(!file_worker_write(
|
||||
instance->file_worker, string_get_cstr(temp_str), string_size(temp_str))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
string_printf(temp_str, "%d\n", instance->upload_raw[instance->ind_write - 1]);
|
||||
if(!file_worker_write(
|
||||
instance->file_worker, string_get_cstr(temp_str), string_size(temp_str))) {
|
||||
break;
|
||||
}
|
||||
|
||||
if(!flipper_file_write_int32(
|
||||
instance->flipper_file, "RAW_Data", instance->upload_raw, instance->ind_write)) {
|
||||
FURI_LOG_E(SUBGHZ_RAW_TAG, "Unable to add RAW_Data");
|
||||
} else {
|
||||
instance->sample_write += instance->ind_write;
|
||||
instance->ind_write = 0;
|
||||
is_write = true;
|
||||
} while(0);
|
||||
string_clear(temp_str);
|
||||
}
|
||||
}
|
||||
return is_write;
|
||||
}
|
||||
@@ -272,9 +237,10 @@ size_t subghz_protocol_raw_get_sample_write(SubGhzProtocolRAW* instance) {
|
||||
}
|
||||
|
||||
bool subghz_protocol_raw_to_load_protocol_from_file(
|
||||
FileWorker* file_worker,
|
||||
FlipperFile* flipper_file,
|
||||
SubGhzProtocolRAW* instance,
|
||||
const char* file_path) {
|
||||
subghz_protocol_set_last_file_name(instance, file_path);
|
||||
furi_assert(file_path);
|
||||
subghz_protocol_raw_set_last_file_name(instance, file_path);
|
||||
return true;
|
||||
}
|
||||
@@ -45,20 +45,20 @@ void subghz_protocol_raw_parse(SubGhzProtocolRAW* instance, bool level, uint32_t
|
||||
*/
|
||||
void subghz_protocol_raw_to_str(SubGhzProtocolRAW* instance, string_t output);
|
||||
|
||||
const char* subghz_protocol_get_last_file_name(SubGhzProtocolRAW* instance);
|
||||
const char* subghz_protocol_raw_get_last_file_name(SubGhzProtocolRAW* instance);
|
||||
|
||||
void subghz_protocol_set_last_file_name(SubGhzProtocolRAW* instance, const char* name);
|
||||
void subghz_protocol_raw_set_last_file_name(SubGhzProtocolRAW* instance, const char* name);
|
||||
|
||||
bool subghz_protocol_raw_save_to_file_init(
|
||||
SubGhzProtocolRAW* instance,
|
||||
const char* dev_name,
|
||||
uint32_t frequency,
|
||||
FuriHalSubGhzPreset preset);
|
||||
const char* preset);
|
||||
void subghz_protocol_raw_save_to_file_stop(SubGhzProtocolRAW* instance);
|
||||
bool subghz_protocol_raw_save_to_file_write(SubGhzProtocolRAW* instance);
|
||||
size_t subghz_protocol_raw_get_sample_write(SubGhzProtocolRAW* instance);
|
||||
|
||||
bool subghz_protocol_raw_to_load_protocol_from_file(
|
||||
FileWorker* file_worker,
|
||||
FlipperFile* flipper_file,
|
||||
SubGhzProtocolRAW* instance,
|
||||
const char* file_path);
|
||||
@@ -130,8 +130,6 @@ void subghz_protocol_scher_khan_parse(
|
||||
instance->common.parser_step = ScherKhanDecoderStepCheckPreambula;
|
||||
instance->common.te_last = duration;
|
||||
instance->common.header_count = 0;
|
||||
} else {
|
||||
instance->common.parser_step = ScherKhanDecoderStepReset;
|
||||
}
|
||||
break;
|
||||
case ScherKhanDecoderStepCheckPreambula:
|
||||
|
||||
@@ -238,7 +238,6 @@ void subghz_protocol_star_line_parse(
|
||||
instance->common.parser_step = StarLineDecoderStepCheckDuration;
|
||||
}
|
||||
} else {
|
||||
instance->common.parser_step = StarLineDecoderStepReset;
|
||||
instance->common.header_count = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user