Fix oregon2 weather protocol (#1642)

This commit is contained in:
Totoo 2023-12-12 06:45:56 +01:00 committed by GitHub
parent 5f8e44e7b7
commit 5b9d898202
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -68,7 +68,7 @@ class FProtoWeatherOregon2 : public FProtoWeatherBase {
void feed(bool level, uint32_t duration) override {
// oregon v2.1 signal is inverted
ManchesterEvent event = level_and_duration_to_event(!level, duration);
bool data;
bool bit_value = false;
// low-level bit sequence decoding
if (event == ManchesterEventReset) {
@ -77,18 +77,18 @@ class FProtoWeatherOregon2 : public FProtoWeatherBase {
decode_data = 0UL;
decode_count_bit = 0;
}
if (manchester_advance(manchester_saved_state, event, &manchester_saved_state, &data)) {
if (manchester_advance(manchester_saved_state, event, &manchester_saved_state, &bit_value)) {
if (have_bit) {
if (!prev_bit && data) {
if (!prev_bit && bit_value) {
subghz_protocol_blocks_add_bit(1);
} else if (prev_bit && !data) {
} else if (prev_bit && !bit_value) {
subghz_protocol_blocks_add_bit(0);
} else {
ws_protocol_decoder_oregon2_reset();
}
have_bit = false;
} else {
prev_bit = data;
prev_bit = bit_value;
have_bit = true;
}
}
@ -118,8 +118,7 @@ class FProtoWeatherOregon2 : public FProtoWeatherBase {
(data & 0xCCCCCCCC) >> 2;
ws_oregon2_decode_const_data();
var_bits =
oregon2_sensor_id_var_bits(OREGON2_SENSOR_ID(data));
var_bits = oregon2_sensor_id_var_bits(OREGON2_SENSOR_ID(data));
if (!var_bits) {
// sensor is not supported, stop decoding, but showing the decoded fixed part