diff --git a/Birdmap.API/Birdmap.API.csproj b/Birdmap.API/Birdmap.API.csproj
index 0510550..cc32bdd 100644
--- a/Birdmap.API/Birdmap.API.csproj
+++ b/Birdmap.API/Birdmap.API.csproj
@@ -35,8 +35,6 @@
runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
diff --git a/Birdmap.API/Controllers/DevicesController.cs b/Birdmap.API/Controllers/DevicesController.cs
index c1cec49..0b345be 100644
--- a/Birdmap.API/Controllers/DevicesController.cs
+++ b/Birdmap.API/Controllers/DevicesController.cs
@@ -1,15 +1,14 @@
using Birdmap.BLL.Interfaces;
+using Birdmap.BLL.Services.CommunicationServices.Hubs;
+using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Mvc.ModelBinding;
+using Microsoft.AspNetCore.SignalR;
using Microsoft.Extensions.Logging;
using System;
-using System.Threading.Tasks;
using System.Collections.Generic;
-using Microsoft.AspNetCore.Mvc.ModelBinding;
using System.Linq;
-using Microsoft.AspNetCore.Authorization;
-using Microsoft.AspNetCore.SignalR;
-using Birdmap.API.Services.Hubs;
-using Birdmap.API.Services;
+using System.Threading.Tasks;
namespace Birdmap.API.Controllers
{
diff --git a/Birdmap.API/Controllers/ServicesController.cs b/Birdmap.API/Controllers/ServicesController.cs
index 79aa554..90d77a9 100644
--- a/Birdmap.API/Controllers/ServicesController.cs
+++ b/Birdmap.API/Controllers/ServicesController.cs
@@ -1,9 +1,8 @@
using AutoMapper;
using Birdmap.API.DTOs;
-using Birdmap.API.Services;
-using Birdmap.API.Services.Hubs;
-using Birdmap.API.Services.Mqtt;
using Birdmap.BLL.Interfaces;
+using Birdmap.BLL.Services.CommunicationServices.Hubs;
+using Birdmap.BLL.Services.CommunicationServices.Mqtt;
using Birdmap.DAL.Entities;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
diff --git a/Birdmap.API/Extensions/ServiceCollectionExtensions.cs b/Birdmap.API/Extensions/ServiceCollectionExtensions.cs
deleted file mode 100644
index a765a80..0000000
--- a/Birdmap.API/Extensions/ServiceCollectionExtensions.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-using Birdmap.API.Options;
-using Birdmap.API.Services.Mqtt;
-using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Extensions.Hosting;
-using System;
-
-namespace Birdmap.API.Extensions
-{
- public static class ServiceCollectionExtensions
- {
- public static IServiceCollection AddMqttClientServiceWithConfig(this IServiceCollection services, Action configureOptions)
- {
- services.AddSingleton(serviceProvider =>
- {
- var optionBuilder = new AspCoreMqttClientOptions(serviceProvider);
- configureOptions(optionBuilder);
- return optionBuilder.Build();
- });
- services.AddSingleton();
- services.AddSingleton(serviceProvider =>
- {
- return serviceProvider.GetService();
- });
- services.AddSingleton(serviceProvider =>
- {
- var mqttClientService = serviceProvider.GetService();
- var mqttClientServiceProvider = new MqttClientServiceProvider(mqttClientService);
- return mqttClientServiceProvider;
- });
- return services;
- }
- }
-}
diff --git a/Birdmap.API/Startup.cs b/Birdmap.API/Startup.cs
index fa906fd..3db4a85 100644
--- a/Birdmap.API/Startup.cs
+++ b/Birdmap.API/Startup.cs
@@ -1,8 +1,7 @@
using AutoMapper;
-using Birdmap.API.Extensions;
using Birdmap.API.Middlewares;
-using Birdmap.API.Services.Hubs;
using Birdmap.BLL;
+using Birdmap.BLL.Services.CommunicationServices.Hubs;
using Birdmap.DAL;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Builder;
@@ -42,8 +41,6 @@ namespace Birdmap.API
services.AddAutoMapper(typeof(Startup));
- services.AddSignalR();
-
var key = Encoding.ASCII.GetBytes(Configuration["Secret"]);
services.AddAuthentication(opt =>
{
@@ -64,33 +61,6 @@ namespace Birdmap.API
};
});
- services.AddMqttClientServiceWithConfig(opt =>
- {
- var mqtt = Configuration.GetSection("Mqtt");
-
- var mqttClient = mqtt.GetSection("ClientSettings");
- var clientSettings = new
- {
- Id = mqttClient.GetValue("Id"),
- Username = mqttClient.GetValue("Username"),
- Password = mqttClient.GetValue("Password"),
- Topic = mqttClient.GetValue("Topic"),
- };
-
- var mqttBrokerHost = mqtt.GetSection("BrokerHostSettings");
- var brokerHostSettings = new
- {
- Host = mqttBrokerHost.GetValue("Host"),
- Port = mqttBrokerHost.GetValue("Port"),
- };
-
- opt
- .WithTopic(clientSettings.Topic)
- .WithCredentials(clientSettings.Username, clientSettings.Password)
- .WithClientId(clientSettings.Id)
- .WithTcpServer(brokerHostSettings.Host, brokerHostSettings.Port);
- });
-
// In production, the React files will be served from this directory
services.AddSpaStaticFiles(configuration =>
{
diff --git a/Birdmap.BLL/Birdmap.BLL.csproj b/Birdmap.BLL/Birdmap.BLL.csproj
index c604365..59e5e5c 100644
--- a/Birdmap.BLL/Birdmap.BLL.csproj
+++ b/Birdmap.BLL/Birdmap.BLL.csproj
@@ -5,6 +5,9 @@
+
+
+
diff --git a/Birdmap.API/Services/IMqttClientService.cs b/Birdmap.BLL/Interfaces/IMqttClientService.cs
similarity index 93%
rename from Birdmap.API/Services/IMqttClientService.cs
rename to Birdmap.BLL/Interfaces/IMqttClientService.cs
index 8316d9a..e55d726 100644
--- a/Birdmap.API/Services/IMqttClientService.cs
+++ b/Birdmap.BLL/Interfaces/IMqttClientService.cs
@@ -3,7 +3,7 @@ using MQTTnet.Client.Connecting;
using MQTTnet.Client.Disconnecting;
using MQTTnet.Client.Receiving;
-namespace Birdmap.API.Services
+namespace Birdmap.BLL.Interfaces
{
public interface IMqttClientService : IHostedService,
IMqttClientConnectedHandler,
diff --git a/Birdmap.API/Options/AspCoreMqttClientOptions.cs b/Birdmap.BLL/Options/AspCoreMqttClientOptions.cs
similarity index 94%
rename from Birdmap.API/Options/AspCoreMqttClientOptions.cs
rename to Birdmap.BLL/Options/AspCoreMqttClientOptions.cs
index 02ae31e..f0e1191 100644
--- a/Birdmap.API/Options/AspCoreMqttClientOptions.cs
+++ b/Birdmap.BLL/Options/AspCoreMqttClientOptions.cs
@@ -1,7 +1,7 @@
using MQTTnet.Client.Options;
using System;
-namespace Birdmap.API.Options
+namespace Birdmap.BLL.Options
{
public class AspCoreMqttClientOptions : MqttClientOptionsBuilder
{
diff --git a/Birdmap.API/Services/Hubs/DevicesHub.cs b/Birdmap.BLL/Services/CommunationServices/Hubs/DevicesHub.cs
similarity index 92%
rename from Birdmap.API/Services/Hubs/DevicesHub.cs
rename to Birdmap.BLL/Services/CommunationServices/Hubs/DevicesHub.cs
index 9938b42..56130c4 100644
--- a/Birdmap.API/Services/Hubs/DevicesHub.cs
+++ b/Birdmap.BLL/Services/CommunationServices/Hubs/DevicesHub.cs
@@ -3,7 +3,7 @@ using Microsoft.Extensions.Logging;
using System;
using System.Threading.Tasks;
-namespace Birdmap.API.Services.Hubs
+namespace Birdmap.BLL.Services.CommunicationServices.Hubs
{
public class DevicesHub : Hub
{
diff --git a/Birdmap.API/Services/Hubs/IDevicesHubClient.cs b/Birdmap.BLL/Services/CommunationServices/Hubs/IDevicesHubClient.cs
similarity index 86%
rename from Birdmap.API/Services/Hubs/IDevicesHubClient.cs
rename to Birdmap.BLL/Services/CommunationServices/Hubs/IDevicesHubClient.cs
index aa4fef1..35de290 100644
--- a/Birdmap.API/Services/Hubs/IDevicesHubClient.cs
+++ b/Birdmap.BLL/Services/CommunationServices/Hubs/IDevicesHubClient.cs
@@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Threading.Tasks;
-namespace Birdmap.API.Services
+namespace Birdmap.BLL.Services.CommunicationServices.Hubs
{
public record Message(Guid DeviceId, DateTime Date, double Probability);
diff --git a/Birdmap.API/Services/Hubs/IServicesHubClient.cs b/Birdmap.BLL/Services/CommunationServices/Hubs/IServicesHubClient.cs
similarity index 68%
rename from Birdmap.API/Services/Hubs/IServicesHubClient.cs
rename to Birdmap.BLL/Services/CommunationServices/Hubs/IServicesHubClient.cs
index 6891865..a03d125 100644
--- a/Birdmap.API/Services/Hubs/IServicesHubClient.cs
+++ b/Birdmap.BLL/Services/CommunationServices/Hubs/IServicesHubClient.cs
@@ -1,6 +1,6 @@
using System.Threading.Tasks;
-namespace Birdmap.API.Services.Hubs
+namespace Birdmap.BLL.Services.CommunicationServices.Hubs
{
public interface IServicesHubClient
{
diff --git a/Birdmap.API/Services/Hubs/ServicesHub.cs b/Birdmap.BLL/Services/CommunationServices/Hubs/ServicesHub.cs
similarity index 92%
rename from Birdmap.API/Services/Hubs/ServicesHub.cs
rename to Birdmap.BLL/Services/CommunationServices/Hubs/ServicesHub.cs
index 17f3ae2..c4881ec 100644
--- a/Birdmap.API/Services/Hubs/ServicesHub.cs
+++ b/Birdmap.BLL/Services/CommunationServices/Hubs/ServicesHub.cs
@@ -3,7 +3,7 @@ using Microsoft.Extensions.Logging;
using System;
using System.Threading.Tasks;
-namespace Birdmap.API.Services.Hubs
+namespace Birdmap.BLL.Services.CommunicationServices.Hubs
{
public class ServicesHub : Hub
{
diff --git a/Birdmap.API/Services/Mqtt/MqttClientService.cs b/Birdmap.BLL/Services/CommunationServices/Mqtt/MqttClientService.cs
similarity index 97%
rename from Birdmap.API/Services/Mqtt/MqttClientService.cs
rename to Birdmap.BLL/Services/CommunationServices/Mqtt/MqttClientService.cs
index 5acb8f2..6143bde 100644
--- a/Birdmap.API/Services/Mqtt/MqttClientService.cs
+++ b/Birdmap.BLL/Services/CommunationServices/Mqtt/MqttClientService.cs
@@ -1,5 +1,5 @@
-using Birdmap.API.Services.Hubs;
-using Birdmap.BLL.Interfaces;
+using Birdmap.BLL.Interfaces;
+using Birdmap.BLL.Services.CommunicationServices.Hubs;
using Microsoft.AspNetCore.SignalR;
using Microsoft.Extensions.Logging;
using MQTTnet;
@@ -15,7 +15,7 @@ using System.Threading;
using System.Threading.Tasks;
using Timer = System.Timers.Timer;
-namespace Birdmap.API.Services.Mqtt
+namespace Birdmap.BLL.Services.CommunicationServices.Mqtt
{
public class MqttClientService : IMqttClientService
{
diff --git a/Birdmap.API/Services/Mqtt/MqttClientServiceProvider.cs b/Birdmap.BLL/Services/CommunationServices/Mqtt/MqttClientServiceProvider.cs
similarity index 74%
rename from Birdmap.API/Services/Mqtt/MqttClientServiceProvider.cs
rename to Birdmap.BLL/Services/CommunationServices/Mqtt/MqttClientServiceProvider.cs
index a1f9aea..f6288ad 100644
--- a/Birdmap.API/Services/Mqtt/MqttClientServiceProvider.cs
+++ b/Birdmap.BLL/Services/CommunationServices/Mqtt/MqttClientServiceProvider.cs
@@ -1,4 +1,6 @@
-namespace Birdmap.API.Services.Mqtt
+using Birdmap.BLL.Interfaces;
+
+namespace Birdmap.BLL.Services.CommunicationServices.Mqtt
{
public class MqttClientServiceProvider
{
diff --git a/Birdmap.BLL/Startup.cs b/Birdmap.BLL/Startup.cs
index 2544875..4df6d2a 100644
--- a/Birdmap.BLL/Startup.cs
+++ b/Birdmap.BLL/Startup.cs
@@ -1,7 +1,11 @@
using Birdmap.BLL.Interfaces;
+using Birdmap.BLL.Options;
using Birdmap.BLL.Services;
+using Birdmap.BLL.Services.CommunicationServices.Mqtt;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Hosting;
+using System;
using System.Net.Http;
namespace Birdmap.BLL
@@ -37,6 +41,57 @@ namespace Birdmap.BLL
});
}
+ services.AddSignalR();
+
+ services.AddMqttClientServiceWithConfig(opt =>
+ {
+ var mqtt = configuration.GetSection("Mqtt");
+
+ var mqttClient = mqtt.GetSection("ClientSettings");
+ var clientSettings = new
+ {
+ Id = mqttClient.GetValue("Id"),
+ Username = mqttClient.GetValue("Username"),
+ Password = mqttClient.GetValue("Password"),
+ Topic = mqttClient.GetValue("Topic"),
+ };
+
+ var mqttBrokerHost = mqtt.GetSection("BrokerHostSettings");
+ var brokerHostSettings = new
+ {
+ Host = mqttBrokerHost.GetValue("Host"),
+ Port = mqttBrokerHost.GetValue("Port"),
+ };
+
+ opt
+ .WithTopic(clientSettings.Topic)
+ .WithCredentials(clientSettings.Username, clientSettings.Password)
+ .WithClientId(clientSettings.Id)
+ .WithTcpServer(brokerHostSettings.Host, brokerHostSettings.Port);
+ });
+
+ return services;
+ }
+
+ private static IServiceCollection AddMqttClientServiceWithConfig(this IServiceCollection services, Action configureOptions)
+ {
+ services.AddSingleton(serviceProvider =>
+ {
+ var optionBuilder = new AspCoreMqttClientOptions(serviceProvider);
+ configureOptions(optionBuilder);
+ return optionBuilder.Build();
+ });
+ services.AddSingleton();
+ services.AddSingleton(serviceProvider =>
+ {
+ return serviceProvider.GetService();
+ });
+ services.AddSingleton(serviceProvider =>
+ {
+ var mqttClientService = serviceProvider.GetService();
+ var mqttClientServiceProvider = new MqttClientServiceProvider(mqttClientService);
+ return mqttClientServiceProvider;
+ });
return services;
}
}
diff --git a/docs/thesis/content/birdmap-backend.tex b/docs/thesis/content/birdmap-backend.tex
index 48e9e30..da1b288 100644
--- a/docs/thesis/content/birdmap-backend.tex
+++ b/docs/thesis/content/birdmap-backend.tex
@@ -138,12 +138,12 @@ Egy másik megoldás a SignalR használata, amellyel a klienseket eseményvezér
Így a kliensek csak akkor indítanak kéréseket amikor az adat tényleg változott. Ezzel a technológiával oldottam meg például, hogy az eszközök állapotainak változására
frissüljön a felület.
-Egy másik szolgáltatás a Birdnetes MQTT kommunikációért felelős szolgáltatás,
+Egy másik szerveroldalon használt szolgáltatás a Birdnetes MQTT kommunikációért felelős szolgáltatás,
mely felregisztrál a \ref{subsect:birdnetes-ai-service}-as alfejezetben bemutatott AI Service által publikált üzenetekre.
Ezekben az üzenetekben található a hanganyagok egyedi azonosítója, illetve azok seregélytől való származásának valószínüsége.
Ha a szolgáltatás kap egy ilyen üzenetet akkor lekérdezi a \ref{subsect:birdnetes-input-service}-es alfejezetben bemutatott Input Service-től
a hanganyag azonosítójához tartozó metaadatokat.
-Ezekből felhasználva a kihelyezett eszköz azonosítóját, a hanganyag beérkezésének dátumát és az említett valószínüséget új üzeneteket készítek, melyeket egy pufferben tárolok.
+Ezekből felhasználva a kihelyezett eszköz azonosítóját, a hanganyag beérkezésének dátumát és az említett valószínüséget új üzenetek készülnek, melyeket egy pufferben tárolódnak.
Ezt a folyamatot a \ref{fig:birdmap-mqtt-service}-es ábra szemlélteti.
\begin{figure}[!ht]
@@ -163,7 +163,7 @@ Míg a szerver képes is az üzeneteket feldolgozni, ha ezeket rögtön tovább
A kontrollerek határozzák meg, hogy a szerveroldalon milyen végpontokat, milyen paraméterekkel lehet meghívni, ahhoz milyen jogosultságok kellenek.
A jogosultságok kezelését a JSON Web Token-ekkel oldottam meg. A fejlasználó bejelentkezéskor kap egy ilyen token-t,
amelyben tárolom a hozzá tartozó szerepet. A \ref{lst:devices-controller}-as listában látszik, hogy hogyan használom ezeket a szerepeket.
-A kontroller végpontjait alapértelmezetten \verb+User+ és \verb+Admin+ jogosultságú felhasználó hívhatja, az online végpontot azonban csak \verb+Admin+ jogosultságú.
+A \verb+DevicesController+ végpontjait alapértelmezetten \verb+User+ és \verb+Admin+ jogosultságú felhasználó hívhatja, az "online" végpontot azonban csak \verb+Admin+ jogosultságú.
Hasonló képpen oldottam meg ezt a többi kontrollernél is. A \verb+User+ felhasználók csak olyan végpontokat hívhat, mely kizárolag az állapotok olvasásával jár.
Az \verb+Admin+ felhasználók hívhatnak bármilyen végpontot.
diff --git a/docs/thesis/thesis.pdf b/docs/thesis/thesis.pdf
index fc71468..249b6c0 100644
--- a/docs/thesis/thesis.pdf
+++ b/docs/thesis/thesis.pdf
@@ -5866,15 +5866,11 @@ endobj
/Filter /FlateDecode
>>
stream
-xڍWnF+x íIAd}ж![̯Om\$q@HV]jiοz;ya9*(:/w^SaJWZ
-اmO_kѿt(ryzuB?GE*/Vh([z
ùR^K E.]VGɮ̴j}ƥU߸l)'R!j-&]NUm
-:/Kr̐ZZmywұ|g&C(sSwMy%^WmUv#@
--hn1r$,Utu&s(eM/
-S~ykD:?CHBk=UY/
$^ֆC^[gVe>Бu#!v5ӻhBP9kwPB A~t#m
-pهIpr+Y8cպ9R&8hLӕ)Kr)!Ļ
>25553b(&l}*.9k Ml`Z(PǹiykcqH/ut0D ǔ*?K1
\Nۦ6CcIyAcݐ3BJ0@6Wf;džfz|^DrX:mԨ\`uNNw}&.`\6)MN(XB:;amp
-g*R\PCeoOO,7A+ֲEIܚ\NHf 5Y%a{}o}7yՒѝdzc) H/N@cE0#Գ0QN x;?itxH$*)fX jj7&9X:$ȏ3=aE% h,A&Hi%A<5VY
;Ӛ2Q}X=X
&tSqn\2#R5W4~4Ryibs@.fr*y)֬ӕf*xȿ#
)PH^#.|*N=c@B: AVaj=bM$ʇ,; .X9̭yȏ(2WT^DG[Iot*ŭZ5A6Tʾ=SL"&~4ƫ[yB,t2WU2
O1#XYj%hb]H NvQd a?(=ڦlpDCohN]!+#qMn,
Sy
Kܲ`ގ5nb#*:7vm2_*LaUS9-h^ DFGuR;VF!Z<ϥ$qleԼN%y]@I^c@Ǡ
-OQ?>Cw բqS>N<4ms}8W^ZSc$LpWt[(ޖS*(
ӏp[MYh:@izr]pCPl3Ιg&L{F:-Erŷڈ\l
j=F& `_\Ae;co0+tÈ$M+GAr@@-NkY <ɏxK
-4I_}b
Y/WB!oR=cB/BS)o
"$ҁ֙P_}D$JaJK*CT8R?}Sފ_LO?k0؆[?zQKBdH8x$Pj3t V$ 6
=77Uiok$?(Mێmi\YgQ;S*&I*ɂ$ctlxΘNl"V~[85ET7Uǧ+
+5+7uE~Y`*&<{|w:I@lMu@Ȩ} n6=m2H;*P/R~bht+8dS"
gxe֭n4TmM6C^;B+1[dH}~jPgj4gz슾8;}Hp[