More protos

This commit is contained in:
HTotoo
2023-12-10 15:02:15 +01:00
parent 1b407f28d0
commit 3a68afe511
6 changed files with 300 additions and 1 deletions
+4
View File
@@ -150,6 +150,10 @@ const char* SubGhzDView::getSensorTypeName(FPROTO_SUBGHZD_SENSOR type) {
return "Doitrand";
case FPS_DOOYA:
return "Dooya";
case FPS_FAAC:
return "Faac";
case FPS_GATETX:
return "Gate TX";
case FPS_Invalid:
default:
return "Unknown";
+87
View File
@@ -0,0 +1,87 @@
#ifndef __FPROTO_FAAC_H__
#define __FPROTO_FAAC_H__
#include "subghzdbase.hpp"
typedef enum {
FaacSLHDecoderStepReset = 0,
FaacSLHDecoderStepFoundPreambula,
FaacSLHDecoderStepSaveDuration,
FaacSLHDecoderStepCheckDuration,
} FaacSLHDecoderStep;
class FProtoSubGhzDCFaac : public FProtoSubGhzDBase {
public:
FProtoSubGhzDCFaac() {
sensorType = FPS_FAAC;
}
void feed(bool level, uint32_t duration) {
switch (parser_step) {
case FaacSLHDecoderStepReset:
if ((level) && (DURATION_DIFF(duration, te_long * 2) < te_delta * 3)) {
parser_step = FaacSLHDecoderStepFoundPreambula;
}
break;
case FaacSLHDecoderStepFoundPreambula:
if ((!level) && (DURATION_DIFF(duration, te_long * 2) < te_delta * 3)) {
// Found Preambula
parser_step = FaacSLHDecoderStepSaveDuration;
decode_data = 0;
decode_count_bit = 0;
} else {
parser_step = FaacSLHDecoderStepReset;
}
break;
case FaacSLHDecoderStepSaveDuration:
if (level) {
if (duration >= ((uint32_t)te_short * 3 + te_delta)) {
parser_step = FaacSLHDecoderStepFoundPreambula;
if (decode_count_bit == min_count_bit_for_found) {
data = decode_data;
data_count_bit = decode_count_bit;
// remark controller skipped
if (callback) callback(this);
}
decode_data = 0;
decode_count_bit = 0;
break;
} else {
te_last = duration;
parser_step = FaacSLHDecoderStepCheckDuration;
}
} else {
parser_step = FaacSLHDecoderStepReset;
}
break;
case FaacSLHDecoderStepCheckDuration:
if (!level) {
if ((DURATION_DIFF(te_last, te_short) < te_delta) &&
(DURATION_DIFF(duration, te_long) < te_delta)) {
subghz_protocol_blocks_add_bit(0);
parser_step = FaacSLHDecoderStepSaveDuration;
} else if (
(DURATION_DIFF(te_last, te_long) < te_delta) &&
(DURATION_DIFF(duration, te_short) < te_delta)) {
subghz_protocol_blocks_add_bit(1);
parser_step = FaacSLHDecoderStepSaveDuration;
} else {
parser_step = FaacSLHDecoderStepReset;
}
} else {
parser_step = FaacSLHDecoderStepReset;
}
break;
}
}
protected:
uint32_t te_short = 255;
uint32_t te_long = 595;
uint32_t te_delta = 100;
uint32_t min_count_bit_for_found = 64;
};
#endif
+90
View File
@@ -0,0 +1,90 @@
#ifndef __FPROTO_GATETX_H__
#define __FPROTO_GATETX_H__
#include "subghzdbase.hpp"
typedef enum {
GateTXDecoderStepReset = 0,
GateTXDecoderStepFoundStartBit,
GateTXDecoderStepSaveDuration,
GateTXDecoderStepCheckDuration,
} GateTXDecoderStep;
class FProtoSubGhzDCGateTx : public FProtoSubGhzDBase {
public:
FProtoSubGhzDCGateTx() {
sensorType = FPS_GATETX;
}
void feed(bool level, uint32_t duration) {
switch (parser_step) {
case GateTXDecoderStepReset:
if ((!level) && (DURATION_DIFF(duration, te_short * 47) < te_delta * 47)) {
// Found Preambula
parser_step = GateTXDecoderStepFoundStartBit;
}
break;
case GateTXDecoderStepFoundStartBit:
if (level && ((DURATION_DIFF(duration, te_long) < te_delta * 3))) {
// Found start bit
parser_step = GateTXDecoderStepSaveDuration;
decode_data = 0;
decode_count_bit = 0;
} else {
parser_step = GateTXDecoderStepReset;
}
break;
case GateTXDecoderStepSaveDuration:
if (!level) {
if (duration >= ((uint32_t)te_short * 10 + te_delta)) {
parser_step = GateTXDecoderStepFoundStartBit;
if (decode_count_bit == min_count_bit_for_found) {
data = decode_data;
data_count_bit = decode_count_bit;
// controller
uint32_t code_found_reverse = FProtoGeneral::subghz_protocol_blocks_reverse_key(data, data_count_bit);
serial = (code_found_reverse & 0xFF) << 12 | ((code_found_reverse >> 8) & 0xFF) << 4 | ((code_found_reverse >> 20) & 0x0F);
btn = ((code_found_reverse >> 16) & 0x0F);
if (callback) callback(this);
}
decode_data = 0;
decode_count_bit = 0;
break;
} else {
te_last = duration;
parser_step = GateTXDecoderStepCheckDuration;
}
}
break;
case GateTXDecoderStepCheckDuration:
if (level) {
if ((DURATION_DIFF(te_last, te_short) < te_delta) &&
(DURATION_DIFF(duration, te_long) < te_delta * 3)) {
subghz_protocol_blocks_add_bit(0);
parser_step = GateTXDecoderStepSaveDuration;
} else if (
(DURATION_DIFF(te_last, te_long) < te_delta * 3) &&
(DURATION_DIFF(duration, te_short) < te_delta)) {
subghz_protocol_blocks_add_bit(1);
parser_step = GateTXDecoderStepSaveDuration;
} else {
parser_step = GateTXDecoderStepReset;
}
} else {
parser_step = GateTXDecoderStepReset;
}
break;
}
}
protected:
uint32_t te_short = 350;
uint32_t te_long = 700;
uint32_t te_delta = 100;
uint32_t min_count_bit_for_found = 24;
};
#endif
+109
View File
@@ -0,0 +1,109 @@
#ifndef __FPROTO_HOLTEK_H__
#define __FPROTO_HOLTEK_H__
#include "subghzdbase.hpp"
#define HOLTEK_HEADER_MASK 0xF000000000
#define HOLTEK_HEADER 0x5000000000
typedef enum {
HoltekDecoderStepReset = 0,
HoltekDecoderStepFoundStartBit,
HoltekDecoderStepSaveDuration,
HoltekDecoderStepCheckDuration,
} HoltekDecoderStep;
class FProtoSubGhzDCHoltek : public FProtoSubGhzDBase {
public:
FProtoSubGhzDCHoltek() {
sensorType = FPS_HOLTEK;
}
void feed(bool level, uint32_t duration) {
switch (parser_step) {
case HoltekDecoderStepReset:
if ((!level) && (DURATION_DIFF(duration, te_short * 36) < te_delta * 36)) {
// Found Preambula
parser_step = HoltekDecoderStepFoundStartBit;
}
break;
case HoltekDecoderStepFoundStartBit:
if ((level) && (DURATION_DIFF(duration, te_short) < te_delta)) {
// Found StartBit
parser_step = HoltekDecoderStepSaveDuration;
decode_data = 0;
decode_count_bit = 0;
} else {
parser_step = HoltekDecoderStepReset;
}
break;
case HoltekDecoderStepSaveDuration:
// save duration
if (!level) {
if (duration >= ((uint32_t)te_short * 10 + te_delta)) {
if (decode_count_bit ==
min_count_bit_for_found) {
if ((decode_data & HOLTEK_HEADER_MASK) == HOLTEK_HEADER) {
data = decode_data;
data_count_bit = decode_count_bit;
// controller
serial = FProtoGeneral::subghz_protocol_blocks_reverse_key((data >> 16) & 0xFFFFF, 20);
uint16_t btn = data & 0xFFFF;
if ((btn & 0xf) != 0xA) {
btn = 0x1 << 4 | (btn & 0xF);
} else if (((btn >> 4) & 0xF) != 0xA) {
btn = 0x2 << 4 | ((btn >> 4) & 0xF);
} else if (((btn >> 8) & 0xF) != 0xA) {
btn = 0x3 << 4 | ((btn >> 8) & 0xF);
} else if (((btn >> 12) & 0xF) != 0xA) {
btn = 0x4 << 4 | ((btn >> 12) & 0xF);
} else {
btn = 0;
}
if (callback) callback(this);
}
}
decode_data = 0;
decode_count_bit = 0;
parser_step = HoltekDecoderStepFoundStartBit;
break;
} else {
te_last = duration;
parser_step = HoltekDecoderStepCheckDuration;
}
} else {
parser_step = HoltekDecoderStepReset;
}
break;
case HoltekDecoderStepCheckDuration:
if (level) {
if ((DURATION_DIFF(te_last, te_short) < te_delta) &&
(DURATION_DIFF(duration, te_long) < te_delta * 2)) {
subghz_protocol_blocks_add_bit(0);
parser_step = HoltekDecoderStepSaveDuration;
} else if (
(DURATION_DIFF(te_last, te_long) < te_delta * 2) &&
(DURATION_DIFF(duration, te_short) < te_delta)) {
subghz_protocol_blocks_add_bit(1);
parser_step = HoltekDecoderStepSaveDuration;
} else {
parser_step = HoltekDecoderStepReset;
}
} else {
parser_step = HoltekDecoderStepReset;
}
break;
}
}
protected:
uint32_t te_short = 430;
uint32_t te_long = 870;
uint32_t te_delta = 100;
uint32_t min_count_bit_for_found = 40;
};
#endif
+7 -1
View File
@@ -20,6 +20,9 @@ So include here the .hpp, and add a new element to the protos vector in the cons
#include "s-clemsa.hpp"
#include "s-doitrand.hpp"
#include "s-dooya.hpp"
#include "s-faac.hpp"
#include "s-gate_tx.hpp"
#include "s-holtek.hpp"
#ifndef __FPROTO_PROTOLISTSGZ_H__
#define __FPROTO_PROTOLISTSGZ_H__
@@ -37,7 +40,10 @@ class SubGhzDProtos : public FProtoListGeneral {
protos.push_back(std::make_unique<FProtoSubGhzDChambCode>()); // 9
protos.push_back(std::make_unique<FProtoSubGhzDClemsa>()); // 10
protos.push_back(std::make_unique<FProtoSubGhzDDoitrand>()); // 11
protos.push_back(std::make_unique<FProtoSubGhzDDooya>()); // 11
protos.push_back(std::make_unique<FProtoSubGhzDDooya>()); // 12
protos.push_back(std::make_unique<FProtoSubGhzDCFaac>()); // 13
protos.push_back(std::make_unique<FProtoSubGhzDCGateTx>()); // 14
protos.push_back(std::make_unique<FProtoSubGhzDCHoltek>()); // 15
// set callback for them
for (const auto& obj : protos) {
@@ -31,6 +31,9 @@ enum FPROTO_SUBGHZD_SENSOR {
FPS_CLEMSA = 10,
FPS_DOITRAND = 11,
FPS_DOOYA = 12,
FPS_FAAC = 13,
FPS_GATETX = 14,
FPS_HOLTEK = 15,
};
#endif