mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-24 03:29:57 -07:00
subghz implement countermodes
This commit is contained in:
@@ -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,
|
||||
@@ -273,24 +275,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++;
|
||||
}
|
||||
@@ -447,6 +469,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);
|
||||
|
||||
@@ -720,6 +754,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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user