Skip to content

Commit

Permalink
Add support for Aston Martin Smartire TPMS sensor, Vantage DB9 protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
ProfBoc75 committed Oct 19, 2024
1 parent 322e04f commit 5f3fb7f
Show file tree
Hide file tree
Showing 5 changed files with 155 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ See [CONTRIBUTING.md](./docs/CONTRIBUTING.md).
[263] Vevor Wireless Weather Station 7-in-1
[264] Arexx Multilogger IP-HA90, IP-TH78EXT, TSN-70E
[265] Rosstech Digital Control Unit DCU-706/Sundance/Jacuzzi
[266] Aston Martin Smartire TPMS sensor, Vantage DB9 protocol
* Disabled by default, use -R n or a conf file to enable
Expand Down
1 change: 1 addition & 0 deletions conf/rtl_433.example.conf
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@ convert si
protocol 263 # Vevor Wireless Weather Station 7-in-1
protocol 264 # Arexx Multilogger IP-HA90, IP-TH78EXT, TSN-70E
protocol 265 # Rosstech Digital Control Unit DCU-706/Sundance/Jacuzzi
protocol 266 # Aston Martin Smartire TPMS sensor, Vantage DB9 protocol

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

Expand Down
1 change: 1 addition & 0 deletions include/rtl_433_devices.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@
DECL(vevor_7in1) \
DECL(arexx_ml) \
DECL(rosstech_dcu706) \
DECL(tpms_aston_martin) \

/* Add new decoders here. */

Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ add_library(r_433 STATIC
devices/thermopro_tx2c.c
devices/thermor.c
devices/tpms_abarth124.c
devices/tpms_aston_martin.c
devices/tpms_ave.c
devices/tpms_bmw.c
devices/tpms_bmw_g3.c
Expand Down
151 changes: 151 additions & 0 deletions src/devices/tpms_aston_martin.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
/** @file
Aston Martin Smartire TPMS sensor.
Copyright (C) 2024 Bruno OCTAU (ProfBoc75)
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
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
*/

#include "decoder.h"

/**
Aston Martin Smartire TPMS sensor.
- Vantage Smartire / Aston Martin DB9 protocol, from 1/2005 till 12/2011
S.a. issue #3067
Data Layout:
- Total of 10 messages at a time, OOK PCM and Differential MC coded.
- 2 types of message have been identified.
- 1 Message with Pressure information follow by
- 1 Message with Temperature information
- Both messages are repeated 5 times
- In case of fast pressure increasing, the pressure message is sent with Fast increased flag, then the 10 messages each 2 seconds with the flag.
Flex decoder:
rtl_433 -X 'n=Aston-Martin-Smartire,m=OOK_PCM,s=167,l=167,r=600,preamble=32b4,decode_dm'
Preamble/Syncword .... : 0x32b4
6 bytes message
Byte Position 0 1 2 3 4 5
Sample 28 3f ff ff 00 fa
VV |I II II || CC
| ||
+----+-+ +----------+
| 1234 | | 12345678 |
| MMII | | FFFFFFXX |
+------+ +----------+
- VV: {8} Pressure value, offset 40, scale 2.5 if Message Type = 0x00
Temperature Value, offset 40, if Message Type = 0x01
- MM: {2} Message Type, 0x00 or 0x01
- II:{22} Sensor ID,
- F : {8} Flags, F1 = quick inflate detected,
F2 to F6 are unknown,
X78:{2} Looks like XOR/checksum/Parity from previous bits, not decoded.
- C : {7} CRC-7, poly 0x45, init 0x6f, final XOR 0x00
Bitbench:
TEMP/PRESSURE 8d MESSAGE_TYPE 2b ID 22d FAST_INCREASE 1b FLAGS ? 5b PARITY_XOR ? 2b CRC_SEVEN 7b 1x
*/

static int tpms_aston_martin_decode(r_device *decoder, bitbuffer_t *bitbuffer)
{
bitbuffer_t decoded = { 0 };
uint8_t *b;
uint8_t const preamble_pattern[] = {0x32, 0xb4};
uint8_t len_msg = 6;
float pressure_kPa = 0;
int temperature_C = 0;

if (bitbuffer->num_rows != 1) {
return DECODE_ABORT_EARLY;
}

int pos = bitbuffer_search(bitbuffer, 0, 0, preamble_pattern, sizeof(preamble_pattern) * 8);
if (pos >= bitbuffer->bits_per_row[0]) {
decoder_logf(decoder, 1, __func__, "Preamble not found");
return DECODE_ABORT_EARLY;
}

decoder_log_bitrow(decoder, 1, __func__, bitbuffer->bb[0], bitbuffer->bits_per_row[0], "MSG");
bitbuffer_differential_manchester_decode(bitbuffer, 0, pos + sizeof(preamble_pattern) * 8, &decoded, len_msg * 8);
decoder_log_bitrow(decoder, 1, __func__, decoded.bb[0], decoded.bits_per_row[0], "DMC");

// check msg length
if (decoded.bits_per_row[0] < (len_msg * 8) - 1 ) { // always missing last bit
decoder_logf(decoder, 1, __func__, "Too short");
return DECODE_ABORT_LENGTH;
}

b = decoded.bb[0];

// verify checksum
if (crc7(b, len_msg, 0x45, 0x6f)) {
decoder_logf(decoder, 1, __func__, "crc error");
return DECODE_FAIL_MIC; // crc mismatch
}

int id = ((b[1] & 0x3f) << 16) | (b [2] << 8) | b[3];
int msg_type = (b[1] & 0xc0) >> 6;
int value = b[0] - 40;

if (msg_type == 0) { // pressure
pressure_kPa = value * 2.5;
}
else if (msg_type == 1) { // temperature
temperature_C = value;
}
else {
decoder_logf(decoder, 1, __func__, "Unknown message type %x", msg_type);
return DECODE_ABORT_EARLY;
}

int inflate = (b[4] & 0x80) >> 7;
int flags = b[4] & 0x7f;

/* clang-format off */
data_t *data = data_make(
"model", "", DATA_STRING, "Aston-Martin-Smartire",
"type", "", DATA_STRING, "TPMS",
"id", "", DATA_INT, id,
"pressure_kPa", "Pressure", DATA_COND, msg_type == 0, DATA_FORMAT, "%.1f kPa", DATA_DOUBLE, (double)pressure_kPa,
"temperature_C", "Temperature", DATA_COND, msg_type == 1, DATA_FORMAT, "%.1f C", DATA_DOUBLE, (double)temperature_C,
"inflate", "Inflate", DATA_COND, inflate == 1, DATA_INT, 1,
"flags", "Flags", DATA_FORMAT, "%07b", DATA_INT, flags,
"mic", "Integrity", DATA_STRING, "CRC",
NULL);
/* clang-format on */

decoder_output_data(decoder, data);
return 1;
}

static char const *const output_fields[] = {
"model",
"type",
"id",
"pressure_kPa",
"temperature_C",
"inflate",
"flags",
"mic",
NULL,
};

r_device const tpms_aston_martin = {
.name = "Aston Martin Smartire TPMS sensor, Vantage DB9 protocol",
.modulation = OOK_PULSE_PCM,
.short_width = 167,
.long_width = 167,
.reset_limit = 1000,
.decode_fn = &tpms_aston_martin_decode,
.fields = output_fields,
};

0 comments on commit 5f3fb7f

Please sign in to comment.