Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: merbanan/rtl_433
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: Topper69/rtl_433
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Can’t automatically merge. Don’t worry, you can still create the pull request.
  • 10 commits
  • 6 files changed
  • 3 contributors

Commits on Jan 21, 2023

  1. 1st commit

    Topper69 authored and zuckschwerdt committed Jan 21, 2023
    Copy the full SHA
    13a5c75 View commit details
  2. fix trailing whitespaces

    Topper69 authored and zuckschwerdt committed Jan 21, 2023
    Copy the full SHA
    7cd51ca View commit details
  3. Copy the full SHA
    0e84381 View commit details
  4. Copy the full SHA
    c01233d View commit details
  5. fix flex decoder @get excided 8

    Topper69 authored and zuckschwerdt committed Jan 21, 2023
    Copy the full SHA
    e0da895 View commit details
  6. typo

    Topper69 authored and zuckschwerdt committed Jan 21, 2023
    Copy the full SHA
    fdba4e3 View commit details
  7. add flex conf file

    Topper69 authored and zuckschwerdt committed Jan 21, 2023
    Copy the full SHA
    b1fecb8 View commit details
  8. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    f7fa6b2 View commit details
  9. Clean up

    zuckschwerdt committed Jan 21, 2023
    Copy the full SHA
    41764cc View commit details
  10. Update docs

    zuckschwerdt committed Jan 21, 2023
    Copy the full SHA
    6f4ca35 View commit details
Showing with 259 additions and 0 deletions.
  1. +1 −0 README.md
  2. +1 −0 conf/rtl_433.example.conf
  3. +52 −0 conf/tyreguard400.conf
  4. +1 −0 include/rtl_433_devices.h
  5. +1 −0 src/CMakeLists.txt
  6. +203 −0 src/devices/tpms_tyreguard400.c
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -307,6 +307,7 @@ See [CONTRIBUTING.md](./docs/CONTRIBUTING.md).
[222] Rubicson Pool Thermometer 48942
[223] Badger ORION water meter, 100kbps (-f 916450000 -s 1200000)
[224] GEO minim+ energy monitor
[225] TyreGuard 400 TPMS
* Disabled by default, use -R n or a conf file to enable
1 change: 1 addition & 0 deletions conf/rtl_433.example.conf
Original file line number Diff line number Diff line change
@@ -446,6 +446,7 @@ stop_after_successful_events false
protocol 222 # Rubicson Pool Thermometer 48942
protocol 223 # Badger ORION water meter, 100kbps (-f 916450000 -s 1200000)
protocol 224 # GEO minim+ energy monitor
protocol 225 # TyreGuard 400 TPMS

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

52 changes: 52 additions & 0 deletions conf/tyreguard400.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# TYREGUARD400 from DAVIES CRAIG
#
# https://daviescraig.com.au/product/tyreguard-400-tpms-4-sensors-kit-1015
#
# - Type : TPMS
# - Freq : 434.1 MHz
# - Modulation : ASK -> OOK_MC_ZEROBIT (Manchester Code with fixed leading zero bit)
# - Sambol duration : 100us (same for l or 0)
# - Length : 22 bytes long
#
# Packet layout:
#
# bytes : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
# coded : S/P S/P S/P S/P S/P S/P S/P ID ID ID ID ID ID ID Pr Pr Temp Temp Flg Flg CRC CRC
#
# - S/P : preamble/sync "0xfd5fd5f" << always fixed
# - ID : 6 bytes long start with 0x6b????? ex 0x6b20d21
# - Pr : Last 2 bytes of pressure in psi ex : 0xe8 means XX232 psi (for XX see flags bytes)
# - Temp : Temperature in °C offset by +40 ex : 0x2f means (47-40)=+7°C
# - Flg : Flags bytes => should be read in binary format :
# - Bit 73 : Unknown ; maybe the 20th MSB pressure bit? The sensor is not capable to reach this so high pressure
# - Bit 74 : add 1024 psi (19th MSB pressure bit)
# - Bit 75 : add 512 psi (18th MSB pressure bit)
# - Bit 76 : add 256 psi (17th MSB pressure bit)
# - Bit 77 : Acknoldge pressure leaking 1=Ack 0=No_ack (nothing to report)
# - Bit 78 : Unknown
# - Bit 79 : Leaking pressure detected 1=Leak 0=No leak (nothing to report)
# - Bit 80 : Leaking pressure detected 1=Leak 0=No leak (nothing to report)
# - CRC : CRC poly 0x31 start value 0xdd final 0x00 from 1st bit 80th bits
#
# To peer a new sensor to the unit, bit 79 and 80 has to be both to 1.
#
# NOTE: In the datasheet, it is said that the sensor can report low batterie. During my tests/reseach i'm not able to see this behavior. I have fuzzed all bits nothing was reported to the reader.
#

decoder {
name = TPMS-TYREGUARD400,
modulation = OOK_MC_ZEROBIT,
short = 100,
long = 100,
gap = 0,
reset = 500,
preamble = fd5fd5f,
get = id:@0:{28},
get = pression:@57:{8},
get = temp:@65:{8},
get = flags:@73:{8},
get = add_psi:@74:{3}:[0:no 1:256 2:512 3:768 4:1024 5:1280 6:1536 7:1792],
get = AckLeaking:@77:{1}:[1: yes 0:no],
get = Leaking_detected:@79:{2}:[0:no 1:yes 2:yes],
get = CRC:@81:{8},
}
1 change: 1 addition & 0 deletions include/rtl_433_devices.h
Original file line number Diff line number Diff line change
@@ -232,6 +232,7 @@
DECL(rubicson_pool_48942) \
DECL(badger_orion) \
DECL(geo_minim) \
DECL(tpms_tyreguard400) \

/* Add new decoders here. */

1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -227,6 +227,7 @@ add_library(r_433 STATIC
devices/tpms_renault_0435r.c
devices/tpms_toyota.c
devices/tpms_truck.c
devices/tpms_tyreguard400.c
devices/ts_ft002.c
devices/ttx201.c
devices/vaillant_vrt340f.c
203 changes: 203 additions & 0 deletions src/devices/tpms_tyreguard400.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
/** @file
TPMS TyreGuard 400 from Davies Craig.
Copyright (C) 2022 R ALVERGNAT
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.
*/
/**
TPMS TyreGuard 400 from Davies Craig.
- Type: TPMS
- Freq: 434.1 MHz
- Modulation: ASK -> OOK_MC_ZEROBIT (Manchester Code with fixed leading zero bit)
- Symbol duration: 100us (same for l or 0)
- Length: 22 bytes long
Packet layout:
bytes : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
coded : S/P S/P S/P S/P S/P S/P S/P ID ID ID ID ID ID ID Pr Pr Temp Temp Flg Flg CRC CRC
- S/P : preamble/sync "0xfd5fd5f" << always fixed
- ID : 6 bytes long start with 0x6b????? ex 0x6b20d21
- Pr : Last 2 bytes of pressure in psi ex : 0xe8 means XX232 psi (for XX see flags bytes)
- Temp : Temperature in °C offset by +40 ex : 0x2f means (47-40)=+7°C
- Flg : Flags bytes => should be read in binary format :
- Bit 73 : Unknown ; maybe the 20th MSB pressure bit? The sensor is not capable to reach this so high pressure
- Bit 74 : add 1024 psi (19th MSB pressure bit)
- Bit 75 : add 512 psi (18th MSB pressure bit)
- Bit 76 : add 256 psi (17th MSB pressure bit)
- Bit 77 : Acknoldge pressure leaking 1=Ack 0=No_ack (nothing to report)
- Bit 78 : Unknown
- Bit 79 : Leaking pressure detected 1=Leak 0=No leak (nothing to report)
- Bit 80 : Leaking pressure detected 1=Leak 0=No leak (nothing to report)
- CRC : CRC poly 0x31 start value 0xdd final 0x00 from 1st bit 80th bits
To peer a new sensor to the unit, bit 79 and 80 has to be both to 1.
NOTE: In the datasheet, it is said that the sensor can report low batterie. During my tests/reseach i'm not able to see this behavior. I have fuzzed all bits nothing was reported to the reader.
Flex decoder:
-X "n=TPMS,m=OOK_MC_ZEROBIT,s=100,l=100,r=500,preamble=fd5fd5f"
decoder {
name = TPMS-TYREGUARD400,
modulation = OOK_MC_ZEROBIT,
short = 100,
long = 100,
gap = 0,
reset = 500,
preamble = fd5fd5f,
get = id:@0:{28},
get = pression:@57:{8},
get = temp:@65:{8},
get = flags:@73:{8},
get = add_psi:@74:{3}:[0:no 1:256 2:512 3:768 4:1024 5:1280 6:1536 7:1792],
get = AckLeaking:@77:{1}:[1: yes 0:no],
get = Leaking_detected:@79:{2}:[0:no 1:yes 2:yes],
get = CRC:@81:{8},
}
*/

#include "decoder.h"

#define TPMS_TYREGUARD400_MESSAGE_BITLEN 88

static int tpms_tyreguard400_decode(r_device *decoder, bitbuffer_t *bitbuffer, unsigned row, unsigned bitpos)
{
uint8_t b[(TPMS_TYREGUARD400_MESSAGE_BITLEN + 7) / 8];

// Extract the message
bitbuffer_extract_bytes(bitbuffer, row, bitpos, b, TPMS_TYREGUARD400_MESSAGE_BITLEN);

//CRC poly 0x31 start value 0xdd final 0x00 from 1st bit to 80bits
if (crc8(b, 11, 0x31, 0xdd) != 0) {
decoder_log_bitrow(decoder, 2, __func__, b, TPMS_TYREGUARD400_MESSAGE_BITLEN, "CRC error");
return DECODE_FAIL_MIC;
}

uint8_t flags = b[9];
//int bat_low = flags & 0x1; // TBC ?!?
int peering_request = flags & 0x3; // bytes = 0b00000011
int ack_leaking = flags & 0x8; // byte = 0b00001000 :: NOTA ack_leaking = 1 means ack ;; ack_leaking=0 nothing to do

// test if bits 1st or 2nd is set to 1 of 0b000000XX
int leaking = flags & 0x3;

//int add256 = (flags & 0x10) >> 4; // bytes = 0b000X0000
//int add512 = (flags & 0x20) >> 5; // bytes = 0b00X00000
//int add1024 = (flags & 0x40) >> 6; // bytes = 0b0X000000

char id_str[8];
sprintf(id_str, "%07x", (uint32_t)(((b[3] & 0xf)<<24)) | (b[4]<<16) | (b[5]<<8) | b[6]); // 28 bits ID
char flags_str[3];
sprintf(flags_str, "%02x", flags);

//id = (b[4] << 8)
int pressure_kpa = b[7] | ((flags & 0x70) << 4);
int temp_c = b[8] - 40;

/* clang-format off */
data_t *data = data_make(
"model", "Model", DATA_STRING, "TyreGuard400",
"type", "Type", DATA_STRING, "TPMS",
"id", "ID", DATA_STRING, id_str,
// "flags", "Flags", DATA_STRING, flags_str,
"pressure_kPa", "Pressure", DATA_FORMAT, "%.1f kPa", DATA_DOUBLE, (double)pressure_kpa,
"temperature_C", "Temperature", DATA_FORMAT, "%.0f C", DATA_DOUBLE, (double)temp_c,
"peering_request", "Peering req", DATA_INT, peering_request,
"leaking", "Leaking detected", DATA_INT, leaking,
"ack_leaking", "Ack leaking", DATA_INT, ack_leaking,
// "add256", "", DATA_INT, add256,
// "add512", "", DATA_INT, add512,
// "add1024", "", DATA_INT, add1024,
// "battery_ok", "Batt OK", DATA_INT, !bat_low,
"mic", "Integrity", DATA_STRING, "CRC",
NULL);
/* clang-format on */

decoder_output_data(decoder, data);
return 1;
}

/** @sa tpms_tyreguard400_decode() */
static int tpms_tyreguard400_callback(r_device *decoder, bitbuffer_t *bitbuffer)
{
//uint8_t const tyreguard_frame_sync[] = {0xf, 0xd5, 0xfd, 0x5f}
uint8_t const tyreguard_frame_sync[] = {0xfd, 0x5f, 0xd5, 0xf0}; // needs to shift sync to align bytes 28x bits usefull

int ret = 0;
int events = 0;

for (int row = 0; row < bitbuffer->num_rows; ++row) {
if (bitbuffer->bits_per_row[row] < TPMS_TYREGUARD400_MESSAGE_BITLEN) {
// bail out of this "too short" row early
if (decoder->verbose >= 2) {
// Output the bad row, only for message level debug / deciphering.
decoder_logf_bitrow(decoder, 2, __func__, bitbuffer->bb[row], bitbuffer->bits_per_row[row],
"Bad message in row %d need %d bits got %d",
row, TPMS_TYREGUARD400_MESSAGE_BITLEN, bitbuffer->bits_per_row[row]);
}
continue; // DECODE_ABORT_LENGTH
}

unsigned bitpos = 0;

// Find a preamble with enough bits after it that it could be a complete packet
while ((bitpos = bitbuffer_search(bitbuffer, row, bitpos, tyreguard_frame_sync, 28)) + TPMS_TYREGUARD400_MESSAGE_BITLEN <=
bitbuffer->bits_per_row[row]) {

if (decoder->verbose >= 2) {
decoder_logf_bitrow(decoder, 2, __func__, bitbuffer->bb[row], bitbuffer->bits_per_row[row],
"Find bitpos with preamble row %d at %u", row, bitpos);
}

ret = tpms_tyreguard400_decode(decoder, bitbuffer, row, bitpos);
if (ret > 0)
events += ret;

bitpos += TPMS_TYREGUARD400_MESSAGE_BITLEN;
}
}
// (Only) for future regression tests.
if ((decoder->verbose >= 3) & (events == 0)) {
decoder_logf(decoder, 3, __func__, "Bad transmission");
}

return events > 0 ? events : ret;
}

static char *output_fields[] = {
"model",
"type",
"id",
// "flags",
"pressure_kPa",
"temperature_C",
"peering_request",
"leaking",
"ack_leaking",
// "add256",
// "add512",
// "add1024",
// "battery_ok",
"mic",
NULL,
};

r_device tpms_tyreguard400 = {
.name = "TyreGuard 400 TPMS",
.modulation = OOK_PULSE_MANCHESTER_ZEROBIT,
.short_width = 100,
.long_width = 100,
.gap_limit = 0,
.reset_limit = 500,
.decode_fn = &tpms_tyreguard400_callback,
.fields = output_fields,
};