@@ -22,6 +22,10 @@ | |||||
| 10 | 0x9002 | √ | 从链路连接应答消息 | | | 10 | 0x9002 | √ | 从链路连接应答消息 | | ||||
| 11 | 0x9003 | √ | 从链路注销请求消息 | | | 11 | 0x9003 | √ | 从链路注销请求消息 | | ||||
| 12 | 0x9004 | √ | 从链路注销应答消息 | | | 12 | 0x9004 | √ | 从链路注销应答消息 | | ||||
| 13 | 0x9005 | √ | 从链路连接保持请求消息 | | |||||
| 14 | 0x9006 | √ | 从链路连接保持应答消息 | | |||||
| 15 | 0x9007 | √ | 从链路断开通知消息 | | |||||
| 16 | 0x9008 | √ | 上级平台主动关闭链路通知消息 | | |||||
@@ -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_0x9007Test | |||||
{ | |||||
[Fact] | |||||
public void Test1() | |||||
{ | |||||
JT809_0x9007 jT809_0X9007 = new JT809_0x9007(); | |||||
jT809_0X9007.ReasonCode = JT809Enums.JT809_0x9007_ReasonCode.无法连接下级平台指定的服务IP与端口; | |||||
var hex = JT809Serializer.Serialize(jT809_0X9007).ToHexString(); | |||||
} | |||||
[Fact] | |||||
public void Test2() | |||||
{ | |||||
var bytes = "00".ToHexBytes(); | |||||
JT809_0x9007 jT809_0X9007 = JT809Serializer.Deserialize<JT809_0x9007>(bytes); | |||||
Assert.Equal(JT809Enums.JT809_0x9007_ReasonCode.无法连接下级平台指定的服务IP与端口, jT809_0X9007.ReasonCode); | |||||
} | |||||
} | |||||
} |
@@ -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_0x9008Test | |||||
{ | |||||
[Fact] | |||||
public void Test1() | |||||
{ | |||||
JT809_0x9008 jT809_0X9008 = new JT809_0x9008(); | |||||
jT809_0X9008.ReasonCode = JT809Enums.JT809_0x9008_ReasonCode.其它原因; | |||||
var hex = JT809Serializer.Serialize(jT809_0X9008).ToHexString(); | |||||
} | |||||
[Fact] | |||||
public void Test2() | |||||
{ | |||||
var bytes = "01".ToHexBytes(); | |||||
JT809_0x9008 jT809_0X9008 = JT809Serializer.Deserialize<JT809_0x9008>(bytes); | |||||
Assert.Equal(JT809Enums.JT809_0x9008_ReasonCode.其它原因, jT809_0X9008.ReasonCode); | |||||
} | |||||
} | |||||
} |
@@ -39,8 +39,10 @@ | |||||
<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" /> | <Compile Include="JT809Enums\JT809_0x1007_ErrorCode.cs" /> | ||||
<Compile Include="JT809Enums\JT809_0x9007_ReasonCode.cs" /> | |||||
<Compile Include="JT809Enums\JT809_0x1008_ReasonCode.cs" /> | <Compile Include="JT809Enums\JT809_0x1008_ReasonCode.cs" /> | ||||
<Compile Include="JT809Enums\JT809_0x9002_Result.cs" /> | <Compile Include="JT809Enums\JT809_0x9002_Result.cs" /> | ||||
<Compile Include="JT809Enums\JT809_0x9008_ReasonCode.cs" /> | |||||
</ItemGroup> | </ItemGroup> | ||||
<ItemGroup> | <ItemGroup> | ||||
@@ -89,21 +89,25 @@ namespace JT809.Protocol.JT809Enums | |||||
///从链路连接保持请求消息 | ///从链路连接保持请求消息 | ||||
///</summary> | ///</summary> | ||||
[Description("从链路连接保持请求消息")] | [Description("从链路连接保持请求消息")] | ||||
[JT809BodiesType(typeof(JT809_0x9005))] | |||||
DOWN_LINKTEST_REQ = 0x9005, | DOWN_LINKTEST_REQ = 0x9005, | ||||
///<summary> | ///<summary> | ||||
///从链路连接保持应答消息 | ///从链路连接保持应答消息 | ||||
///</summary> | ///</summary> | ||||
[Description("从链路连接保持应答消息")] | [Description("从链路连接保持应答消息")] | ||||
[JT809BodiesType(typeof(JT809_0x9006))] | |||||
DOWN_LINKTEST_RSP = 0x9006, | DOWN_LINKTEST_RSP = 0x9006, | ||||
///<summary> | ///<summary> | ||||
///从链路断开通知消息 | ///从链路断开通知消息 | ||||
///</summary> | ///</summary> | ||||
[Description("从链路断开通知消息")] | [Description("从链路断开通知消息")] | ||||
[JT809BodiesType(typeof(JT809_0x9007))] | |||||
DOWN_DISCONNECT_INFORM = 0x9007, | DOWN_DISCONNECT_INFORM = 0x9007, | ||||
///<summary> | ///<summary> | ||||
///上级平台主动关闭链路通知消息 | ///上级平台主动关闭链路通知消息 | ||||
///</summary> | ///</summary> | ||||
[Description("上级平台主动关闭链路通知消息")] | [Description("上级平台主动关闭链路通知消息")] | ||||
[JT809BodiesType(typeof(JT809_0x9008))] | |||||
DOWN_CLOSELINK_INFORM = 0x9008, | DOWN_CLOSELINK_INFORM = 0x9008, | ||||
#endregion | #endregion | ||||
#region 信息统计类 | #region 信息统计类 | ||||
@@ -0,0 +1,16 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
namespace JT809.Protocol.JT809Enums | |||||
{ | |||||
/// <summary> | |||||
/// 错误代码 | |||||
/// </summary> | |||||
public enum JT809_0x9007_ReasonCode : byte | |||||
{ | |||||
无法连接下级平台指定的服务IP与端口 = 0x00, | |||||
级平台客户端与下级平台服务端断开 = 0x01, | |||||
其他原因=0x02 | |||||
} | |||||
} |
@@ -0,0 +1,15 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
namespace JT809.Protocol.JT809Enums | |||||
{ | |||||
/// <summary> | |||||
/// 错误代码 | |||||
/// </summary> | |||||
public enum JT809_0x9008_ReasonCode:byte | |||||
{ | |||||
网关重启=0x00, | |||||
其它原因=0x01 | |||||
} | |||||
} |
@@ -0,0 +1,27 @@ | |||||
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_0x9007Formatter : IJT809Formatter<JT809_0x9007> | |||||
{ | |||||
public JT809_0x9007 Deserialize(ReadOnlySpan<byte> bytes, out int readSize) | |||||
{ | |||||
int offset = 0; | |||||
JT809_0x9007 jT809_0X9007 = new JT809_0x9007(); | |||||
jT809_0X9007.ReasonCode = (JT809Enums.JT809_0x9007_ReasonCode)JT809BinaryExtensions.ReadByteLittle(bytes, ref offset); | |||||
readSize = offset; | |||||
return jT809_0X9007; | |||||
} | |||||
public int Serialize(IMemoryOwner<byte> memoryOwner, int offset, JT809_0x9007 value) | |||||
{ | |||||
offset += JT809BinaryExtensions.WriteByteLittle(memoryOwner, offset,(byte)value.ReasonCode); | |||||
return offset; | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,27 @@ | |||||
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_0x9008Formatter : IJT809Formatter<JT809_0x9008> | |||||
{ | |||||
public JT809_0x9008 Deserialize(ReadOnlySpan<byte> bytes, out int readSize) | |||||
{ | |||||
int offset = 0; | |||||
JT809_0x9008 jT809_0X9008 = new JT809_0x9008(); | |||||
jT809_0X9008.ReasonCode = (JT809Enums.JT809_0x9008_ReasonCode)JT809BinaryExtensions.ReadByteLittle(bytes, ref offset); | |||||
readSize = offset; | |||||
return jT809_0X9008; | |||||
} | |||||
public int Serialize(IMemoryOwner<byte> memoryOwner, int offset, JT809_0x9008 value) | |||||
{ | |||||
offset += JT809BinaryExtensions.WriteByteLittle(memoryOwner, offset, (byte)value.ReasonCode); | |||||
return offset; | |||||
} | |||||
} | |||||
} |
@@ -0,0 +1,19 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
namespace JT809.Protocol.JT809MessageBody | |||||
{ | |||||
/// <summary> | |||||
/// 从链路连接保持请求消息 | |||||
/// <para>链路类型:从链路</para> | |||||
/// <para>消息方向:上级平台往下级平台</para> | |||||
/// <para>业务数据类型标识:DOWN_LINKTEST_REQ</para> | |||||
/// <para>描述:从链路建立成功后,上级平台向下级平台发送从链路连接保持请求消息,以保持从链路的连接状态</para> | |||||
/// <para>从链路连接保持请求消息,数据体为空</para> | |||||
/// </summary> | |||||
public class JT809_0x9005:JT809Bodies | |||||
{ | |||||
} | |||||
} |
@@ -0,0 +1,18 @@ | |||||
using System; | |||||
using System.Collections.Generic; | |||||
using System.Text; | |||||
namespace JT809.Protocol.JT809MessageBody | |||||
{ | |||||
/// <summary> | |||||
/// 从链路连接保持应答消息 | |||||
/// <para>链路类型:从链路</para> | |||||
/// <para>消息方向:上级平台往下级平台</para> | |||||
/// <para>业务数据类型标识:DOWN_LINKTEST_REP</para> | |||||
/// <para>描述:下级平台收到上级平台链路连接保持请求消息后,向上级平台返回从链路连接保持应答消息,保持从链路连接状态</para> | |||||
/// <para>从链路连接保持应答消息,数据体为空</para> | |||||
/// </summary> | |||||
public class JT809_0x9006:JT809Bodies | |||||
{ | |||||
} | |||||
} |
@@ -0,0 +1,29 @@ | |||||
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>业务数据类型标识:DOWN_DISCONNECT_INFORM</para> | |||||
/// <para>描述: | |||||
/// 情景 1:上级平台与下级平台的从链路中断后,重连二次仍未成功时,上级平台通过主链路发送本消息给下级平台。 | |||||
/// 情景 2:上级平台作为客户端向下级平台登录时,根据之前收到的 IP 地址及端口无法连接到下级平台服务端时发送本消息通知下级平台。 | |||||
/// </para> | |||||
/// <para>本条消息无需被通知方应答</para> | |||||
/// </summary> | |||||
[JT809Formatter(typeof(JT809_0x9007Formatter))] | |||||
public class JT809_0x9007:JT809Bodies | |||||
{ | |||||
/// <summary> | |||||
/// 错误代码 | |||||
/// </summary> | |||||
public JT809_0x9007_ReasonCode ReasonCode { get; set; } | |||||
} | |||||
} |
@@ -0,0 +1,22 @@ | |||||
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>业务数据类型标识:DOWN_CLOSELINK_INFORM</para> | |||||
/// </summary> | |||||
[JT809Formatter(typeof(JT809_0x9008Formatter))] | |||||
public class JT809_0x9008:JT809Bodies | |||||
{ | |||||
/// <summary> | |||||
/// 错误代码 | |||||
/// </summary> | |||||
public JT809_0x9008_ReasonCode ReasonCode { get; set; } | |||||
} | |||||
} |