private static MiDeviceData ReadDatas(Windows.Storage.Streams.IBuffer buffer) { List <byte> data = new List <byte>(capacity: (int)buffer.Length); using (Windows.Storage.Streams.DataReader dr = Windows.Storage.Streams.DataReader.FromBuffer(buffer)) { while (dr.UnconsumedBufferLength > 0) { data.Add(dr.ReadByte()); } } byte[] readableValue = data.ToArray(); double temperature = ((readableValue[1] & 0x7F) << 8 | readableValue[0]) / 100.0; byte moisture = readableValue[2]; return(new MiDeviceData() { Temperature = temperature, Moisture = moisture }); }