public GlucoseMeasurementValueWrapper(GlucoseMeasurementValue measurement) 
		{
			this.Measurement = measurement;
			this.timeOffSet = this.Measurement.TimeOffset.ToString();
			this.sequenceNumber = this.Measurement.SequenceNumber.ToString();
			this.baseTime = this.Measurement.BaseTime.ToString();
			this.location = this.Measurement.Location.ToString();
			this.type = this.Measurement.Type.ToString();
			this.glucoseConcentrationKgL = this.Measurement.GlucoseConcentrationKgL.ToString();
			this.glucoseConcentrationMolL = this.Measurement.GlucoseConcentrationMolL.ToString();
		}
        public GlucoseMeasurementValue ProcessData(IBuffer values)
        {
            int currentOffset           = 0;
            int bluetoothDataTimeLength = 7;
            int SINT   = 2;
            int SFLOAT = 2;
            //Flags
            byte TimeOffsetPresent = 0x01;
            byte GlucoseConcentration_TypeAndSample_LocationPresent = 0x02;
            byte GlucoseConcentrationUnits       = 0x04;
            byte SensorStatus_AnnuncationPresent = 0x08;
            byte ContextInformationFollows       = 0x10;

            var glucoseMeasureValue = new GlucoseMeasurementValue();

            byte[] data = File.ToBytes(values);
            var    flag = data[currentOffset];
            bool   isTimeOffsetPresent = (flag & TimeOffsetPresent) != 0;
            bool   isGlucoseConcentration_TypeAndSample_LocationPresent = (flag & GlucoseConcentration_TypeAndSample_LocationPresent) != 0;
            bool   isGlucoseConcentrationUnitsPresent = (flag & GlucoseConcentrationUnits) != 0;
            bool   isSensorStatus_AnnuncationPresent  = (flag & SensorStatus_AnnuncationPresent) != 0;
            bool   isContextInformationFollows        = (flag & ContextInformationFollows) != 0;

            currentOffset++;

            var sequenceNumber = (ushort)((data[currentOffset + 1] << 8) + data[currentOffset]);

            glucoseMeasureValue.SequenceNumber = sequenceNumber;
            currentOffset += 2;

            byte[] baseTime = new byte[bluetoothDataTimeLength];
            Array.Copy(data, currentOffset, baseTime, 0, bluetoothDataTimeLength);
            glucoseMeasureValue.BaseTime = glucoseMeasureValue.ToDateTime(baseTime);
            currentOffset += 7;

            if (isTimeOffsetPresent)
            {
                var timeOffsetValue = (short)((data[currentOffset + 1] << 8) + data[currentOffset]);
                glucoseMeasureValue.TimeOffset = timeOffsetValue;
                currentOffset += SINT;
            }
            if (isGlucoseConcentration_TypeAndSample_LocationPresent && !isGlucoseConcentrationUnitsPresent)
            {
                byte[] GlucoseConcentrationValueKgL = new byte[SFLOAT];
                Array.Copy(data, currentOffset, GlucoseConcentrationValueKgL, 0, SFLOAT);
                var value = BitConverter.ToSingle(GlucoseConcentrationValueKgL, 0);
                glucoseMeasureValue.GlucoseConcentrationKgL = value;
                currentOffset += SFLOAT;
            }
            if (isGlucoseConcentration_TypeAndSample_LocationPresent && isGlucoseConcentrationUnitsPresent)
            {
                byte[] GlucoseConcentrationValueMolL = new byte[SFLOAT];
                Array.Copy(data, currentOffset, GlucoseConcentrationValueMolL, 0, SFLOAT);
                var value = glucoseMeasureValue.ToSFloat(GlucoseConcentrationValueMolL);
                glucoseMeasureValue.GlucoseConcentrationMolL = value;
                currentOffset += SFLOAT;
            }
            if (isGlucoseConcentration_TypeAndSample_LocationPresent)
            {
                byte type_SampleLocation = data[currentOffset];
                var  type = glucoseMeasureValue.GetType(type_SampleLocation);
                glucoseMeasureValue.Type = glucoseMeasureValue.GetGlucoseMeasureSampleType(type);
                var location = glucoseMeasureValue.GetLocation(type_SampleLocation);
                glucoseMeasureValue.Location = glucoseMeasureValue.GetGlucoseMeasureSampleLocation(location);
                currentOffset++;
            }
            if (isSensorStatus_AnnuncationPresent)
            {
                var sensorStatusAnnunication = (ushort)((data[currentOffset + 1] << 8) + data[currentOffset]);
                glucoseMeasureValue.SetSensorStatusAnnunciation(sensorStatusAnnunication);
            }
            return(glucoseMeasureValue);
        }
		private async void GlucoseServiceHandler_MeasurementNotification(GlucoseMeasurementValue measurement)
		{
			await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
			 {
				 var value = new GlucoseMeasurementValueWrapper(measurement);
				 this.glucoseMeasurementList.Add(value);
			 });
		}
		public GlucoseMeasurementValue ProcessData(IBuffer values)
		{
			int currentOffset = 0;
			int bluetoothDataTimeLength = 7;
			int SINT = 2;
			int SFLOAT = 2;
			//Flags
			byte TimeOffsetPresent = 0x01;
			byte GlucoseConcentration_TypeAndSample_LocationPresent = 0x02;
			byte GlucoseConcentrationUnits = 0x04;
			byte SensorStatus_AnnuncationPresent = 0x08;
			byte ContextInformationFollows = 0x10;

			var glucoseMeasureValue = new GlucoseMeasurementValue();
			byte[] data = File.ToBytes(values);
			var flag = data[currentOffset];
			bool isTimeOffsetPresent = (flag & TimeOffsetPresent) != 0;
			bool isGlucoseConcentration_TypeAndSample_LocationPresent = (flag & GlucoseConcentration_TypeAndSample_LocationPresent) != 0;
			bool isGlucoseConcentrationUnitsPresent = (flag & GlucoseConcentrationUnits) != 0;
			bool isSensorStatus_AnnuncationPresent = (flag & SensorStatus_AnnuncationPresent) != 0;
			bool isContextInformationFollows = (flag & ContextInformationFollows) != 0;
			currentOffset++;

			var sequenceNumber = (ushort)((data[currentOffset + 1] << 8) + data[currentOffset]);
			glucoseMeasureValue.SequenceNumber = sequenceNumber;
			currentOffset += 2;

			byte[] baseTime = new byte[bluetoothDataTimeLength];
			Array.Copy(data, currentOffset, baseTime, 0, bluetoothDataTimeLength);
			glucoseMeasureValue.BaseTime = File.ToDateTime(baseTime);
			currentOffset += 7;

			if(isTimeOffsetPresent)
			{
				var timeOffsetValue = (short)((data[currentOffset + 1] << 8) + data[currentOffset]);
				glucoseMeasureValue.TimeOffset = timeOffsetValue;
				currentOffset += SINT;
			}
			if(isGlucoseConcentration_TypeAndSample_LocationPresent && !isGlucoseConcentrationUnitsPresent)
			{
				byte[] GlucoseConcentrationValueKgL = new byte[SFLOAT];
				Array.Copy(data, currentOffset, GlucoseConcentrationValueKgL, 0, SFLOAT);
				var value = BitConverter.ToSingle(GlucoseConcentrationValueKgL, 0);
				glucoseMeasureValue.GlucoseConcentrationKgL = value;
				currentOffset += SFLOAT;
			}
			if(isGlucoseConcentration_TypeAndSample_LocationPresent && isGlucoseConcentrationUnitsPresent)
			{
				byte[] GlucoseConcentrationValueMolL = new byte[SFLOAT];
				Array.Copy(data, currentOffset, GlucoseConcentrationValueMolL, 0, SFLOAT);
				var value = File.ToSFloat(GlucoseConcentrationValueMolL);
				glucoseMeasureValue.GlucoseConcentrationMolL = value;
				currentOffset += SFLOAT;
			}
			if(isGlucoseConcentration_TypeAndSample_LocationPresent)
			{
				byte type_SampleLocation = data[currentOffset];
				var type = glucoseMeasureValue.GetType(type_SampleLocation);
				glucoseMeasureValue.Type = glucoseMeasureValue.GetGlucoseMeasureSampleType(type);
				var location = glucoseMeasureValue.GetLocation(type_SampleLocation);
				glucoseMeasureValue.Location = glucoseMeasureValue.GetGlucoseMeasureSampleLocation(location);
				currentOffset++;
			}
			if(isSensorStatus_AnnuncationPresent)
			{
				var sensorStatusAnnunication = (ushort)((data[currentOffset + 1] << 8) + data[currentOffset]);
				glucoseMeasureValue.SetSensorStatusAnnunciation(sensorStatusAnnunication);
			}
			return glucoseMeasureValue;
		}