Skip to content

2.3 ImFine C# Application

Peter F. Jorgensen edited this page Mar 28, 2016 · 10 revisions

IoTHub backend console app.

The main application basically configures the IoTHub and then start to monitor incoming messages. When receiving a new message, this is logged in the database and depending on the contents of the message received, a reply may be sent back to the device. This is currently used to activate the piezo beeper on the device as a response to the user pressing the button on the device in order to inform the user that the message is acknowledged.

When sending data to the device, the application monitors if the messages is delivered to the device or not. The response from the IoTHub feedback system updates the status of the message data in the database.

BackendConsole

The console application prints all messages in colors depending on the source. Light blue/Cyan colored lines are incoming messages received from the Arduino device. White colored lines are outgoing messages sent from the backend application to the device. The green lines are status responses from the IoTHub feedback system, monitoring the outgoing messages to the device.

Visual Studio 2015 Solution

The backend solution which connects to the service side of the IoTHub is implemented in 3 projects:

Visual Studio Solution

  1. ImFineBackendConsole
  2. ImFineDatamodel
  3. IoTHubServiceBackend

###ImFineBackendConsole The main application is implemented as a C# console application.

###ImFineDatamodel A datamodel using Entity Framework 6 is made on top of a SQL Server database. I have used the "database first" approach and built the model from the database.

Database table

Database table

Entity Framework model

EF model

Currently the database only contains one table to hold all incoming and outgoing messages through the IoTHub.

Database data

###IoTHubServiceBackend This project contains 3 classes which implement functionality to receive data from a device, to send data to a device and monitor the feedback status and last a class to handle sending emails.