/// <summary> /// Create a `DateTime` response from a Band command /// response containing time specified as a sequence /// of 8 `ushort` from a given position. /// </summary> /// <param name="response">response</param> /// <param name="position">Position to read sequence from </param> /// <returns>DateTime</returns> public static DateTime DateTimeResponse( CommandResponse response, int position = 0) { ushort[] t = response.GetByteStream().GetUshorts(8, position); List <ushort> times = new List <ushort>(t); times.RemoveAt(2); return(TimeHelper.DateTimeUshorts(times.ToArray())); }
/// <summary> /// Create a new Sleep instance from a Band last sleep response. /// /// Does not in any way validate the given response is a valid sleep. /// </summary> /// <param name="response">response</param> public Sleep(CommandResponse response) { ByteStream bytes = response.GetByteStream(); this.Calories = bytes.GetUint32(26); this.Duration = (bytes.GetUint32(10) / 1000); this.Feeling = bytes.GetUint32(50); this.RestingHR = bytes.GetUint32(30); this.TimeAsleep = (bytes.GetUint32(22) / 1000); this.TimeAwake = (bytes.GetUint32(18) / 1000); this.TimeToSleep = (bytes.GetUint32(46) / 1000); this.TimesAwoke = bytes.GetUint32(14); this.Timestamp = DateTime.FromFileTime(((long)bytes.GetUint64(0))); this.WokeUp = DateTime.FromFileTime(((long)bytes.GetUint64(38))); this.Version = bytes.GetUshort(8); }