public static bool TryParse(byte[] bytes, out TransceiverMessage message) { message = null; var packetLength = bytes[0]; PacketType packetType; if (!(packetLength == 4 && PacketType.TryParse(bytes[1], out packetType))) { return(false); } TransceiverMessageSubType subType; if (!TransceiverMessageSubType.TryParse(bytes[2], out subType)) { return(false); } var sequenceNumber = bytes[3]; TransceiverResponse response = null; if (subType == TransceiverMessageSubType.Response) { TransceiverResponse.TryParse(bytes[4], out response); } message = new TransceiverMessage(packetLength, packetType, subType, sequenceNumber, response); return(true); }
public TransceiverMessage(byte packetLength, PacketType packetType, TransceiverMessageSubType subType, byte sequenceNumber, TransceiverResponse response) { PacketLength = packetLength; PacketType = packetType; SubType = subType; SequenceNumber = sequenceNumber; Response = response; }