2023-11-28 15:11:30 -05:00
|
|
|
|
|
|
|
#ifndef __FPROTO_LACROSSE_TX141thbv2_H__
|
|
|
|
#define __FPROTO_LACROSSE_TX141thbv2_H__
|
|
|
|
|
|
|
|
#include "weatherbase.hpp"
|
|
|
|
|
|
|
|
#define LACROSSE_TX141TH_BV2_BIT_COUNT 41
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
LaCrosse_TX141THBv2DecoderStepReset = 0,
|
|
|
|
LaCrosse_TX141THBv2DecoderStepCheckPreambule,
|
|
|
|
LaCrosse_TX141THBv2DecoderStepSaveDuration,
|
|
|
|
LaCrosse_TX141THBv2DecoderStepCheckDuration,
|
|
|
|
} LaCrosse_TX141THBv2DecoderStep;
|
|
|
|
|
|
|
|
class FProtoWeatherLaCrosseTx141thbv2 : public FProtoWeatherBase {
|
|
|
|
public:
|
|
|
|
FProtoWeatherLaCrosseTx141thbv2() {
|
|
|
|
sensorType = FPW_LACROSSETX141thbv2;
|
|
|
|
}
|
|
|
|
|
|
|
|
void feed(bool level, uint32_t duration) {
|
|
|
|
switch (parser_step) {
|
|
|
|
case LaCrosse_TX141THBv2DecoderStepReset:
|
|
|
|
if ((level) && (DURATION_DIFF(duration, te_short * 4) < te_delta * 2)) {
|
|
|
|
parser_step = LaCrosse_TX141THBv2DecoderStepCheckPreambule;
|
|
|
|
te_last = duration;
|
|
|
|
header_count = 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LaCrosse_TX141THBv2DecoderStepCheckPreambule:
|
|
|
|
if (level) {
|
|
|
|
te_last = duration;
|
|
|
|
} else {
|
|
|
|
if ((DURATION_DIFF(te_last, te_short * 4) < te_delta * 2) &&
|
|
|
|
(DURATION_DIFF(duration, te_short * 4) < te_delta * 2)) {
|
|
|
|
// Found preambule
|
|
|
|
header_count++;
|
|
|
|
} else if (header_count == 4) {
|
|
|
|
if (ws_protocol_decoder_lacrosse_tx141thbv2_add_bit(te_last, duration)) {
|
|
|
|
decode_data = decode_data & 1;
|
|
|
|
decode_count_bit = 1;
|
|
|
|
parser_step = LaCrosse_TX141THBv2DecoderStepSaveDuration;
|
|
|
|
} else {
|
|
|
|
parser_step = LaCrosse_TX141THBv2DecoderStepReset;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
parser_step = LaCrosse_TX141THBv2DecoderStepReset;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LaCrosse_TX141THBv2DecoderStepSaveDuration:
|
|
|
|
if (level) {
|
|
|
|
te_last = duration;
|
|
|
|
parser_step = LaCrosse_TX141THBv2DecoderStepCheckDuration;
|
|
|
|
} else {
|
|
|
|
parser_step = LaCrosse_TX141THBv2DecoderStepReset;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case LaCrosse_TX141THBv2DecoderStepCheckDuration:
|
|
|
|
if (!level) {
|
|
|
|
if (((DURATION_DIFF(te_last, te_short * 3) < te_delta * 2) &&
|
|
|
|
(DURATION_DIFF(duration, te_short * 4) < te_delta * 2))) {
|
|
|
|
if ((decode_count_bit == min_count_bit_for_found) ||
|
|
|
|
(decode_count_bit == LACROSSE_TX141TH_BV2_BIT_COUNT)) {
|
|
|
|
if (ws_protocol_lacrosse_tx141thbv2_check_crc()) {
|
2024-09-06 14:23:11 -04:00
|
|
|
if (decode_count_bit == LACROSSE_TX141TH_BV2_BIT_COUNT) {
|
|
|
|
decode_data >>= 1;
|
|
|
|
}
|
2023-11-28 15:11:30 -05:00
|
|
|
if (callback) callback(this);
|
|
|
|
}
|
|
|
|
decode_data = 0;
|
|
|
|
decode_count_bit = 0;
|
|
|
|
header_count = 1;
|
|
|
|
parser_step = LaCrosse_TX141THBv2DecoderStepCheckPreambule;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else if (ws_protocol_decoder_lacrosse_tx141thbv2_add_bit(te_last, duration)) {
|
|
|
|
parser_step = LaCrosse_TX141THBv2DecoderStepSaveDuration;
|
|
|
|
} else {
|
|
|
|
parser_step = LaCrosse_TX141THBv2DecoderStepReset;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
parser_step = LaCrosse_TX141THBv2DecoderStepReset;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
uint32_t te_short = 208;
|
|
|
|
uint32_t te_long = 417;
|
|
|
|
uint32_t te_delta = 120;
|
|
|
|
uint32_t min_count_bit_for_found = 40;
|
|
|
|
|
|
|
|
bool ws_protocol_lacrosse_tx141thbv2_check_crc() {
|
|
|
|
if (!decode_data) return false;
|
|
|
|
uint64_t data = decode_data;
|
|
|
|
if (decode_count_bit == LACROSSE_TX141TH_BV2_BIT_COUNT) {
|
|
|
|
data >>= 1;
|
|
|
|
}
|
|
|
|
uint8_t msg[] = {static_cast<uint8_t>(data >> 32), static_cast<uint8_t>(data >> 24), static_cast<uint8_t>(data >> 16), static_cast<uint8_t>(data >> 8)};
|
|
|
|
|
Subghz decoder (#1646)
* 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 8a84aac2f59274b72de7c7803deb137a21838076.
* 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
2023-12-16 17:37:51 -05:00
|
|
|
uint8_t crc = FProtoGeneral::subghz_protocol_blocks_lfsr_digest8_reflect(msg, 4, 0x31, 0xF4);
|
2023-11-28 15:11:30 -05:00
|
|
|
return (crc == (data & 0xFF));
|
|
|
|
}
|
2024-09-06 14:23:11 -04:00
|
|
|
|
2023-11-28 15:11:30 -05:00
|
|
|
bool ws_protocol_decoder_lacrosse_tx141thbv2_add_bit(uint32_t te_last, uint32_t te_current) {
|
|
|
|
bool ret = false;
|
|
|
|
if (DURATION_DIFF(te_last + te_current, te_short + te_long) < te_delta * 2) {
|
|
|
|
if (te_last > te_current) {
|
|
|
|
subghz_protocol_blocks_add_bit(1);
|
|
|
|
} else {
|
|
|
|
subghz_protocol_blocks_add_bit(0);
|
|
|
|
}
|
|
|
|
ret = true;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|