For many years, writing an application which connects to a hardware and controls its was very hard. You even needed to have tool to burn your code on hardware!
I am new to both Windows IoT and .Net Core IoT. I started a few weeks ago and I was thinking of coming up with a funny idea to create an application. My purpose was to see how to connect some technologies. And finally, I found this, a Morse messenger. A light that connects to the electrical really and the electrical relay is controlling by and Windows Univeral App. The app is hosted on a Windows IoT in a Raspberry Pi 3. Then I created a simple user-interface based on the Blazor. The Blazor app sends a message to .Net Core WebApi and then the WebApi application sends the push notification to the Windows Univeral App on the Raspberry Pi. And finally, the Windows Universal Application translates the string the Morse code and turn on and off the light.
The first step in learning how to connect a Raspberry Pi to hardware is learning Gpio Pins. Gpio Pins are the gateway to all external hardware. I can guid you to the official document in RaspberryPi.org about the GPIOs pins.
As I mentioned I am using Windows 10 for IoT to host my application in the Raspberry Pi. I can say that for my application which just provides a gateway and listens to push notification from the API, the Windows 10 for IoT is not the best solution. Because I don't need to provide a Graphic User-Interface on the Raspberry Pi device.
For installing the "Windows 10 for IoT" on the Raspberry Pi you need to install the Windows 10 IoT Dashboard on your Windows. When you install the IoT Dashboard it is so simple to select your device type and the OS and then flush it on an SD Card.
UWP is one of many ways to create client applications for Windows. UWP apps use WinRT APIs to provide powerful UI and advanced asynchronous features that are ideal for internet-connected devices.
A UWP app is:
In your Visual Studio, you just need to go the File -> New -> Project and then,
Here, you can see how to connect and initialize the GPIO Pins on the .Net Core code. in the First step, you need to instantiate a Gpio Controller GpioController.GetDefault(); and then in the .Net Core it is so easy to connect to a pin and then specify what is the reason for opening the Pin. With _bluePin.SetDriveMode(GpioPinDriveMode.Output);, you can specify what is the reason for initializing the pin. Then with the Write method, you can send Low and High to the pin.
For subscribing with Push Notification Server, you need to create a HubConnectionBuilder and specifies the Url. Please take care of the WithAutomaticReconnect to handle the reconnection in case of the server is off.
After that, you need to listen to the specific method and specify an action to call when receiving the push notification. Then you just need to listen. SO EASY!!
For the rest of the solution I don't got into the details. As I mentioned in the title, I used the Blazor font-end application for the UI and .Net Core WebApi for the RESTful Api.
You can see and download the code from my GitHub Repository, dotnet-talk-morse
And, please send a message to me in the UI here Morse Messenger and turn a light on my apartment.