Skip to content

Commit

Permalink
move logic
Browse files Browse the repository at this point in the history
  • Loading branch information
xMasterX committed Sep 6, 2024
1 parent 4d8777d commit 9103805
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/subghz/protocols/gangqi.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,9 +488,14 @@ void subghz_protocol_decoder_gangqi_get_string(void* context, FuriString* output
((instance->generic.data >> 24) & 0xFF) -
((instance->generic.data >> 16) & 0xFF) - ((instance->generic.data >> 8) & 0xFF);

// Get 3 bytes sum
uint16_t sum_3bytes_serial = ((instance->generic.serial >> 16) & 0xFF) +
((instance->generic.serial >> 8) & 0xFF) +
(instance->generic.serial & 0xFF);
// Returns true if serial is valid
bool serial_is_valid =
((!(sum_3bytes_serial & 0x3)) &&
((0xb2 < sum_3bytes_serial) && (sum_3bytes_serial < 0x1ae)));

furi_string_cat_printf(
output,
Expand All @@ -507,8 +512,5 @@ void subghz_protocol_decoder_gangqi_get_string(void* context, FuriString* output
crc,
instance->generic.btn,
subghz_protocol_gangqi_get_button_name(instance->generic.btn),
((!(sum_3bytes_serial & 0x3)) &&
((0xb2 < sum_3bytes_serial) && (sum_3bytes_serial < 0x1ae))) ?
"valid" :
"invalid");
serial_is_valid ? "valid" : "invalid");
}

0 comments on commit 9103805

Please sign in to comment.