mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2024-12-14 20:18:13 +00:00
AIS: More simplifying of packet length/validation code.
This commit is contained in:
parent
af74daf092
commit
0c1c0da8a5
@ -183,21 +183,7 @@ size_t Packet::length() const {
|
||||
}
|
||||
|
||||
bool Packet::is_valid() const {
|
||||
if( data_and_fcs_length() < 38 ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const size_t extra_bits = data_and_fcs_length() & 7;
|
||||
if( extra_bits != 0 ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
PacketLengthValidator packet_length_valid;
|
||||
if( !packet_length_valid(message_id(), data_length()) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return crc_ok();
|
||||
return length_valid() && crc_ok();
|
||||
}
|
||||
|
||||
rtc::RTC Packet::received_at() const {
|
||||
@ -279,6 +265,20 @@ size_t Packet::data_length() const {
|
||||
return data_and_fcs_length() - fcs_length;
|
||||
}
|
||||
|
||||
bool Packet::length_valid() const {
|
||||
const size_t extra_bits = data_and_fcs_length() & 7;
|
||||
if( extra_bits != 0 ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const PacketLengthValidator packet_length_valid;
|
||||
if( !packet_length_valid(message_id(), data_length()) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} /* namespace ais */
|
||||
} /* namespace baseband */
|
||||
|
||||
|
@ -106,6 +106,8 @@ private:
|
||||
|
||||
size_t data_and_fcs_length() const;
|
||||
size_t data_length() const;
|
||||
|
||||
bool length_valid() const;
|
||||
};
|
||||
|
||||
} /* namespace ais */
|
||||
|
Loading…
Reference in New Issue
Block a user