[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:
@@ -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) {
|
||||
|
Reference in New Issue
Block a user