mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2026-09-11 17:19:29 +00:00
Proto: bett
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
|
||||
#ifndef __FPROTO_BETT_H__
|
||||
#define __FPROTO_BETT_H__
|
||||
|
||||
#include "subghzdbase.hpp"
|
||||
|
||||
typedef enum {
|
||||
BETTDecoderStepReset = 0,
|
||||
BETTDecoderStepSaveDuration,
|
||||
BETTDecoderStepCheckDuration,
|
||||
} BETTDecoderStep;
|
||||
|
||||
class FProtoSubGhzDBett : public FProtoSubGhzDBase {
|
||||
public:
|
||||
FProtoSubGhzDBett() {
|
||||
sensorType = FPS_BETT;
|
||||
}
|
||||
|
||||
void feed(bool level, uint32_t duration) {
|
||||
switch (parser_step) {
|
||||
case BETTDecoderStepReset:
|
||||
if ((!level) && (DURATION_DIFF(duration, te_short * 44) <
|
||||
(te_delta * 15))) {
|
||||
decode_data = 0;
|
||||
decode_count_bit = 0;
|
||||
parser_step = BETTDecoderStepCheckDuration;
|
||||
}
|
||||
break;
|
||||
case BETTDecoderStepSaveDuration:
|
||||
if (!level) {
|
||||
if (DURATION_DIFF(duration, te_short * 44) <
|
||||
(te_delta * 15)) {
|
||||
if (decode_count_bit ==
|
||||
min_count_bit_for_found) {
|
||||
data = decode_data;
|
||||
data_count_bit = decode_count_bit;
|
||||
// dip decoder needed
|
||||
if (callback) callback(this);
|
||||
} else {
|
||||
parser_step = BETTDecoderStepReset;
|
||||
}
|
||||
decode_data = 0;
|
||||
decode_count_bit = 0;
|
||||
break;
|
||||
} else {
|
||||
if ((DURATION_DIFF(duration, te_short) <
|
||||
te_delta) ||
|
||||
(DURATION_DIFF(duration, te_long) <
|
||||
te_delta * 3)) {
|
||||
parser_step = BETTDecoderStepCheckDuration;
|
||||
} else {
|
||||
parser_step = BETTDecoderStepReset;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case BETTDecoderStepCheckDuration:
|
||||
if (level) {
|
||||
if (DURATION_DIFF(duration, te_long) <
|
||||
te_delta * 3) {
|
||||
subghz_protocol_blocks_add_bit(1);
|
||||
parser_step = BETTDecoderStepSaveDuration;
|
||||
} else if (
|
||||
DURATION_DIFF(duration, te_short) <
|
||||
te_delta) {
|
||||
subghz_protocol_blocks_add_bit(0);
|
||||
parser_step = BETTDecoderStepSaveDuration;
|
||||
} else {
|
||||
parser_step = BETTDecoderStepReset;
|
||||
}
|
||||
} else {
|
||||
parser_step = BETTDecoderStepReset;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
uint32_t te_short = 340;
|
||||
uint32_t te_long = 2000;
|
||||
uint32_t te_delta = 150;
|
||||
uint32_t min_count_bit_for_found = 18;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -26,6 +26,8 @@ class FProtoSubGhzDBase {
|
||||
uint32_t getSensorSerial() { return serial; }
|
||||
uint16_t getBits() { return data_count_bit; }
|
||||
uint8_t getBtn() { return btn; }
|
||||
uint32_t getData() { return data; }
|
||||
uint32_t getData2() { return data_2; }
|
||||
uint8_t modulation = FPM_AM; // override this, if FM
|
||||
protected:
|
||||
// Helper functions to keep it as compatible with flipper as we can, so adding new protos will be easy.
|
||||
@@ -42,15 +44,16 @@ class FProtoSubGhzDBase {
|
||||
uint32_t serial = SD_NO_SERIAL;
|
||||
uint16_t data_count_bit = 0;
|
||||
uint32_t seed = SD_NO_SEED;
|
||||
// princeton TE
|
||||
uint64_t data = 0;
|
||||
uint64_t data_2 = 0;
|
||||
// princeton TE?! //todo
|
||||
|
||||
// inner logic stuff, also for flipper compatibility.
|
||||
SubGhzDProtocolDecoderBaseRxCallback callback = NULL;
|
||||
uint16_t header_count = 0;
|
||||
uint8_t parser_step = 0;
|
||||
uint32_t te_last = 0;
|
||||
uint64_t data = 0;
|
||||
uint64_t data_2 = 0;
|
||||
|
||||
uint64_t decode_data = 0;
|
||||
uint32_t decode_count_bit = 0;
|
||||
uint8_t cnt_2 = 0;
|
||||
|
||||
@@ -12,6 +12,7 @@ So include here the .hpp, and add a new element to the protos vector in the cons
|
||||
#include "subghzdbase.hpp"
|
||||
#include "s-ansonic.hpp"
|
||||
#include "s-princeton.hpp"
|
||||
#include "s-bett.hpp"
|
||||
|
||||
#ifndef __FPROTO_PROTOLISTSGZ_H__
|
||||
#define __FPROTO_PROTOLISTSGZ_H__
|
||||
@@ -22,6 +23,7 @@ class SubGhzDProtos : public FProtoListGeneral {
|
||||
// add protos
|
||||
protos.push_back(std::make_unique<FProtoSubGhzDAnsonic>()); // 1
|
||||
protos.push_back(std::make_unique<FProtoSubGhzDPrinceton>()); // 2
|
||||
protos.push_back(std::make_unique<FProtoSubGhzDBett>()); // 3
|
||||
|
||||
// set callback for them
|
||||
for (const auto& obj : protos) {
|
||||
@@ -30,7 +32,7 @@ class SubGhzDProtos : public FProtoListGeneral {
|
||||
}
|
||||
|
||||
static void callbackTarget(FProtoSubGhzDBase* instance) {
|
||||
SubGhzDDataMessage packet_message{instance->getSensorType(), instance->getSensorSerial(), instance->getBits(), instance->getBtn()};
|
||||
SubGhzDDataMessage packet_message{instance->getSensorType(), instance->getSensorSerial(), instance->getBits(), instance->getData(), instance->getData2(), instance->getBtn()};
|
||||
shared_memory.application_queue.push(packet_message);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ enum FPROTO_SUBGHZD_SENSOR {
|
||||
FPS_Invalid = 0,
|
||||
FPS_ANSONIC = 1,
|
||||
FPS_PRINCETON = 2,
|
||||
|
||||
FPS_BETT = 3,
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user