namespace YD_TrainingCompetition_Api.Protocols; // JumpProtocolParser 负责解析来自 2.4G 终端的 12 字节上行帧。 // 这里只做格式校验和字段提取,不做业务状态判断。 public sealed class JumpProtocolParser : IJumpProtocolParser { public bool TryParse(ReadOnlySpan frame, out JumpFrame? parsed) { parsed = null; if (frame.Length < 12) { return false; } // 旧版设备上行帧格式固定为 AA ... 55。 if (frame[0] != 0xAA || frame[11] != 0x55) { return false; } // 帧类型目前仅接受实时成绩帧和设备完成帧。 if (frame[1] != 0x00 && frame[1] != 0xAA) { return false; } // 关键字段位置与旧版 Form1 的解析规则保持一致。 parsed = new JumpFrame { DeviceNo = frame[2], Counter = frame[3] * 256 + frame[4], Battery = frame[5], Mode = frame[6], RemainingSeconds = frame[7] * 256 + frame[8] }; return true; } }