public static IotRequest CreateRequest(IotReceiveFilter filter, string mac, string command, string dataHex = "") { var request = new IotRequest(filter); request.Device = IotDevice.Load(mac); request.SessionId = request.Device.Mac.Right(4); request.Command = new IotCommand(command, dataHex); request.Key = request.Command.Key; request.Length = request.Command.Data.Length + 12; return(request); }
private void LoadData() { Body = filter.Crypto.Decrypt(EncryptedBody); BodyHex = Body.ToHex(); Length = Body.Length; SessionId = BodyHex.Substring(0, 4); //2b var mac = BodyHex.Substring(4, 12); //6b var bytes = Body.CloneRange(2, 6); //6b Device = IotDevice.Load(mac, bytes); //mac var command = BodyHex.Substring(16, 4); //2b var data = Body.CloneRange(10, Length - 12); //-12b var dataHex = BodyHex.Substring(20, 2 * data.Length); Command = new IotCommand(command, dataHex, data); //cmd Crc16 = BodyHex.Right(4); Key = Command.Key; }