Exemplo 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);
     }
 }
Exemplo 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);
     }
 }
Exemplo n.º 3
0
 void sensor_ConnectionStateChanged(IBleDevice sender, BleConnectionStateChangedEventArgs e)
 {
     if (e.NewState == BleConnectionState.Disconnected)
     {
         this.SelectedDevice = null;
     }
 }
Exemplo 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);
     }
 }
Exemplo 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);
     }
 }
Exemplo 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);
     }
 }
Exemplo 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);
     }
 }
Exemplo 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);
     }
 }
Exemplo 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);
     }
 }
Exemplo n.º 10
0
 void BleCyclingSensor_ConnectionStateChanged(IBleDevice sender, BleConnectionStateChangedEventArgs e)
 {
     RaisePropertyChanged("ConnectionState");
     if (ConnectionState == BleConnectionState.Connected)
     {
         this.DiscoverServices();
     }
 }
Exemplo 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);
     }
 }
Exemplo 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());
        }
Exemplo 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);
            }
        }
Exemplo 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");
        }
Exemplo 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);
        }
Exemplo 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!";
                }
            }
        }
Exemplo 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);
 }
Exemplo 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);
 }
Exemplo 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);
 }
Exemplo 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);
 }
Exemplo 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);
 }
Exemplo 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);
 }
Exemplo 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);
 }
Exemplo 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);
 }
Exemplo 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;
 }
Exemplo 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);
 }
Exemplo 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);
 }
Exemplo 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);
 }
Exemplo 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);
 }
Exemplo 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);
 }