Example #1
0
        private void LoadBaseCharacteristics()
        {
            Guid notificationSourceUuid = new Guid("9FBF120D-6301-42D9-8C58-25E699A21DBD");
            Guid controlPointUuid       = new Guid("69D1D8F3-45E1-49A8-9821-9BBDFDAAD9D9");
            Guid dataSourceUuid         = new Guid("22EAC6E9-24D6-4BB5-BE44-B36ACE7C7BFB");

            IReadOnlyList <GattCharacteristic> allCharacteristics = DeviceService.GetAllCharacteristics();

            foreach (GattCharacteristic c in allCharacteristics)
            {
                if (c.Uuid == controlPointUuid)
                {
                    try
                    {
                        _ControlPoint = new ControlPoint(c);
                    }
                    catch (Exception e)
                    {
                        throw e;
                    }
                }
                else if (c.Uuid == dataSourceUuid)
                {
                    try
                    {
                        _DataSource = new DataSource(c);
                    }
                    catch (Exception e)
                    {
                        throw e;
                    }
                }
                else if (c.Uuid == notificationSourceUuid)
                {
                    try
                    {
                        _NotificationSource = new NotificationSource(c);
                    }
                    catch (Exception e)
                    {
                        throw e;
                    }
                }
            }

            if (_NotificationSource == null)
            {
                //    throw new AppleNotificationCenterServiceCharacteristicNotFound("Missing notification source characteristic");
                throw new Exception("Missing notification source characteristic");
            }
            else if (_ControlPoint == null)
            {
                //    throw new AppleNotificationCenterServiceCharacteristicNotFound("Missing control point characteristic");
                throw new Exception("Missing control point characteristic");
            }
            else if (_DataSource == null)
            {
                //    throw new AppleNotificationCenterServiceCharacteristicNotFound("Missing data source characteristic");
                throw new Exception("Missing data source characteristic");
            }

            // Add watcher for connection status changes
            //DeviceService.Device.ConnectionStatusChanged += Device_ConnectionStatusChanged;
        }