SubGHz: Fix keeloq, SL, counter going higher than 16bits

Proper reset to 0 after we get to 0xFFFF
This commit is contained in:
MX 2022-11-24 17:03:50 +03:00
parent 6e7b7f1d89
commit bf62f66dc8
No known key found for this signature in database
GPG key ID: 6C4C311DFD4B4AB5
2 changed files with 10 additions and 2 deletions

View file

@ -137,7 +137,11 @@ void subghz_protocol_encoder_keeloq_free(void* context) {
* @param btn Button number, 4 bit
*/
static bool subghz_protocol_keeloq_gen_data(SubGhzProtocolEncoderKeeloq* instance, uint8_t btn) {
instance->generic.cnt++;
if(instance->generic.cnt < 0xFFFF) {
instance->generic.cnt++;
} else if(instance->generic.cnt >= 0xFFFF) {
instance->generic.cnt = 0;
}
uint32_t fix = btn << 28 | instance->generic.serial;
uint32_t decrypt = btn << 28 |
(instance->generic.serial & 0x3FF)

View file

@ -138,7 +138,11 @@ void subghz_protocol_encoder_star_line_free(void* context) {
*/
static bool
subghz_protocol_star_line_gen_data(SubGhzProtocolEncoderStarLine* instance, uint8_t btn) {
instance->generic.cnt++;
if(instance->generic.cnt < 0xFFFF) {
instance->generic.cnt++;
} else if(instance->generic.cnt >= 0xFFFF) {
instance->generic.cnt = 0;
}
uint32_t fix = btn << 24 | instance->generic.serial;
uint32_t decrypt = btn << 24 | (instance->generic.serial & 0xFF) << 16 | instance->generic.cnt;
uint32_t hop = 0;