If all you want to rely on is the MAC address of an interface you can use this code. It has been available since .NET 2 and it should be implemented in IoT and Mono alike
public static HashSet<string> NetworkIds()
{
var result = new HashSet<string>();
var networkProfiles = Windows.Networking.Connectivity.NetworkInformation.GetConnectionProfiles().ToList();
foreach (var net in networkProfiles)
{
result.Add(net.NetworkAdapter.NetworkAdapterId.ToString());
}
return result;
}
You can also go and explore this namespace on the IoT
import Windows.Security.ExchangeActiveSyncProvisioning;
and try checking what lies on these object. Try and test them on two Pi's
var deviceInfo = new EasClientDeviceInformation;
deviceInfo.
Here is another, more complete sample that may be usefull.
using System;
using Windows.Security.ExchangeActiveSyncProvisioning;
using Windows.System.Profile;
public sealed class DeviceInfo
{
private static DeviceInfo _Instance;
public static DeviceInfo Instance
{
get {
if (_Instance == null)
_Instance = new DeviceInfo();
return _Instance; }
}
public string Id { get; private set; }
public string Model { get; private set; }
public string Manufracturer { get; private set; }
public string Name { get; private set; }
public static string OSName { get; set; }
private DeviceInfo()
{
Id = GetId();
var deviceInformation = new EasClientDeviceInformation();
Model = deviceInformation.SystemProductName;
Manufracturer = deviceInformation.SystemManufacturer;
Name = deviceInformation.FriendlyName;
OSName = deviceInformation.OperatingSystem;
}
private static string GetId()
{
if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.System.Profile.HardwareIdentification"))
{
var token = HardwareIdentification.GetPackageSpecificToken(null);
var hardwareId = token.Id;
var dataReader = Windows.Storage.Streams.DataReader.FromBuffer(hardwareId);
byte[] bytes = new byte[hardwareId.Length];
dataReader.ReadBytes(bytes);
return BitConverter.ToString(bytes).Replace("-", "");
}
throw new Exception("NO API FOR DEVICE ID PRESENT!");
}
}