Skip to main content

Real-Time Talk: Windows 10 IoT Core Background Tasks and ASP.NET Core Web Apps

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.
Windows 10 IoT Core background task and ASP.NET Core web application
To make my sample more informative, I also implemented some primitive functionalities to demonstrate how data moves.


  1. The Windows 10 IoT Core background task reports random numbers to the web application every 10 seconds.
  2. The web application has a simple console to send commands to the Windows 10 IoT Core background task. Supported commands are:
    1. opsys: returns operating system information from the background task
    2. machine 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.
WebSocket sample output with command

    Comments

    Popular posts from this blog

    How to construct a File System that lives in Shared Memory.

    Shared Memory File System Goals 1. MOUNTED IN SHARED MEMORY The result is a very fast, real time file system. We use Shared Memory so that the file system is public and not private. 2. PERSISTS TO DISK When the file system is unmounted, what happens to it? We need to be able to save the file system so that a system reboot does not destroy it. A great way to achieve this is to save the file system to disk. 3. EXTENSIBLE IN PLACE We want to be able to grow the file system in place. 4. SUPPORTS CONCURRENCY We want multiple users to be able to access the file system at the same time. In fact, we want multiple users to be able to access the same file at the same time. With the goals now in mind we can now talk about the major design issues: FAT File System & Design Issues The  FAT File System  has been around for quite some time. Basically it provides a pretty good file structure. But I have two problems with it: 1. FAT IS NOT EXTENSIBLE IN PLAC...

    Common Sense Identification of the Security Problems

    Organizations make key information security mistakes, which leads to inefficient and ineffective control environment. High profile data breaches and cyber-attacks drive the industry to look for more comprehensive protection measures since many organizations feel that their capability to withstand persistent targeted attacks is minimal. But at the same time, these organizations make some key information security mistakes, that jeopardize their efforts towards control robustness. Although many firms invest in security technologies and people, no one has the confidence that the measures taken are good enough to protect their data from compromises. Below are the 10 worst mistakes which are common to find, and important to address in the path of mature information security posture. If you analyze the cyber security scenarios, and organizational capabilities, the prevailing trend is a vendor-driven approach. In many cases, security professionals adopt the attitude of procuring...

    Ingesting IoT Sensor Data Into S3 With an RPI3

    StreamSets Data Collector Edge is a lightweight agent used to create end-to-end data flow pipelines. We'll use it help stream data collected from a sensor. Due to the increasing amount of data produced from outside source systems, enterprises are facing difficulties in reading, collecting, and ingesting data into a desired, central database system. An edge pipeline runs on an edge device with limited resources, receives data from another pipeline or reads the data from the device, and controls the device based on the data. StreamSets Data Collector (SDC) Edge, an ultra-lightweight agent, is used to create end-to-end data flow pipelines in StreamSets Data Collector and to run the pipelines to read and export data in and out of systems. In this blog, StreamSets Data Collector Edge is used to read data from an air pressure sensor (BMP180) from an IoT device (Raspberry Pi3). Meanwhile, StreamSets Data Collector is used to load the data into Amazon's Simple Storage Service ...