Beispiel #1
0
        /// <summary>
        /// Initialize the Open Vario device proxy
        /// </summary>
        /// <returns>true if the proxy has been initialized, false otherwise</returns>
        public async Task <bool> Initialize()
        {
            bool ret = true;

            // List all services
            IList <BleGattService> ble_services = await _ble_device.GetServicesAsync();

            foreach (BleGattService ble_service in ble_services)
            {
                // Add service to the list
                _ble_services.Add(ble_service.Guid, ble_service);
            }

            // Look for the identification service
            try
            {
                BleGattService identification_service = _ble_services[IdentificationService.Guid];
                IdentificationService = new IdentificationService(_ble_device, identification_service);
                IdentificationService.IdentificationInfo id_info = await IdentificationService.GetIdentificationInfo();

                if (id_info != null)
                {
                    ret = true;
                }
            }
            catch (KeyNotFoundException)
            {
                ret = false;
            }
            if (ret)
            {
                // Look for the other services
                try
                {
                    BleGattService altimeter_service = _ble_services[AltimeterService.Guid];
                    AltimeterService = new AltimeterService(_ble_device, altimeter_service);

                    BleGattService navigation_service = _ble_services[NavigationService.Guid];
                    NavigationService = new NavigationService(_ble_device, navigation_service);

                    BleGattService barometer_service = _ble_services[BarometerService.Guid];
                    BarometerService = new BarometerService(_ble_device, barometer_service);

                    BleGattService variometer_service = _ble_services[VariometerService.Guid];
                    VariometerService = new VariometerService(_ble_device, variometer_service);
                }
                catch (KeyNotFoundException)
                {
                    _ble_services.Clear();
                    AltimeterService  = null;
                    NavigationService = null;
                    BarometerService  = null;
                    VariometerService = null;

                    ret = false;
                }
            }
            return(ret);
        }
Beispiel #2
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="ble_device">BLE device proxy to use to communicate with the Open Vario device</param>
 /// <param name="ble_service">BLE service representing the variometer service</param>
 public VariometerService(IBleDevice ble_device, BleGattService ble_service)
     : base(ble_device, ble_service)
 {
     _variometer_characteristics = new Dictionary <VariometerValue, BleGattCharacteristic>(10);
 }
Beispiel #3
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="ble_device">BLE device proxy to use to communicate with the Open Vario device</param>
 /// <param name="ble_service">BLE service representing the navigation service</param>
 public NavigationService(IBleDevice ble_device, BleGattService ble_service)
     : base(ble_device, ble_service)
 {
     _navigation_characteristics = new Dictionary <NavigationValue, BleGattCharacteristic>(10);
 }
Beispiel #4
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="ble_device">BLE device proxy to use to communicate with the Open Vario device</param>
 /// <param name="ble_service">BLE service representing the altimeter service</param>
 public AltimeterService(IBleDevice ble_device, BleGattService ble_service)
     : base(ble_device, ble_service)
 {
     _altitude_characteristics = new Dictionary <Altitude, BleGattCharacteristic>(10);
 }
Beispiel #5
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="ble_device">BLE device proxy to use to communicate with the Open Vario device</param>
 /// <param name="ble_service">BLE service representing the service</param>
 public OpenVarioBleService(IBleDevice ble_device, BleGattService ble_service)
 {
     BleDevice          = ble_device;
     BleService         = ble_service;
     BleCharacteristics = new Dictionary <Guid, BleGattCharacteristic>(20);
 }
Beispiel #6
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="ble_device">BLE device proxy to use to communicate with the Open Vario device</param>
 /// <param name="ble_service">BLE service representing the identification service</param>
 public IdentificationService(IBleDevice ble_device, BleGattService ble_service)
     : base(ble_device, ble_service)
 {
     _identification_info = null;
 }