diff --git a/backend/Api/Api.csproj b/backend/Api/Api.csproj
index 71bca14..486cff1 100644
--- a/backend/Api/Api.csproj
+++ b/backend/Api/Api.csproj
@@ -22,6 +22,8 @@
runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
diff --git a/backend/Api/Api.sln b/backend/Api/Api.sln
index 409cce6..ebc8b3a 100644
--- a/backend/Api/Api.sln
+++ b/backend/Api/Api.sln
@@ -5,6 +5,8 @@ VisualStudioVersion = 17.9.34607.119
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Api", "Api.csproj", "{9CCF78E1-969C-420F-BE31-F8AFCE0C6827}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "test", "..\test\test.csproj", "{5ACD3275-AE0C-458C-AACD-12FE1E165621}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -15,6 +17,10 @@ Global
{9CCF78E1-969C-420F-BE31-F8AFCE0C6827}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9CCF78E1-969C-420F-BE31-F8AFCE0C6827}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9CCF78E1-969C-420F-BE31-F8AFCE0C6827}.Release|Any CPU.Build.0 = Release|Any CPU
+ {5ACD3275-AE0C-458C-AACD-12FE1E165621}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {5ACD3275-AE0C-458C-AACD-12FE1E165621}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {5ACD3275-AE0C-458C-AACD-12FE1E165621}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {5ACD3275-AE0C-458C-AACD-12FE1E165621}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/backend/Api/MQTTReciever/MQTTReciever.cs b/backend/Api/MQTTReciever/MQTTReciever.cs
new file mode 100644
index 0000000..aec5de5
--- /dev/null
+++ b/backend/Api/MQTTReciever/MQTTReciever.cs
@@ -0,0 +1,57 @@
+using Api.DBAccess;
+using MQTTnet;
+using MQTTnet.Extensions.TopicTemplate;
+using System.Text;
+
+
+namespace Api.MQTTReciever
+{
+ public class MQTTReciever
+ {
+ IMqttClient mqttClient;
+ private readonly IConfiguration _configuration;
+
+ public MQTTReciever(IConfiguration configuration)
+ {
+ _configuration = configuration;
+ }
+
+
+ public async Task Handle_Received_Application_Message()
+ {
+ var mqttFactory = new MqttClientFactory();
+
+ using (mqttClient = mqttFactory.CreateMqttClient())
+ {
+ var mqttClientOptions = new MqttClientOptionsBuilder()
+ .WithTcpServer($"{_configuration["MQTT:host"]}", 1883)
+ .WithCredentials($"{_configuration["MQTT:username"]}", $"{_configuration["MQTT:password"]}")
+ .WithCleanSession()
+ .Build();
+
+ // Setup message handling before connecting so that queued messages
+ // are also handled properly. When there is no event handler attached all
+ // received messages get lost.
+ mqttClient.ApplicationMessageReceivedAsync += e =>
+ {
+ Console.WriteLine("Received application message.");
+
+ return Task.CompletedTask;
+ };
+
+
+ await mqttClient.ConnectAsync(mqttClientOptions, CancellationToken.None);
+ Console.WriteLine("mqttClient");
+
+ //var mqttSubscribeOptions = mqttFactory.CreateSubscribeOptionsBuilder().WithTopicTemplate(topic).Build();
+
+ await mqttClient.SubscribeAsync("temperature");
+
+ Console.WriteLine("MQTT client subscribed to topic.");
+
+ Console.WriteLine("Press enter to exit.");
+ Console.ReadLine();
+ }
+ }
+ }
+}
diff --git a/backend/Api/Program.cs b/backend/Api/Program.cs
index 5802836..34262fb 100644
--- a/backend/Api/Program.cs
+++ b/backend/Api/Program.cs
@@ -1,13 +1,18 @@
using Api;
+using Api.MQTTReciever;
using Microsoft.AspNetCore;
using Microsoft.EntityFrameworkCore;
+using Microsoft.Extensions.Configuration;
class Program
{
+
public static void Main(string[] args)
{
var app = CreateWebHostBuilder(args).Build();
-
+ var configuration = app.Services.GetRequiredService();
+ MQTTReciever mqtt = new MQTTReciever(configuration);
+ mqtt.Handle_Received_Application_Message();
RunMigrations(app);
app.Run();
diff --git a/backend/test/Program.cs b/backend/test/Program.cs
new file mode 100644
index 0000000..cc6d76a
--- /dev/null
+++ b/backend/test/Program.cs
@@ -0,0 +1,36 @@
+using MQTTnet;
+
+var mqttFactory = new MqttClientFactory();
+IMqttClient mqttClient;
+
+using (mqttClient = mqttFactory.CreateMqttClient())
+ {
+ var mqttClientOptions = new MqttClientOptionsBuilder()
+ .WithTcpServer($"10.135.51.116", 1883)
+ .WithCredentials($"h5", $"Merc1234")
+ .WithCleanSession()
+ .Build();
+
+ // Setup message handling before connecting so that queued messages
+ // are also handled properly. When there is no event handler attached all
+ // received messages get lost.
+ mqttClient.ApplicationMessageReceivedAsync += e =>
+ {
+ Console.WriteLine("Received application message.");
+
+ return Task.CompletedTask;
+ };
+
+
+ await mqttClient.ConnectAsync(mqttClientOptions, CancellationToken.None);
+ Console.WriteLine("mqttClient");
+
+ //var mqttSubscribeOptions = mqttFactory.CreateSubscribeOptionsBuilder().WithTopicTemplate(topic).Build();
+
+ await mqttClient.SubscribeAsync("temperature");
+
+ Console.WriteLine("MQTT client subscribed to topic.");
+
+ Console.WriteLine("Press enter to exit.");
+ Console.ReadLine();
+}
diff --git a/backend/test/test.csproj b/backend/test/test.csproj
new file mode 100644
index 0000000..f105f42
--- /dev/null
+++ b/backend/test/test.csproj
@@ -0,0 +1,14 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+
+
+
+
+
+
+
diff --git a/frontend/home/index.html b/frontend/home/index.html
index ab234ca..2f7d6a8 100644
--- a/frontend/home/index.html
+++ b/frontend/home/index.html
@@ -10,17 +10,11 @@
-
-
-
- ×
-
-
+
+
-
Name |
diff --git a/frontend/styles/home.css b/frontend/styles/home.css
index d0c75f3..9eb7fac 100644
--- a/frontend/styles/home.css
+++ b/frontend/styles/home.css
@@ -74,40 +74,6 @@ tr:nth-child(even) {
width: 20px;
}
-/* The Modal (background) */
-.modal {
- display: none; /* Hidden by default */
- position: fixed; /* Stay in place */
- z-index: 1; /* Sit on top */
- left: 0;
- top: 0;
- width: 100%; /* Full width */
- height: 100%; /* Full height */
- background-color: rgb(0, 0, 0); /* Fallback color */
- background-color: rgba(0, 0, 0, 0.6); /* Black w/ opacity */
-}
-
-/* Modal Content/Box */
-.modal-content {
- border-radius: 20px;
- background-color: #fefefe;
- margin: 15% auto; /* 15% from the top and centered */
- padding: 20px;
- border: 1px solid #888;
- width: 80%; /* Could be more or less, depending on screen size */
-}
-
-/* The Close Button */
-.close {
- color: #aaa;
- float: right;
- font-size: 28px;
- font-weight: bold;
-}
-
-.close:hover,
-.close:focus {
- color: black;
- text-decoration: none;
- cursor: pointer;
+.chartContainer{
+ margin: 20px;
}