A Universal Windows App that mimics the web portal to a Windows 10 IoT Core device. Makes use of the web portal through REST and uses JSON to process the response for display. Can get ipconfig, processes, installed app, default app, OS info etc… All in an app.
Project on GitHub: https://github.com/djaus2/IoTSysInfo
Development Requirements: Windows 10, Visual Studio 2015 RTM, Windows 10 IoT device (eg Raspberry Pi 2)
Updates: This blog has been updated with more background information. Also Version 2.1 of the app has a new command that list all installed apps. Version 2.2: Some code improvement that would slightly simplify adding additional commands.
Windows 10 IoT, Windows 10 Desktop, Windows 10 Phone(Version 2 of app) [Phone’s not working yet. Scren resolution changes don’t work]
What the app doesn’t do:
There are two versions, both using the same REST and JSON processing code. They differ on the UI interface in that the first version is simple interface meant for a standard desktop screen. The second is more complex in that the UI is divided into three sections and are subject to State Triggers. This version is meant for smaller screens as well as the desktop as the triggers can automatically hide parts of the UI which can be manually triggered for display.
This app shows you how you access various system attributes of a Windows 10 IoT device from a Universal Windows App running on the device or on another Windows 10 device (IoT, Phone or Desktop). It exemplifies REST calls and recursive JSON parsing.
The basis of this app (wrt REST and the Web Portal API) came for a blog by Bruce Eitman:
Windows 10 IoT Core: Getting the MAC Address from Raspberry Pi.
The app can run on a Windows 10 desktop, Windows 10 Phone or Windows 10 IoT device, depending upon the CPU target used when building the app. But the subject of the app is always a Windows 10 IoT device as it exploits the web service that runs on those devices. Hence the app either runs in local or remote mode. If running in local mode, on a Raspberry Pi 2 for example, you set the target to localhost, the device name or its IPAddress. If running remotely though, you can’t use localhost of course. The port needs to be set to 8080 as per the web interface. You set the login credentials for on the device which default to those for when a device is first initiated. When press the button for whichever command you want to action. The result of the query appears in teh right-hand pane. eg:
Version 1.0 of the app (Click me)
In the above image of the app ipconfig has been run.
With some commands where items are indexed, they can be expanded by clicking upon them to get details. For example, Devices returns a large numbers of devices, each which has a large set of (the same) properties. For each, the initial query just displays the Name property of each device. By clicking on a particular device you get all of its properties. The same for Processes, Installed Packages and Providers. Ipconfig will return an array where there is more than one network adapter. This can be exemplified by plugging in a USB network adapter ( i use the one supplied with the Galileo board). In this case you initially just get a list of the nics. If you then click on one you get the interface’s details.
The target IoT device is configured in the top left of the UI, as circled in red.
The user credentials on are just below that as circled in blue.
The commands in the bottom left of the UI.
Most calls in the app are async including the REST call. “In principle” you can cancel the REST call if its taking too long or set a timeout beforehand.To set the time just vary the slider position, It seems that an incorrectly targeted REST call can’t be stopped in this manner though. It just eventually fails
The REST calls use a URL made up of the target name or IPAddress, the port (8080) and an API path:
The following are the APIs used in the app.
/api/appx/installed <- Add in Version 2.1
If you wish to experiment with these API paths, no that these paths are copied into the box just to the right of the [API] command button.When the [API] button is pressed, whatever path is in that box is used and so you can test any API path you wish. Note also that below the [API] button is another textbox. This can be used to add any REST parameters.
Version 2.0 has the same functionality as Version1.0. The underlying “engine” is unchanged. It just a reworked UI that is more dynamic.
This version has the UI in three sections (Click me):
In full screen on a desktop, all three panes show, by default. The first two can though be hidden by pressing
For smaller screens the Settings pane is hidden by default and for even smaller screen (say the phone) the commands are also hidden.
Note that the Glyph and Settings Icon are also used to show their panes when not showing..
Next: The REST and JSON processing: Win 10-IoT- SysInfo- A Universal Windows App (Part 2)- REST & JSON Code