public ICharacteristic GetServicesCharacterisitic(Constants.CharacteristicsUUID uuid) { ICharacteristic characterisitic = null; foreach (var service in this.Device.Services) { Debug.WriteLine("Service: " + service.ID); foreach (var chr in service.Characteristics) { Debug.WriteLine("Characteristic: " + chr.ID); if (chr.Uuid.ToString().ToUpper().Contains(uuid.ToString().Replace("_", ""))) { Debug.WriteLine("Characteristic Found!"); characterisitic = chr; if (characterisitic.CanRead) { if (CharValueUpdated == null) { Debug.WriteLine("Subscribing valueupdated!"); CharValueUpdated = new EventHandler<CharacteristicReadEventArgs>(GetValueFromChar); characterisitic.ValueUpdated += CharValueUpdated; } } break; } } } return characterisitic; }
public ICharacteristic GetServicesCharacteristic(Constants.CharacteristicsUUID uuid) { ICharacteristic characterisitic = null; foreach (var service in this.Device.Services) { foreach (var chr in service.Characteristics) { if (chr.Uuid.ToString().ToUpper().Contains(uuid.ToString().Replace("_", ""))) { Debug.WriteLine("Characteristic Found: " + chr.ID); characterisitic = chr; if (characterisitic.CanUpdate) { if (NotifyStateUpdated == null) { Debug.WriteLine("Subscribing notifystateupdate!"); NotifyStateUpdated = new EventHandler<CharacteristicReadEventArgs>(NotifyStateUpdateDone); characterisitic.NotificationStateValueUpdated += NotifyStateUpdateDone; } } break; } } } return characterisitic; }