Esempio n. 1
0
 /// <summary>
 /// Raises the characteristic write event.
 /// </summary>
 /// <param name="sender">Sender.</param>
 /// <param name="e">E.</param>
 public void OnCharacteristicWrite(IBleDevice sender, BleCharacteristicWriteEventArgs e)
 {
     if (CharacteristicWrite != null)
     {
         CharacteristicWrite(sender, e);
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Raises the characteristic changed event.
 /// </summary>
 /// <param name="sender">Sender.</param>
 /// <param name="e">E.</param>
 public void OnCharacteristicChanged(IBleDevice sender, BleCharacteristicChangedEventArgs e)
 {
     if (CharacteristicChanged != null)
     {
         CharacteristicChanged(sender, e);
     }
 }
 void sensor_ConnectionStateChanged(IBleDevice sender, BleConnectionStateChangedEventArgs e)
 {
     if (e.NewState == BleConnectionState.Disconnected)
     {
         this.SelectedDevice = null;
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Raises the descriptor write event.
 /// </summary>
 /// <param name="sender">Sender.</param>
 /// <param name="e">E.</param>
 public void OnDescriptorWrite(IBleDevice sender, BleDescriptorWriteEventArgs e)
 {
     if (DescriptorWrite != null)
     {
         DescriptorWrite(sender, e);
     }
 }
Esempio n. 5
0
 /// <summary>
 /// Raises the descriptor read event.
 /// </summary>
 /// <param name="sender">Sender.</param>
 /// <param name="e">E.</param>
 public void OnDescriptorRead(IBleDevice sender, BleDescriptorReadEventArgs e)
 {
     if (DescriptorRead != null)
     {
         DescriptorRead(sender, e);
     }
 }
Esempio n. 6
0
 /// <summary>
 /// Raises the read remote rssi event.
 /// </summary>
 /// <param name="sender">Sender.</param>
 /// <param name="e">E.</param>
 public void OnReadRemoteRssi(IBleDevice sender, BleReadRemoteRssiEventArgs e)
 {
     if (ReadRemoteRssi != null)
     {
         ReadRemoteRssi(sender, e);
     }
 }
Esempio n. 7
0
 /// <summary>
 /// Raises the reliable write completed event.
 /// </summary>
 /// <param name="sender">Sender.</param>
 /// <param name="e">E.</param>
 public void OnReliableWriteCompleted(IBleDevice sender, BleReliableWriteCompletedEventArgs e)
 {
     if (ReliableWriteCompleted != null)
     {
         ReliableWriteCompleted(sender, e);
     }
 }
Esempio n. 8
0
 /// <summary>
 /// Raises the services discovered event.
 /// </summary>
 /// <param name="sender">Sender.</param>
 /// <param name="e">E.</param>
 public void OnServicesDiscovered(IBleDevice sender, BleServicesDiscoveredEventArgs e)
 {
     if (ServicesDiscovered != null)
     {
         ServicesDiscovered(sender, e);
     }
 }
Esempio n. 9
0
 void BleCyclingSensor_ServicesDiscovered(IBleDevice sender, BleServicesDiscoveredEventArgs e)
 {
     if (e.State == BleGattOperationState.Success)
     {
         object CSCMeasurement = this.GetCharacteristic(new Guid("00002a5b-0000-1000-8000-00805f9b34fb"));
         this.EnableNotifications(CSCMeasurement, true);
     }
 }
Esempio n. 10
0
 void BleCyclingSensor_ConnectionStateChanged(IBleDevice sender, BleConnectionStateChangedEventArgs e)
 {
     RaisePropertyChanged("ConnectionState");
     if (ConnectionState == BleConnectionState.Connected)
     {
         this.DiscoverServices();
     }
 }
Esempio n. 11
0
 /// <summary>
 /// Raises the connection state changed event.
 /// </summary>
 /// <param name="sender">Sender.</param>
 /// <param name="e">E.</param>
 public void OnConnectionStateChanged(IBleDevice sender, BleConnectionStateChangedEventArgs e)
 {
     ConnectionState = e.NewState;
     if (ConnectionStateChanged != null)
     {
         ConnectionStateChanged(sender, e);
     }
 }
Esempio n. 12
0
        /// <summary>
        /// Compares to.
        /// </summary>
        /// <returns>The to.</returns>
        /// <param name="obj">Object.</param>
        public int CompareTo(object obj)
        {
            IBleDevice otherDevice = obj as IBleDevice;

            if (otherDevice != null)
            {
                return(otherDevice.ID.CompareTo(this.ID));
            }
            throw new NotSupportedException("Unable to compare: " + this.GetType() + " with " + obj.GetType());
        }
Esempio n. 13
0
        /// <summary>
        /// Determines whether the specified <see cref="System.Object"/> is equal to the current <see cref="XBleApi.BleDevice"/>.
        /// </summary>
        /// <param name="obj">The <see cref="System.Object"/> to compare with the current <see cref="XBleApi.BleDevice"/>.</param>
        /// <returns><c>true</c> if the specified <see cref="System.Object"/> is equal to the current <see cref="XBleApi.BleDevice"/>;
        /// otherwise, <c>false</c>.</returns>
        public override bool Equals(object obj)
        {
            IBleDevice otherDevice = obj as IBleDevice;

            if (otherDevice != null)
            {
                return(otherDevice.ID == this.ID);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 14
0
        void BleCyclingSensor_CharacteristicChanged(IBleDevice sender, BleCharacteristicChangedEventArgs e)
        {
            WheelRev  = BitConverter.ToUInt32(e.CharacteristicValue, 1);
            WheelTime = BitConverter.ToUInt16(e.CharacteristicValue, 5);
            CrankRev  = BitConverter.ToUInt16(e.CharacteristicValue, 7);
            CrankTime = BitConverter.ToUInt16(e.CharacteristicValue, 9);


            RaisePropertyChanged("WheelRev");
            RaisePropertyChanged("WheelTime");
            RaisePropertyChanged("CrankRev");
            RaisePropertyChanged("CrankTime");
        }
Esempio n. 15
0
        /// <summary>
        /// Create a BLE device proxy object from a BLE device information
        /// </summary>
        /// <param name="device_info">BLE device information to use</param>
        /// <returns>BLE device proxy object on success, null otherwise</returns>
        public async Task <IBleDevice> CreateDeviceAsync(BleDeviceInformation device_info)
        {
            IBleDevice ble_device = null;

            UwpBleDevice win_ble_device = new UwpBleDevice(device_info);
            bool         init_succeed   = await win_ble_device.Initialize();

            if (init_succeed)
            {
                ble_device = win_ble_device;
            }

            return(ble_device);
        }
Esempio n. 16
0
        async void Connect(object param)
        {
            if (lvDevices.SelectedItem != null)
            {
                lbStatus.Text = "Connecting...";
                IBleDevice ble_device = await _ble_stack.CreateDeviceAsync(lvDevices.SelectedItem as BleDeviceInformation);

                _open_vario_device = new OpenVarioDevice(ble_device);
                if (await _open_vario_device.Initialize())
                {
                    lbStatus.Text = "Connected!";
                }
                else
                {
                    lbStatus.Text = "Not an Open Vario device!";
                }
            }
        }
Esempio n. 17
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);
 }
Esempio n. 18
0
 /// <summary>
 /// Raises the characteristic changed event.
 /// </summary>
 /// <param name="sender">Sender.</param>
 /// <param name="e">E.</param>
 public void OnCharacteristicChanged(IBleDevice sender, BleCharacteristicChangedEventArgs e)
 {
     dev.OnCharacteristicChanged(sender, e);
 }
Esempio n. 19
0
 /// <summary>
 /// Raises the descriptor read event.
 /// </summary>
 /// <param name="sender">Sender.</param>
 /// <param name="e">E.</param>
 public void OnDescriptorRead(IBleDevice sender, BleDescriptorReadEventArgs e)
 {
     dev.OnDescriptorRead(sender, e);
 }
Esempio n. 20
0
 /// <summary>
 /// Raises the descriptor write event.
 /// </summary>
 /// <param name="sender">Sender.</param>
 /// <param name="e">E.</param>
 public void OnDescriptorWrite(IBleDevice sender, BleDescriptorWriteEventArgs e)
 {
     dev.OnDescriptorWrite(sender, e);
 }
Esempio n. 21
0
 /// <summary>
 /// Raises the read remote rssi event.
 /// </summary>
 /// <param name="sender">Sender.</param>
 /// <param name="e">E.</param>
 public void OnReadRemoteRssi(IBleDevice sender, BleReadRemoteRssiEventArgs e)
 {
     dev.OnReadRemoteRssi(sender, e);
 }
Esempio n. 22
0
 /// <summary>
 /// Raises the reliable write completed event.
 /// </summary>
 /// <param name="sender">Sender.</param>
 /// <param name="e">E.</param>
 public void OnReliableWriteCompleted(IBleDevice sender, BleReliableWriteCompletedEventArgs e)
 {
     dev.OnReliableWriteCompleted(sender, e);
 }
Esempio n. 23
0
 /// <summary>
 /// Raises the services discovered event.
 /// </summary>
 /// <param name="sender">Sender.</param>
 /// <param name="e">E.</param>
 public void OnServicesDiscovered(IBleDevice sender, BleServicesDiscoveredEventArgs e)
 {
     dev.OnServicesDiscovered(sender, e);
 }
Esempio n. 24
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);
 }
Esempio n. 25
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;
 }
Esempio n. 26
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="ble_device">BLE device proxy to use to communicate with the Open Vario device</param>
 public OpenVarioDevice(IBleDevice ble_device)
 {
     _ble_device   = ble_device;
     _ble_services = new Dictionary <Guid, BleGattService>(10);
 }
Esempio n. 27
0
 /// <summary>
 /// Raises the characteristic write event.
 /// </summary>
 /// <param name="sender">Sender.</param>
 /// <param name="e">E.</param>
 public void OnCharacteristicWrite(IBleDevice sender, BleCharacteristicWriteEventArgs e)
 {
     dev.OnCharacteristicWrite(sender, e);
 }
Esempio n. 28
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);
 }
Esempio n. 29
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);
 }
Esempio n. 30
0
 /// <summary>
 /// Raises the connection state changed event.
 /// </summary>
 /// <param name="sender">Sender.</param>
 /// <param name="e">E.</param>
 public void OnConnectionStateChanged(IBleDevice sender, BleConnectionStateChangedEventArgs e)
 {
     dev.OnConnectionStateChanged(sender, e);
 }