Windows 10 UAP determine if device is IoT (e.g. Raspberry Pi 2)

I was wondering how to determine if the device belongs to the IoT-family, in my case a Raspberry Pi 2, but I don't need to know if it is specifically a Raspberry, just an IoT device.

I tried the following code:

//if(ApiInformation.IsApiContractPresent("DevicesLowLevelContract ", 1))
if (ApiInformation.IsTypePresent("Windows.Devices.Gpio"))
{
    this.InitializeSensor();
    return;
}

Both wont be true on my notebook, but wont be true as well on my Rasbperry Pi. Has someone an idea or knows how to do it right?

Upvotes: 2

Views: 1615

Answers (3)

György Balássy
György Balássy

Reputation: 2988

I'm struggling with the same issue, see: How to detect running on a real device?

Unfortunately IsTypePresent for the GpioController class returns true on desktop as well.

Upvotes: 0

Daniel Meixner
Daniel Meixner

Reputation: 1839

With ApiInformation.IsTypePresent you are looking for a type not for a namespace. "Windows.Devices.Gpio" is a namespace. Try using the method with "Windows.Devices.Gpio.GpioController" instead.

I recommend working with the typeof keyword here to avoid working with strings. Like this:

ApiInformation.IsTypePresent(typeof(Windows.Devices.Gpio.GpioController).ToString());

Upvotes: 1

Sevenate
Sevenate

Reputation: 6485

I would expect that property

Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily

is what you are looking for - it should return something like "Windows.IoT" in your case, since when I've checked it in universal app on desktop it was "Windows.Desktop" and on the phone with Windows 10 Mobile (preview) it was, well, "Windows.Mobile".

Upvotes: 4

Related Questions