mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-24 03:29:57 -07:00
Update faac_slh.c
Seed now is saving properly, no deletion after reboot.
This commit is contained in:
@@ -78,7 +78,7 @@ const SubGhzProtocol subghz_protocol_faac_slh = {
|
||||
.encoder = &subghz_protocol_faac_slh_encoder,
|
||||
};
|
||||
|
||||
static uint32_t seed_global;
|
||||
//static uint32_t seed_global;
|
||||
|
||||
/**
|
||||
* Analysis of received data
|
||||
@@ -169,7 +169,7 @@ bool subghz_protocol_faac_slh_create_data(
|
||||
instance->generic.btn = btn;
|
||||
instance->generic.cnt = cnt;
|
||||
instance->generic.seed = seed;
|
||||
seed_global = instance->generic.seed;
|
||||
//seed_global = instance->generic.seed;
|
||||
instance->manufacture_name = manufacture_name;
|
||||
instance->generic.data_count_bit = 64;
|
||||
bool res = subghz_protocol_faac_slh_gen_data(instance);
|
||||
@@ -232,6 +232,16 @@ bool subghz_protocol_encoder_faac_slh_deserialize(void* context, FlipperFormat*
|
||||
FURI_LOG_E(TAG, "Deserialize 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;
|
||||
}
|
||||
if(!flipper_format_read_hex(flipper_format, "Seed", seed_data, sizeof(uint32_t))) {
|
||||
FURI_LOG_E(TAG, "Missing Seed");
|
||||
break;
|
||||
}
|
||||
instance->generic.seed = seed_data[0] << 24 | seed_data[1] << 16 | seed_data[2] << 8 | seed_data[3] ;
|
||||
FURI_LOG_I(TAG, "encoder seed = %8X", instance->generic.seed);
|
||||
|
||||
subghz_protocol_faac_slh_check_remote_controller(
|
||||
&instance->generic, instance->keystore, &instance->manufacture_name);
|
||||
@@ -254,16 +264,7 @@ bool subghz_protocol_encoder_faac_slh_deserialize(void* context, FlipperFormat*
|
||||
FURI_LOG_E(TAG, "Unable to add Key");
|
||||
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;
|
||||
}
|
||||
if(!flipper_format_read_hex(flipper_format, "Seed", seed_data, sizeof(uint32_t))) {
|
||||
FURI_LOG_E(TAG, "Missing Seed");
|
||||
break;
|
||||
}
|
||||
instance->generic.seed = seed_data[0] << 24 | seed_data[1] << 16 | seed_data[2] << 8 | seed_data[3] ;
|
||||
FURI_LOG_I(TAG, "encoder seed = %8X", instance->generic.seed);
|
||||
|
||||
instance->encoder.is_runing = true;
|
||||
|
||||
res = true;
|
||||
@@ -398,7 +399,7 @@ static void subghz_protocol_faac_slh_check_remote_controller
|
||||
(SubGhzBlockGeneric* instance,
|
||||
SubGhzKeystore* keystore,
|
||||
const char** manufacture_name) {
|
||||
instance->seed = seed_global;
|
||||
//instance->seed = seed_global;
|
||||
FURI_LOG_I(TAG, "seed check = %8X", instance->seed);
|
||||
uint32_t code_fix = instance->data >> 32;
|
||||
uint32_t code_hop = instance->data & 0xFFFFFFFF;
|
||||
@@ -435,10 +436,9 @@ bool subghz_protocol_decoder_faac_slh_serialize(
|
||||
FuriHalSubGhzPreset preset) {
|
||||
furi_assert(context);
|
||||
SubGhzProtocolDecoderFaacSLH* instance = context;
|
||||
subghz_protocol_faac_slh_check_remote_controller(
|
||||
&instance->generic, instance->keystore, &instance->manufacture_name);
|
||||
|
||||
bool res = subghz_block_generic_serialize(&instance->generic, flipper_format, frequency, preset);
|
||||
|
||||
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;
|
||||
@@ -449,6 +449,10 @@ bool subghz_protocol_decoder_faac_slh_serialize(
|
||||
}
|
||||
instance->generic.seed = seed_data[0] << 24 | seed_data[1] << 16 | seed_data[2] << 8 | seed_data[3] ;
|
||||
FURI_LOG_I(TAG, "decoder seed = %8X", instance->generic.seed);
|
||||
|
||||
subghz_protocol_faac_slh_check_remote_controller(
|
||||
&instance->generic, instance->keystore, &instance->manufacture_name);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user