private static byte[] GeneralDataBytes(AutoReportConfig config) { var data = new byte[38]; Array.ConstrainedCopy(AutoReportData, 0, data, 0, 38); var current = BitConverter.GetBytes(config.CleanerNumber); Array.Reverse(current); Array.ConstrainedCopy(current, 0, data, 5, 4); data[2] = (byte)(config.CleanerSwitch ? 0x01 : 0x00); data[11] = (byte)(config.FanSwitch ? 0x01 : 0x00); return(data); }
public static byte[] GetAutoReportBytes(AutoReportConfig config) { var byteList = new List <byte>(); var nodeBytes = HexStringToByteArray(config.NodeId); byteList.AddRange(AutoReportHead); byteList.AddRange(nodeBytes); byteList.AddRange(AutoReportBody); byteList.AddRange(GeneralDataBytes(config)); var crc = new byte[2]; Uint16ToBytes(GetUsmbcrc16(byteList.ToArray(), (ushort)byteList.Count), crc, 0, false); byteList.AddRange(crc); byteList.Add(ProtocolTail); return(byteList.ToArray()); }