20 case State::WaitingForPreamble:
24 _state = State::ReadingLength;
29 case State::ReadingLength:
30 _lengthBytes[_lengthBytesRead++] = byte;
31 _buffer[_bytesRead++] = byte;
32 if (_lengthBytesRead == 2) {
33 _messageLength = ((_lengthBytes[0] & 0x03) << 8) | _lengthBytes[1];
34 if (_messageLength > 0 && _messageLength <= kMaxPayloadLength) {
35 _state = State::ReadingMessage;
42 case State::ReadingMessage:
44 _buffer[_bytesRead++] = byte;
52 _state = State::ReadingCRC;
57 case State::ReadingCRC:
58 _crcBytes[_crcBytesRead++] = byte;