async Task <GattCharacteristic> DoGetCharacteristic(BluetoothUuid characteristic) { var result = await _service.GetCharacteristicsForUuidAsync(characteristic); if (result.Status == WBluetooth.GattCommunicationStatus.Success && result.Characteristics.Count > 0) { return(new GattCharacteristic(this, result.Characteristics[0])); } return(null); }
async Task <GattCharacteristic> PlatformGetCharacteristic(BluetoothUuid characteristic) { var result = await _service.GetCharacteristicsForUuidAsync(characteristic, Windows.Devices.Bluetooth.BluetoothCacheMode.Cached); if (result.Status == WBluetooth.GattCommunicationStatus.Success && result.Characteristics.Count > 0) { return(new GattCharacteristic(this, result.Characteristics[0])); } return(null); }
async Task <IReadOnlyList <GattCharacteristic> > _GetCharacteristicsAsync(Guid uuid) { var result = await service.GetCharacteristicsForUuidAsync(uuid); switch (result.Status) { case Win.GattCommunicationStatus.Success: return(result.Characteristics.Select(x => new GattCharacteristic(this, x)).ToList().AsReadOnly()); case Win.GattCommunicationStatus.AccessDenied: throw new AccessViolationException("Access denied"); case Win.GattCommunicationStatus.ProtocolError: case Win.GattCommunicationStatus.Unreachable: default: throw new Exception("Need a better exception here"); } }