An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
DeviceInformation.CreateFromIdAsync(deviceId) crashed
longevity uyl
285
Reputation points
The following code crashed when deviceId="BluetoothLE#BluetoothLEd8:f8:83:9f:72:1a-c4:4d:87:46:02:3a"
DeviceInformation deviceInfo = await DeviceInformation.CreateFromIdAsync(deviceId);
And I get deviceId from member function GetId() of Device class. Do you have suggestion to fix this issue?
internal abstract class Device
{
private readonly Windows.Devices.Enumeration.DeviceInformation info;
protected abstract bool IsConnected { get; }
public ConnectionStatus ConnectionStatus =>
IsConnected
? ConnectionStatus.Connected
: PairingInfo.IsPaired
? ConnectionStatus.Paired
: ConnectionStatus.NotPaired;
public Windows.Devices.Enumeration.DeviceInformationPairing PairingInfo => info.Pairing;
public DeviceInfoId Id { get; }
public string Name => info.Name;
protected Device(Windows.Devices.Enumeration.DeviceInformation info)
{
this.info = info;
Id = new DeviceInfoId(info);
}
public string GetId() {
return info.Id;
}
public override string ToString()
{
return $"name:'{Name}' mac:'{Id.DeviceMac}' type:'{Id.DeviceType}' ConnectionStatus:'{ConnectionStatus}'";
}
}
Developer technologies | C#
Developer technologies | C#
Sign in to answer