[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:
Skorpionm
2021-11-11 16:49:19 +04:00
committed by GitHub
parent 5209701add
commit ac8b1457f2
44 changed files with 721 additions and 993 deletions

View File

@@ -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) {