/// <summary> /// Helper function to convert a UUID to a name /// </summary> /// <param name="uuid"></param> /// <returns>Name of the UUID</returns> public static string ConvertUuidToName(Guid uuid) { var shortId = BluetoothUuidHelper.TryGetShortId(uuid); if (shortId.HasValue && Enum.TryParse(shortId.Value.ToString(), out GattDescriptorUuid name) == true) { return(name.ToString()); } return(uuid.ToString()); }
/// <summary> /// Initializes a new instance of the<see cref="ObservableGattCharacteristics" /> class. /// </summary> /// <param name="characteristic">Characteristic this class wraps</param> /// <param name="parent">The parent service that wraps this characteristic</param> public ObservableGattCharacteristics(GattCharacteristic characteristic, ObservableGattDeviceService parent) { Characteristic = characteristic; Parent = parent; Name = GattCharacteristicUuidHelper.ConvertUuidToName(characteristic.Uuid); var shortId = BluetoothUuidHelper.TryGetShortId(characteristic.Uuid); if (shortId.HasValue) { ShortUUID = "0x" + shortId.Value.ToString("X"); } else { ShortUUID = ""; } UUID = characteristic.Uuid.ToString(); }
private uint AsShortIdImpl() { var shortId = BluetoothUuidHelper.TryGetShortId(_uuid); return(shortId.HasValue ? shortId.Value: 0); }