Display useful information from your Windows 10 IoT Core application in an ASP.NET Core web app, essential for integrating IoT data into a solution.
Windows 10 IoT background task talk with a web application using WebSockets.
Problems
As my path to this solution has been troublesome, I am listing here the main problems I faced so my dear readers have a better idea of dead-end streets along the way:
- I was not able to make the ASP.NET Core web application run under a Windows 10 IoT background service.
- I found no information about when or if it will be supported in the near future.
- ASP.NET MVC and ASP.NET Core have different SignalR implementations.
- I was not able to make a SignalR client for .NET Core work with SignalR hosted on a web application.
I was able to make things work by directly using a WebSocket. It’s not as nice a solution as I had in my mind, but it works until things get better.
Making the Background Task and Web Application Talk
I worked out simple and not-very-well polished solution to make a Windows 10 IoT Core background task communicate with an ASP.NET Core web application hosted on a Raspberry Pi. I implemented two types of communication on the same WebSocket endpoint. The following image illustrates what is supported.
To make my sample more informative, I also implemented some primitive functionalities to demonstrate how data moves.
The Windows 10 IoT Core background task reports random numbers to the web application every 10 seconds.- The web application has a simple console to send commands to the Windows 10 IoT Core background task. Supported commands are:
opsys
: returns operating system information from the background taskmachine name
: returns the machine name where the background task runs
Here is a fragment of the web application's front page when the background service runs.
Comments
Post a Comment