From 5f3fb7f13c7bcc4f36f00fa059bb8e33044bf0ea Mon Sep 17 00:00:00 2001 From: ProfBoc75 Date: Sat, 19 Oct 2024 18:18:46 +0200 Subject: [PATCH 1/3] Add support for Aston Martin Smartire TPMS sensor, Vantage DB9 protocol --- README.md | 1 + conf/rtl_433.example.conf | 1 + include/rtl_433_devices.h | 1 + src/CMakeLists.txt | 1 + src/devices/tpms_aston_martin.c | 151 ++++++++++++++++++++++++++++++++ 5 files changed, 155 insertions(+) create mode 100644 src/devices/tpms_aston_martin.c diff --git a/README.md b/README.md index c4b245b95..ba3c9ec49 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/conf/rtl_433.example.conf b/conf/rtl_433.example.conf index a3c2dacc7..64b1e046a 100644 --- a/conf/rtl_433.example.conf +++ b/conf/rtl_433.example.conf @@ -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") diff --git a/include/rtl_433_devices.h b/include/rtl_433_devices.h index f7d3bb310..c2c447a5b 100644 --- a/include/rtl_433_devices.h +++ b/include/rtl_433_devices.h @@ -273,6 +273,7 @@ DECL(vevor_7in1) \ DECL(arexx_ml) \ DECL(rosstech_dcu706) \ + DECL(tpms_aston_martin) \ /* Add new decoders here. */ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 27df950ed..412a5a6e6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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 diff --git a/src/devices/tpms_aston_martin.c b/src/devices/tpms_aston_martin.c new file mode 100644 index 000000000..5fee50476 --- /dev/null +++ b/src/devices/tpms_aston_martin.c @@ -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, +}; From 34be1a997f83c5c8ccf530d84143c9e3b88ef6a1 Mon Sep 17 00:00:00 2001 From: ProfBoc75 Date: Sun, 20 Oct 2024 10:40:51 +0200 Subject: [PATCH 2/3] Rename Aston Martin Smartire to SmarTire and minor changes --- README.md | 2 +- conf/rtl_433.example.conf | 2 +- include/rtl_433_devices.h | 2 +- src/CMakeLists.txt | 2 +- src/devices/tpms_smartire.c | 151 ++++++++++++++++++++++++++++++++++++ 5 files changed, 155 insertions(+), 4 deletions(-) create mode 100644 src/devices/tpms_smartire.c diff --git a/README.md b/README.md index ba3c9ec49..ee6ff6f9c 100644 --- a/README.md +++ b/README.md @@ -351,7 +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 + [266] SmarTire TPMS sensor, Aston Martin/Vantage DB9 protocol * Disabled by default, use -R n or a conf file to enable diff --git a/conf/rtl_433.example.conf b/conf/rtl_433.example.conf index 64b1e046a..a65c76a16 100644 --- a/conf/rtl_433.example.conf +++ b/conf/rtl_433.example.conf @@ -492,7 +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 + protocol 266 # SmarTire TPMS sensor, Aston Martin/Vantage DB9 protocol ## Flex devices (command line option "-X") diff --git a/include/rtl_433_devices.h b/include/rtl_433_devices.h index c2c447a5b..f944a9419 100644 --- a/include/rtl_433_devices.h +++ b/include/rtl_433_devices.h @@ -273,7 +273,7 @@ DECL(vevor_7in1) \ DECL(arexx_ml) \ DECL(rosstech_dcu706) \ - DECL(tpms_aston_martin) \ + DECL(tpms_smartire) \ /* Add new decoders here. */ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 412a5a6e6..8645fca78 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -241,7 +241,6 @@ 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 @@ -258,6 +257,7 @@ add_library(r_433 STATIC devices/tpms_porsche.c devices/tpms_renault.c devices/tpms_renault_0435r.c + devices/tpms_smartire.c devices/tpms_toyota.c devices/tpms_truck.c devices/tpms_tyreguard400.c diff --git a/src/devices/tpms_smartire.c b/src/devices/tpms_smartire.c new file mode 100644 index 000000000..522b546b7 --- /dev/null +++ b/src/devices/tpms_smartire.c @@ -0,0 +1,151 @@ +/** @file + 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" + +/** +SmarTire TPMS sensor. +- SmarTire Vantage / 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=SmarTire-AM,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, 0b00 or 0b01 +- 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_smartire_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, "SmarTire-AM", // Aston Martin model + "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_smartire = { + .name = "SmarTire TPMS sensor, Aston Martin/Vantage DB9 protocol", + .modulation = OOK_PULSE_PCM, + .short_width = 167, + .long_width = 167, + .reset_limit = 1000, + .decode_fn = &tpms_smartire_decode, + .fields = output_fields, +}; From c65699f81184eee3bc879fc80803e041d3de866a Mon Sep 17 00:00:00 2001 From: ProfBoc75 Date: Sun, 20 Oct 2024 10:46:19 +0200 Subject: [PATCH 3/3] Remove previous tpms_aston.c renamed to tpms_smartire.c --- src/devices/tpms_aston_martin.c | 151 -------------------------------- 1 file changed, 151 deletions(-) delete mode 100644 src/devices/tpms_aston_martin.c diff --git a/src/devices/tpms_aston_martin.c b/src/devices/tpms_aston_martin.c deleted file mode 100644 index 5fee50476..000000000 --- a/src/devices/tpms_aston_martin.c +++ /dev/null @@ -1,151 +0,0 @@ -/** @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, -};