Skip to content

Commit 48b7916

Browse files
author
Benjamin Larsson
committed
Add Amazon Basics Meat Thermometer decoder
1 parent ad55a53 commit 48b7916

File tree

8 files changed

+110
-0
lines changed

8 files changed

+110
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ See [CONTRIBUTING.md](./docs/CONTRIBUTING.md).
259259
[178] Security+ (Keyfob)
260260
[179] Cavius smoke, heat and water detector
261261
[180] Jansite TPMS Model Solar
262+
[181] Amazon Basics Meat Thermometer
262263
263264
* Disabled by default, use -R n or -G
264265

conf/rtl_433.example.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ stop_after_successful_events false
362362
protocol 178 # Security+ (Keyfob)
363363
protocol 179 # Cavius smoke, heat and water detector
364364
protocol 180 # Jansite TPMS Model Solar
365+
protocol 181 # Amazon Basics Meat Thermometer
365366

366367
## Flex devices (command line option "-X")
367368

include/rtl_433_devices.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@
188188
DECL(secplus_v1) \
189189
DECL(cavius) \
190190
DECL(tpms_jansite_solar) \
191+
DECL(abmt) \
191192
/* Add new decoders here. */
192193

193194
#define DECL(name) extern r_device name;

src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ add_library(r_433 STATIC
3535
term_ctl.c
3636
util.c
3737
write_sigrok.c
38+
devices/abmt.c
3839
devices/acurite.c
3940
devices/akhan_100F14.c
4041
devices/alecto.c

src/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ rtl_433_SOURCES = abuf.c \
3434
term_ctl.c \
3535
util.c \
3636
write_sigrok.c \
37+
devices/abmt.c \
3738
devices/acurite.c \
3839
devices/akhan_100F14.c \
3940
devices/alecto.c \

src/devices/abmt.c

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
/** @file
2+
Amazon Basics Meat Thermometer
3+
4+
Copyright (C) 2021 Benjamin Larsson
5+
6+
This program is free software; you can redistribute it and/or modify
7+
it under the terms of the GNU General Public License as published by
8+
the Free Software Foundation; either version 2 of the License, or
9+
(at your option) any later version.
10+
*/
11+
/**
12+
Amazon Basics Meat Thermometer
13+
14+
Manchester encoded PCM signal.
15+
16+
[00] {48} e4 00 a3 01 40 ff
17+
18+
II 00 UU TT T0 FF
19+
20+
I - power on random id
21+
0 - zeros
22+
U - Unknown
23+
T - bcd coded temperature
24+
F - ones
25+
26+
27+
*/
28+
#include "decoder.h"
29+
30+
#define SYNC_PATTERN_START_OFF 72
31+
32+
// Convert two BCD encoded nibbles to an integer
33+
static unsigned bcd2int(uint8_t bcd)
34+
{
35+
return 10*(bcd>>4) + (bcd & 0xF);
36+
}
37+
38+
static int abmt_callback(r_device *decoder, bitbuffer_t *bitbuffer)
39+
{
40+
int row;
41+
float temp_c;
42+
bitbuffer_t packet_bits = {0};
43+
unsigned int id;
44+
data_t *data;
45+
unsigned bitpos = 0;
46+
uint8_t *b;
47+
int16_t temp;
48+
uint8_t const sync_pattern[3] = {0x55, 0xAA, 0xAA};
49+
50+
// Find repeats
51+
row = bitbuffer_find_repeated_row(bitbuffer, 4, 90);
52+
if (row < 0)
53+
return DECODE_ABORT_EARLY;
54+
55+
if (bitbuffer->bits_per_row[row] > 120)
56+
return DECODE_ABORT_LENGTH;
57+
58+
// search for 24 bit sync pattern
59+
bitpos = bitbuffer_search(bitbuffer, row, bitpos, sync_pattern, 24);
60+
// if sync is not found or sync is found with to little bits available, abort
61+
if ((bitpos == bitbuffer->bits_per_row[row]) || (bitpos < SYNC_PATTERN_START_OFF))
62+
return DECODE_FAIL_SANITY;
63+
64+
// sync bitstream
65+
bitbuffer_manchester_decode(bitbuffer, row, bitpos-SYNC_PATTERN_START_OFF, &packet_bits, 48);
66+
bitbuffer_invert(&packet_bits);
67+
68+
b = packet_bits.bb[0];
69+
id = b[0];
70+
temp = bcd2int(b[3])*10 + bcd2int(b[4]>>4);
71+
temp_c = (float)temp;
72+
73+
/* clang-format off */
74+
data = data_make(
75+
"model", "", DATA_STRING, "Basics-Meat",
76+
"id", "Id", DATA_INT, id,
77+
"temperature_C", "Temperature", DATA_FORMAT, "%.01f C", DATA_DOUBLE, temp_c,
78+
NULL);
79+
/* clang-format on */
80+
decoder_output_data(decoder, data);
81+
return 1;
82+
}
83+
84+
static char *output_fields[] = {
85+
"model",
86+
"id",
87+
"temperature_C",
88+
NULL,
89+
};
90+
91+
r_device abmt = {
92+
.name = "Amazon Basics Meat Thermometer",
93+
.modulation = OOK_PULSE_PCM_RZ,
94+
.short_width = 550,
95+
.long_width = 550,
96+
.gap_limit = 2000,
97+
.reset_limit = 5000,
98+
.decode_fn = &abmt_callback,
99+
.disabled = 0,
100+
.fields = output_fields,
101+
};

vs15/rtl_433.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ COPY ..\..\libusb\MS64\dll\libusb*.dll $(TargetDir)</Command>
163163
<ClCompile Include="..\src\term_ctl.c" />
164164
<ClCompile Include="..\src\util.c" />
165165
<ClCompile Include="..\src\write_sigrok.c" />
166+
<ClCompile Include="..\src\devices\abmt.c" />
166167
<ClCompile Include="..\src\devices\acurite.c" />
167168
<ClCompile Include="..\src\devices\akhan_100F14.c" />
168169
<ClCompile Include="..\src\devices\alecto.c" />

vs15/rtl_433.vcxproj.filters

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,9 @@
226226
<ClCompile Include="..\src\getopt\getopt.c">
227227
<Filter>Source Files\getopt</Filter>
228228
</ClCompile>
229+
<ClCompile Include="..\src\devices\abmt.c">
230+
<Filter>Source Files\devices</Filter>
231+
</ClCompile>
229232
<ClCompile Include="..\src\devices\acurite.c">
230233
<Filter>Source Files\devices</Filter>
231234
</ClCompile>

0 commit comments

Comments
 (0)