mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-12-25 07:19:28 -05:00
2ccda5aebd
* Initial commit - wip
* Half part of the transition of baseband processor.
* More SGD
* WIP, Weather refactor, UI improv
* Rename
* Added 4msps, and fixes
* Fixes
* princeton working
* Renamed proc_weather, bc now multifunctional
* Proto: bett
* FPS_CAME = 4,
FPS_PRASTEL = 5,
FPS_AIRFORCE = 6,
* Came Atomo, fixes
* Separate weather and sgd, bc of baseband size limit
* Fix display
* Save space
* More protos
* Dooya proto added
* More protos
* add protos
* More protos
* Move weather to ext app
* nw
* Revert "Move weather to ext app"
This reverts commit 8a84aac2f5
.
* revert
* Fix merge
* Better naming
* More protos
* More protos
* Add protos
* Fix warning
* Add NeroRadio
* more protos
* more protos
* More protos
* Shrink a bit
* fixes
* More protos
* Nicer code
* Fix naming
* Fix format
* Remove unused
* Fix some protos, that needs a LOOOONG part with the same lo/high
* Modify key calculation
111 lines
4.6 KiB
C++
111 lines
4.6 KiB
C++
|
|
#ifndef __FPROTO_SECPLUSV2_H__
|
|
#define __FPROTO_SECPLUSV2_H__
|
|
|
|
#include "subghzdbase.hpp"
|
|
|
|
#define SECPLUS_V2_HEADER 0x3C0000000000
|
|
#define SECPLUS_V2_HEADER_MASK 0xFFFF3C0000000000
|
|
#define SECPLUS_V2_PACKET_1 0x000000000000
|
|
#define SECPLUS_V2_PACKET_2 0x010000000000
|
|
#define SECPLUS_V2_PACKET_MASK 0x30000000000
|
|
|
|
typedef enum : uint8_t {
|
|
SecPlus_v2DecoderStepReset = 0,
|
|
SecPlus_v2DecoderStepDecoderData,
|
|
} SecPlus_v2DecoderStep;
|
|
|
|
class FProtoSubGhzDSecPlusV2 : public FProtoSubGhzDBase {
|
|
public:
|
|
FProtoSubGhzDSecPlusV2() {
|
|
sensorType = FPS_SECPLUSV2;
|
|
te_short = 250;
|
|
te_long = 500;
|
|
te_delta = 110;
|
|
min_count_bit_for_found = 62;
|
|
}
|
|
|
|
void feed(bool level, uint32_t duration) {
|
|
ManchesterEvent event = ManchesterEventReset;
|
|
switch (parser_step) {
|
|
case SecPlus_v2DecoderStepReset:
|
|
if ((!level) && (DURATION_DIFF(duration, te_long * 130) < te_delta * 100)) {
|
|
// Found header Security+ 2.0
|
|
parser_step = SecPlus_v2DecoderStepDecoderData;
|
|
decode_data = 0;
|
|
decode_count_bit = 0;
|
|
secplus_packet_1 = 0;
|
|
FProtoGeneral::manchester_advance(manchester_saved_state, ManchesterEventReset, &manchester_saved_state, NULL);
|
|
FProtoGeneral::manchester_advance(manchester_saved_state, ManchesterEventLongHigh, &manchester_saved_state, NULL);
|
|
FProtoGeneral::manchester_advance(manchester_saved_state, ManchesterEventShortLow, &manchester_saved_state, NULL);
|
|
}
|
|
break;
|
|
case SecPlus_v2DecoderStepDecoderData:
|
|
if (!level) {
|
|
if (DURATION_DIFF(duration, te_short) < te_delta) {
|
|
event = ManchesterEventShortLow;
|
|
} else if (
|
|
DURATION_DIFF(duration, te_long) < te_delta) {
|
|
event = ManchesterEventLongLow;
|
|
} else if (
|
|
duration >= (te_long * 2UL + te_delta)) {
|
|
if (decode_count_bit == min_count_bit_for_found) {
|
|
data = decode_data;
|
|
data_count_bit = decode_count_bit;
|
|
if (subghz_protocol_secplus_v2_check_packet()) {
|
|
// controller too big
|
|
if (callback) callback(this);
|
|
parser_step = SecPlus_v2DecoderStepReset;
|
|
}
|
|
}
|
|
decode_data = 0;
|
|
decode_count_bit = 0;
|
|
FProtoGeneral::manchester_advance(manchester_saved_state, ManchesterEventReset, &manchester_saved_state, NULL);
|
|
FProtoGeneral::manchester_advance(manchester_saved_state, ManchesterEventLongHigh, &manchester_saved_state, NULL);
|
|
FProtoGeneral::manchester_advance(manchester_saved_state, ManchesterEventShortLow, &manchester_saved_state, NULL);
|
|
} else {
|
|
parser_step = SecPlus_v2DecoderStepReset;
|
|
}
|
|
} else {
|
|
if (DURATION_DIFF(duration, te_short) < te_delta) {
|
|
event = ManchesterEventShortHigh;
|
|
} else if (
|
|
DURATION_DIFF(duration, te_long) < te_delta) {
|
|
event = ManchesterEventLongHigh;
|
|
} else {
|
|
parser_step = SecPlus_v2DecoderStepReset;
|
|
}
|
|
}
|
|
if (event != ManchesterEventReset) {
|
|
bool bit;
|
|
bool data_ok = FProtoGeneral::manchester_advance(manchester_saved_state, event, &manchester_saved_state, &bit);
|
|
|
|
if (data_ok) {
|
|
decode_data = (decode_data << 1) | bit;
|
|
decode_count_bit++;
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
protected:
|
|
uint64_t secplus_packet_1 = 0;
|
|
ManchesterState manchester_saved_state = ManchesterStateMid0;
|
|
|
|
bool subghz_protocol_secplus_v2_check_packet() {
|
|
if ((decode_data & SECPLUS_V2_HEADER_MASK) == SECPLUS_V2_HEADER) {
|
|
if ((decode_data & SECPLUS_V2_PACKET_MASK) == SECPLUS_V2_PACKET_1) {
|
|
secplus_packet_1 = decode_data;
|
|
} else if (
|
|
((decode_data & SECPLUS_V2_PACKET_MASK) == SECPLUS_V2_PACKET_2) &&
|
|
(secplus_packet_1)) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
};
|
|
|
|
#endif
|