SubGHz Fixes: BFT fix, other small fixes

This commit is contained in:
MX 2022-11-02 01:05:05 +03:00
parent 348c4c3b5f
commit 165d9972e7
No known key found for this signature in database
GPG key ID: 6C4C311DFD4B4AB5
4 changed files with 53 additions and 29 deletions

View file

@ -67,6 +67,8 @@ bool subghz_scene_set_seed_bft_on_event(void* context, SceneManagerEvent event)
flipper_format_write_hex(
subghz->txrx->fff_data, "Seed", seed_data, sizeof(uint32_t));
flipper_format_write_string_cstr(subghz->txrx->fff_data, "Manufacture", "BFT");
generated_protocol = true;
} else {
generated_protocol = false;

View file

@ -462,10 +462,7 @@ bool subghz_protocol_decoder_faac_slh_deserialize(void* context, FlipperFormat*
FURI_LOG_E(TAG, "Wrong number of bits in key");
break;
}
if(!flipper_format_rewind(flipper_format)) {
FURI_LOG_E(TAG, "Rewind error");
break;
}
uint8_t seed_data[sizeof(uint32_t)] = {0};
for(size_t i = 0; i < sizeof(uint32_t); i++) {
seed_data[sizeof(uint32_t) - i - 1] = (instance->generic.seed >> i * 8) & 0xFF;
@ -476,6 +473,11 @@ bool subghz_protocol_decoder_faac_slh_deserialize(void* context, FlipperFormat*
}
instance->generic.seed = seed_data[0] << 24 | seed_data[1] << 16 | seed_data[2] << 8 |
seed_data[3];
if(!flipper_format_rewind(flipper_format)) {
FURI_LOG_E(TAG, "Rewind error");
break;
}
res = true;
} while(false);

View file

@ -371,15 +371,6 @@ bool subghz_protocol_encoder_keeloq_deserialize(void* context, FlipperFormat* fl
break;
}
// Read manufacturer from file
if(flipper_format_read_string(
flipper_format, "Manufacture", instance->manufacture_from_file)) {
instance->manufacture_name = furi_string_get_cstr(instance->manufacture_from_file);
mfname = furi_string_get_cstr(instance->manufacture_from_file);
} else {
FURI_LOG_D(TAG, "ENCODER: Missing Manufacture");
}
uint8_t seed_data[sizeof(uint32_t)] = {0};
for(size_t i = 0; i < sizeof(uint32_t); i++) {
seed_data[sizeof(uint32_t) - i - 1] = (instance->generic.seed >> i * 8) & 0xFF;
@ -390,6 +381,20 @@ bool subghz_protocol_encoder_keeloq_deserialize(void* context, FlipperFormat* fl
instance->generic.seed = seed_data[0] << 24 | seed_data[1] << 16 | seed_data[2] << 8 |
seed_data[3];
// Read manufacturer from file
if(flipper_format_read_string(
flipper_format, "Manufacture", instance->manufacture_from_file)) {
instance->manufacture_name = furi_string_get_cstr(instance->manufacture_from_file);
mfname = furi_string_get_cstr(instance->manufacture_from_file);
} else {
FURI_LOG_D(TAG, "ENCODER: Missing Manufacture");
}
if(!flipper_format_rewind(flipper_format)) {
FURI_LOG_E(TAG, "Rewind error");
break;
}
subghz_protocol_keeloq_check_remote_controller(
&instance->generic, instance->keystore, &instance->manufacture_name);
@ -979,9 +984,22 @@ bool subghz_protocol_decoder_keeloq_serialize(
subghz_protocol_keeloq_check_remote_controller(
&instance->generic, instance->keystore, &instance->manufacture_name);
if(strcmp(instance->manufacture_name, "BFT") == 0) {
uint8_t seed_data[sizeof(uint32_t)] = {0};
for(size_t i = 0; i < sizeof(uint32_t); i++) {
seed_data[sizeof(uint32_t) - i - 1] = (instance->generic.seed >> i * 8) & 0xFF;
}
if(res && !flipper_format_write_hex(flipper_format, "Seed", seed_data, sizeof(uint32_t))) {
FURI_LOG_E(TAG, "DECODER Serialize: Unable to add Seed");
res = false;
}
instance->generic.seed = seed_data[0] << 24 | seed_data[1] << 16 | seed_data[2] << 8 |
seed_data[3];
}
if(res && !flipper_format_write_string_cstr(
flipper_format, "Manufacture", instance->manufacture_name)) {
FURI_LOG_E(TAG, "Unable to add manufacture name");
FURI_LOG_E(TAG, "DECODER Serialize: Unable to add manufacture name");
res = false;
}
return res;
@ -1001,19 +1019,6 @@ bool subghz_protocol_decoder_keeloq_deserialize(void* context, FlipperFormat* fl
FURI_LOG_E(TAG, "Wrong number of bits in key");
break;
}
if(!flipper_format_rewind(flipper_format)) {
FURI_LOG_E(TAG, "Rewind error");
break;
}
// Read manufacturer from file
if(flipper_format_read_string(
flipper_format, "Manufacture", instance->manufacture_from_file)) {
instance->manufacture_name = furi_string_get_cstr(instance->manufacture_from_file);
mfname = furi_string_get_cstr(instance->manufacture_from_file);
} else {
FURI_LOG_D(TAG, "DECODER: Missing Manufacture");
}
uint8_t seed_data[sizeof(uint32_t)] = {0};
for(size_t i = 0; i < sizeof(uint32_t); i++) {
@ -1024,6 +1029,21 @@ bool subghz_protocol_decoder_keeloq_deserialize(void* context, FlipperFormat* fl
}
instance->generic.seed = seed_data[0] << 24 | seed_data[1] << 16 | seed_data[2] << 8 |
seed_data[3];
// Read manufacturer from file
if(flipper_format_read_string(
flipper_format, "Manufacture", instance->manufacture_from_file)) {
instance->manufacture_name = furi_string_get_cstr(instance->manufacture_from_file);
mfname = furi_string_get_cstr(instance->manufacture_from_file);
} else {
FURI_LOG_D(TAG, "DECODER: Missing Manufacture");
}
if(!flipper_format_rewind(flipper_format)) {
FURI_LOG_E(TAG, "Rewind error");
break;
}
res = true;
} while(false);

View file

@ -92,7 +92,7 @@ void* subghz_protocol_encoder_nice_flor_s_alloc(SubGhzEnvironment* environment)
instance->nice_flor_s_rainbow_table_file_name =
subghz_environment_get_nice_flor_s_rainbow_table_file_name(environment);
if(instance->nice_flor_s_rainbow_table_file_name) {
FURI_LOG_I(
FURI_LOG_D(
TAG, "Loading rainbow table from %s", instance->nice_flor_s_rainbow_table_file_name);
}
instance->encoder.repeat = 10;
@ -343,7 +343,7 @@ void* subghz_protocol_decoder_nice_flor_s_alloc(SubGhzEnvironment* environment)
instance->nice_flor_s_rainbow_table_file_name =
subghz_environment_get_nice_flor_s_rainbow_table_file_name(environment);
if(instance->nice_flor_s_rainbow_table_file_name) {
FURI_LOG_I(
FURI_LOG_D(
TAG, "Loading rainbow table from %s", instance->nice_flor_s_rainbow_table_file_name);
}
return instance;