mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-01-13 05:33:38 +00:00
TPMS: Validate checksum for OOK 8k192 Schrader.
This commit is contained in:
parent
9628815da7
commit
a475daeeea
@ -67,16 +67,32 @@ Optional<Reading> Packet::reading_fsk_19k2_schrader() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Optional<Reading> Packet::reading_ook_8k192_schrader() const {
|
Optional<Reading> Packet::reading_ook_8k192_schrader() const {
|
||||||
|
/*
|
||||||
|
* Preamble: 11*2, 01*14, 11, 10
|
||||||
|
* Function code: 3 Manchester symbols
|
||||||
|
* ID: 24 Manchester symbols (one variant seen with 21 symbols?)
|
||||||
|
* Pressure: 8 Manchester symbols
|
||||||
|
* Checksum: 2 Manchester symbols (2 LSBs of sum incl this field == 3)
|
||||||
|
*/
|
||||||
const auto flags = reader_.read(0, 3);
|
const auto flags = reader_.read(0, 3);
|
||||||
const auto checksum = reader_.read(35, 2);
|
const auto checksum = reader_.read(35, 2);
|
||||||
|
|
||||||
return Reading {
|
uint32_t checksum_calculated = reader_.read(0, 1);
|
||||||
Reading::Type::Schrader,
|
for(size_t i=1; i<37; i+=2) {
|
||||||
reader_.read(3, 24),
|
checksum_calculated += reader_.read(i, 2);
|
||||||
Pressure { static_cast<int>(reader_.read(27, 8)) * 4 / 3 },
|
}
|
||||||
{ },
|
|
||||||
Flags { (flags << 4) | checksum }
|
if( (checksum_calculated & 3) == 3 ) {
|
||||||
};
|
return Reading {
|
||||||
|
Reading::Type::Schrader,
|
||||||
|
reader_.read(3, 24),
|
||||||
|
Pressure { static_cast<int>(reader_.read(27, 8)) * 4 / 3 },
|
||||||
|
{ },
|
||||||
|
Flags { (flags << 4) | checksum }
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return { };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<Reading> Packet::reading_ook_8k4_schrader() const {
|
Optional<Reading> Packet::reading_ook_8k4_schrader() const {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user