Exemplo n.º 1
0
        /// <summary>
        /// Initialize the list of all characteristics in this service.
        /// </summary>
        public void InitializeCharacteristics()
        {
            // Don't need to initialize multiple times.
            if (CharacteristicModels.Count > 0)
            {
                return;
            }

            // Get characteristics.
            try
            {
                IReadOnlyList <GattCharacteristic> characteristics = _service.GetAllCharacteristics();
                foreach (GattCharacteristic characteristic in characteristics)
                {
                    BECharacteristicModel characteristicM = new BECharacteristicModel();
                    characteristicM.Initialize(this, characteristic);
                    CharacteristicModels.Add(characteristicM);
                }
            }
            catch (Exception ex)
            {
                // GetAllCharacteristics can fail with E_ACCESS_DENIED if another app is holding a
                // reference to the BTLE service.  It can be an active background task, or in the
                // backstack.
                Utilities.OnExceptionWithMessage(ex, "This exception may be encountered if a another app holds a reference to the BTLE service.");
            }
        }
 /// <summary>
 /// Test for equality
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool ToastEquals(BECharacteristicModel model)
 {
     return(_toastName.Equals(model._toastName));
 }