Skip to content

Commit cb4e1e4

Browse files
authored
Add battery status to TFA-Marbella (#3524)
1 parent 00d1c70 commit cb4e1e4

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

src/devices/tfa_marbella.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,17 @@ The Marbella sensor operates at 868MHz frequency band.
2323
FSK_PCM with 105 us long high durations
2424
2525
AA 2D D4 68 3F 16 0A 31 9A AA XX
26-
PP SS SS RR RR RR ZC TT TA AA LL
26+
PP SS SS RR RR RR FF TT TA AA LL
2727
2828
2929
P - preamble 0xA
3030
S - common sync 0x2dd4
3131
R - serial number of sensor
32-
Z - always zero
33-
C - 3 bit counter
32+
F - flags byte:
33+
bit 7 battery low indicator
34+
bit 6-4 reserved / unknown
35+
bit 3-1 3-bit rolling counter
36+
bit 0 reserved / unknown
3437
T - 12 bit temperature in degree celsius
3538
A - always 0xA
3639
L - lsfr, byte reflected reverse galois with 0x31 key and generator
@@ -67,7 +70,8 @@ static int tfa_marbella_callback(r_device *decoder, bitbuffer_t *bitbuffer)
6770

6871
int temp_raw = (msg[7] << 4) | (msg[8] >> 4);
6972
float temp_c = (temp_raw - 400) * 0.1f;
70-
int counter = (msg[6] & 0xF) >> 1;
73+
int battery_low = (msg[6] >> 7) & 0x01;
74+
int counter = (msg[6] >> 1) & 0x07;
7175
int serialnr = msg[3] << 16 | msg[4] << 8 | msg[5];
7276

7377
char serialnr_str[6 * 2 + 1];
@@ -78,6 +82,7 @@ static int tfa_marbella_callback(r_device *decoder, bitbuffer_t *bitbuffer)
7882
"model", "", DATA_STRING, "TFA-Marbella",
7983
"id", "", DATA_STRING, serialnr_str,
8084
"counter", "", DATA_INT, counter,
85+
"battery_ok", "Battery", DATA_INT, !battery_low,
8186
"temperature_C", "Temperature", DATA_FORMAT, "%.1f C", DATA_DOUBLE, temp_c,
8287
"mic", "Integrity", DATA_STRING, "CRC",
8388
NULL);
@@ -91,6 +96,7 @@ static char const *const output_fields[] = {
9196
"model",
9297
"id",
9398
"counter",
99+
"battery_ok",
94100
"temperature_C",
95101
"mic",
96102
NULL,

0 commit comments

Comments
 (0)