From a29e34c3f499d26dfaff109928f202cc5a964b4d Mon Sep 17 00:00:00 2001 From: r3df0xx Date: Tue, 7 Jun 2022 20:01:22 +0300 Subject: [PATCH] Update came_atomo.c code make-up, fix pause to 68ms --- lib/subghz/protocols/came_atomo.c | 33 ++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/lib/subghz/protocols/came_atomo.c b/lib/subghz/protocols/came_atomo.c index 5a54e5d3c..bc5bf22f6 100644 --- a/lib/subghz/protocols/came_atomo.c +++ b/lib/subghz/protocols/came_atomo.c @@ -133,24 +133,29 @@ static void subghz_protocol_encoder_came_atomo_get_upload(SubGhzProtocolEncoderC ManchesterEncoderResult result; uint8_t pack[8] = {}; - pack[0] = (instance->generic.data_2 >> 56); pack[1] = ((instance->generic.data_2 >> 48) & 0xFF); pack[2] = ((instance->generic.data_2 >> 40) & 0xFF); pack[3] = ((instance->generic.data_2 >> 32) & 0xFF); - pack[4] = ((instance->generic.data_2 >> 24) & 0xFF); pack[5] = ((instance->generic.data_2 >> 16) & 0xFF); pack[6] = ((instance->generic.data_2 >> 8) & 0xFF); pack[7] = (instance->generic.data_2 & 0xFF); + pack[0] = (instance->generic.data_2 >> 56); pack[1] = ((instance->generic.data_2 >> 48) & 0xFF); + pack[2] = ((instance->generic.data_2 >> 40) & 0xFF); pack[3] = ((instance->generic.data_2 >> 32) & 0xFF); + pack[4] = ((instance->generic.data_2 >> 24) & 0xFF); pack[5] = ((instance->generic.data_2 >> 16) & 0xFF); + pack[6] = ((instance->generic.data_2 >> 8) & 0xFF); pack[7] = (instance->generic.data_2 & 0xFF); - FURI_LOG_I(TAG, "encoder prepared: %02X %02X %02X %02X %02X %02X %02X %02X\n", pack[0], pack[1], pack[2], pack[3], pack[4], pack[5], pack[6], pack[7]); + FURI_LOG_I(TAG, "encoder prepared: %02X %02X %02X %02X %02X %02X %02X %02X\n", + pack[0], pack[1], pack[2], pack[3], pack[4], pack[5], pack[6], pack[7]); atomo_encrypt(pack); uint32_t hi = pack[0] << 24 | pack[1] << 16 | pack[2] << 8 | pack[3]; uint32_t lo = pack[4] << 24 | pack[5] << 16 | pack[6] << 8 | pack[7]; instance->generic.data = (uint64_t)hi << 32 | lo; - FURI_LOG_I(TAG, "encrypted data: %02X %02X %02X %02X %02X %02X %02X %02X\n", pack[0], pack[1], pack[2], pack[3], pack[4], pack[5], pack[6], pack[7]); + FURI_LOG_I(TAG, "encrypted data: %02X %02X %02X %02X %02X %02X %02X %02X\n", + pack[0], pack[1], pack[2], pack[3], pack[4], pack[5], pack[6], pack[7]); uint64_t invert = instance->generic.data ^ 0xFFFFFFFFFFFFFFFF; invert >>= 4; invert = (uint64_t)0x1 << 60 | invert; hi = invert >> 32; lo = invert & 0xFFFFFFFF; - FURI_LOG_I(TAG, "inverted to upload: %02X %02X %02X %02X %02X %02X %02X %02X\n", (hi >> 24), ((hi >> 16) & 0xFF), ((hi >> 8) & 0xFF), (hi & 0xFF), - (lo >> 24), ((lo >> 16) & 0xFF), ((lo >> 8) & 0xFF), (lo & 0xFF)); + FURI_LOG_I(TAG, "inverted to upload: %02X %02X %02X %02X %02X %02X %02X %02X\n", + (hi >> 24), ((hi >> 16) & 0xFF), ((hi >> 8) & 0xFF), (hi & 0xFF), + (lo >> 24), ((lo >> 16) & 0xFF), ((lo >> 8) & 0xFF), (lo & 0xFF)); for(uint8_t i = instance->generic.data_count_bit; i > 0; i--) { if(!manchester_encoder_advance(&enc_state, !bit_read(invert, i - 1), &result)) { @@ -168,7 +173,7 @@ static void subghz_protocol_encoder_came_atomo_get_upload(SubGhzProtocolEncoderC } //pause instance->encoder.upload[index++] = - level_duration_make(false, (uint32_t)subghz_protocol_came_atomo_const.te_short * 113); + level_duration_make(false, (uint32_t)subghz_protocol_came_atomo_const.te_delta * 272); instance->encoder.size_upload = index; } @@ -393,13 +398,17 @@ static void subghz_protocol_came_atomo_remote_controller( instance->data <<= 4; uint32_t hi = instance->data >> 32; uint32_t lo = instance->data & 0xFFFFFFFF; - FURI_LOG_I(TAG, "inverted data: %02X %02X %02X %02X %02X %02X %02X %02X\n", (hi >> 24), ((hi >> 16) & 0xFF), ((hi >> 8) & 0xFF), (hi & 0xFF), - (lo >> 24), ((lo >> 16) & 0xFF), ((lo >> 8) & 0xFF), (lo & 0xFF)); + FURI_LOG_I(TAG, "inverted data: %02X %02X %02X %02X %02X %02X %02X %02X\n", + (hi >> 24), ((hi >> 16) & 0xFF), ((hi >> 8) & 0xFF), (hi & 0xFF), + (lo >> 24), ((lo >> 16) & 0xFF), ((lo >> 8) & 0xFF), (lo & 0xFF)); uint8_t pack[8] = {}; - pack[0] = (instance->data >> 56); pack[1] = ((instance->data >> 48) & 0xFF); pack[2] = ((instance->data >> 40) & 0xFF); pack[3] = ((instance->data >> 32) & 0xFF); - pack[4] = ((instance->data >> 24) & 0xFF); pack[5] = ((instance->data >> 16) & 0xFF); pack[6] = ((instance->data >> 8) & 0xFF); pack[7] = (instance->data & 0xFF); + pack[0] = (instance->data >> 56); pack[1] = ((instance->data >> 48) & 0xFF); + pack[2] = ((instance->data >> 40) & 0xFF); pack[3] = ((instance->data >> 32) & 0xFF); + pack[4] = ((instance->data >> 24) & 0xFF); pack[5] = ((instance->data >> 16) & 0xFF); + pack[6] = ((instance->data >> 8) & 0xFF); pack[7] = (instance->data & 0xFF); atomo_decrypt(pack); - FURI_LOG_I(TAG, "decrypted data: %02X %02X %02X %02X %02X %02X %02X %02X\n", pack[0], pack[1], pack[2], pack[3], pack[4], pack[5], pack[6], pack[7]); + FURI_LOG_I(TAG, "decrypted data: %02X %02X %02X %02X %02X %02X %02X %02X\n", + pack[0], pack[1], pack[2], pack[3], pack[4], pack[5], pack[6], pack[7]); instance->cnt_2 = pack[0]; instance->cnt = (uint16_t)pack[1] << 8 | pack[2]; instance->serial = (uint32_t)(pack[3]) << 24 | pack[4] << 16 | pack[5] << 8 | pack[6];