Clean up TFA 30.3221.02

This commit is contained in:
Christian W. Zuckschwerdt 2020-09-03 12:38:30 +02:00
parent 57b015b569
commit 67b0131a42
9 changed files with 63 additions and 37 deletions

View file

@ -237,7 +237,8 @@ See [CONTRIBUTING.md](./docs/CONTRIBUTING.md).
[161] Interval Data Message (IDM) for Net Meters [161] Interval Data Message (IDM) for Net Meters
[162]* ThermoPro-TX2 temperature sensor [162]* ThermoPro-TX2 temperature sensor
[163] Acurite 590TX Temperature with optional Humidity [163] Acurite 590TX Temperature with optional Humidity
[164] Security+ 2.0 (Keyfob) [164] Security+ 2.0 (Keyfob)
[165] TFA Dostmann 30.3221.02 T/H Outdoor Sensor
* Disabled by default, use -R n or -G * Disabled by default, use -R n or -G

View file

@ -345,6 +345,8 @@ stop_after_successful_events false
protocol 161 # Interval Data Message (IDM) for Net Meters protocol 161 # Interval Data Message (IDM) for Net Meters
# protocol 162 # ThermoPro-TX2 temperature sensor # protocol 162 # ThermoPro-TX2 temperature sensor
protocol 163 # Acurite 590TX Temperature with optional Humidity protocol 163 # Acurite 590TX Temperature with optional Humidity
protocol 164 # Security+ 2.0 (Keyfob)
protocol 165 # TFA Dostmann 30.3221.02 T/H Outdoor Sensor
## Flex devices (command line option "-X") ## Flex devices (command line option "-X")

View file

@ -612,7 +612,10 @@ Interval Data Message (IDM) for Net Meters
Acurite 590TX Temperature with optional Humidity Acurite 590TX Temperature with optional Humidity
.TP .TP
[ \fB164\fI\fP ] [ \fB164\fI\fP ]
Security+ 2.0 (Keyfob) Security+ 2.0 (Keyfob)
.TP
[ \fB165\fI\fP ]
TFA Dostmann 30.3221.02 T/H Outdoor Sensor
* Disabled by default, use \-R n or \-G * Disabled by default, use \-R n or \-G
.SS "Input device selection" .SS "Input device selection"

View file

@ -142,6 +142,7 @@ add_library(r_433 STATIC
devices/springfield.c devices/springfield.c
devices/steelmate.c devices/steelmate.c
devices/tfa_30_3196.c devices/tfa_30_3196.c
devices/tfa_30_3221.c
devices/tfa_drop_30.3233.c devices/tfa_drop_30.3233.c
devices/tfa_pool_thermometer.c devices/tfa_pool_thermometer.c
devices/tfa_twin_plus_30.3049.c devices/tfa_twin_plus_30.3049.c
@ -168,7 +169,6 @@ add_library(r_433 STATIC
devices/wt450.c devices/wt450.c
devices/x10_rf.c devices/x10_rf.c
devices/x10_sec.c devices/x10_sec.c
devices/tfa_30_3221.c
) )
if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")

View file

@ -141,6 +141,7 @@ rtl_433_SOURCES = abuf.c \
devices/springfield.c \ devices/springfield.c \
devices/steelmate.c \ devices/steelmate.c \
devices/tfa_30_3196.c \ devices/tfa_30_3196.c \
devices/tfa_30_3221.c \
devices/tfa_drop_30.3233.c \ devices/tfa_drop_30.3233.c \
devices/tfa_pool_thermometer.c \ devices/tfa_pool_thermometer.c \
devices/tfa_twin_plus_30.3049.c \ devices/tfa_twin_plus_30.3049.c \

View file

@ -397,7 +397,7 @@ static int secplus_v2_callback(r_device *decoder, bitbuffer_t *bitbuffer)
// rolling_total is a 28 bit unsigned number // rolling_total is a 28 bit unsigned number
// fixed_totals is 40 bit in a uint64_t // fixed_totals is 40 bit in a uint64_t
snprintf(fixed_str, sizeof(fixed_str), "%lu", fixed_total); snprintf(fixed_str, sizeof(fixed_str), "%llu", fixed_total);
snprintf(rolling_str, sizeof(rolling_str), "%u", rolling_total); snprintf(rolling_str, sizeof(rolling_str), "%u", rolling_total);
/* clang-format off */ /* clang-format off */
@ -431,7 +431,7 @@ static char *output_fields[] = {
// -X "n=vI3,m=OOK_PCM,s=230,l=230,t=40,r=10000,g=7400,match={24}0xaaaa9560" // -X "n=vI3,m=OOK_PCM,s=230,l=230,t=40,r=10000,g=7400,match={24}0xaaaa9560"
r_device secplus_v2 = { r_device secplus_v2 = {
.name = "Security+ 2.0 (Keyfob) ", .name = "Security+ 2.0 (Keyfob)",
.modulation = OOK_PULSE_PCM_RZ, .modulation = OOK_PULSE_PCM_RZ,
.short_width = 250, .short_width = 250,
.long_width = 250, .long_width = 250,

View file

@ -1,26 +1,32 @@
/** @file /** @file
TFA 30.3221.02 decoder Temperature/Humidity outdoor sensor TFA 30.3221.02.
Copyright (C) 2020 Odessa Claude Copyright (C) 2020 Odessa Claude
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. (at your option) any later version.
*/ */
/* /**
Temperature/Humidity outdoor sensor TFA 30.3221.02 Temperature/Humidity outdoor sensor TFA 30.3221.02.
-------------------------------------------------------------------------------------------------
source : https://github.com/RFD-FHEM/RFFHEM/blob/master/FHEM/14_SD_WS.pm S.a. https://github.com/RFD-FHEM/RFFHEM/blob/master/FHEM/14_SD_WS.pm
0 4 | 8 12 | 16 20 | 24 28 | 32 36
0 4 | 8 12 | 16 20 | 24 28 | 32 36
--------- | --------- | --------- | --------- | ---------
0000 1001 | 0001 0110 | 0001 0000 | 0000 0111 | 0100 1001 0000 1001 | 0001 0110 | 0001 0000 | 0000 0111 | 0100 1001
iiii iiii | bscc tttt | tttt tttt | hhhh hhhh | ???? ???? iiii iiii | bscc tttt | tttt tttt | hhhh hhhh | ???? ????
i: 8 bit random id (changes on power-loss)
b: 1 bit battery indicator (0=>OK, 1=>LOW) - i: 8 bit random id (changes on power-loss)
s: 1 bit sendmode (0=>auto, 1=>manual) - b: 1 bit battery indicator (0=>OK, 1=>LOW)
c: 2 bit channel valid channels are 0-2 (1-3) - s: 1 bit sendmode (0=>auto, 1=>manual)
t: 12 bit unsigned temperature, offset 500, scaled by 10 - c: 2 bit channel valid channels are 0-2 (1-3)
h: 8 bit relative humidity percentage - t: 12 bit unsigned temperature, offset 500, scaled by 10
?: 8 bit unknown - h: 8 bit relative humidity percentage
The sensor sends 3 repetitions at intervals of about 60 seconds - ?: 8 bit checksum digest 0x31, 0xf4
The sensor sends 3 repetitions at intervals of about 60 seconds.
*/ */
#include "decoder.h" #include "decoder.h"
@ -28,44 +34,53 @@
static int tfa_303221_callback(r_device *decoder, bitbuffer_t *bitbuffer) static int tfa_303221_callback(r_device *decoder, bitbuffer_t *bitbuffer)
{ {
int row, sendmode, channel, battery_low, temp_raw, humidity; int row, sendmode, channel, battery_low, temp_raw, humidity;
double temp_c; float temp_c;
data_t *data; data_t *data;
uint8_t *bytes; uint8_t *b;
unsigned int device; unsigned int device;
/* Device send 4 row, checking for two repeated */ // Device send 4 row, checking for two repeated
row = bitbuffer_find_repeated_row(bitbuffer, (bitbuffer->num_rows > 4) ? 4 : 2, 40); row = bitbuffer_find_repeated_row(bitbuffer, (bitbuffer->num_rows > 4) ? 4 : 2, 40);
/* Checking for right number of bits per row*/ // Checking for right number of bits per row
if (bitbuffer->bits_per_row[0] != 41) if (bitbuffer->bits_per_row[0] != 41)
return DECODE_ABORT_LENGTH; return DECODE_ABORT_LENGTH;
bitbuffer_invert(bitbuffer); bitbuffer_invert(bitbuffer);
bytes = bitbuffer->bb[row]; b = bitbuffer->bb[row];
device = bytes[0]; device = b[0];
/* Sanity Check */ // Sanity Check
if (device == 0) if (device == 0)
return DECODE_FAIL_SANITY; return DECODE_FAIL_SANITY;
temp_raw = ((bytes[1] & 0x0F) << 8) | bytes[2]; // Validate checksum
temp_c = (double)(temp_raw - 500)/10; int observed_checksum = b[4];
humidity = bytes[3]; int computed_checksum = lfsr_digest8_reflect(b, 4, 0x31, 0xf4);
battery_low = bytes[1] >> 7; if (observed_checksum != computed_checksum) {
channel = ((bytes[1] >> 4) & 3) + 1; return DECODE_FAIL_MIC;
sendmode = (bytes[1] >> 6) & 1; }
temp_raw = ((b[1] & 0x0F) << 8) | b[2];
temp_c = (float)(temp_raw - 500) * 0.1f;
humidity = b[3];
battery_low = b[1] >> 7;
channel = ((b[1] >> 4) & 3) + 1;
sendmode = (b[1] >> 6) & 1;
/* clang-format off */ /* clang-format off */
data = data_make( data = data_make(
"model", "", DATA_STRING, "TFA-30322102", "model", "", DATA_STRING, "TFA-303221",
"id", "Sensor ID", DATA_INT, device, "id", "Sensor ID", DATA_INT, device,
"channel", "Channel", DATA_INT, channel, "channel", "Channel", DATA_INT, channel,
"battery_ok", "Battery", DATA_INT, !battery_low, "battery_ok", "Battery", DATA_INT, !battery_low,
"temperature_C", "Temperature", DATA_FORMAT, "%.2f C", DATA_DOUBLE, temp_c, "temperature_C", "Temperature", DATA_FORMAT, "%.2f C", DATA_DOUBLE, temp_c,
"humidity", "Humidity", DATA_FORMAT, "%u %%", DATA_INT, humidity, "humidity", "Humidity", DATA_FORMAT, "%u %%", DATA_INT, humidity,
"sendmode", "Test ?", DATA_STRING, sendmode ? "Yes" : "No", "sendmode", "Test mode", DATA_INT, sendmode,
"mic", "Integrity", DATA_STRING, "CRC",
NULL); NULL);
/* clang-format on */
decoder_output_data(decoder, data); decoder_output_data(decoder, data);
return 1; return 1;
@ -79,17 +94,17 @@ static char *output_fields[] = {
"temperature_C", "temperature_C",
"humidity", "humidity",
"sendmode", "sendmode",
"mic",
NULL, NULL,
}; };
r_device tfa_30_3221 = { r_device tfa_30_3221 = {
.name = "TFA Dostmann 30.3221 T/H Outdoor Sensor", .name = "TFA Dostmann 30.3221.02 T/H Outdoor Sensor",
.modulation = OOK_PULSE_PWM, .modulation = OOK_PULSE_PWM,
.short_width = 235, .short_width = 235,
.long_width = 480, .long_width = 480,
.reset_limit = 850, .reset_limit = 850,
.sync_width = 836, .sync_width = 836,
.decode_fn = &tfa_303221_callback, .decode_fn = &tfa_303221_callback,
.disabled = 0,
.fields = output_fields, .fields = output_fields,
}; };

View file

@ -265,6 +265,7 @@ COPY ..\..\libusb\MS64\dll\libusb*.dll $(TargetDir)</Command>
<ClCompile Include="..\src\devices\springfield.c" /> <ClCompile Include="..\src\devices\springfield.c" />
<ClCompile Include="..\src\devices\steelmate.c" /> <ClCompile Include="..\src\devices\steelmate.c" />
<ClCompile Include="..\src\devices\tfa_30_3196.c" /> <ClCompile Include="..\src\devices\tfa_30_3196.c" />
<ClCompile Include="..\src\devices\tfa_30_3221.c" />
<ClCompile Include="..\src\devices\tfa_drop_30.3233.c" /> <ClCompile Include="..\src\devices\tfa_drop_30.3233.c" />
<ClCompile Include="..\src\devices\tfa_pool_thermometer.c" /> <ClCompile Include="..\src\devices\tfa_pool_thermometer.c" />
<ClCompile Include="..\src\devices\tfa_twin_plus_30.3049.c" /> <ClCompile Include="..\src\devices\tfa_twin_plus_30.3049.c" />

View file

@ -532,6 +532,9 @@
<ClCompile Include="..\src\devices\tfa_30_3196.c"> <ClCompile Include="..\src\devices\tfa_30_3196.c">
<Filter>Source Files\devices</Filter> <Filter>Source Files\devices</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\src\devices\tfa_30_3221.c">
<Filter>Source Files\devices</Filter>
</ClCompile>
<ClCompile Include="..\src\devices\tfa_drop_30.3233.c"> <ClCompile Include="..\src\devices\tfa_drop_30.3233.c">
<Filter>Source Files\devices</Filter> <Filter>Source Files\devices</Filter>
</ClCompile> </ClCompile>