Exemple #1
0
 /// <summary>
 /// Called when a altitude value is being notified
 /// </summary>
 /// <param name="characteristic">Characteristic which notified the value</param>
 /// <param name="value">New characteristic value</param>
 private void OnAltitudeNotification(BleGattCharacteristic characteristic, BleValue value)
 {
     if (characteristic.Guid == MainAltiGuid)
     {
         MainAltitudeChanged?.Invoke(Altitude.MainAltitude, value.ToInt16());
     }
     else if (characteristic.Guid == Alti1Guid)
     {
         Altitude1Changed?.Invoke(Altitude.Altitude1, value.ToInt16());
     }
     else if (characteristic.Guid == Alti2Guid)
     {
         Altitude2Changed?.Invoke(Altitude.Altitude2, value.ToInt16());
     }
     else if (characteristic.Guid == Alti3Guid)
     {
         Altitude3Changed?.Invoke(Altitude.Altitude3, value.ToInt16());
     }
     else if (characteristic.Guid == Alti4Guid)
     {
         Altitude4Changed?.Invoke(Altitude.Altitude4, value.ToInt16());
     }
     else
     {
     }
 }
Exemple #2
0
 /// <summary>
 /// Called when a variometer value is being notified
 /// </summary>
 /// <param name="characteristic">Characteristic which notified the value</param>
 /// <param name="value">New characteristic value</param>
 private void OnVariometerNotification(BleGattCharacteristic characteristic, BleValue value)
 {
     if (characteristic.Guid == VarioGuid)
     {
         VarioChanged?.Invoke(value.ToInt16());
     }
     else if (characteristic.Guid == AccelerationGuid)
     {
         AccelerationChanged?.Invoke(value.ToUInt8());
     }
     else
     {
     }
 }
Exemple #3
0
 /// <summary>
 /// Called when a barometer value is being notified
 /// </summary>
 /// <param name="characteristic">Characteristic which notified the value</param>
 /// <param name="value">New characteristic value</param>
 private void OnBarometerNotification(BleGattCharacteristic characteristic, BleValue value)
 {
     if (characteristic.Guid == PressureGuid)
     {
         PressureChanged?.Invoke(value.ToUInt32());
     }
     else if (characteristic.Guid == TemperatureGuid)
     {
         TemperatureChanged?.Invoke(value.ToInt16());
     }
     else
     {
     }
 }
Exemple #4
0
        /// <summary>
        /// Read a specified variometer value
        /// </summary>
        /// <param name="value">Variometer value to read</param>
        /// <returns>true if the operation succeeded, false otherwise</returns>
        public async Task <ReadVariometerValueResult> ReadVariometerValue(VariometerValue value)
        {
            ReadVariometerValueResult ret = new ReadVariometerValueResult();

            // List characteristics
            ret.Success = await InitCharacteristics();

            if (ret.Success)
            {
                // Look for the selected characteristic
                BleValue val = new BleValue();
                BleGattCharacteristic vario_characteristic = _variometer_characteristics[value];
                ret.Success = await BleDevice.ReadValueAsync(vario_characteristic, val);

                if (ret.Success)
                {
                    switch (value)
                    {
                    case VariometerValue.Vario:
                    {
                        ret.VarioValue = val.ToInt16();
                        break;
                    }

                    case VariometerValue.Acceleration:
                    {
                        ret.AccelerationValue = val.ToUInt8();
                        break;
                    }

                    default:
                    {
                        ret.Success = false;
                        break;
                    }
                    }
                }
            }

            return(ret);
        }
Exemple #5
0
        /// <summary>
        /// Read a specified barometer value
        /// </summary>
        /// <param name="value">Barometer value to read</param>
        /// <returns>true if the operation succeeded, false otherwise</returns>
        public async Task <ReadBarometerValueResult> ReadBarometerValue(BarometerValue value)
        {
            ReadBarometerValueResult ret = new ReadBarometerValueResult();

            // List characteristics
            ret.Success = await InitCharacteristics();

            if (ret.Success)
            {
                // Look for the selected characteristic
                BleValue val = new BleValue();
                BleGattCharacteristic baro_characteristic = _barometer_characteristics[value];
                ret.Success = await BleDevice.ReadValueAsync(baro_characteristic, val);

                if (ret.Success)
                {
                    switch (value)
                    {
                    case BarometerValue.Pressure:
                    {
                        ret.PressureValue = val.ToUInt32();
                        break;
                    }

                    case BarometerValue.Temperature:
                    {
                        ret.TemperatureValue = val.ToInt16();
                        break;
                    }

                    default:
                    {
                        ret.Success = false;
                        break;
                    }
                    }
                }
            }

            return(ret);
        }
Exemple #6
0
        /// <summary>
        /// Read a specified altitude value
        /// </summary>
        /// <param name="altitude">Altitude to read</param>
        /// <returns>true if the operation succeeded, false otherwise</returns>
        public async Task <ReadAltitudeResult> ReadAltitude(Altitude altitude)
        {
            ReadAltitudeResult ret = new ReadAltitudeResult();

            // List characteristics
            ret.Success = await InitCharacteristics();

            if (ret.Success)
            {
                // Look for the selected characteristic
                BleValue val = new BleValue();
                BleGattCharacteristic alti_characteristic = _altitude_characteristics[altitude];
                ret.Success = await BleDevice.ReadValueAsync(alti_characteristic, val);

                if (ret.Success)
                {
                    ret.Value = val.ToInt16();
                }
            }

            return(ret);
        }