From 0b496f70c2609e4ab2bf2bd0d9790d82a46d0106 Mon Sep 17 00:00:00 2001 From: r3df0xx Date: Sat, 2 Apr 2022 21:47:52 +0300 Subject: [PATCH] Update nice_flor_s.c --- lib/subghz/protocols/nice_flor_s.c | 45 ++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/lib/subghz/protocols/nice_flor_s.c b/lib/subghz/protocols/nice_flor_s.c index ae5e56c18..ce6717034 100644 --- a/lib/subghz/protocols/nice_flor_s.c +++ b/lib/subghz/protocols/nice_flor_s.c @@ -128,13 +128,17 @@ static bool } instance->generic.cnt++; - FURI_LOG_I(TAG, "serial = %07lX", instance->generic.serial); - FURI_LOG_I(TAG, "counter = %04lX", instance->generic.cnt); - FURI_LOG_I(TAG, "button = %01lX", btn); + FURI_LOG_I(TAG, "serial = %7X", instance->generic.serial); + FURI_LOG_I(TAG, "counter = %4X", instance->generic.cnt); + FURI_LOG_I(TAG, "button = %1X", btn); uint64_t decrypt = ((uint64_t)instance->generic.serial << 16) | instance->generic.cnt; - FURI_LOG_I(TAG, "decrypt = %011lX", (uint64_t)decrypt); + uint32_t hi = decrypt >> 32; + uint32_t lo = decrypt & 0xFFFFFFFF; + FURI_LOG_I(TAG, "decrypt = %3X%8X", hi, lo); uint64_t enc_part = subghz_protocol_nice_flor_s_encrypt(decrypt, file_name); - FURI_LOG_I(TAG, "enc_part = %011lX", (uint64_t)enc_part); + hi = enc_part >> 32; + lo = enc_part & 0xFFFFFFFF; + FURI_LOG_I(TAG, "enc_part = %3X%8X", hi, lo); for (int i = 0; i < 16; i++) { @@ -153,24 +157,31 @@ static bool 0x7, 0x6, 0x5, 0x4, 0x3, 0x2, 0x1, 0x0, 0xF, 0xE, 0xD, 0xC, 0xB, 0xA, 0x9, 0x8 } }; - + uint8_t byte; + if (btn == 0x1) { //Button 1 - instance->generic.data = ((uint64_t)btn << 4) | (0xF ^ btn ^ loops[0][i]) << 44 | enc_part; + byte = btn << 4 | (0xF ^ btn ^ loops[0][i]); + instance->generic.data = (uint64_t)byte << 44 | enc_part; } if (btn == 0x2) { //Button 2 - instance->generic.data = ((uint64_t)btn << 4) | (0xF ^ btn ^ loops[1][i]) << 44 | enc_part; + byte = btn << 4 | (0xF ^ btn ^ loops[1][i]); + instance->generic.data = (uint64_t)byte << 44 | enc_part; } if (btn == 0x4) { //Button 3 - instance->generic.data = ((uint64_t)btn << 4) | (0xF ^ btn ^ loops[2][i]) << 44 | enc_part; + byte = btn << 4 | (0xF ^ btn ^ loops[2][i]); + instance->generic.data = (uint64_t)byte << 44 | enc_part; } if (btn == 0x8) { //Button 4 - instance->generic.data = ((uint64_t)btn << 4) | (0xF ^ btn ^ loops[3][i]) << 44 | enc_part; + byte = btn << 4 | (0xF ^ btn ^ loops[3][i]); + instance->generic.data = (uint64_t)byte << 44 | enc_part; } - FURI_LOG_I(TAG, "key = %013lX", (uint64_t)instance->generic.data); + hi = instance->generic.data >> 32; + lo = instance->generic.data & 0xFFFFFFFF; + FURI_LOG_I(TAG, "key = %5X%8X", hi, lo); //Send header for(uint8_t i = 35; i > 0; i--) { @@ -323,7 +334,9 @@ uint64_t subghz_protocol_nice_flor_s_encrypt(uint64_t data, const char* file_nam k = ~p[3]; p[3] = ~p[1]; p[1] = k; - FURI_LOG_I(TAG, "encrypted_data = %011lX", (uint64_t)data); + uint32_t hi = data >> 32; + uint32_t lo = data & 0xFFFFFFFF; + FURI_LOG_I(TAG, "encrypted_data = %3X%8X", hi, lo); return data; } @@ -362,7 +375,9 @@ static uint64_t p[1] = k; } } - FURI_LOG_I(TAG, "decrypted_data = %011lX", (uint64_t)data); + uint32_t hi = data >> 32; + uint32_t lo = data & 0xFFFFFFFF; + FURI_LOG_I(TAG, "decrypted_data = %5X%8X", hi, lo); return data; } @@ -507,7 +522,9 @@ static void subghz_protocol_nice_flor_s_remote_controller( instance->btn = 0; } else { uint64_t decrypt = subghz_protocol_nice_flor_s_decrypt(instance, file_name); - FURI_LOG_I(TAG, "init_decrypted_data = %013lX", (uint64_t)decrypt); + uint32_t hi = decrypt >> 32; + uint32_t lo = decrypt & 0xFFFFFFFF; + FURI_LOG_I(TAG, "init_decrypted_data = %5X%8X", hi, lo); instance->cnt = decrypt & 0xFFFF; instance->serial = (decrypt >> 16) & 0xFFFFFFF; instance->btn = (decrypt >> 48) & 0xF;