mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-01-13 09:03:37 +00:00
Simplify PacketBuilder pattern matching and symbol accumulation.
This commit is contained in:
parent
36689f5c45
commit
1bdad62496
@ -51,13 +51,13 @@ public:
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case State::Payload:
|
case State::Payload:
|
||||||
if( found_end_flag() || packet_truncated() ) {
|
|
||||||
payload_handler(payload, bits_received);
|
|
||||||
reset_state();
|
|
||||||
} else {
|
|
||||||
if( !found_stuffing_bit() ) {
|
if( !found_stuffing_bit() ) {
|
||||||
payload[bits_received++] = symbol;
|
payload[bits_received++] = symbol;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( found_end_flag() || packet_truncated() ) {
|
||||||
|
payload_handler(payload, bits_received);
|
||||||
|
reset_state();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
bool packet_truncated() const {
|
bool packet_truncated() const {
|
||||||
return bits_received > payload.size();
|
return bits_received >= payload.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool found_preamble() const {
|
bool found_preamble() const {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user