Simplify PacketBuilder pattern matching and symbol accumulation.

This commit is contained in:
Jared Boone 2015-09-28 12:36:04 -07:00
parent 36689f5c45
commit 1bdad62496

View File

@ -51,13 +51,13 @@ public:
break;
case State::Payload:
if( found_end_flag() || packet_truncated() ) {
payload_handler(payload, bits_received);
reset_state();
} else {
if( !found_stuffing_bit() ) {
payload[bits_received++] = symbol;
}
if( found_end_flag() || packet_truncated() ) {
payload_handler(payload, bits_received);
reset_state();
}
break;
@ -74,7 +74,7 @@ private:
};
bool packet_truncated() const {
return bits_received > payload.size();
return bits_received >= payload.size();
}
bool found_preamble() const {