Example #1
0
        /// <summary>
        /// Loads GATT services information in list and attaches to CapSense and RGB led custom services if available.
        /// </summary>
        private void LoadGattServices()
        {
            if (currentCapSenseCharacteristic != null)
            {
                currentCapSenseCharacteristic.ValueChanged -= currentCapSenseCharacteristic_ValueChanged;
            }
            currentCapSenseCharacteristic = null;
            currentRGBLedCharacteristic   = null;
            lstGattServices.Items.Clear();
            lstCharacteristics.Items.Clear();

            string description = string.Empty;

            foreach (var service in currentDevice.GattServices)
            {
                description = UUIDHelper.GetUUIDDescription(service.Uuid.ToString());
                lstGattServices.Items.Add(new MyGattService(description, service));

                foreach (var characteristic in service.GetAllCharacteristics())
                {
                    if (characteristic.Uuid == Guid.Parse("0000caa2-0000-1000-8000-00805f9b34fb"))
                    {
                        AttachToCapSense(characteristic);
                    }
                    else if (characteristic.Uuid == Guid.Parse("0000cbb1-0000-1000-8000-00805f9b34fb"))
                    {
                        AttachToRGBLed(characteristic);
                    }
                }
            }
        }