2023-11-28 15:11:30 -05:00
|
|
|
|
|
|
|
#ifndef __FPROTO_Ambient_H__
|
|
|
|
#define __FPROTO_Ambient_H__
|
|
|
|
|
|
|
|
#include "weatherbase.hpp"
|
|
|
|
|
|
|
|
#define AMBIENT_WEATHER_PACKET_HEADER_1 0xFFD440000000000 // 0xffd45 .. 0xffd46
|
|
|
|
#define AMBIENT_WEATHER_PACKET_HEADER_2 0x001440000000000 // 0x00145 .. 0x00146
|
|
|
|
#define AMBIENT_WEATHER_PACKET_HEADER_MASK 0xFFFFC0000000000
|
|
|
|
|
|
|
|
class FProtoWeatherAmbient : public FProtoWeatherBase {
|
|
|
|
public:
|
|
|
|
FProtoWeatherAmbient() {
|
|
|
|
sensorType = FPW_Ambient;
|
|
|
|
}
|
|
|
|
|
|
|
|
void feed(bool level, uint32_t duration) {
|
|
|
|
ManchesterEvent event = ManchesterEventReset;
|
|
|
|
if (!level) {
|
|
|
|
if (DURATION_DIFF(duration, te_short) < te_delta) {
|
|
|
|
event = ManchesterEventShortLow;
|
|
|
|
} else if (
|
|
|
|
DURATION_DIFF(duration, te_long) < te_delta * 2) {
|
|
|
|
event = ManchesterEventLongLow;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (DURATION_DIFF(duration, te_short) < te_delta) {
|
|
|
|
event = ManchesterEventShortHigh;
|
|
|
|
} else if (
|
|
|
|
DURATION_DIFF(duration, te_long) < te_delta * 2) {
|
|
|
|
event = ManchesterEventLongHigh;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (event != ManchesterEventReset) {
|
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
|
|
|
bool bit;
|
|
|
|
bool data_ok = FProtoGeneral::manchester_advance(manchester_saved_state, event, &manchester_saved_state, &bit);
|
2023-11-28 15:11:30 -05:00
|
|
|
|
|
|
|
if (data_ok) {
|
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
|
|
|
decode_data = (decode_data << 1) | !bit;
|
2023-11-28 15:11:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (((decode_data & AMBIENT_WEATHER_PACKET_HEADER_MASK) == AMBIENT_WEATHER_PACKET_HEADER_1) ||
|
|
|
|
((decode_data & AMBIENT_WEATHER_PACKET_HEADER_MASK) == AMBIENT_WEATHER_PACKET_HEADER_2)) {
|
|
|
|
if (ws_protocol_ambient_weather_check_crc()) {
|
|
|
|
data = decode_data;
|
|
|
|
data_count_bit = min_count_bit_for_found;
|
|
|
|
ws_protocol_ambient_weather_remote_controller();
|
|
|
|
if (callback) callback(this);
|
|
|
|
decode_data = 0;
|
|
|
|
decode_count_bit = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
decode_data = 0;
|
|
|
|
decode_count_bit = 0;
|
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
|
|
|
FProtoGeneral::manchester_advance(manchester_saved_state, ManchesterEventReset, &manchester_saved_state, NULL);
|
2023-11-28 15:11:30 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
uint32_t te_short = 500;
|
|
|
|
uint32_t te_long = 1000;
|
|
|
|
uint32_t te_delta = 120;
|
|
|
|
uint32_t min_count_bit_for_found = 48;
|
2024-07-24 05:53:09 -04:00
|
|
|
ManchesterState manchester_saved_state = ManchesterStateMid1;
|
2023-11-28 15:11:30 -05:00
|
|
|
bool ws_protocol_ambient_weather_check_crc() {
|
|
|
|
uint8_t msg[] = {
|
|
|
|
static_cast<uint8_t>(decode_data >> 40),
|
|
|
|
static_cast<uint8_t>(decode_data >> 32),
|
|
|
|
static_cast<uint8_t>(decode_data >> 24),
|
|
|
|
static_cast<uint8_t>(decode_data >> 16),
|
|
|
|
static_cast<uint8_t>(decode_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(msg, 5, 0x98, 0x3e) ^ 0x64;
|
2023-11-28 15:11:30 -05:00
|
|
|
return (crc == (uint8_t)(decode_data & 0xFF));
|
|
|
|
}
|
|
|
|
|
|
|
|
void ws_protocol_ambient_weather_remote_controller() {
|
|
|
|
id = (data >> 32) & 0xFF;
|
|
|
|
battery_low = (data >> 31) & 1;
|
|
|
|
channel = ((data >> 28) & 0x07) + 1;
|
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
|
|
|
temp = FProtoGeneral::locale_fahrenheit_to_celsius(((float)((data >> 16) & 0x0FFF) - 400.0f) / 10.0f);
|
2023-11-28 15:11:30 -05:00
|
|
|
humidity = (data >> 8) & 0xFF;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|