diff --git a/NB-Iot/README.md b/NB-Iot/README.md
index b952478..dbbb5eb 100644
--- a/NB-Iot/README.md
+++ b/NB-Iot/README.md
@@ -6,6 +6,65 @@
[中国电信官方JT/T808协议规范参考文档](https://help.ctwing.cn/%E8%AE%BE%E5%A4%87%E6%8E%A5%E5%85%A5%E8%A7%84%E8%8C%83/jtt808%E5%8D%8F%E8%AE%AE%E6%8E%A5%E5%85%A5/jtt808%E5%8D%8F%E8%AE%AE%E8%A7%84%E8%8C%83.html)
-注意事项:
+## 使用教程
-todo:
+> 前提条件:需要注册和实名登记之后才可以使用电信平台
+
+1.开通终端接入和MQ消息推送服务
+
+2.再设备管理->产品,创建对应的JT/T808产品,如图所示
+
+
+
+3.再对应的产品中按图所示进行点击进入设备添加列表
+
+
+
+
+
+4.再MQ消息推送里面创建对应的Topic,如图所示
+
+
+
+> 注意:由于电信平台只提供java版本的sdk,这边需要去下载对应的语言包的sdk[中国电信使用的MQ开源库](http://pulsar.apache.org/docs/en/client-libraries-dotnet/#installation)
+
+5.模拟设备上电信平台
+
+需要注意几项:
+
+5.1.这边设备模拟的是2013版本的808协议,平台给的参考是2019版本,但是例子里面确是2013版本的;
+
+5.2.模拟的终端注册的关键三个参数,制造商编号、设备型号、设备编号这三个参数很重要,很重要,很重要。
+
+6.设备与消息进行调试如图所示
+
+
+
+
+
+7.使用JT808.Gateway.NBIotSimpleClient项目进行模拟测试
+
+需要修改一下参数配置:
+
+7.1.Jobs目录下面的Up2013Service文件
+
+```1
+MakerId = "12345", //制造商编号
+TerminalModel = "123456", //设备型号
+TerminalId = "1234567", //设备编号
+```
+
+7.2.Services目录下面的AEPMsgConsumerService文件
+
+```2
+//自己填写电信平台配置的参数
+ string topic = "test";
+//自己填写电信平台配置的参数
+string tenantId = "";
+//自己填写电信平台配置的参数
+string token = "";
+```
+
+7.3.以上配置好就可以运行看效果了
+
+> 要是不成功的话,那多半以上没有配置好,导致的。
diff --git a/NB-Iot/img/debug1.png b/NB-Iot/img/debug1.png
new file mode 100644
index 0000000..41516e6
Binary files /dev/null and b/NB-Iot/img/debug1.png differ
diff --git a/NB-Iot/img/debug2.png b/NB-Iot/img/debug2.png
new file mode 100644
index 0000000..3b620e3
Binary files /dev/null and b/NB-Iot/img/debug2.png differ
diff --git a/NB-Iot/img/device1.png b/NB-Iot/img/device1.png
new file mode 100644
index 0000000..65b9258
Binary files /dev/null and b/NB-Iot/img/device1.png differ
diff --git a/NB-Iot/img/device2.png b/NB-Iot/img/device2.png
new file mode 100644
index 0000000..bca28f2
Binary files /dev/null and b/NB-Iot/img/device2.png differ
diff --git a/NB-Iot/img/mq.png b/NB-Iot/img/mq.png
new file mode 100644
index 0000000..d7e6158
Binary files /dev/null and b/NB-Iot/img/mq.png differ
diff --git a/NB-Iot/img/product.png b/NB-Iot/img/product.png
new file mode 100644
index 0000000..09ced9b
Binary files /dev/null and b/NB-Iot/img/product.png differ
diff --git a/simples/JT808.DotNetty.SimpleClient/JT808.DotNetty.SimpleClient.csproj b/simples/JT808.DotNetty.SimpleClient/JT808.DotNetty.SimpleClient.csproj
index 96c1695..f7fbdb1 100644
--- a/simples/JT808.DotNetty.SimpleClient/JT808.DotNetty.SimpleClient.csproj
+++ b/simples/JT808.DotNetty.SimpleClient/JT808.DotNetty.SimpleClient.csproj
@@ -6,12 +6,11 @@
7.3
-
-
+
diff --git a/simples/JT808.DotNetty.SimpleQueueServer/JT808.DotNetty.SimpleQueueServer.csproj b/simples/JT808.DotNetty.SimpleQueueServer/JT808.DotNetty.SimpleQueueServer.csproj
index b1c84a3..5a2d2e6 100644
--- a/simples/JT808.DotNetty.SimpleQueueServer/JT808.DotNetty.SimpleQueueServer.csproj
+++ b/simples/JT808.DotNetty.SimpleQueueServer/JT808.DotNetty.SimpleQueueServer.csproj
@@ -11,12 +11,11 @@
-
-
+
diff --git a/simples/JT808.DotNetty.SimpleQueueService/JT808.DotNetty.SimpleQueueService.csproj b/simples/JT808.DotNetty.SimpleQueueService/JT808.DotNetty.SimpleQueueService.csproj
index 0e412af..b647c44 100644
--- a/simples/JT808.DotNetty.SimpleQueueService/JT808.DotNetty.SimpleQueueService.csproj
+++ b/simples/JT808.DotNetty.SimpleQueueService/JT808.DotNetty.SimpleQueueService.csproj
@@ -11,14 +11,11 @@
-
-
-
-
+
diff --git a/simples/JT808.DotNetty.SimpleServer/JT808.DotNetty.SimpleServer.csproj b/simples/JT808.DotNetty.SimpleServer/JT808.DotNetty.SimpleServer.csproj
index 3707cd4..2918d80 100644
--- a/simples/JT808.DotNetty.SimpleServer/JT808.DotNetty.SimpleServer.csproj
+++ b/simples/JT808.DotNetty.SimpleServer/JT808.DotNetty.SimpleServer.csproj
@@ -6,7 +6,6 @@
7.3
-
@@ -18,5 +17,5 @@
Always
-
+
diff --git a/simples/JT808.Gateway.NBIotSimpleClient/JT808.Gateway.NBIotSimpleClient.csproj b/simples/JT808.Gateway.NBIotSimpleClient/JT808.Gateway.NBIotSimpleClient.csproj
index 749ffd1..e3bcb61 100644
--- a/simples/JT808.Gateway.NBIotSimpleClient/JT808.Gateway.NBIotSimpleClient.csproj
+++ b/simples/JT808.Gateway.NBIotSimpleClient/JT808.Gateway.NBIotSimpleClient.csproj
@@ -5,12 +5,11 @@
net5.0
-
-
-
+
+
diff --git a/simples/JT808.Gateway.NBIotSimpleClient/Jobs/Up2019Service.cs b/simples/JT808.Gateway.NBIotSimpleClient/Jobs/Up2013Service.cs
similarity index 94%
rename from simples/JT808.Gateway.NBIotSimpleClient/Jobs/Up2019Service.cs
rename to simples/JT808.Gateway.NBIotSimpleClient/Jobs/Up2013Service.cs
index ba8ad5e..f42fad2 100644
--- a/simples/JT808.Gateway.NBIotSimpleClient/Jobs/Up2019Service.cs
+++ b/simples/JT808.Gateway.NBIotSimpleClient/Jobs/Up2013Service.cs
@@ -14,12 +14,12 @@ using JT808.Gateway.NBIotSimpleClient.Services;
namespace JT808.Gateway.NBIotSimpleClient.Jobs
{
- public class Up2019Service : IHostedService
+ public class Up2013Service : IHostedService
{
IJT808TcpClientFactory jT808TcpClientFactory;
JT808Serializer Serializer;
DeviceInfoService DeviceInfoService;
- public Up2019Service(
+ public Up2013Service(
DeviceInfoService deviceInfoService,
IJT808Config jT808Config,
IJT808TcpClientFactory jT808TcpClientFactory)
@@ -40,9 +40,9 @@ namespace JT808.Gateway.NBIotSimpleClient.Jobs
PlateNo = "粤A12346",
PlateColor = 0,
AreaID = 0,
- CityOrCountyId = 0,
- MakerId = "12345",
- TerminalModel = "123456".PadRight(20,'\0'), //设备型号
+ CityOrCountyId = 0,
+ MakerId = "12345", //制造商编号
+ TerminalModel = "123456", //设备型号
TerminalId = "1234567", //设备编号
});
var p1_1 = Serializer.Serialize(p1).ToHexString();
diff --git a/simples/JT808.Gateway.NBIotSimpleClient/Program.cs b/simples/JT808.Gateway.NBIotSimpleClient/Program.cs
index 9740eec..5a963cb 100644
--- a/simples/JT808.Gateway.NBIotSimpleClient/Program.cs
+++ b/simples/JT808.Gateway.NBIotSimpleClient/Program.cs
@@ -31,8 +31,9 @@ namespace JT808.Gateway.NBIotSimpleClient
services.AddJT808Configure()
.AddClient()
.AddMessageProducer();
- services.AddHostedService();
- services.AddHostedService();
+ services.AddHostedService()
+ .AddHostedService()
+ .AddHostedService();
});
await serverHostBuilder.RunConsoleAsync();
}
diff --git a/simples/JT808.Gateway.NBIotSimpleClient/Services/AEPMsgConsumerService.cs b/simples/JT808.Gateway.NBIotSimpleClient/Services/AEPMsgConsumerService.cs
new file mode 100644
index 0000000..8c9169e
--- /dev/null
+++ b/simples/JT808.Gateway.NBIotSimpleClient/Services/AEPMsgConsumerService.cs
@@ -0,0 +1,62 @@
+using DotPulsar;
+using DotPulsar.Abstractions;
+using DotPulsar.Extensions;
+using Microsoft.Extensions.Hosting;
+using Microsoft.Extensions.Logging;
+using System;
+using System.Buffers;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace JT808.Gateway.NBIotSimpleClient.Services
+{
+ public class AEPMsgConsumerService : IHostedService
+ {
+ ILogger Logger;
+
+ const string pulsarMqTenant = "aep-msgpush";
+
+ IConsumer> pulsarConsumer;
+
+ public AEPMsgConsumerService(ILoggerFactory loggerFactory)
+ {
+ Logger = loggerFactory.CreateLogger();
+ //自己填写
+ string topic = "test";
+ //自己填写
+ string tenantId = "";
+ //自己填写
+ string token = "";
+ var pulsarClient = PulsarClient.Builder().ServiceUrl(new Uri($"pulsar+ssl://msgpush.ctwing.cn:16651"))
+ .AuthenticateUsingToken(token)
+ .Build();
+ pulsarConsumer = pulsarClient.NewConsumer()
+ .SubscriptionName(tenantId)
+ .Topic($"{pulsarMqTenant}/{tenantId}/{topic}")
+ .InitialPosition(SubscriptionInitialPosition.Earliest)
+ .SubscriptionType(SubscriptionType.Shared)
+ .Create();
+ }
+
+ public Task StartAsync(CancellationToken cancellationToken)
+ {
+ Task.Run(async() =>
+ {
+ await foreach (var message in pulsarConsumer.Messages(cancellationToken))
+ {
+ Logger.LogDebug("Received: " + Encoding.UTF8.GetString(message.Data.ToArray()));
+ }
+ });
+ return Task.CompletedTask;
+ }
+
+ public Task StopAsync(CancellationToken cancellationToken)
+ {
+ pulsarConsumer.Unsubscribe();
+ return Task.CompletedTask;
+ }
+ }
+}
diff --git a/simples/JT808.Gateway.SimpleClient/JT808.Gateway.SimpleClient.csproj b/simples/JT808.Gateway.SimpleClient/JT808.Gateway.SimpleClient.csproj
index 0e94e69..6d5d65d 100644
--- a/simples/JT808.Gateway.SimpleClient/JT808.Gateway.SimpleClient.csproj
+++ b/simples/JT808.Gateway.SimpleClient/JT808.Gateway.SimpleClient.csproj
@@ -6,12 +6,10 @@
-
-
-
+
diff --git a/simples/JT808.Gateway.SimpleQueueNotification/Impl/JT808MsgIdHandlerImpl.cs b/simples/JT808.Gateway.SimpleQueueNotification/Impl/JT808MsgIdHandlerImpl.cs
index 27ffba3..d30a0cd 100644
--- a/simples/JT808.Gateway.SimpleQueueNotification/Impl/JT808MsgIdHandlerImpl.cs
+++ b/simples/JT808.Gateway.SimpleQueueNotification/Impl/JT808MsgIdHandlerImpl.cs
@@ -1,4 +1,5 @@
-using JT808.Gateway.MsgIdHandler;
+using JT808.Gateway.Abstractions;
+using JT808.Gateway.MsgIdHandler;
using JT808.Gateway.SimpleQueueNotification.Hubs;
using JT808.Protocol.Extensions;
using Microsoft.AspNetCore.SignalR;
@@ -11,8 +12,7 @@ using System.Threading.Tasks;
namespace JT808.Gateway.SimpleQueueNotification.Impl
{
- //todo: public class JT808MsgIdHandlerImpl : IJT808MsgIdHandler
- public class JT808MsgIdHandlerImpl
+ public class JT808MsgIdHandlerImpl: IJT808UpMessageHandler
{
private readonly ILogger logger;
@@ -26,15 +26,16 @@ namespace JT808.Gateway.SimpleQueueNotification.Impl
this._hubContext = hubContext;
logger = loggerFactory.CreateLogger();
}
- public void Processor((string TerminalNo, byte[] Data) parameter)
+
+ public void Processor(string TerminalNo, byte[] Data)
{
try
{
if (logger.IsEnabled(LogLevel.Trace))
{
- logger.LogTrace($"{parameter.TerminalNo}-{parameter.Data.ToHexString()}");
+ logger.LogTrace($"{TerminalNo}-{Data.ToHexString()}");
}
- _hubContext.Clients.All.SendAsync("ReceiveMessage", parameter.TerminalNo, parameter.Data.ToHexString());
+ _hubContext.Clients.All.SendAsync("ReceiveMessage", TerminalNo, Data.ToHexString());
}
catch (Exception ex)
{
diff --git a/simples/JT808.Gateway.SimpleQueueNotification/JT808.Gateway.SimpleQueueNotification.csproj b/simples/JT808.Gateway.SimpleQueueNotification/JT808.Gateway.SimpleQueueNotification.csproj
index cfe7bf7..b2bcb50 100644
--- a/simples/JT808.Gateway.SimpleQueueNotification/JT808.Gateway.SimpleQueueNotification.csproj
+++ b/simples/JT808.Gateway.SimpleQueueNotification/JT808.Gateway.SimpleQueueNotification.csproj
@@ -26,8 +26,5 @@
-
-
-
-
+
diff --git a/simples/JT808.Gateway.SimpleQueueNotification/Startup.cs b/simples/JT808.Gateway.SimpleQueueNotification/Startup.cs
index e052af6..e39f8e1 100644
--- a/simples/JT808.Gateway.SimpleQueueNotification/Startup.cs
+++ b/simples/JT808.Gateway.SimpleQueueNotification/Startup.cs
@@ -57,9 +57,8 @@ namespace JT808.Gateway.SimpleQueueNotification
services.Configure(Configuration.GetSection("AuthOptions"));
services.AddJT808Configure()
.AddClientKafka()
- .AddMsgConsumer(Configuration);
- //todo:JT808MsgIdHandlerImpl
- //.AddMsgIdHandler();
+ .AddMsgConsumer(Configuration)
+ .AddMsgIdHandler();
}
diff --git a/simples/JT808.Gateway.SimpleQueueServer/JT808.Gateway.SimpleQueueServer.csproj b/simples/JT808.Gateway.SimpleQueueServer/JT808.Gateway.SimpleQueueServer.csproj
index 185a13c..f4db71e 100644
--- a/simples/JT808.Gateway.SimpleQueueServer/JT808.Gateway.SimpleQueueServer.csproj
+++ b/simples/JT808.Gateway.SimpleQueueServer/JT808.Gateway.SimpleQueueServer.csproj
@@ -6,14 +6,12 @@
-
-
-
+
Always
diff --git a/simples/JT808.Gateway.SimpleQueueService/Impl/JT808QueueReplyMessageHandlerImpl.cs b/simples/JT808.Gateway.SimpleQueueService/Impl/JT808QueueReplyMessageHandlerImpl.cs
index 3ffa5d8..9a0101b 100644
--- a/simples/JT808.Gateway.SimpleQueueService/Impl/JT808QueueReplyMessageHandlerImpl.cs
+++ b/simples/JT808.Gateway.SimpleQueueService/Impl/JT808QueueReplyMessageHandlerImpl.cs
@@ -10,9 +10,7 @@ using System.Text;
namespace JT808.Gateway.SimpleQueueService.Impl
{
- //todo:
- //public class JT808QueueReplyMessageHandlerImpl : IJT808ReplyMessageHandler
- public class JT808QueueReplyMessageHandlerImpl
+ public class JT808QueueReplyMessageHandlerImpl: IJT808DownMessageHandler
{
private ILogger logger;
diff --git a/simples/JT808.Gateway.SimpleQueueService/JT808.Gateway.SimpleQueueService.csproj b/simples/JT808.Gateway.SimpleQueueService/JT808.Gateway.SimpleQueueService.csproj
index 8e4cbde..29a3d48 100644
--- a/simples/JT808.Gateway.SimpleQueueService/JT808.Gateway.SimpleQueueService.csproj
+++ b/simples/JT808.Gateway.SimpleQueueService/JT808.Gateway.SimpleQueueService.csproj
@@ -6,20 +6,12 @@
-
-
-
-
-
-
-
-
-
+
Always
diff --git a/simples/JT808.Gateway.SimpleQueueService/Program.cs b/simples/JT808.Gateway.SimpleQueueService/Program.cs
index a867e98..add3c80 100644
--- a/simples/JT808.Gateway.SimpleQueueService/Program.cs
+++ b/simples/JT808.Gateway.SimpleQueueService/Program.cs
@@ -33,8 +33,7 @@ namespace JT808.Gateway.SimpleQueueService
.AddMsgConsumer(hostContext.Configuration)
.AddMsgReplyProducer(hostContext.Configuration)
.AddSessionConsumer(hostContext.Configuration)
- //todo:JT808QueueReplyMessageHandlerImpl
- //.AddReplyMessage()
+ .AddReplyMessage()
.AddSessionNotice();
});
diff --git a/simples/JT808.Gateway.SimpleServer/JT808.Gateway.SimpleServer.csproj b/simples/JT808.Gateway.SimpleServer/JT808.Gateway.SimpleServer.csproj
index 5d37bd9..cc65e51 100644
--- a/simples/JT808.Gateway.SimpleServer/JT808.Gateway.SimpleServer.csproj
+++ b/simples/JT808.Gateway.SimpleServer/JT808.Gateway.SimpleServer.csproj
@@ -5,16 +5,12 @@
net5.0
-
-
-
-
-
+
Always
diff --git a/simples/README.md b/simples/README.md
new file mode 100644
index 0000000..1cefbeb
--- /dev/null
+++ b/simples/README.md
@@ -0,0 +1,5 @@
+# JT808.Simples
+
+1.先在当前目录,命令行窗口中执行dotnet build或者直接双击build.bat进行编译
+
+2.再打开对应的解决方案
diff --git a/simples/build.bat b/simples/build.bat
new file mode 100644
index 0000000..b718b37
--- /dev/null
+++ b/simples/build.bat
@@ -0,0 +1,3 @@
+dotnet build
+
+pause
\ No newline at end of file
diff --git a/simples/netty.props b/simples/netty.props
new file mode 100644
index 0000000..93803a2
--- /dev/null
+++ b/simples/netty.props
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/simples/pipeline.props b/simples/pipeline.props
new file mode 100644
index 0000000..52758ec
--- /dev/null
+++ b/simples/pipeline.props
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/JT808.DotNetty.Abstractions/JT808.DotNetty.Abstractions.csproj b/src/JT808.DotNetty.Abstractions/JT808.DotNetty.Abstractions.csproj
index 0317431..cc4e3f5 100644
--- a/src/JT808.DotNetty.Abstractions/JT808.DotNetty.Abstractions.csproj
+++ b/src/JT808.DotNetty.Abstractions/JT808.DotNetty.Abstractions.csproj
@@ -20,7 +20,7 @@
基于DotNetty实现的JT808DotNetty的抽象库
-
+
diff --git a/src/JT808.DotNetty.Client/JT808.DotNetty.Client.csproj b/src/JT808.DotNetty.Client/JT808.DotNetty.Client.csproj
index a0b2f45..8a1dbc9 100644
--- a/src/JT808.DotNetty.Client/JT808.DotNetty.Client.csproj
+++ b/src/JT808.DotNetty.Client/JT808.DotNetty.Client.csproj
@@ -24,7 +24,7 @@
-
+
diff --git a/src/JT808.Gateway.Abstractions/JT808.Gateway.Abstractions.csproj b/src/JT808.Gateway.Abstractions/JT808.Gateway.Abstractions.csproj
index 61e502c..faca108 100644
--- a/src/JT808.Gateway.Abstractions/JT808.Gateway.Abstractions.csproj
+++ b/src/JT808.Gateway.Abstractions/JT808.Gateway.Abstractions.csproj
@@ -28,7 +28,7 @@
-
+
diff --git a/src/JT808.Gateway.Client/JT808.Gateway.Client.csproj b/src/JT808.Gateway.Client/JT808.Gateway.Client.csproj
index 6ebadc5..631d078 100644
--- a/src/JT808.Gateway.Client/JT808.Gateway.Client.csproj
+++ b/src/JT808.Gateway.Client/JT808.Gateway.Client.csproj
@@ -23,7 +23,7 @@
-
+