Merge remote-tracking branch 'ul/dev' into mntm-dev --nobuild

This commit is contained in:
WillyJL
2025-11-29 20:34:44 +01:00
9 changed files with 664 additions and 56 deletions

View File

@@ -47,6 +47,8 @@ typedef enum {
Alutech_at_4nDecoderStepCheckDuration,
} Alutech_at_4nDecoderStep;
static uint8_t alutech_at4n_counter_mode = 0;
const SubGhzProtocolDecoder subghz_protocol_alutech_at_4n_decoder = {
.alloc = subghz_protocol_decoder_alutech_at_4n_alloc,
.free = subghz_protocol_decoder_alutech_at_4n_free,
@@ -275,24 +277,44 @@ static bool subghz_protocol_alutech_at_4n_gen_data(
instance->generic.serial = (uint32_t)(data >> 24) & 0xFFFFFFFF;
}
// Check for OFEX (overflow experimental) mode
if(furi_hal_subghz_get_rolling_counter_mult() != 0xFFFE) {
if(instance->generic.cnt < 0xFFFF) {
if((instance->generic.cnt + furi_hal_subghz_get_rolling_counter_mult()) > 0xFFFF) {
if(alutech_at4n_counter_mode == 0) {
// Check for OFEX (overflow experimental) mode
if(furi_hal_subghz_get_rolling_counter_mult() != 0xFFFE) {
if(instance->generic.cnt < 0xFFFF) {
if((instance->generic.cnt + furi_hal_subghz_get_rolling_counter_mult()) > 0xFFFF) {
instance->generic.cnt = 0;
} else {
instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult();
}
} else if(
(instance->generic.cnt >= 0xFFFF) &&
(furi_hal_subghz_get_rolling_counter_mult() != 0)) {
instance->generic.cnt = 0;
} else {
instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult();
}
} else if(
(instance->generic.cnt >= 0xFFFF) &&
(furi_hal_subghz_get_rolling_counter_mult() != 0)) {
instance->generic.cnt = 0;
} else {
if((instance->generic.cnt + 0x1) > 0xFFFF) {
instance->generic.cnt = 0;
} else if(instance->generic.cnt >= 0x1 && instance->generic.cnt != 0xFFFE) {
instance->generic.cnt = furi_hal_subghz_get_rolling_counter_mult();
} else {
instance->generic.cnt++;
}
}
} else {
} else if(alutech_at4n_counter_mode == 1) {
// Mode 1
// 0000 / 0001 / FFFE / FFFF
if((instance->generic.cnt + 0x1) > 0xFFFF) {
instance->generic.cnt = 0;
} else if(instance->generic.cnt >= 0x1 && instance->generic.cnt != 0xFFFE) {
instance->generic.cnt = furi_hal_subghz_get_rolling_counter_mult();
instance->generic.cnt = 0xFFFE;
} else {
instance->generic.cnt++;
}
} else {
// Mode 2
// 0x0000 / 0x0001 / 0x0002 / 0x0003 / 0x0004 / 0x0005
if(instance->generic.cnt >= 0x0005) {
instance->generic.cnt = 0;
} else {
instance->generic.cnt++;
}
@@ -449,6 +471,18 @@ SubGhzProtocolStatus subghz_protocol_encoder_alutech_at_4n_deserialize(
flipper_format_read_uint32(
flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1);
if(!flipper_format_rewind(flipper_format)) {
FURI_LOG_E(TAG, "Rewind error");
break;
}
uint32_t tmp_counter_mode;
if(flipper_format_read_uint32(flipper_format, "CounterMode", &tmp_counter_mode, 1)) {
alutech_at4n_counter_mode = (uint8_t)tmp_counter_mode;
} else {
alutech_at4n_counter_mode = 0;
}
subghz_protocol_alutech_at_4n_remote_controller(
&instance->generic, instance->crc, instance->alutech_at_4n_rainbow_table_file_name);
@@ -722,6 +756,18 @@ SubGhzProtocolStatus subghz_protocol_decoder_alutech_at_4n_deserialize(
ret = SubGhzProtocolStatusErrorParserOthers;
break;
}
if(!flipper_format_rewind(flipper_format)) {
FURI_LOG_E(TAG, "Rewind error");
break;
}
uint32_t tmp_counter_mode;
if(flipper_format_read_uint32(flipper_format, "CounterMode", &tmp_counter_mode, 1)) {
alutech_at4n_counter_mode = (uint8_t)tmp_counter_mode;
} else {
alutech_at4n_counter_mode = 0;
}
} while(false);
return ret;
}

View File

@@ -39,6 +39,8 @@ typedef enum {
CameAtomoDecoderStepDecoderData,
} CameAtomoDecoderStep;
static uint8_t came_atomo_counter_mode = 0;
const SubGhzProtocolDecoder subghz_protocol_came_atomo_decoder = {
.alloc = subghz_protocol_decoder_came_atomo_alloc,
.free = subghz_protocol_decoder_came_atomo_free,
@@ -187,27 +189,52 @@ static void subghz_protocol_encoder_came_atomo_get_upload(
uint8_t pack[8] = {};
// Check for OFEX (overflow experimental) mode
if(furi_hal_subghz_get_rolling_counter_mult() != 0xFFFE) {
if(instance->generic.cnt < 0xFFFF) {
if((instance->generic.cnt + furi_hal_subghz_get_rolling_counter_mult()) > 0xFFFF) {
if(came_atomo_counter_mode == 0) {
// Check for OFEX (overflow experimental) mode
if(furi_hal_subghz_get_rolling_counter_mult() != 0xFFFE) {
if(instance->generic.cnt < 0xFFFF) {
if((instance->generic.cnt + furi_hal_subghz_get_rolling_counter_mult()) > 0xFFFF) {
instance->generic.cnt = 0;
} else {
instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult();
}
} else if(
(instance->generic.cnt >= 0xFFFF) &&
(furi_hal_subghz_get_rolling_counter_mult() != 0)) {
instance->generic.cnt = 0;
} else {
instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult();
}
} else if(
(instance->generic.cnt >= 0xFFFF) &&
(furi_hal_subghz_get_rolling_counter_mult() != 0)) {
instance->generic.cnt = 0;
} else {
if((instance->generic.cnt + 0x1) > 0xFFFF) {
instance->generic.cnt = 0;
} else if(instance->generic.cnt >= 0x1 && instance->generic.cnt != 0xFFFE) {
instance->generic.cnt = furi_hal_subghz_get_rolling_counter_mult();
} else {
instance->generic.cnt++;
}
}
} else {
} else if(came_atomo_counter_mode == 1) {
// Mode 1
// 0000 / 0001 / FFFE / FFFF
if((instance->generic.cnt + 0x1) > 0xFFFF) {
instance->generic.cnt = 0;
} else if(instance->generic.cnt >= 0x1 && instance->generic.cnt != 0xFFFE) {
instance->generic.cnt = furi_hal_subghz_get_rolling_counter_mult();
instance->generic.cnt = 0xFFFE;
} else {
instance->generic.cnt++;
}
} else if(came_atomo_counter_mode == 2) {
// Mode 2
// 0x807B / 0x807C / 0x007B / 0x007C
if(instance->generic.cnt != 0x807B && instance->generic.cnt != 0x807C &&
instance->generic.cnt != 0x007B) {
instance->generic.cnt = 0x807B;
} else if(instance->generic.cnt == 0x807C) {
instance->generic.cnt = 0x007B;
} else {
instance->generic.cnt++;
}
} else {
// Mode 3 - Freeze counter
}
// Save original button for later use
@@ -354,6 +381,18 @@ SubGhzProtocolStatus
flipper_format_read_uint32(
flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1);
if(!flipper_format_rewind(flipper_format)) {
FURI_LOG_E(TAG, "Rewind error");
break;
}
uint32_t tmp_counter_mode;
if(flipper_format_read_uint32(flipper_format, "CounterMode", &tmp_counter_mode, 1)) {
came_atomo_counter_mode = (uint8_t)tmp_counter_mode;
} else {
came_atomo_counter_mode = 0;
}
subghz_protocol_came_atomo_remote_controller(&instance->generic);
subghz_protocol_encoder_came_atomo_get_upload(instance, instance->generic.btn);
@@ -754,10 +793,32 @@ SubGhzProtocolStatus
subghz_protocol_decoder_came_atomo_deserialize(void* context, FlipperFormat* flipper_format) {
furi_assert(context);
SubGhzProtocolDecoderCameAtomo* instance = context;
return subghz_block_generic_deserialize_check_count_bit(
&instance->generic,
flipper_format,
subghz_protocol_came_atomo_const.min_count_bit_for_found);
SubGhzProtocolStatus status = SubGhzProtocolStatusOk;
status = subghz_block_generic_deserialize(&instance->generic, flipper_format);
if(status != SubGhzProtocolStatusOk) {
FURI_LOG_E(TAG, "Deserialize error");
return status;
}
if(instance->generic.data_count_bit !=
subghz_protocol_came_atomo_const.min_count_bit_for_found) {
FURI_LOG_E(TAG, "Wrong number of bits in key");
return SubGhzProtocolStatusErrorValueBitCount;
}
if(!flipper_format_rewind(flipper_format)) {
FURI_LOG_E(TAG, "Rewind error");
return SubGhzProtocolStatusError;
}
uint32_t tmp_counter_mode;
if(flipper_format_read_uint32(flipper_format, "CounterMode", &tmp_counter_mode, 1)) {
came_atomo_counter_mode = (uint8_t)tmp_counter_mode;
} else {
came_atomo_counter_mode = 0;
}
return status;
}
void subghz_protocol_decoder_came_atomo_get_string(void* context, FuriString* output) {

View File

@@ -54,6 +54,8 @@ typedef enum {
KeeloqDecoderStepCheckDuration,
} KeeloqDecoderStep;
static uint8_t keeloq_counter_mode = 0;
const SubGhzProtocolDecoder subghz_protocol_keeloq_decoder = {
.alloc = subghz_protocol_decoder_keeloq_alloc,
.free = subghz_protocol_decoder_keeloq_free,
@@ -184,29 +186,83 @@ static bool subghz_protocol_keeloq_gen_data(
if(counter_up && prog_mode == PROG_MODE_OFF) {
// Counter increment conditions
// Check for OFEX (overflow experimental) mode
if(furi_hal_subghz_get_rolling_counter_mult() != 0xFFFE) {
// If counter is 0xFFFF we will reset it to 0
if(instance->generic.cnt < 0xFFFF) {
// Increase counter with value set in global settings (mult)
if((instance->generic.cnt + furi_hal_subghz_get_rolling_counter_mult()) > 0xFFFF) {
if(keeloq_counter_mode == 0) {
// Check for OFEX (overflow experimental) mode
if(furi_hal_subghz_get_rolling_counter_mult() != 0xFFFE) {
// If counter is 0xFFFF we will reset it to 0
if(instance->generic.cnt < 0xFFFF) {
// Increase counter with value set in global settings (mult)
if((instance->generic.cnt + furi_hal_subghz_get_rolling_counter_mult()) >
0xFFFF) {
instance->generic.cnt = 0;
} else {
instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult();
}
} else if(
(instance->generic.cnt >= 0xFFFF) &&
(furi_hal_subghz_get_rolling_counter_mult() != 0)) {
instance->generic.cnt = 0;
} else {
instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult();
}
} else if(
(instance->generic.cnt >= 0xFFFF) &&
(furi_hal_subghz_get_rolling_counter_mult() != 0)) {
instance->generic.cnt = 0;
} else {
if((instance->generic.cnt + 0x1) > 0xFFFF) {
instance->generic.cnt = 0;
} else if(instance->generic.cnt >= 0x1 && instance->generic.cnt != 0xFFFE) {
instance->generic.cnt = furi_hal_subghz_get_rolling_counter_mult();
} else {
instance->generic.cnt++;
}
}
} else {
} else if(keeloq_counter_mode == 1) {
// Mode 1
// 0000 / 0001 / FFFE / FFFF
if((instance->generic.cnt + 0x1) > 0xFFFF) {
instance->generic.cnt = 0;
} else if(instance->generic.cnt >= 0x1 && instance->generic.cnt != 0xFFFE) {
instance->generic.cnt = furi_hal_subghz_get_rolling_counter_mult();
instance->generic.cnt = 0xFFFE;
} else {
instance->generic.cnt++;
}
} else if(keeloq_counter_mode == 2) {
// Mode 2
// + 0x3333 each time
if((instance->generic.cnt + 0x3333) > 0xFFFF) {
instance->generic.cnt = 0;
} else {
instance->generic.cnt += 0x3333;
}
} else if(keeloq_counter_mode == 3) {
// Mode 3
// 0x8006 / 0x8007 / 0x0006 / 0x0007
if(instance->generic.cnt != 0x8006 && instance->generic.cnt != 0x8007 &&
instance->generic.cnt != 0x0006) {
instance->generic.cnt = 0x8006;
} else if(instance->generic.cnt == 0x8007) {
instance->generic.cnt = 0x0006;
} else {
instance->generic.cnt++;
}
} else if(keeloq_counter_mode == 4) {
// Mode 4
// 0x807B / 0x807C / 0x007B / 0x007C
if(instance->generic.cnt != 0x807B && instance->generic.cnt != 0x807C &&
instance->generic.cnt != 0x007B) {
instance->generic.cnt = 0x807B;
} else if(instance->generic.cnt == 0x807C) {
instance->generic.cnt = 0x007B;
} else {
instance->generic.cnt++;
}
} else if(keeloq_counter_mode == 5) {
// Mode 5
// 0000 / FFFF
if((instance->generic.cnt + 0x1) > 0xFFFF) {
instance->generic.cnt = 0;
} else {
instance->generic.cnt = 0xFFFF;
}
} else {
// Mode 6 - Freeze counter
}
}
if(prog_mode == PROG_MODE_OFF) {
@@ -464,6 +520,8 @@ static bool
klq_last_custom_btn = 0x9;
} else if((strcmp(instance->manufacture_name, "EcoStar") == 0)) {
klq_last_custom_btn = 0x6;
} else if((strcmp(instance->manufacture_name, "AN-Motors") == 0)) {
klq_last_custom_btn = 0xC;
}
btn = subghz_protocol_keeloq_get_btn_code(klq_last_custom_btn);
@@ -573,6 +631,18 @@ SubGhzProtocolStatus
break;
}
uint32_t tmp_counter_mode;
if(flipper_format_read_uint32(flipper_format, "CounterMode", &tmp_counter_mode, 1)) {
keeloq_counter_mode = (uint8_t)tmp_counter_mode;
} else {
keeloq_counter_mode = 0;
}
if(!flipper_format_rewind(flipper_format)) {
FURI_LOG_E(TAG, "Rewind error");
break;
}
subghz_protocol_keeloq_check_remote_controller(
&instance->generic, instance->keystore, &instance->manufacture_name);
@@ -1212,6 +1282,18 @@ SubGhzProtocolStatus
break;
}
uint32_t tmp_counter_mode;
if(flipper_format_read_uint32(flipper_format, "CounterMode", &tmp_counter_mode, 1)) {
keeloq_counter_mode = (uint8_t)tmp_counter_mode;
} else {
keeloq_counter_mode = 0;
}
if(!flipper_format_rewind(flipper_format)) {
FURI_LOG_E(TAG, "Rewind error");
break;
}
res = SubGhzProtocolStatusOk;
} while(false);

View File

@@ -53,6 +53,8 @@ typedef enum {
NiceFlorSDecoderStepCheckDuration,
} NiceFlorSDecoderStep;
static uint8_t nice_flors_counter_mode = 0;
const SubGhzProtocolDecoder subghz_protocol_nice_flor_s_decoder = {
.alloc = subghz_protocol_decoder_nice_flor_s_alloc,
.free = subghz_protocol_decoder_nice_flor_s_free,
@@ -154,25 +156,42 @@ static void subghz_protocol_encoder_nice_flor_s_get_upload(
} else {
instance->encoder.size_upload = size_upload;
}
// Check for OFEX (overflow experimental) mode
if(furi_hal_subghz_get_rolling_counter_mult() != 0xFFFE) {
if(instance->generic.cnt < 0xFFFF) {
if((instance->generic.cnt + furi_hal_subghz_get_rolling_counter_mult()) > 0xFFFF) {
if(nice_flors_counter_mode == 0) {
// Check for OFEX (overflow experimental) mode
if(furi_hal_subghz_get_rolling_counter_mult() != 0xFFFE) {
if(instance->generic.cnt < 0xFFFF) {
if((instance->generic.cnt + furi_hal_subghz_get_rolling_counter_mult()) > 0xFFFF) {
instance->generic.cnt = 0;
} else {
instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult();
}
} else if(
(instance->generic.cnt >= 0xFFFF) &&
(furi_hal_subghz_get_rolling_counter_mult() != 0)) {
instance->generic.cnt = 0;
} else {
instance->generic.cnt += furi_hal_subghz_get_rolling_counter_mult();
}
} else if(
(instance->generic.cnt >= 0xFFFF) &&
(furi_hal_subghz_get_rolling_counter_mult() != 0)) {
instance->generic.cnt = 0;
} else {
if((instance->generic.cnt + 0x1) > 0xFFFF) {
instance->generic.cnt = 0;
} else if(instance->generic.cnt >= 0x1 && instance->generic.cnt != 0xFFFE) {
instance->generic.cnt = furi_hal_subghz_get_rolling_counter_mult();
} else {
instance->generic.cnt++;
}
}
} else if(nice_flors_counter_mode == 1) {
// Mode 1 (floxi2r)
// 0001 / FFFE
if(instance->generic.cnt == 0xFFFE) {
instance->generic.cnt = 0x0001;
} else {
instance->generic.cnt = 0xFFFE;
}
} else {
if((instance->generic.cnt + 0x1) > 0xFFFF) {
// Mode 2 (ox2)
// 0x0000 / 0x0001
if(instance->generic.cnt >= 0x0001) {
instance->generic.cnt = 0;
} else if(instance->generic.cnt >= 0x1 && instance->generic.cnt != 0xFFFE) {
instance->generic.cnt = furi_hal_subghz_get_rolling_counter_mult();
} else {
instance->generic.cnt++;
}
@@ -270,6 +289,17 @@ SubGhzProtocolStatus
flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1);
// flipper_format_read_uint32(
// flipper_format, "Data", (uint32_t*)&instance->generic.data_2, 1);
if(!flipper_format_rewind(flipper_format)) {
FURI_LOG_E(TAG, "Rewind error");
break;
}
uint32_t tmp_counter_mode;
if(flipper_format_read_uint32(flipper_format, "CounterMode", &tmp_counter_mode, 1)) {
nice_flors_counter_mode = (uint8_t)tmp_counter_mode;
} else {
nice_flors_counter_mode = 0;
}
subghz_protocol_nice_flor_s_remote_controller(
&instance->generic, instance->nice_flor_s_rainbow_table_file_name);
@@ -770,6 +800,17 @@ SubGhzProtocolStatus
}
instance->data = (uint64_t)temp;
}
if(!flipper_format_rewind(flipper_format)) {
FURI_LOG_E(TAG, "Rewind error");
break;
}
uint32_t tmp_counter_mode;
if(flipper_format_read_uint32(flipper_format, "CounterMode", &tmp_counter_mode, 1)) {
nice_flors_counter_mode = (uint8_t)tmp_counter_mode;
} else {
nice_flors_counter_mode = 0;
}
} while(false);
return ret;
}