Skip to content

Commit 751cfef

Browse files
merbananBenjamin Larsson
authored and
Benjamin Larsson
committed
Add decoder for jansite solar tpms
1 parent a81f543 commit 751cfef

8 files changed

+145
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ See [CONTRIBUTING.md](./docs/CONTRIBUTING.md).
258258
[177] Burnhard BBQ thermometer
259259
[178] Security+ (Keyfob)
260260
[179] Cavius smoke, heat and water detector
261+
[180] Jansite TPMS Model Solar
261262
262263
* Disabled by default, use -R n or -G
263264

conf/rtl_433.example.conf

+1
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,7 @@ stop_after_successful_events false
361361
protocol 177 # Burnhard BBQ thermometer
362362
protocol 178 # Security+ (Keyfob)
363363
protocol 179 # Cavius smoke, heat and water detector
364+
protocol 180 # Jansite TPMS Model Solar
364365

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

include/rtl_433_devices.h

+1
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@
187187
DECL(burnhardbbq) \
188188
DECL(secplus_v1) \
189189
DECL(cavius) \
190+
DECL(tpms_jansite_solar) \
190191
/* Add new decoders here. */
191192

192193
#define DECL(name) extern r_device name;

src/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ add_library(r_433 STATIC
172172
devices/tpms_elantra2012.c
173173
devices/tpms_ford.c
174174
devices/tpms_jansite.c
175+
devices/tpms_jansite_solar.c
175176
devices/tpms_pmv107j.c
176177
devices/tpms_renault.c
177178
devices/tpms_toyota.c

src/Makefile.am

+1
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ rtl_433_SOURCES = abuf.c \
171171
devices/tpms_elantra2012.c \
172172
devices/tpms_ford.c \
173173
devices/tpms_jansite.c \
174+
devices/tpms_jansite_solar.c \
174175
devices/tpms_pmv107j.c \
175176
devices/tpms_renault.c \
176177
devices/tpms_toyota.c \

src/devices/tpms_jansite_solar.c

+136
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
/** @file
2+
Jansite FSK 11 byte Manchester encoded checksummed TPMS data.
3+
4+
Copyright (C) 2021 Benjamin Larsson
5+
6+
based on code
7+
2019 Andreas Spiess and Christian W. Zuckschwerdt <[email protected]>
8+
9+
This program is free software; you can redistribute it and/or modify
10+
it under the terms of the GNU General Public License as published by
11+
the Free Software Foundation; either version 2 of the License, or
12+
(at your option) any later version.
13+
*/
14+
15+
/**
16+
Jansite Solar TPMS Solar Model
17+
18+
Signal is manchester encoded, and a 11 byte large message
19+
20+
Data layout (nibbles):
21+
22+
SS SS II II II 00 TT PP 00 CC CC
23+
24+
- S: 16 bits sync word, 0xdd33
25+
- I: 24 bits ID
26+
- 0: 8 bits Unknown data 1
27+
- T: 8 bit Temperature (deg. C offset by 55)
28+
- P: 8 bit Pressure
29+
- 0: 8 bits Unknown data 2
30+
- C: 16 bit CRC (CRC-16/BUYPASS)
31+
- The preamble is 0xa6, 0xa6, 0x5a
32+
33+
TODO: identify battery bits
34+
*/
35+
36+
#include "decoder.h"
37+
38+
static int tpms_jansite_solar_decode(r_device *decoder, bitbuffer_t *bitbuffer, unsigned row, unsigned bitpos)
39+
{
40+
data_t *data;
41+
bitbuffer_t packet_bits = {0};
42+
uint8_t *b;
43+
unsigned id;
44+
char id_str[7 + 1];
45+
int flags;
46+
int pressure;
47+
int temperature;
48+
char code_str[9 * 2 + 1];
49+
50+
bitbuffer_manchester_decode(bitbuffer, row, bitpos, &packet_bits, 88);
51+
bitbuffer_invert(&packet_bits);
52+
53+
if (packet_bits.bits_per_row[0] < 88) {
54+
return DECODE_FAIL_SANITY;
55+
}
56+
b = packet_bits.bb[0];
57+
58+
/* Check for sync */
59+
if ((b[0]<<8 | b[1]) != 0xdd33) {
60+
return DECODE_FAIL_SANITY;
61+
}
62+
63+
/* Check crc */
64+
uint16_t crc_calc = crc16(&b[2], 7, 0x8005, 0x0000);
65+
if ( ((b[9]<<8) | b[10]) != crc_calc) {
66+
fprintf(stderr, "CRC missmatch %04x vs %02x %02x\n", crc_calc, b[9], b[10]);
67+
return DECODE_FAIL_MIC;
68+
}
69+
70+
id = (unsigned)b[2] << 16 | b[3] << 8 | b[4];
71+
flags = b[5];
72+
temperature = b[6];
73+
pressure = b[7];
74+
sprintf(id_str, "%06x", id);
75+
sprintf(code_str, "%02x%02x%02x%02x%02x%02x%02x%02x%02x", b[2], b[3], b[4], b[5], b[6], b[7], b[8], b[9], b[10]);
76+
77+
/* clang-format off */
78+
data = data_make(
79+
"model", "", DATA_STRING, "Jansite Solar",
80+
"type", "", DATA_STRING, "TPMS",
81+
"id", "", DATA_STRING, id_str,
82+
"flags", "", DATA_INT, flags,
83+
"pressure_kPa", "Pressure", DATA_FORMAT, "%.0f kPa", DATA_DOUBLE, (float)pressure * 1.6,
84+
"temperature_C", "Temperature", DATA_FORMAT, "%.0f C", DATA_DOUBLE, (float)temperature - 55.0,
85+
"code", "", DATA_STRING, code_str,
86+
"mic", "", DATA_STRING, "CRC",
87+
NULL);
88+
/* clang-format on */
89+
90+
decoder_output_data(decoder, data);
91+
return 1;
92+
}
93+
94+
/** @sa tpms_jansite_solar_decode() */
95+
static int tpms_jansite_solar_callback(r_device *decoder, bitbuffer_t *bitbuffer)
96+
{
97+
uint8_t const preamble_pattern[3] = {0xa6, 0xa6, 0x5a};
98+
99+
unsigned bitpos = 0;
100+
int ret = 0;
101+
int events = 0;
102+
103+
while ((bitpos = bitbuffer_search(bitbuffer, 0, bitpos, preamble_pattern, 24)) + 80 <=
104+
bitbuffer->bits_per_row[0]) {
105+
106+
ret = tpms_jansite_solar_decode(decoder, bitbuffer, 0, bitpos);
107+
if (ret > 0)
108+
events += ret;
109+
bitpos += 2;
110+
}
111+
112+
return events > 0 ? events : ret;
113+
}
114+
115+
static char *output_fields[] = {
116+
"model",
117+
"type",
118+
"id",
119+
"flags",
120+
"pressure_kPa",
121+
"temperature_C",
122+
"code",
123+
"mic",
124+
NULL,
125+
};
126+
127+
r_device tpms_jansite_solar = {
128+
.name = "Jansite TPMS Model Solar",
129+
.modulation = FSK_PULSE_PCM,
130+
.short_width = 51,
131+
.long_width = 51,
132+
.reset_limit = 5000, // Large enough to merge the 3 duplicate messages
133+
.decode_fn = &tpms_jansite_solar_callback,
134+
.disabled = 0,
135+
.fields = output_fields,
136+
};

vs15/rtl_433.vcxproj

+1
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ COPY ..\..\libusb\MS64\dll\libusb*.dll $(TargetDir)</Command>
300300
<ClCompile Include="..\src\devices\tpms_elantra2012.c" />
301301
<ClCompile Include="..\src\devices\tpms_ford.c" />
302302
<ClCompile Include="..\src\devices\tpms_jansite.c" />
303+
<ClCompile Include="..\src\devices\tpms_jansite_solar.c" />
303304
<ClCompile Include="..\src\devices\tpms_pmv107j.c" />
304305
<ClCompile Include="..\src\devices\tpms_renault.c" />
305306
<ClCompile Include="..\src\devices\tpms_toyota.c" />

vs15/rtl_433.vcxproj.filters

+3
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,9 @@
637637
<ClCompile Include="..\src\devices\tpms_jansite.c">
638638
<Filter>Source Files\devices</Filter>
639639
</ClCompile>
640+
<ClCompile Include="..\src\devices\tpms_jansite_solar.c">
641+
<Filter>Source Files\devices</Filter>
642+
</ClCompile>
640643
<ClCompile Include="..\src\devices\tpms_pmv107j.c">
641644
<Filter>Source Files\devices</Filter>
642645
</ClCompile>

0 commit comments

Comments
 (0)