@@ -8,9 +8,14 @@ | |||||
## JT809终端通讯协议消息对照表 | ## JT809终端通讯协议消息对照表 | ||||
|序号|消息体名称|消息ID|完成情况| | |||||
|序号|消息ID|完成情况|消息体名称| | |||||
|:------:|:------:|:------:|:------:| | |:------:|:------:|:------:|:------:| | ||||
| 1 | 主链路登录请求消息 | 0x1001 | √ | | |||||
| 2 | 主链路登录应答消息 | 0x1002 | √ | | |||||
| 3 | 主链路注销请求消息 | 0x1003 | √ | | |||||
| 4 | 主链路注销应答消息 | 0x1004 | √ | | |||||
| 1 | 0x1001 | √ | 主链路登录请求消息 | | |||||
| 2 | 0x1002 | √ | 主链路登录应答消息 | | |||||
| 3 | 0x1003 | √ | 主链路注销请求消息 | | |||||
| 4 | 0x1004 | √ | 主链路注销应答消息 | | |||||
| 5 | 0x1005 | √ | 主链路连接保持请求消息 | | |||||
| 6 | 0x1006 | √ | 主链路连接保持应答消息 | | |||||
| 7 | 0x1007 | √ | 主链路断开通知消息 | | |||||
@@ -0,0 +1,30 @@ | |||||
using JT809.Protocol; | |||||
using JT809.Protocol.JT809Extensions; | |||||
using JT809.Protocol.JT809MessageBody; | |||||
using JT809.Protocol.JT809Exceptions; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
using Xunit; | |||||
namespace JT809.Protocol.Test.JT809MessageBody | |||||
{ | |||||
public class JT809_0x1007Test | |||||
{ | |||||
[Fact] | |||||
public void Test1() | |||||
{ | |||||
JT809_0x1007 jT809_0X1007 = new JT809_0x1007(); | |||||
jT809_0X1007.ErrorCode = JT809Enums.JT809_0x1007_ErrorCode.主链路断开; | |||||
var hex = JT809Serializer.Serialize(jT809_0X1007).ToHexString(); | |||||
} | |||||
[Fact] | |||||
public void Test2() | |||||
{ | |||||
var bytes = "00".ToHexBytes(); | |||||
JT809_0x1007 jT809_0X1007 = JT809Serializer.Deserialize<JT809_0x1007>(bytes); | |||||
Assert.Equal(JT809Enums.JT809_0x1007_ErrorCode.主链路断开, jT809_0X1007.ErrorCode); | |||||
} | |||||
} | |||||
} |
@@ -38,6 +38,7 @@ | |||||
<Compile Include="JT809Enums\JT809BusinessType.cs" /> | <Compile Include="JT809Enums\JT809BusinessType.cs" /> | ||||
<Compile Include="JT809Enums\JT809SubBusinessType.cs" /> | <Compile Include="JT809Enums\JT809SubBusinessType.cs" /> | ||||
<Compile Include="JT809Enums\JT809_0x1002_Result.cs" /> | <Compile Include="JT809Enums\JT809_0x1002_Result.cs" /> | ||||
<Compile Include="JT809Enums\JT809_0x1007_ErrorCode.cs" /> | |||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
@@ -41,16 +41,19 @@ namespace JT809.Protocol.JT809Enums | |||||
///主链路连接保持请求消息 | ///主链路连接保持请求消息 | ||||
///</summary> | ///</summary> | ||||
[Description("主链路连接保持请求消息")] | [Description("主链路连接保持请求消息")] | ||||
[JT809BodiesType(typeof(JT809_0x1005))] | |||||
UP_LINKTEST_REQ = 0x1005, | UP_LINKTEST_REQ = 0x1005, | ||||
///<summary> | ///<summary> | ||||
///主链路连接保持应答消息 | ///主链路连接保持应答消息 | ||||
///</summary> | ///</summary> | ||||
[Description("主链路连接保持应答消息")] | [Description("主链路连接保持应答消息")] | ||||
[JT809BodiesType(typeof(JT809_0x1006))] | |||||
UP_LINKTEST_RSP = 0x1006, | UP_LINKTEST_RSP = 0x1006, | ||||
///<summary> | ///<summary> | ||||
///主链路断开通知消息 | ///主链路断开通知消息 | ||||
///</summary> | ///</summary> | ||||
[Description("主链路断开通知消息")] | [Description("主链路断开通知消息")] | ||||
[JT809BodiesType(typeof(JT809_0x1007))] | |||||
UP_DISCONNECT_INFORM = 0x1007, | UP_DISCONNECT_INFORM = 0x1007, | ||||
///<summary> | ///<summary> | ||||
///下级平台主动关闭链路通知消息 | ///下级平台主动关闭链路通知消息 | ||||
@@ -0,0 +1,15 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
namespace JT809.Protocol.JT809Enums | |||||
{ | |||||
/// <summary> | |||||
/// 错误代码 | |||||
/// </summary> | |||||
public enum JT809_0x1007_ErrorCode:byte | |||||
{ | |||||
主链路断开=0x00, | |||||
其他原因=0x01 | |||||
} | |||||
} |
@@ -0,0 +1,28 @@ | |||||
using JT809.Protocol.JT809Enums; | |||||
using JT809.Protocol.JT809Extensions; | |||||
using JT809.Protocol.JT809MessageBody; | |||||
using System; | |||||
using System.Buffers; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
namespace JT809.Protocol.JT809Formatters.JT809MessageBodyFormatters | |||||
{ | |||||
public class JT809_0x1007Formatter : IJT809Formatter<JT809_0x1007> | |||||
{ | |||||
public JT809_0x1007 Deserialize(ReadOnlySpan<byte> bytes, out int readSize) | |||||
{ | |||||
int offset = 0; | |||||
JT809_0x1007 jT809_0X1007 = new JT809_0x1007(); | |||||
jT809_0X1007.ErrorCode = (JT809_0x1007_ErrorCode)JT809BinaryExtensions.ReadByteLittle(bytes, ref offset); | |||||
readSize = offset; | |||||
return jT809_0X1007; | |||||
} | |||||
public int Serialize(IMemoryOwner<byte> memoryOwner, int offset, JT809_0x1007 value) | |||||
{ | |||||
offset += JT809BinaryExtensions.WriteByteLittle(memoryOwner, offset, (byte)value.ErrorCode); | |||||
return offset; | |||||
} | |||||
} | |||||
} |
@@ -12,7 +12,7 @@ namespace JT809.Protocol.JT809MessageBody | |||||
/// <para>链路类型:主链路</para> | /// <para>链路类型:主链路</para> | ||||
/// <para>消息方向:上级平台往下级平台</para> | /// <para>消息方向:上级平台往下级平台</para> | ||||
/// <para>业务数据类型标识:UP_CONNCCT_RSP</para> | /// <para>业务数据类型标识:UP_CONNCCT_RSP</para> | ||||
/// <para>上级平台对下级平台登录请求信息、进行安全验证后,返回相应的验证结果。</para> | |||||
/// <para>描述:上级平台对下级平台登录请求信息、进行安全验证后,返回相应的验证结果。</para> | |||||
/// </summary> | /// </summary> | ||||
[JT809Formatter(typeof(JT809_0x1002Formatter))] | [JT809Formatter(typeof(JT809_0x1002Formatter))] | ||||
public class JT809_0x1002 : JT809Bodies | public class JT809_0x1002 : JT809Bodies | ||||
@@ -0,0 +1,18 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
namespace JT809.Protocol.JT809MessageBody | |||||
{ | |||||
/// <summary> | |||||
/// 主链路连接保持请求消息 | |||||
/// <para>链路类型:主链路</para> | |||||
/// <para>消息方向:上级平台往下级平台</para> | |||||
/// <para>业务数据类型标识:UP_LINKTEST_RSP</para> | |||||
/// <para>描述:上级平台收到下级平台的主链路连接保持请求消息后,向下级平台返回.主链路连接保持应答消息,保持主链路的连接状态</para> | |||||
/// <para>主链路连接保持应答消息,数据体为空</para> | |||||
/// </summary> | |||||
public class JT809_0x1005:JT809Bodies | |||||
{ | |||||
} | |||||
} |
@@ -0,0 +1,19 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
namespace JT809.Protocol.JT809MessageBody | |||||
{ | |||||
/// <summary> | |||||
/// 主链路连接保持应答消息 | |||||
/// <para>链路类型:主链路</para> | |||||
/// <para>消息方向:上级平台往下级平台</para> | |||||
/// <para>业务数据类型标识:UP_LINKTEST_RSP。</para> | |||||
/// <para>描述:上级平台收到下级平台的主链路连接保持请求消息后,向下级平台返回.主链路连接保持应答消息,保持主链路的连接状态。</para> | |||||
/// <para>主链路连接保持应答消息,数据体为空。</para> | |||||
/// </summary> | |||||
public class JT809_0x1006:JT809Bodies | |||||
{ | |||||
} | |||||
} |
@@ -0,0 +1,27 @@ | |||||
using JT809.Protocol.JT809Attributes; | |||||
using JT809.Protocol.JT809Enums; | |||||
using JT809.Protocol.JT809Formatters.JT809MessageBodyFormatters; | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
namespace JT809.Protocol.JT809MessageBody | |||||
{ | |||||
/// <summary> | |||||
/// 主链路断开通知消息 | |||||
/// <para>链路类型:从链路</para> | |||||
/// <para>消息方向:下级平台往上级平台</para> | |||||
/// <para>业务数据类型标识:UP_DISCONNECT_INFORM</para> | |||||
/// <para>描述:'当主链路中断后,下级平台可通过从链路向上级平台发送本消息通知上级平台主链路中断</para> | |||||
/// <para>主链路连接保持应答消息,数据体为空</para> | |||||
/// <para>本条消息无需被通知方应答</para> | |||||
/// </summary> | |||||
[JT809Formatter(typeof(JT809_0x1007Formatter))] | |||||
public class JT809_0x1007:JT809Bodies | |||||
{ | |||||
/// <summary> | |||||
/// 错误代码 | |||||
/// </summary> | |||||
public JT809_0x1007_ErrorCode ErrorCode { get; set; } | |||||
} | |||||
} |