Update nice_flor_s.c

Check if counter++ works
This commit is contained in:
r3df0xx 2022-03-20 18:55:06 +03:00
parent 8a0c498b1c
commit d74c5fb149

View file

@ -99,6 +99,13 @@ void subghz_protocol_encoder_nice_flor_s_free(void* context) {
free(instance); free(instance);
} }
static bool subghz_protocol_nice_flor_s_gen_data(SubGhzProtocolEncoderNiceFlorS* instance, uint8_t btn, const char* file_name) {
instance->generic.cnt++;
uint64_t data_to_encrypt = btn | instance->generic.serial | instance->generic.cnt;
instance->generic.data = subghz_protocol_nice_flor_s_encrypt(data_to_encrypt, file_name);
return true;
}
bool subghz_protocol_nice_flor_s_create_data( bool subghz_protocol_nice_flor_s_create_data(
void* context, void* context,
FlipperFormat* flipper_format, FlipperFormat* flipper_format,
@ -110,15 +117,15 @@ bool subghz_protocol_nice_flor_s_create_data(
const char* file_name) { const char* file_name) {
furi_assert(context); furi_assert(context);
SubGhzProtocolEncoderNiceFlorS* instance = context; SubGhzProtocolEncoderNiceFlorS* instance = context;
instance->generic.btn = btn;
instance->generic.serial = serial; instance->generic.serial = serial;
instance->generic.cnt = cnt; instance->generic.cnt = cnt;
instance->generic.data_count_bit = 52; instance->generic.data_count_bit = 52;
instance->generic.cnt++; bool res = subghz_protocol_nice_flor_s_gen_data(instance, btn, file_name);
uint64_t data_to_encrypt = btn | instance->generic.serial | instance->generic.cnt; if (res) {
instance->generic.data = subghz_protocol_nice_flor_s_encrypt(data_to_encrypt, file_name); res =
subghz_block_generic_serialize(&instance->generic, flipper_format, frequency, preset); subghz_block_generic_serialize(&instance->generic, flipper_format, frequency, preset);
return true; }
return res;
} }
/** /**
@ -127,9 +134,16 @@ bool subghz_protocol_nice_flor_s_create_data(
* @return true On success * @return true On success
*/ */
static bool static bool
subghz_protocol_encoder_nice_flor_s_get_upload(SubGhzProtocolEncoderNiceFlorS* instance, uint8_t btn) { subghz_protocol_encoder_nice_flor_s_get_upload(SubGhzProtocolEncoderNiceFlorS* instance, uint8_t btn, const char* file_name) {
furi_assert(instance); furi_assert(instance);
//gen new key
if(subghz_protocol_nice_flor_s_gen_data(instance, btn, file_name)) {
//ToDo if you need to add a callback to automatically update the data on the display
} else {
return false;
}
size_t index = 0; size_t index = 0;
size_t size_upload = (instance->generic.data_count_bit * 2) + ((35 + 2 + 2) * 2); size_t size_upload = (instance->generic.data_count_bit * 2) + ((35 + 2 + 2) * 2);
if(size_upload > instance->encoder.size_upload) { if(size_upload > instance->encoder.size_upload) {