mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2024-11-23 10:01:58 +03:00
keeloq to kestore
This commit is contained in:
parent
2af8f00d0d
commit
2414346ec3
@ -560,6 +560,8 @@ bool subghz_txrx_get_debug_pin_state(SubGhzTxRx* instance) {
|
||||
void subghz_txrx_reset_dynamic(SubGhzTxRx* instance) {
|
||||
furi_assert(instance);
|
||||
subghz_environment_reset_keeloq(instance->environment);
|
||||
|
||||
keeloq_reset_original_btn();
|
||||
subghz_custom_btns_reset();
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
entry,status,name,type,params
|
||||
Version,+,26.5,,
|
||||
Version,+,26.6,,
|
||||
Header,+,applications/services/bt/bt_service/bt.h,,
|
||||
Header,+,applications/services/cli/cli.h,,
|
||||
Header,+,applications/services/cli/cli_vcp.h,,
|
||||
@ -2727,9 +2727,6 @@ Function,+,subghz_environment_get_keystore,SubGhzKeystore*,SubGhzEnvironment*
|
||||
Function,+,subghz_environment_get_nice_flor_s_rainbow_table_file_name,const char*,SubGhzEnvironment*
|
||||
Function,+,subghz_environment_get_protocol_name_registry,const char*,"SubGhzEnvironment*, size_t"
|
||||
Function,+,subghz_environment_get_protocol_registry,void*,SubGhzEnvironment*
|
||||
Function,-,subghz_environment_keeloq_get_kl_type,uint8_t,SubGhzEnvironment*
|
||||
Function,-,subghz_environment_keeloq_get_mf,const char*,SubGhzEnvironment*
|
||||
Function,-,subghz_environment_keeloq_set_mf,void,"SubGhzEnvironment*, const char*, uint8_t"
|
||||
Function,+,subghz_environment_load_keystore,_Bool,"SubGhzEnvironment*, const char*"
|
||||
Function,+,subghz_environment_reset_keeloq,void,SubGhzEnvironment*
|
||||
Function,+,subghz_environment_set_alutech_at_4n_rainbow_table_file_name,void,"SubGhzEnvironment*, const char*"
|
||||
@ -2742,6 +2739,7 @@ Function,-,subghz_keystore_get_data,SubGhzKeyArray_t*,SubGhzKeystore*
|
||||
Function,-,subghz_keystore_load,_Bool,"SubGhzKeystore*, const char*"
|
||||
Function,-,subghz_keystore_raw_encrypted_save,_Bool,"const char*, const char*, uint8_t*"
|
||||
Function,-,subghz_keystore_raw_get_data,_Bool,"const char*, size_t, uint8_t*, size_t"
|
||||
Function,-,subghz_keystore_reset_kl,void,SubGhzKeystore*
|
||||
Function,-,subghz_keystore_save,_Bool,"SubGhzKeystore*, const char*, uint8_t*"
|
||||
Function,-,subghz_protocol_alutech_at_4n_create_data,_Bool,"void*, FlipperFormat*, uint32_t, uint8_t, uint16_t, SubGhzRadioPreset*"
|
||||
Function,+,subghz_protocol_blocks_add_bit,void,"SubGhzBlockDecoder*, uint8_t"
|
||||
|
|
@ -124,25 +124,5 @@ const char*
|
||||
void subghz_environment_reset_keeloq(SubGhzEnvironment* instance) {
|
||||
furi_assert(instance);
|
||||
|
||||
instance->mfname = "";
|
||||
instance->kl_type = 0;
|
||||
subghz_keystore_reset_kl(instance->keystore);
|
||||
}
|
||||
|
||||
const char* subghz_environment_keeloq_get_mf(SubGhzEnvironment* instance) {
|
||||
furi_assert(instance);
|
||||
|
||||
return instance->mfname;
|
||||
}
|
||||
|
||||
uint8_t subghz_environment_keeloq_get_kl_type(SubGhzEnvironment* instance) {
|
||||
furi_assert(instance);
|
||||
|
||||
return instance->kl_type;
|
||||
}
|
||||
|
||||
void subghz_environment_keeloq_set_mf(SubGhzEnvironment* instance, const char* mf, uint8_t kl_type) {
|
||||
furi_assert(instance);
|
||||
|
||||
instance->mfname = mf;
|
||||
instance->kl_type = kl_type;
|
||||
}
|
@ -116,12 +116,6 @@ const char* subghz_environment_get_protocol_name_registry(SubGhzEnvironment* ins
|
||||
*/
|
||||
void subghz_environment_reset_keeloq(SubGhzEnvironment* instance);
|
||||
|
||||
// Private
|
||||
|
||||
const char* subghz_environment_keeloq_get_mf(SubGhzEnvironment* instance);
|
||||
uint8_t subghz_environment_keeloq_get_kl_type(SubGhzEnvironment* instance);
|
||||
void subghz_environment_keeloq_set_mf(SubGhzEnvironment* instance, const char* mf, uint8_t kl_type);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "../blocks/math.h"
|
||||
|
||||
#include "../blocks/custom_btn.h"
|
||||
#include "../subghz_keystore_i.h"
|
||||
|
||||
#define TAG "SubGhzProtocolKeeloq"
|
||||
|
||||
@ -93,8 +94,6 @@ const SubGhzProtocol subghz_protocol_keeloq = {
|
||||
static uint8_t klq_prog_mode;
|
||||
static uint16_t temp_counter;
|
||||
|
||||
static SubGhzEnvironment* kl_environment;
|
||||
|
||||
void keeloq_reset_original_btn() {
|
||||
subghz_custom_btns_reset();
|
||||
temp_counter = 0;
|
||||
@ -119,8 +118,6 @@ void* subghz_protocol_encoder_keeloq_alloc(SubGhzEnvironment* environment) {
|
||||
instance->generic.protocol_name = instance->base.protocol->name;
|
||||
instance->keystore = subghz_environment_get_keystore(environment);
|
||||
|
||||
kl_environment = environment;
|
||||
|
||||
instance->encoder.repeat = 100;
|
||||
instance->encoder.size_upload = 256;
|
||||
instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration));
|
||||
@ -246,7 +243,7 @@ static bool subghz_protocol_keeloq_gen_data(
|
||||
decrypt = btn << 28 | (0x000) << 16 | instance->generic.cnt;
|
||||
// Beninca / Allmatic -> no serial - simple XOR
|
||||
}
|
||||
uint8_t kl_type_en = subghz_environment_keeloq_get_kl_type(kl_environment);
|
||||
uint8_t kl_type_en = instance->keystore->kl_type;
|
||||
for
|
||||
M_EACH(
|
||||
manufacture_code,
|
||||
@ -501,10 +498,7 @@ SubGhzProtocolStatus
|
||||
if(flipper_format_read_string(
|
||||
flipper_format, "Manufacture", instance->manufacture_from_file)) {
|
||||
instance->manufacture_name = furi_string_get_cstr(instance->manufacture_from_file);
|
||||
subghz_environment_keeloq_set_mf(
|
||||
kl_environment,
|
||||
furi_string_get_cstr(instance->manufacture_from_file),
|
||||
subghz_environment_keeloq_get_kl_type(kl_environment));
|
||||
instance->keystore->mfname = instance->manufacture_name;
|
||||
} else {
|
||||
FURI_LOG_D(TAG, "ENCODER: Missing Manufacture");
|
||||
}
|
||||
@ -576,7 +570,6 @@ void* subghz_protocol_decoder_keeloq_alloc(SubGhzEnvironment* environment) {
|
||||
instance->keystore = subghz_environment_get_keystore(environment);
|
||||
instance->manufacture_from_file = furi_string_alloc();
|
||||
|
||||
kl_environment = environment;
|
||||
klq_prog_mode = KEELOQ_PROG_MODE_OFF;
|
||||
|
||||
return instance;
|
||||
@ -594,7 +587,9 @@ void subghz_protocol_decoder_keeloq_reset(void* context) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolDecoderKeeloq* instance = context;
|
||||
instance->decoder.parser_step = KeeloqDecoderStepReset;
|
||||
subghz_environment_reset_keeloq(kl_environment);
|
||||
// TODO
|
||||
instance->keystore->mfname = "";
|
||||
instance->keystore->kl_type = 0;
|
||||
}
|
||||
|
||||
void subghz_protocol_decoder_keeloq_feed(void* context, bool level, uint32_t duration) {
|
||||
@ -742,8 +737,7 @@ static uint8_t subghz_protocol_keeloq_check_remote_controller_selector(
|
||||
// mfname = "";
|
||||
// }
|
||||
|
||||
const char* mfname = subghz_environment_keeloq_get_mf(kl_environment);
|
||||
uint8_t kl_type_en = subghz_environment_keeloq_get_kl_type(kl_environment);
|
||||
const char* mfname = keystore->mfname;
|
||||
|
||||
if(strcmp(mfname, "Unknown") == 0) {
|
||||
return 1;
|
||||
@ -759,8 +753,7 @@ static uint8_t subghz_protocol_keeloq_check_remote_controller_selector(
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, manufacture_code->key);
|
||||
if(subghz_protocol_keeloq_check_decrypt(instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = furi_string_get_cstr(manufacture_code->name);
|
||||
subghz_environment_keeloq_set_mf(
|
||||
kl_environment, *manufacture_name, kl_type_en);
|
||||
keystore->mfname = *manufacture_name;
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
@ -772,8 +765,7 @@ static uint8_t subghz_protocol_keeloq_check_remote_controller_selector(
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, man);
|
||||
if(subghz_protocol_keeloq_check_decrypt(instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = furi_string_get_cstr(manufacture_code->name);
|
||||
subghz_environment_keeloq_set_mf(
|
||||
kl_environment, *manufacture_name, kl_type_en);
|
||||
keystore->mfname = *manufacture_name;
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
@ -783,8 +775,7 @@ static uint8_t subghz_protocol_keeloq_check_remote_controller_selector(
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, man);
|
||||
if(subghz_protocol_keeloq_check_decrypt(instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = furi_string_get_cstr(manufacture_code->name);
|
||||
subghz_environment_keeloq_set_mf(
|
||||
kl_environment, *manufacture_name, kl_type_en);
|
||||
keystore->mfname = *manufacture_name;
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
@ -794,8 +785,7 @@ static uint8_t subghz_protocol_keeloq_check_remote_controller_selector(
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, man);
|
||||
if(subghz_protocol_keeloq_check_decrypt(instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = furi_string_get_cstr(manufacture_code->name);
|
||||
subghz_environment_keeloq_set_mf(
|
||||
kl_environment, *manufacture_name, kl_type_en);
|
||||
keystore->mfname = *manufacture_name;
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
@ -805,8 +795,7 @@ static uint8_t subghz_protocol_keeloq_check_remote_controller_selector(
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, man);
|
||||
if(subghz_protocol_keeloq_check_decrypt(instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = furi_string_get_cstr(manufacture_code->name);
|
||||
subghz_environment_keeloq_set_mf(
|
||||
kl_environment, *manufacture_name, kl_type_en);
|
||||
keystore->mfname = *manufacture_name;
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
@ -816,8 +805,7 @@ static uint8_t subghz_protocol_keeloq_check_remote_controller_selector(
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, man);
|
||||
if(subghz_protocol_keeloq_check_decrypt(instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = furi_string_get_cstr(manufacture_code->name);
|
||||
subghz_environment_keeloq_set_mf(
|
||||
kl_environment, *manufacture_name, kl_type_en);
|
||||
keystore->mfname = *manufacture_name;
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
@ -827,8 +815,7 @@ static uint8_t subghz_protocol_keeloq_check_remote_controller_selector(
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, man);
|
||||
if(subghz_protocol_keeloq_check_decrypt(instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = furi_string_get_cstr(manufacture_code->name);
|
||||
subghz_environment_keeloq_set_mf(
|
||||
kl_environment, *manufacture_name, kl_type_en);
|
||||
keystore->mfname = *manufacture_name;
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
@ -837,7 +824,8 @@ static uint8_t subghz_protocol_keeloq_check_remote_controller_selector(
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, manufacture_code->key);
|
||||
if(subghz_protocol_keeloq_check_decrypt(instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = furi_string_get_cstr(manufacture_code->name);
|
||||
subghz_environment_keeloq_set_mf(kl_environment, *manufacture_name, 1);
|
||||
keystore->mfname = *manufacture_name;
|
||||
keystore->kl_type = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -852,7 +840,8 @@ static uint8_t subghz_protocol_keeloq_check_remote_controller_selector(
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, man_rev);
|
||||
if(subghz_protocol_keeloq_check_decrypt(instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = furi_string_get_cstr(manufacture_code->name);
|
||||
subghz_environment_keeloq_set_mf(kl_environment, *manufacture_name, 1);
|
||||
keystore->mfname = *manufacture_name;
|
||||
keystore->kl_type = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -864,7 +853,8 @@ static uint8_t subghz_protocol_keeloq_check_remote_controller_selector(
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, man);
|
||||
if(subghz_protocol_keeloq_check_decrypt(instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = furi_string_get_cstr(manufacture_code->name);
|
||||
subghz_environment_keeloq_set_mf(kl_environment, *manufacture_name, 2);
|
||||
keystore->mfname = *manufacture_name;
|
||||
keystore->kl_type = 2;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -873,7 +863,8 @@ static uint8_t subghz_protocol_keeloq_check_remote_controller_selector(
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, man);
|
||||
if(subghz_protocol_keeloq_check_decrypt(instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = furi_string_get_cstr(manufacture_code->name);
|
||||
subghz_environment_keeloq_set_mf(kl_environment, *manufacture_name, 2);
|
||||
keystore->mfname = *manufacture_name;
|
||||
keystore->kl_type = 2;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -883,7 +874,8 @@ static uint8_t subghz_protocol_keeloq_check_remote_controller_selector(
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, man);
|
||||
if(subghz_protocol_keeloq_check_decrypt(instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = furi_string_get_cstr(manufacture_code->name);
|
||||
subghz_environment_keeloq_set_mf(kl_environment, *manufacture_name, 3);
|
||||
keystore->mfname = *manufacture_name;
|
||||
keystore->kl_type = 3;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -893,7 +885,8 @@ static uint8_t subghz_protocol_keeloq_check_remote_controller_selector(
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, man);
|
||||
if(subghz_protocol_keeloq_check_decrypt(instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = furi_string_get_cstr(manufacture_code->name);
|
||||
subghz_environment_keeloq_set_mf(kl_environment, *manufacture_name, 3);
|
||||
keystore->mfname = *manufacture_name;
|
||||
keystore->kl_type = 3;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -903,7 +896,8 @@ static uint8_t subghz_protocol_keeloq_check_remote_controller_selector(
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, man);
|
||||
if(subghz_protocol_keeloq_check_decrypt(instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = furi_string_get_cstr(manufacture_code->name);
|
||||
subghz_environment_keeloq_set_mf(kl_environment, *manufacture_name, 4);
|
||||
keystore->mfname = *manufacture_name;
|
||||
keystore->kl_type = 4;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -912,7 +906,8 @@ static uint8_t subghz_protocol_keeloq_check_remote_controller_selector(
|
||||
decrypt = subghz_protocol_keeloq_common_decrypt(hop, man);
|
||||
if(subghz_protocol_keeloq_check_decrypt(instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = furi_string_get_cstr(manufacture_code->name);
|
||||
subghz_environment_keeloq_set_mf(kl_environment, *manufacture_name, 4);
|
||||
keystore->mfname = *manufacture_name;
|
||||
keystore->kl_type = 4;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -922,7 +917,7 @@ static uint8_t subghz_protocol_keeloq_check_remote_controller_selector(
|
||||
}
|
||||
|
||||
*manufacture_name = "Unknown";
|
||||
subghz_environment_keeloq_set_mf(kl_environment, "Unknown", kl_type_en);
|
||||
keystore->mfname = "Unknown";
|
||||
instance->cnt = 0;
|
||||
|
||||
return 0;
|
||||
@ -935,7 +930,6 @@ static void subghz_protocol_keeloq_check_remote_controller(
|
||||
uint64_t key = subghz_protocol_blocks_reverse_key(instance->data, instance->data_count_bit);
|
||||
uint32_t key_fix = key >> 32;
|
||||
uint32_t key_hop = key & 0x00000000ffffffff;
|
||||
uint8_t kl_type_en = subghz_environment_keeloq_get_kl_type(kl_environment);
|
||||
|
||||
// If we are in BFT / Aprimatic programming mode we will set previous remembered counter and skip mf keys check
|
||||
if(klq_prog_mode == KEELOQ_PROG_MODE_OFF) {
|
||||
@ -943,11 +937,11 @@ static void subghz_protocol_keeloq_check_remote_controller(
|
||||
if((key_hop >> 24) == ((key_hop >> 16) & 0x00ff) &&
|
||||
(key_fix >> 28) == ((key_hop >> 12) & 0x0f) && (key_hop & 0xFFF) == 0x404) {
|
||||
*manufacture_name = "AN-Motors";
|
||||
subghz_environment_keeloq_set_mf(kl_environment, *manufacture_name, kl_type_en);
|
||||
keystore->mfname = *manufacture_name;
|
||||
instance->cnt = key_hop >> 16;
|
||||
} else if((key_hop & 0xFFF) == (0x000) && (key_fix >> 28) == ((key_hop >> 12) & 0x0f)) {
|
||||
*manufacture_name = "HCS101";
|
||||
subghz_environment_keeloq_set_mf(kl_environment, *manufacture_name, kl_type_en);
|
||||
keystore->mfname = *manufacture_name;
|
||||
instance->cnt = key_hop >> 16;
|
||||
} else {
|
||||
subghz_protocol_keeloq_check_remote_controller_selector(
|
||||
@ -957,11 +951,11 @@ static void subghz_protocol_keeloq_check_remote_controller(
|
||||
|
||||
} else if(klq_prog_mode == KEELOQ_PROG_MODE_BFT) {
|
||||
*manufacture_name = "BFT";
|
||||
subghz_environment_keeloq_set_mf(kl_environment, *manufacture_name, kl_type_en);
|
||||
keystore->mfname = *manufacture_name;
|
||||
instance->cnt = temp_counter;
|
||||
} else if(klq_prog_mode == KEELOQ_PROG_MODE_APRIMATIC) {
|
||||
*manufacture_name = "Aprimatic";
|
||||
subghz_environment_keeloq_set_mf(kl_environment, *manufacture_name, kl_type_en);
|
||||
keystore->mfname = *manufacture_name;
|
||||
instance->cnt = temp_counter;
|
||||
}
|
||||
|
||||
@ -1053,10 +1047,7 @@ SubGhzProtocolStatus
|
||||
if(flipper_format_read_string(
|
||||
flipper_format, "Manufacture", instance->manufacture_from_file)) {
|
||||
instance->manufacture_name = furi_string_get_cstr(instance->manufacture_from_file);
|
||||
subghz_environment_keeloq_set_mf(
|
||||
kl_environment,
|
||||
furi_string_get_cstr(instance->manufacture_from_file),
|
||||
subghz_environment_keeloq_get_kl_type(kl_environment));
|
||||
instance->keystore->mfname = instance->manufacture_name;
|
||||
} else {
|
||||
FURI_LOG_D(TAG, "DECODER: Missing Manufacture");
|
||||
}
|
||||
|
@ -10,6 +10,8 @@
|
||||
#include "../blocks/generic.h"
|
||||
#include "../blocks/math.h"
|
||||
|
||||
#include "../subghz_keystore_i.h"
|
||||
|
||||
#define TAG "SubGhzProtocolStarLine"
|
||||
|
||||
static const SubGhzBlockConst subghz_protocol_star_line_const = {
|
||||
@ -83,8 +85,6 @@ const SubGhzProtocol subghz_protocol_star_line = {
|
||||
.encoder = &subghz_protocol_star_line_encoder,
|
||||
};
|
||||
|
||||
static SubGhzEnvironment* kl_environment;
|
||||
|
||||
/**
|
||||
* Analysis of received data
|
||||
* @param instance Pointer to a SubGhzBlockGeneric* instance
|
||||
@ -103,8 +103,6 @@ void* subghz_protocol_encoder_star_line_alloc(SubGhzEnvironment* environment) {
|
||||
instance->generic.protocol_name = instance->base.protocol->name;
|
||||
instance->keystore = subghz_environment_get_keystore(environment);
|
||||
|
||||
kl_environment = environment;
|
||||
|
||||
instance->manufacture_from_file = furi_string_alloc();
|
||||
|
||||
instance->encoder.repeat = 10;
|
||||
@ -155,7 +153,7 @@ static bool
|
||||
instance->generic.data, instance->generic.data_count_bit);
|
||||
hop = code_found_reverse & 0x00000000ffffffff;
|
||||
} else {
|
||||
uint8_t kl_type_en = subghz_environment_keeloq_get_kl_type(kl_environment);
|
||||
uint8_t kl_type_en = instance->keystore->kl_type;
|
||||
for
|
||||
M_EACH(
|
||||
manufacture_code,
|
||||
@ -293,10 +291,7 @@ SubGhzProtocolStatus
|
||||
if(flipper_format_read_string(
|
||||
flipper_format, "Manufacture", instance->manufacture_from_file)) {
|
||||
instance->manufacture_name = furi_string_get_cstr(instance->manufacture_from_file);
|
||||
subghz_environment_keeloq_set_mf(
|
||||
kl_environment,
|
||||
furi_string_get_cstr(instance->manufacture_from_file),
|
||||
subghz_environment_keeloq_get_kl_type(kl_environment));
|
||||
instance->keystore->mfname = instance->manufacture_name;
|
||||
} else {
|
||||
FURI_LOG_D(TAG, "ENCODER: Missing Manufacture");
|
||||
}
|
||||
@ -362,7 +357,6 @@ void* subghz_protocol_decoder_star_line_alloc(SubGhzEnvironment* environment) {
|
||||
instance->manufacture_from_file = furi_string_alloc();
|
||||
|
||||
instance->keystore = subghz_environment_get_keystore(environment);
|
||||
kl_environment = environment;
|
||||
|
||||
return instance;
|
||||
}
|
||||
@ -379,7 +373,9 @@ void subghz_protocol_decoder_star_line_reset(void* context) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolDecoderStarLine* instance = context;
|
||||
instance->decoder.parser_step = StarLineDecoderStepReset;
|
||||
subghz_environment_reset_keeloq(kl_environment);
|
||||
// TODO
|
||||
instance->keystore->mfname = "";
|
||||
instance->keystore->kl_type = 0;
|
||||
}
|
||||
|
||||
void subghz_protocol_decoder_star_line_feed(void* context, bool level, uint32_t duration) {
|
||||
@ -524,8 +520,7 @@ static uint8_t subghz_protocol_star_line_check_remote_controller_selector(
|
||||
// mfname = "";
|
||||
// }
|
||||
|
||||
const char* mfname = subghz_environment_keeloq_get_mf(kl_environment);
|
||||
uint8_t kl_type_en = subghz_environment_keeloq_get_kl_type(kl_environment);
|
||||
const char* mfname = keystore->mfname;
|
||||
|
||||
if(strcmp(mfname, "Unknown") == 0) {
|
||||
return 1;
|
||||
@ -542,8 +537,7 @@ static uint8_t subghz_protocol_star_line_check_remote_controller_selector(
|
||||
if(subghz_protocol_star_line_check_decrypt(
|
||||
instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = furi_string_get_cstr(manufacture_code->name);
|
||||
subghz_environment_keeloq_set_mf(
|
||||
kl_environment, *manufacture_name, kl_type_en);
|
||||
keystore->mfname = *manufacture_name;
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
@ -556,8 +550,7 @@ static uint8_t subghz_protocol_star_line_check_remote_controller_selector(
|
||||
if(subghz_protocol_star_line_check_decrypt(
|
||||
instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = furi_string_get_cstr(manufacture_code->name);
|
||||
subghz_environment_keeloq_set_mf(
|
||||
kl_environment, *manufacture_name, kl_type_en);
|
||||
keystore->mfname = *manufacture_name;
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
@ -567,7 +560,8 @@ static uint8_t subghz_protocol_star_line_check_remote_controller_selector(
|
||||
if(subghz_protocol_star_line_check_decrypt(
|
||||
instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = furi_string_get_cstr(manufacture_code->name);
|
||||
subghz_environment_keeloq_set_mf(kl_environment, *manufacture_name, 1);
|
||||
keystore->mfname = *manufacture_name;
|
||||
keystore->kl_type = 1;
|
||||
return 1;
|
||||
}
|
||||
// Check for mirrored man
|
||||
@ -581,7 +575,8 @@ static uint8_t subghz_protocol_star_line_check_remote_controller_selector(
|
||||
if(subghz_protocol_star_line_check_decrypt(
|
||||
instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = furi_string_get_cstr(manufacture_code->name);
|
||||
subghz_environment_keeloq_set_mf(kl_environment, *manufacture_name, 1);
|
||||
keystore->mfname = *manufacture_name;
|
||||
keystore->kl_type = 1;
|
||||
return 1;
|
||||
}
|
||||
//###########################
|
||||
@ -593,7 +588,8 @@ static uint8_t subghz_protocol_star_line_check_remote_controller_selector(
|
||||
if(subghz_protocol_star_line_check_decrypt(
|
||||
instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = furi_string_get_cstr(manufacture_code->name);
|
||||
subghz_environment_keeloq_set_mf(kl_environment, *manufacture_name, 2);
|
||||
keystore->mfname = *manufacture_name;
|
||||
keystore->kl_type = 2;
|
||||
return 1;
|
||||
}
|
||||
// Check for mirrored man
|
||||
@ -603,7 +599,8 @@ static uint8_t subghz_protocol_star_line_check_remote_controller_selector(
|
||||
if(subghz_protocol_star_line_check_decrypt(
|
||||
instance, decrypt, btn, end_serial)) {
|
||||
*manufacture_name = furi_string_get_cstr(manufacture_code->name);
|
||||
subghz_environment_keeloq_set_mf(kl_environment, *manufacture_name, 2);
|
||||
keystore->mfname = *manufacture_name;
|
||||
keystore->kl_type = 2;
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
@ -612,7 +609,7 @@ static uint8_t subghz_protocol_star_line_check_remote_controller_selector(
|
||||
}
|
||||
|
||||
*manufacture_name = "Unknown";
|
||||
subghz_environment_keeloq_set_mf(kl_environment, "Unknown", kl_type_en);
|
||||
keystore->mfname = "Unknown";
|
||||
instance->cnt = 0;
|
||||
|
||||
return 0;
|
||||
@ -688,10 +685,7 @@ SubGhzProtocolStatus
|
||||
if(flipper_format_read_string(
|
||||
flipper_format, "Manufacture", instance->manufacture_from_file)) {
|
||||
instance->manufacture_name = furi_string_get_cstr(instance->manufacture_from_file);
|
||||
subghz_environment_keeloq_set_mf(
|
||||
kl_environment,
|
||||
furi_string_get_cstr(instance->manufacture_from_file),
|
||||
subghz_environment_keeloq_get_kl_type(kl_environment));
|
||||
instance->keystore->mfname = instance->manufacture_name;
|
||||
} else {
|
||||
FURI_LOG_D(TAG, "DECODER: Missing Manufacture");
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "subghz_keystore.h"
|
||||
#include "subghz_keystore_i.h"
|
||||
|
||||
#include <furi.h>
|
||||
#include <furi_hal.h>
|
||||
@ -26,18 +27,25 @@ typedef enum {
|
||||
SubGhzKeystoreEncryptionAES256,
|
||||
} SubGhzKeystoreEncryption;
|
||||
|
||||
struct SubGhzKeystore {
|
||||
SubGhzKeyArray_t data;
|
||||
};
|
||||
|
||||
|
||||
SubGhzKeystore* subghz_keystore_alloc() {
|
||||
SubGhzKeystore* instance = malloc(sizeof(SubGhzKeystore));
|
||||
|
||||
SubGhzKeyArray_init(instance->data);
|
||||
|
||||
subghz_keystore_reset_kl(instance);
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
void subghz_keystore_reset_kl(SubGhzKeystore* instance) {
|
||||
furi_assert(instance);
|
||||
|
||||
instance->mfname = "";
|
||||
instance->kl_type = 0;
|
||||
}
|
||||
|
||||
void subghz_keystore_free(SubGhzKeystore* instance) {
|
||||
furi_assert(instance);
|
||||
|
||||
|
@ -75,6 +75,8 @@ bool subghz_keystore_raw_encrypted_save(
|
||||
*/
|
||||
bool subghz_keystore_raw_get_data(const char* file_name, size_t offset, uint8_t* data, size_t len);
|
||||
|
||||
void subghz_keystore_reset_kl(SubGhzKeystore* instance);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
9
lib/subghz/subghz_keystore_i.h
Normal file
9
lib/subghz/subghz_keystore_i.h
Normal file
@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <m-array.h>
|
||||
|
||||
struct SubGhzKeystore {
|
||||
SubGhzKeyArray_t data;
|
||||
const char* mfname;
|
||||
uint8_t kl_type;
|
||||
};
|
Loading…
Reference in New Issue
Block a user