From 6cdd1fcfd808277f1a592cf09664df4257706845 Mon Sep 17 00:00:00 2001 From: "SmallChi(Koike)" <564952747@qq.com> Date: Mon, 31 May 2021 18:03:53 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=A2=9E=E5=8A=A0=E7=B2=A4=E6=A0=87=E5=8D=8F?= =?UTF-8?q?=E8=AE=AE=202.=E5=A2=9E=E5=8A=A0=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E4=BD=8D=E7=BD=AE=E9=99=84=E5=8A=A0=E4=BF=A1=E6=81=AF=E9=95=BF?= =?UTF-8?q?=E5=BA=A6=E6=94=AF=E6=8C=81=E5=9B=9B=E4=B8=AA=E5=AD=97=E8=8A=82?= =?UTF-8?q?=E7=9A=84=E6=89=A9=E5=B1=95=E5=8F=8A=E5=AF=B9=E5=BA=94=E6=B5=8B?= =?UTF-8?q?=E8=AF=95Demo12=203.=E4=BF=AE=E6=94=B9=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 9 + .../JT808_0x0200_0x64_Test.cs | 2 +- .../JT808_0x0200_0x67_Test.cs | 6 +- .../MessageBody/JT808_0x0200_0x64.cs | 5 +- .../MessageBody/JT808_0x0200_0x65.cs | 5 +- .../MessageBody/JT808_0x0200_0x67.cs | 5 +- .../Enums/JT808UpgradeStatus.cs | 57 ++++++ .../Enums/JT808_YueBiao_MsgId.cs | 4 + .../JT808.Protocol.Extensions.YueBiao.xml | 184 ++++++++++++++++++ .../JT808_YueBiao_Constants.cs | 5 + .../MessageBody/JT808_0x0200_0x64.cs | 7 +- .../MessageBody/JT808_0x0200_0x65.cs | 5 +- .../MessageBody/JT808_0x0200_0x66.cs | 2 +- .../MessageBody/JT808_0x0200_0x67.cs | 5 +- .../MessageBody/JT808_0x0900_0xF7.cs | 2 +- .../MessageBody/JT808_0x0900_0xF8.cs | 2 +- .../MessageBody/JT808_0x1211.cs | 2 +- .../MessageBody/JT808_0x1212.cs | 2 +- .../MessageBody/JT808_0x1FC4.cs | 99 ++++++++++ .../MessageBody/JT808_0x8103_0xF364.cs | 2 +- .../MessageBody/JT808_0x8103_0xF365.cs | 2 +- .../MessageBody/JT808_0x8103_0xF366.cs | 2 +- .../MessageBody/JT808_0x8103_0xF367.cs | 2 +- .../MessageBody/JT808_0x8103_0xF370.cs | 72 +++++++ .../MessageBody/JT808_0x8900_0xF7.cs | 2 +- .../MessageBody/JT808_0x8900_0xF8.cs | 2 +- .../MessageBody/JT808_0x9208.cs | 2 +- .../MessageBody/JT808_0x9212.cs | 2 +- .../JT808.Protocol.Test.csproj | 3 +- ...0x06.cs => JT808LocationAttachImpl0x61.cs} | 0 .../JT808LocationAttachImpl0x62.cs | 34 ++++ src/JT808.Protocol.Test/Simples/Demo12.cs | 96 +++++++++ .../Enums/JT808UpgradeResult.cs | 22 ++- src/JT808.Protocol/Enums/JT808UpgradeType.cs | 20 +- src/JT808.Protocol/JT808.Protocol.xml | 58 +++++- .../MessageBody/JT808_0x0200_BodyBase.cs | 6 - .../JT808_0x0200_CustomBodyBase.cs | 6 + .../MessageBody/JT808_0x8105.cs | 7 +- .../MessageBody/JT808_0x8801.cs | 1 + 39 files changed, 698 insertions(+), 51 deletions(-) create mode 100644 src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/Enums/JT808UpgradeStatus.cs create mode 100644 src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x1FC4.cs create mode 100644 src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x8103_0xF370.cs rename src/JT808.Protocol.Test/MessageBody/JT808LocationAttachExtensions/{JT808LocationAttachImpl0x06.cs => JT808LocationAttachImpl0x61.cs} (100%) create mode 100644 src/JT808.Protocol.Test/MessageBody/JT808LocationAttachExtensions/JT808LocationAttachImpl0x62.cs create mode 100644 src/JT808.Protocol.Test/Simples/Demo12.cs diff --git a/README.md b/README.md index 5166f1b..e95ab28 100644 --- a/README.md +++ b/README.md @@ -304,6 +304,15 @@ JT808Serializer DT2JT808Serializer = new JT808Serializer(DT2JT808Config); [可以参考Simples的Demo11](https://github.com/SmallChi/JT808/blob/master/src/JT808.Protocol.Test/Simples/Demo11.cs) +### 举个栗子12 + +场景: +由于粤标的设备厂家自定义的附加信息长度可以为四4个字节的,所以需要兼容。 + +[可以参考Simples的Demo12](https://github.com/SmallChi/JT808/blob/master/src/JT808.Protocol.Test/Simples/Demo12.cs) + +>注意:只适用于已知的设备厂家协议才行 + ## NuGet安装 | Package Name| Version| Preview Version |Downloads|Remark| diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety.Test/JT808_0x0200_0x64_Test.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety.Test/JT808_0x0200_0x64_Test.cs index 91f92d8..cedcf44 100644 --- a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety.Test/JT808_0x0200_0x64_Test.cs +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety.Test/JT808_0x0200_0x64_Test.cs @@ -60,7 +60,7 @@ namespace JT808.Protocol.Extensions.JTActiveSafety.Test VehicleState = 19 }); var hex = JT808Serializer.Serialize(jT808UploadLocationRequest).ToHexString(); - Assert.Equal("000000010000000200BA7F0E07E4F11C0028003C00001807151010106420000000010C0605120A0B100F1100070000000D0000000E191211183100001334343434343434191210183100030200", hex); + Assert.Equal("000000010000000200BA7F0E07E4F11C0028003C0000180715101010642F000000010C0605120A0B100F1100070000000D0000000E191211183100001334343434343434191210183100030200", hex); } [Fact] public void Deserialize() diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety.Test/JT808_0x0200_0x67_Test.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety.Test/JT808_0x0200_0x67_Test.cs index ac19c82..a81c53e 100644 --- a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety.Test/JT808_0x0200_0x67_Test.cs +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety.Test/JT808_0x0200_0x67_Test.cs @@ -55,12 +55,12 @@ namespace JT808.Protocol.Extensions.JTActiveSafety.Test VehicleState = 19 }); var hex = JT808Serializer.Serialize(jT808UploadLocationRequest).ToHexString(); - Assert.Equal("000000010000000200BA7F0E07E4F11C0028003C0000180715101010671A000000010C09081100070000000D0000000E191211183100001334343434343434191210183100030200", hex); + Assert.Equal("000000010000000200BA7F0E07E4F11C0028003C0000180715101010672A000000010C09081100070000000D0000000E191211183100001334343434343434191210183100030200", hex); } [Fact] public void Deserialize() { - var jT808UploadLocationRequest = JT808Serializer.Deserialize("000000010000000200BA7F0E07E4F11C0028003C0000180715101010671A000000010C09081100070000000D0000000E191211183100001334343434343434191210183100030200".ToHexBytes()); + var jT808UploadLocationRequest = JT808Serializer.Deserialize("000000010000000200BA7F0E07E4F11C0028003C0000180715101010672A000000010C09081100070000000D0000000E191211183100001334343434343434191210183100030200".ToHexBytes()); jT808UploadLocationRequest.JT808LocationAttachData.TryGetValue(JT808_JTActiveSafety_Constants.JT808_0X0200_0x67, out var value); JT808_0x0200_0x67 jT808_0X0200_0X67 = value as JT808_0x0200_0x67; Assert.Equal(1u, jT808_0X0200_0X67.AlarmId); @@ -73,7 +73,7 @@ namespace JT808.Protocol.Extensions.JTActiveSafety.Test Assert.Equal(8, jT808_0X0200_0X67.AlarmLevel); Assert.Equal(9, jT808_0X0200_0X67.AlarmOrEventType); Assert.Equal(0x67, jT808_0X0200_0X67.AttachInfoId); - Assert.Equal(26, jT808_0X0200_0X67.AttachInfoLength); + Assert.Equal(42, jT808_0X0200_0X67.AttachInfoLength); Assert.Equal(12, jT808_0X0200_0X67.FlagState); Assert.Equal(13, jT808_0X0200_0X67.Latitude); Assert.Equal(14, jT808_0X0200_0X67.Longitude); diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x0200_0x64.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x0200_0x64.cs index eb195fe..5f9c46f 100644 --- a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x0200_0x64.cs +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x0200_0x64.cs @@ -22,7 +22,7 @@ namespace JT808.Protocol.Extensions.JTActiveSafety.MessageBody /// /// 高级驾驶辅助系统报警信息附加长度 /// - public override byte AttachInfoLength { get; set; } = 32; + public override byte AttachInfoLength { get; set; } /// /// 报警ID /// @@ -315,7 +315,7 @@ namespace JT808.Protocol.Extensions.JTActiveSafety.MessageBody public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0200_0x64 value, IJT808Config config) { writer.WriteByte(value.AttachInfoId); - writer.WriteByte(value.AttachInfoLength); + writer.Skip(1, out int AttachInfoLengthPosition); writer.WriteUInt32(value.AlarmId); writer.WriteByte(value.FlagState); writer.WriteByte(value.AlarmOrEventType); @@ -339,6 +339,7 @@ namespace JT808.Protocol.Extensions.JTActiveSafety.MessageBody writer.WriteByte(value.AlarmIdentification.SN); writer.WriteByte(value.AlarmIdentification.AttachCount); writer.WriteByte(value.AlarmIdentification.Retain); + writer.WriteByteReturn((byte)(writer.GetCurrentPosition() - AttachInfoLengthPosition - 1), AttachInfoLengthPosition); } } } diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x0200_0x65.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x0200_0x65.cs index 95ec9da..3d26d50 100644 --- a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x0200_0x65.cs +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x0200_0x65.cs @@ -22,7 +22,7 @@ namespace JT808.Protocol.Extensions.JTActiveSafety.MessageBody /// /// 驾驶员状态监测系统报警信息长度 /// - public override byte AttachInfoLength { get; set; } = 47; + public override byte AttachInfoLength { get; set; } /// /// 报警ID /// @@ -264,7 +264,7 @@ namespace JT808.Protocol.Extensions.JTActiveSafety.MessageBody public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0200_0x65 value, IJT808Config config) { writer.WriteByte(value.AttachInfoId); - writer.WriteByte(value.AttachInfoLength); + writer.Skip(1, out int AttachInfoLengthPosition); writer.WriteUInt32(value.AlarmId); writer.WriteByte(value.FlagState); writer.WriteByte(value.AlarmOrEventType); @@ -290,6 +290,7 @@ namespace JT808.Protocol.Extensions.JTActiveSafety.MessageBody writer.WriteByte(value.AlarmIdentification.SN); writer.WriteByte(value.AlarmIdentification.AttachCount); writer.WriteByte(value.AlarmIdentification.Retain); + writer.WriteByteReturn((byte)(writer.GetCurrentPosition() - AttachInfoLengthPosition - 1), AttachInfoLengthPosition); } } } diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x0200_0x67.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x0200_0x67.cs index c6c5d57..b3c7568 100644 --- a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x0200_0x67.cs +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.JTActiveSafety/MessageBody/JT808_0x0200_0x67.cs @@ -22,7 +22,7 @@ namespace JT808.Protocol.Extensions.JTActiveSafety.MessageBody /// /// 盲区监测系统报警信息长度 /// - public override byte AttachInfoLength { get; set; } = 26; + public override byte AttachInfoLength { get; set; } /// /// 报警ID /// @@ -254,7 +254,7 @@ namespace JT808.Protocol.Extensions.JTActiveSafety.MessageBody public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0200_0x67 value, IJT808Config config) { writer.WriteByte(value.AttachInfoId); - writer.WriteByte(value.AttachInfoLength); + writer.Skip(1, out int AttachInfoLengthPosition); writer.WriteUInt32(value.AlarmId); writer.WriteByte(value.FlagState); writer.WriteByte(value.AlarmOrEventType); @@ -274,6 +274,7 @@ namespace JT808.Protocol.Extensions.JTActiveSafety.MessageBody writer.WriteByte(value.AlarmIdentification.SN); writer.WriteByte(value.AlarmIdentification.AttachCount); writer.WriteByte(value.AlarmIdentification.Retain); + writer.WriteByteReturn((byte)(writer.GetCurrentPosition() - AttachInfoLengthPosition - 1), AttachInfoLengthPosition); } } } diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/Enums/JT808UpgradeStatus.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/Enums/JT808UpgradeStatus.cs new file mode 100644 index 0000000..8f9592f --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/Enums/JT808UpgradeStatus.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Protocol.Extensions.YueBiao.Enums +{ + /// + /// 升级状态 + /// + public enum JT808UpgradeStatus:byte + { + /// + /// 固件下载中 + /// + 固件下载中 = 0x01, + /// + /// 固件下载成功 + /// + 固件下载成功 = 0x02, + /// + /// 固件下载失败 + /// + 固件下载失败 = 0x03, + /// + /// 固件安装中 + /// + 固件安装中 = 0x04, + /// + /// 安装成功 + /// + 安装成功 = 0x05, + /// + /// 安装失败 + /// + 安装失败 = 0x06, + /// + /// 未找到目标设备 + /// + 未找到目标设备 = 0x07, + /// + /// 硬件型号不支持 + /// + 硬件型号不支持 = 0x08, + /// + /// 软件版本相同 + /// + 软件版本相同 = 0x09, + /// + /// 软件版本不支持 + /// + 软件版本不支持 = 0x0a, + /// + /// 其他 + /// + 其他 = 0x0b, + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/Enums/JT808_YueBiao_MsgId.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/Enums/JT808_YueBiao_MsgId.cs index aa2d916..e354a70 100644 --- a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/Enums/JT808_YueBiao_MsgId.cs +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/Enums/JT808_YueBiao_MsgId.cs @@ -29,5 +29,9 @@ namespace JT808.Protocol.Extensions.YueBiao.Enums /// 文件上传完成消息应答 /// 文件上传完成消息应答 = 0x9212, + /// + /// 终端升级进度上报 + /// + 终端升级进度上报 = 0x1FC4, } } diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/JT808.Protocol.Extensions.YueBiao.xml b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/JT808.Protocol.Extensions.YueBiao.xml index 7ccb3a4..a379e70 100644 --- a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/JT808.Protocol.Extensions.YueBiao.xml +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/JT808.Protocol.Extensions.YueBiao.xml @@ -46,6 +46,66 @@ 不修改参数 + + + 升级状态 + + + + + 固件下载中 + + + + + 固件下载成功 + + + + + 固件下载失败 + + + + + 固件安装中 + + + + + 安装成功 + + + + + 安装失败 + + + + + 未找到目标设备 + + + + + 硬件型号不支持 + + + + + 软件版本相同 + + + + + 软件版本不支持 + + + + + 其他 + + 主动安全消息Id @@ -76,6 +136,11 @@ 文件上传完成消息应答 + + + 终端升级进度上报 + + 拍照分辨率 @@ -261,6 +326,12 @@ 盲区监测系统参数设置 + + + 智能视频协议版本信息 + 引入此智能视频协议版本信息方便平台进行版本控制初始版本是 1,每次修订版本号都会递增 + + 状态查询 @@ -971,6 +1042,72 @@ + + + 终端升级进度上报 + + + + + 终端升级进度上报 + + + + + 终端升级进度上报 + + + + + 流水号 + + + + + 升级类型 + + + + + 升级状态 + + + + + 升级进度 + 0-100 + + + + + 错误码 + 由厂家自定义 + + + + + + + + + + + + + + + + + + + + + + + + + + 高级驾驶辅助系统参数 @@ -1589,6 +1726,53 @@ + + + 智能视频协议版本信息 + + + + + 系统参数Id + + + + + 参数长度 + + + + + 智能视频协议版本信息 + 引入此智能视频协议版本信息方便平台进行版本控制初始版本是 + 1,每次修订版本号都会递增* + 注:只支持获取,不支持设置 + + + + + + + + + + + + + + + + + + + + + + + + + + 状态查询 diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/JT808_YueBiao_Constants.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/JT808_YueBiao_Constants.cs index 95dfe1f..7a21693 100644 --- a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/JT808_YueBiao_Constants.cs +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/JT808_YueBiao_Constants.cs @@ -42,6 +42,11 @@ namespace JT808.Protocol.Extensions.YueBiao /// public const uint JT808_0X8103_0xF367 = 0xF367; /// + /// 智能视频协议版本信息 + /// 引入此智能视频协议版本信息方便平台进行版本控制初始版本是 1,每次修订版本号都会递增 + /// + public const uint JT808_0X8103_0xF370 = 0xF370; + /// /// 状态查询 /// public const byte JT808_0X0900_0xF7 = 0xF7; diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x0200_0x64.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x0200_0x64.cs index 8f92a51..d348ba9 100644 --- a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x0200_0x64.cs +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x0200_0x64.cs @@ -13,7 +13,7 @@ namespace JT808.Protocol.Extensions.YueBiao.MessageBody /// /// 高级驾驶辅助系统报警信息 /// - public class JT808_0x0200_0x64 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter, IJT808Analyze + public class JT808_0x0200_0x64 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter, IJT808Analyze,IJT808_2019_Version { /// /// 高级驾驶辅助系统报警信息Id @@ -22,7 +22,7 @@ namespace JT808.Protocol.Extensions.YueBiao.MessageBody /// /// 高级驾驶辅助系统报警信息附加长度 /// - public override byte AttachInfoLength { get; set; } = 32; + public override byte AttachInfoLength { get; set; } = 73; /// /// 报警ID /// @@ -322,7 +322,7 @@ namespace JT808.Protocol.Extensions.YueBiao.MessageBody public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0200_0x64 value, IJT808Config config) { writer.WriteByte(value.AttachInfoId); - writer.WriteByte(value.AttachInfoLength); + writer.Skip(1, out int AttachInfoLengthPosition); writer.WriteUInt32(value.AlarmId); writer.WriteByte(value.FlagState); writer.WriteByte(value.AlarmOrEventType); @@ -347,6 +347,7 @@ namespace JT808.Protocol.Extensions.YueBiao.MessageBody writer.WriteByte(value.AlarmIdentification.AttachCount); writer.WriteByte(value.AlarmIdentification.Retain1); writer.WriteByte(value.AlarmIdentification.Retain2); + writer.WriteByteReturn((byte)(writer.GetCurrentPosition() - AttachInfoLengthPosition - 1), AttachInfoLengthPosition); } } } diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x0200_0x65.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x0200_0x65.cs index 6f18db6..a368377 100644 --- a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x0200_0x65.cs +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x0200_0x65.cs @@ -13,7 +13,7 @@ namespace JT808.Protocol.Extensions.YueBiao.MessageBody /// /// 驾驶员状态监测系统报警信息 /// - public class JT808_0x0200_0x65 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter, IJT808Analyze + public class JT808_0x0200_0x65 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter, IJT808Analyze, IJT808_2019_Version { /// /// 驾驶员状态监测系统报警信息Id @@ -283,7 +283,7 @@ namespace JT808.Protocol.Extensions.YueBiao.MessageBody public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0200_0x65 value, IJT808Config config) { writer.WriteByte(value.AttachInfoId); - writer.WriteByte(value.AttachInfoLength); + writer.Skip(1, out int AttachInfoLengthPosition); writer.WriteUInt32(value.AlarmId); writer.WriteByte(value.FlagState); writer.WriteByte(value.AlarmOrEventType); @@ -310,6 +310,7 @@ namespace JT808.Protocol.Extensions.YueBiao.MessageBody writer.WriteByte(value.AlarmIdentification.AttachCount); writer.WriteByte(value.AlarmIdentification.Retain1); writer.WriteByte(value.AlarmIdentification.Retain2); + writer.WriteByteReturn((byte)(writer.GetCurrentPosition() - AttachInfoLengthPosition - 1), AttachInfoLengthPosition); } } } diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x0200_0x66.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x0200_0x66.cs index 163c6e5..ecb54da 100644 --- a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x0200_0x66.cs +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x0200_0x66.cs @@ -13,7 +13,7 @@ namespace JT808.Protocol.Extensions.YueBiao.MessageBody /// /// 胎压监测系统报警信息 /// - public class JT808_0x0200_0x66 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter, IJT808Analyze + public class JT808_0x0200_0x66 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter, IJT808Analyze, IJT808_2019_Version { /// /// 胎压监测系统报警信息Id diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x0200_0x67.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x0200_0x67.cs index 2dacb56..a1dbec7 100644 --- a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x0200_0x67.cs +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x0200_0x67.cs @@ -13,7 +13,7 @@ namespace JT808.Protocol.Extensions.YueBiao.MessageBody /// /// 盲区监测系统报警信息 /// - public class JT808_0x0200_0x67 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter, IJT808Analyze + public class JT808_0x0200_0x67 : JT808_0x0200_BodyBase, IJT808MessagePackFormatter, IJT808Analyze, IJT808_2019_Version { /// /// 盲区监测系统报警信息Id @@ -257,7 +257,7 @@ namespace JT808.Protocol.Extensions.YueBiao.MessageBody public void Serialize(ref JT808MessagePackWriter writer, JT808_0x0200_0x67 value, IJT808Config config) { writer.WriteByte(value.AttachInfoId); - writer.WriteByte(value.AttachInfoLength); + writer.Skip(1, out int AttachInfoLengthPosition); writer.WriteUInt32(value.AlarmId); writer.WriteByte(value.FlagState); writer.WriteByte(value.AlarmOrEventType); @@ -278,6 +278,7 @@ namespace JT808.Protocol.Extensions.YueBiao.MessageBody writer.WriteByte(value.AlarmIdentification.AttachCount); writer.WriteByte(value.AlarmIdentification.Retain1); writer.WriteByte(value.AlarmIdentification.Retain2); + writer.WriteByteReturn((byte)(writer.GetCurrentPosition() - AttachInfoLengthPosition - 1), AttachInfoLengthPosition); } } } diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x0900_0xF7.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x0900_0xF7.cs index 811ff9a..3e1e6b4 100644 --- a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x0900_0xF7.cs +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x0900_0xF7.cs @@ -14,7 +14,7 @@ namespace JT808.Protocol.Extensions.YueBiao.MessageBody /// /// 透传数据 /// - public class JT808_0x0900_0xF7 : JT808_0x0900_BodyBase, IJT808MessagePackFormatter, IJT808Analyze + public class JT808_0x0900_0xF7 : JT808_0x0900_BodyBase, IJT808MessagePackFormatter, IJT808Analyze, IJT808_2019_Version { /// /// 透传类型 diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x0900_0xF8.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x0900_0xF8.cs index 1ae0f4c..a8fbd49 100644 --- a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x0900_0xF8.cs +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x0900_0xF8.cs @@ -13,7 +13,7 @@ namespace JT808.Protocol.Extensions.YueBiao.MessageBody /// /// 透传数据 /// - public class JT808_0x0900_0xF8 : JT808_0x0900_BodyBase, IJT808MessagePackFormatter, IJT808Analyze + public class JT808_0x0900_0xF8 : JT808_0x0900_BodyBase, IJT808MessagePackFormatter, IJT808Analyze, IJT808_2019_Version { /// /// 透传类型 diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x1211.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x1211.cs index 924688f..c769e04 100644 --- a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x1211.cs +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x1211.cs @@ -8,7 +8,7 @@ namespace JT808.Protocol.Extensions.YueBiao.MessageBody /// /// 文件信息上传 /// - public class JT808_0x1211 : JT808Bodies, IJT808MessagePackFormatter, IJT808Analyze + public class JT808_0x1211 : JT808Bodies, IJT808MessagePackFormatter, IJT808Analyze, IJT808_2019_Version { /// /// 文件信息上传 diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x1212.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x1212.cs index 91719d4..bbbf523 100644 --- a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x1212.cs +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x1212.cs @@ -8,7 +8,7 @@ namespace JT808.Protocol.Extensions.YueBiao.MessageBody /// /// 文件上传完成消息 /// - public class JT808_0x1212 : JT808Bodies, IJT808MessagePackFormatter, IJT808Analyze + public class JT808_0x1212 : JT808Bodies, IJT808MessagePackFormatter, IJT808Analyze, IJT808_2019_Version { /// /// 文件上传完成消息 diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x1FC4.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x1FC4.cs new file mode 100644 index 0000000..7a41e80 --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x1FC4.cs @@ -0,0 +1,99 @@ +using JT808.Protocol.Enums; +using JT808.Protocol.Extensions.YueBiao.Enums; +using JT808.Protocol.Extensions.YueBiao.Metadata; +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessagePack; +using System.Collections.Generic; +using System.Text.Json; + +namespace JT808.Protocol.Extensions.YueBiao.MessageBody +{ + /// + /// 终端升级进度上报 + /// + public class JT808_0x1FC4 : JT808Bodies, IJT808MessagePackFormatter, IJT808Analyze, IJT808_2019_Version + { + /// + /// 终端升级进度上报 + /// + public override string Description => "终端升级进度上报"; + /// + /// 终端升级进度上报 + /// + public override ushort MsgId => JT808_YueBiao_MsgId.终端升级进度上报.ToUInt16Value(); + /// + /// 流水号 + /// + public ushort MsgNum { get; set; } + /// + /// 升级类型 + /// + public JT808UpgradeType UpgradeType { get; set; } + /// + /// 升级状态 + /// + public JT808UpgradeStatus UpgradeStatus { get; set; } + /// + /// 升级进度 + /// 0-100 + /// + public byte UploadProgress { get; set; } + /// + /// 错误码 + /// 由厂家自定义 + /// + public byte ErrorCode { get; set; } + + /// + /// + /// + /// + /// + /// + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + JT808_0x1FC4 value = new JT808_0x1FC4(); + value.MsgNum = reader.ReadUInt16(); + writer.WriteNumber($"[{value.MsgNum.ReadNumber()}]流水号", value.MsgNum); + value.UpgradeType = (JT808UpgradeType)reader.ReadByte(); + writer.WriteString($"[{value.UpgradeType.ToByteValue().ReadNumber()}]升级类型", value.UpgradeType.ToString()); + value.UpgradeStatus = (JT808UpgradeStatus)reader.ReadByte(); + writer.WriteString($"[{value.UpgradeStatus.ToByteValue().ReadNumber()}]升级状态", value.UpgradeStatus.ToString()); + value.UploadProgress = reader.ReadByte(); + writer.WriteNumber($"[{value.UploadProgress.ReadNumber()}]升级进度", UploadProgress); + value.ErrorCode = reader.ReadByte(); + writer.WriteNumber($"[{value.ErrorCode.ReadNumber()}]错误码", ErrorCode); + } + /// + /// + /// + /// + /// + /// + public JT808_0x1FC4 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_0x1FC4 value = new JT808_0x1FC4(); + value.MsgNum = reader.ReadUInt16(); + value.UpgradeType = (JT808UpgradeType)reader.ReadByte(); + value.UpgradeStatus = (JT808UpgradeStatus)reader.ReadByte(); + value.UploadProgress = reader.ReadByte(); + value.ErrorCode = reader.ReadByte(); + return value; + } + /// + /// + /// + /// + /// + /// + public void Serialize(ref JT808MessagePackWriter writer, JT808_0x1FC4 value, IJT808Config config) + { + writer.WriteUInt16(value.MsgNum); + writer.WriteByte(value.UpgradeType.ToByteValue()); + writer.WriteByte(value.UpgradeStatus.ToByteValue()); + writer.WriteByte(value.UploadProgress); + writer.WriteByte(value.ErrorCode); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x8103_0xF364.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x8103_0xF364.cs index f11578c..fdb445f 100644 --- a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x8103_0xF364.cs +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x8103_0xF364.cs @@ -11,7 +11,7 @@ namespace JT808.Protocol.Extensions.YueBiao.MessageBody /// /// 高级驾驶辅助系统参数 /// - public class JT808_0x8103_0xF364 : JT808_0x8103_BodyBase, IJT808MessagePackFormatter, IJT808Analyze + public class JT808_0x8103_0xF364 : JT808_0x8103_BodyBase, IJT808MessagePackFormatter, IJT808Analyze, IJT808_2019_Version { /// /// 高级驾驶辅助系统参数 diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x8103_0xF365.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x8103_0xF365.cs index 09231d9..d40729a 100644 --- a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x8103_0xF365.cs +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x8103_0xF365.cs @@ -11,7 +11,7 @@ namespace JT808.Protocol.Extensions.YueBiao.MessageBody /// /// 驾驶员状态监测系统参数 /// - public class JT808_0x8103_0xF365 : JT808_0x8103_BodyBase, IJT808MessagePackFormatter, IJT808Analyze + public class JT808_0x8103_0xF365 : JT808_0x8103_BodyBase, IJT808MessagePackFormatter, IJT808Analyze, IJT808_2019_Version { /// /// 驾驶员状态监测系统参数 diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x8103_0xF366.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x8103_0xF366.cs index 2635e8d..55087ca 100644 --- a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x8103_0xF366.cs +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x8103_0xF366.cs @@ -9,7 +9,7 @@ namespace JT808.Protocol.Extensions.YueBiao.MessageBody /// /// 胎压监测系统参数 /// - public class JT808_0x8103_0xF366 : JT808_0x8103_BodyBase, IJT808MessagePackFormatter, IJT808Analyze + public class JT808_0x8103_0xF366 : JT808_0x8103_BodyBase, IJT808MessagePackFormatter, IJT808Analyze, IJT808_2019_Version { /// /// 胎压监测系统参数Id diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x8103_0xF367.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x8103_0xF367.cs index 4d1afcb..e3bd5ba 100644 --- a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x8103_0xF367.cs +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x8103_0xF367.cs @@ -9,7 +9,7 @@ namespace JT808.Protocol.Extensions.YueBiao.MessageBody /// /// 盲区监测系统参数 /// - public class JT808_0x8103_0xF367 : JT808_0x8103_BodyBase, IJT808MessagePackFormatter, IJT808Analyze + public class JT808_0x8103_0xF367 : JT808_0x8103_BodyBase, IJT808MessagePackFormatter, IJT808Analyze, IJT808_2019_Version { /// /// 盲区监测系统参数Id diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x8103_0xF370.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x8103_0xF370.cs new file mode 100644 index 0000000..dfb5dfa --- /dev/null +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x8103_0xF370.cs @@ -0,0 +1,72 @@ +using JT808.Protocol.Formatters; +using JT808.Protocol.Interfaces; +using JT808.Protocol.MessageBody; +using JT808.Protocol.MessagePack; +using System.Text.Json; + +namespace JT808.Protocol.Extensions.YueBiao.MessageBody +{ + /// + /// 智能视频协议版本信息 + /// + public class JT808_0x8103_0xF370 : JT808_0x8103_BodyBase, IJT808MessagePackFormatter, IJT808Analyze, IJT808_2019_Version + { + /// + /// 系统参数Id + /// + public override uint ParamId { get; set; } = JT808_YueBiao_Constants.JT808_0X8103_0xF370; + /// + /// 参数长度 + /// + public override byte ParamLength { get; set; } = 1; + /// + /// 智能视频协议版本信息 + /// 引入此智能视频协议版本信息方便平台进行版本控制初始版本是 + /// 1,每次修订版本号都会递增* + /// 注:只支持获取,不支持设置 + /// + public byte SmartVideoProtocolVersion { get; set; } + /// + /// + /// + /// + /// + /// + public void Analyze(ref JT808MessagePackReader reader, Utf8JsonWriter writer, IJT808Config config) + { + JT808_0x8103_0xF370 value = new JT808_0x8103_0xF370(); + value.ParamId = reader.ReadUInt32(); + value.ParamLength = reader.ReadByte(); + writer.WriteNumber($"[{ value.ParamId.ReadNumber()}]参数ID", value.ParamId); + writer.WriteNumber($"[{value.ParamLength.ReadNumber()}]参数长度", value.ParamLength); + value.SmartVideoProtocolVersion = reader.ReadByte(); + writer.WriteNumber($"[{value.SmartVideoProtocolVersion.ReadNumber()}]智能视频协议版本信息", value.SmartVideoProtocolVersion); + } + /// + /// + /// + /// + /// + /// + public JT808_0x8103_0xF370 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808_0x8103_0xF370 value = new JT808_0x8103_0xF370(); + value.ParamId = reader.ReadUInt32(); + value.ParamLength = reader.ReadByte(); + value.SmartVideoProtocolVersion = reader.ReadByte(); + return value; + } + /// + /// + /// + /// + /// + /// + public void Serialize(ref JT808MessagePackWriter writer, JT808_0x8103_0xF370 value, IJT808Config config) + { + writer.WriteUInt32(value.ParamId); + writer.WriteByte(value.ParamLength); + writer.WriteByte(value.SmartVideoProtocolVersion); + } + } +} diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x8900_0xF7.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x8900_0xF7.cs index 5627e69..710a311 100644 --- a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x8900_0xF7.cs +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x8900_0xF7.cs @@ -10,7 +10,7 @@ namespace JT808.Protocol.Extensions.YueBiao.MessageBody /// /// 状态查询 /// - public class JT808_0x8900_0xF7 : JT808_0x8900_BodyBase, IJT808MessagePackFormatter, IJT808Analyze + public class JT808_0x8900_0xF7 : JT808_0x8900_BodyBase, IJT808MessagePackFormatter, IJT808Analyze, IJT808_2019_Version { /// /// 查询基本信息类型 diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x8900_0xF8.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x8900_0xF8.cs index 1fea038..b5ed717 100644 --- a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x8900_0xF8.cs +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x8900_0xF8.cs @@ -10,7 +10,7 @@ namespace JT808.Protocol.Extensions.YueBiao.MessageBody /// /// 信息查询 /// - public class JT808_0x8900_0xF8 : JT808_0x8900_BodyBase, IJT808MessagePackFormatter, IJT808Analyze + public class JT808_0x8900_0xF8 : JT808_0x8900_BodyBase, IJT808MessagePackFormatter, IJT808Analyze, IJT808_2019_Version { /// /// 查询基本信息透传类型 diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x9208.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x9208.cs index 1dfd08a..60ac76a 100644 --- a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x9208.cs +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x9208.cs @@ -10,7 +10,7 @@ namespace JT808.Protocol.Extensions.YueBiao.MessageBody /// /// 报警附件上传指令 /// - public class JT808_0x9208: JT808Bodies, IJT808MessagePackFormatter, IJT808Analyze + public class JT808_0x9208: JT808Bodies, IJT808MessagePackFormatter, IJT808Analyze, IJT808_2019_Version { /// /// Description diff --git a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x9212.cs b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x9212.cs index 0e4bf41..4c0584d 100644 --- a/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x9212.cs +++ b/src/JT808.Protocol.Extensions/JT808.Protocol.Extensions.YueBiao/MessageBody/JT808_0x9212.cs @@ -10,7 +10,7 @@ namespace JT808.Protocol.Extensions.YueBiao.MessageBody /// /// 文件上传完成消息应答 /// - public class JT808_0x9212: JT808Bodies, IJT808MessagePackFormatter, IJT808Analyze + public class JT808_0x9212: JT808Bodies, IJT808MessagePackFormatter, IJT808Analyze, IJT808_2019_Version { /// /// 文件上传完成消息应答 diff --git a/src/JT808.Protocol.Test/JT808.Protocol.Test.csproj b/src/JT808.Protocol.Test/JT808.Protocol.Test.csproj index 0a3eb0e..d75f2c9 100644 --- a/src/JT808.Protocol.Test/JT808.Protocol.Test.csproj +++ b/src/JT808.Protocol.Test/JT808.Protocol.Test.csproj @@ -33,7 +33,8 @@ - + + diff --git a/src/JT808.Protocol.Test/MessageBody/JT808LocationAttachExtensions/JT808LocationAttachImpl0x06.cs b/src/JT808.Protocol.Test/MessageBody/JT808LocationAttachExtensions/JT808LocationAttachImpl0x61.cs similarity index 100% rename from src/JT808.Protocol.Test/MessageBody/JT808LocationAttachExtensions/JT808LocationAttachImpl0x06.cs rename to src/JT808.Protocol.Test/MessageBody/JT808LocationAttachExtensions/JT808LocationAttachImpl0x61.cs diff --git a/src/JT808.Protocol.Test/MessageBody/JT808LocationAttachExtensions/JT808LocationAttachImpl0x62.cs b/src/JT808.Protocol.Test/MessageBody/JT808LocationAttachExtensions/JT808LocationAttachImpl0x62.cs new file mode 100644 index 0000000..93367ea --- /dev/null +++ b/src/JT808.Protocol.Test/MessageBody/JT808LocationAttachExtensions/JT808LocationAttachImpl0x62.cs @@ -0,0 +1,34 @@ +using JT808.Protocol.Formatters; +using JT808.Protocol.MessageBody; +using JT808.Protocol.MessagePack; + +namespace JT808.Protocol.Test.JT808LocationAttach +{ + /// + /// 自定义附加信息 + /// data-byte[]-256 + /// + public class JT808LocationAttachImpl0x62 : JT808_0x0200_CustomBodyBase, IJT808MessagePackFormatter + { + public override byte AttachInfoId { get; set; } = 0x62; + public override uint AttachInfoLengthExtend { get; set; } = 256; + public override byte AttachInfoLength { get; set; } + public byte[] Data { get; set; } + + public JT808LocationAttachImpl0x62 Deserialize(ref JT808MessagePackReader reader, IJT808Config config) + { + JT808LocationAttachImpl0x62 jT808LocationAttachImpl0x62 = new JT808LocationAttachImpl0x62(); + jT808LocationAttachImpl0x62.AttachInfoId = reader.ReadByte(); + jT808LocationAttachImpl0x62.AttachInfoLengthExtend = reader.ReadUInt32(); + jT808LocationAttachImpl0x62.Data = reader.ReadArray((int)jT808LocationAttachImpl0x62.AttachInfoLengthExtend).ToArray(); + return jT808LocationAttachImpl0x62; + } + + public void Serialize(ref JT808MessagePackWriter writer, JT808LocationAttachImpl0x62 value, IJT808Config config) + { + writer.WriteByte(value.AttachInfoId); + writer.WriteUInt32((uint)value.Data.Length); + writer.WriteArray(value.Data); + } + } +} diff --git a/src/JT808.Protocol.Test/Simples/Demo12.cs b/src/JT808.Protocol.Test/Simples/Demo12.cs new file mode 100644 index 0000000..19c173e --- /dev/null +++ b/src/JT808.Protocol.Test/Simples/Demo12.cs @@ -0,0 +1,96 @@ +using JT808.Protocol.Enums; +using JT808.Protocol.Interfaces; +using JT808.Protocol.Internal; +using JT808.Protocol.Extensions; +using Microsoft.Extensions.DependencyInjection; +using System; +using System.Collections.Generic; +using System.Text; +using Xunit; +using JT808.Protocol.MessageBody; +using JT808.Protocol.Formatters; +using JT808.Protocol.MessagePack; +using System.Text.Json; +using JT808.Protocol.MessageBody.CarDVR; +using System.Linq; +using JT808.Protocol.Test.JT808LocationAttach; + +namespace JT808.Protocol.Test.Simples +{ + public class Demo12 + { + JT808Serializer JT808Serializer; + + public Demo12() + { + IJT808Config jT808Config = new DefaultGlobalConfig(); + jT808Config.JT808_0X0200_Custom_Factory.SetMap(); + JT808Serializer = new JT808Serializer(jT808Config); + } + + [Fact] + public void Test1() + { + JT808Package jT808Package = new JT808Package(); + jT808Package.Header = new JT808Header + { + MsgId = Enums.JT808MsgId.位置信息汇报.ToUInt16Value(), + ManualMsgNum = 1, + TerminalPhoneNo = "1122334455", + }; + JT808_0x0200 jT808UploadLocationRequest = new JT808_0x0200 + { + AlarmFlag = 1, + Altitude = 40, + GPSTime = DateTime.Parse("2021-05-31 18:17:10"), + Lat = 12222222, + Lng = 132444444, + Speed = 60, + Direction = 0, + StatusFlag = 2, + JT808LocationAttachData = new Dictionary(), + JT808CustomLocationAttachData = new Dictionary() + }; + jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808Constants.JT808_0x0200_0x01, new JT808_0x0200_0x01 + { + Mileage = 100 + }); + jT808UploadLocationRequest.JT808LocationAttachData.Add(JT808Constants.JT808_0x0200_0x02, new JT808_0x0200_0x02 + { + Oil = 55 + }); + jT808UploadLocationRequest.JT808CustomLocationAttachData.Add(0x62, new JT808LocationAttachImpl0x62 + { + Data=new byte[256] + }); + jT808Package.Bodies = jT808UploadLocationRequest; + var hex = JT808Serializer.Serialize(jT808Package).ToHexString(); + Assert.Equal("7E0200012B0011223344550001000000010000000200BA7F0E07E4F11C0028003C000021053118171001040000006402020037620000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000D57E", hex); + } + + [Fact] + public void Test2() + { + byte[] bytes = "7E0200012B0011223344550001000000010000000200BA7F0E07E4F11C0028003C000021053118171001040000006402020037620000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000D57E".ToHexBytes(); + var jT808Package = JT808Serializer.Deserialize(bytes); + Assert.Equal(Enums.JT808MsgId.位置信息汇报.ToValue(), jT808Package.Header.MsgId); + Assert.Equal(1u, jT808Package.Header.MsgNum); + Assert.Equal("1122334455", jT808Package.Header.TerminalPhoneNo); + JT808_0x0200 jT808UploadLocationRequest = (JT808_0x0200)jT808Package.Bodies; + Assert.Equal(1u, jT808UploadLocationRequest.AlarmFlag); + Assert.Equal(40u, jT808UploadLocationRequest.Altitude); + Assert.Equal(DateTime.Parse("2021-05-31 18:17:10"), jT808UploadLocationRequest.GPSTime); + Assert.Equal(12222222, jT808UploadLocationRequest.Lat); + Assert.Equal(132444444, jT808UploadLocationRequest.Lng); + Assert.Equal(60, jT808UploadLocationRequest.Speed); + Assert.Equal(2u, jT808UploadLocationRequest.StatusFlag); + Assert.Equal(100, ((JT808_0x0200_0x01)jT808UploadLocationRequest.JT808LocationAttachData[JT808Constants.JT808_0x0200_0x01]).Mileage); + Assert.Equal(55, ((JT808_0x0200_0x02)jT808UploadLocationRequest.JT808LocationAttachData[JT808Constants.JT808_0x0200_0x02]).Oil); + var jT808LocationAttachImpl0X62 = (JT808LocationAttachImpl0x62)jT808UploadLocationRequest.JT808CustomLocationAttachData[0x62]; + Assert.Equal(0x62, jT808LocationAttachImpl0X62.AttachInfoId); + Assert.Equal(new byte[256], jT808LocationAttachImpl0X62.Data); + Assert.Equal(256u, jT808LocationAttachImpl0X62.AttachInfoLengthExtend); + Assert.Equal(0, jT808LocationAttachImpl0X62.AttachInfoLength); + } + } +} diff --git a/src/JT808.Protocol/Enums/JT808UpgradeResult.cs b/src/JT808.Protocol/Enums/JT808UpgradeResult.cs index a67cc80..43b27af 100644 --- a/src/JT808.Protocol/Enums/JT808UpgradeResult.cs +++ b/src/JT808.Protocol/Enums/JT808UpgradeResult.cs @@ -8,14 +8,30 @@ /// /// 成功 /// - 成功 = 0, + 成功 = 0x00, /// /// 失败 /// - 失败 = 1, + 失败 = 0x01, /// /// 取消 /// - 取消 = 2, + 取消 = 0x02, + /// + /// 粤标主动安全-未找到目标设备 + /// + 未找到目标设备 = 0x10, + /// + /// 粤标主动安全-硬件型号不支持 + /// + 硬件型号不支持 = 0x11, + /// + /// 粤标主动安全-软件版本相同 + /// + 软件版本相同 = 0x12, + /// + /// 粤标主动安全-软件版本不支持 + /// + 软件版本不支持 = 0x13 } } diff --git a/src/JT808.Protocol/Enums/JT808UpgradeType.cs b/src/JT808.Protocol/Enums/JT808UpgradeType.cs index 2a0ac74..dff1a4d 100644 --- a/src/JT808.Protocol/Enums/JT808UpgradeType.cs +++ b/src/JT808.Protocol/Enums/JT808UpgradeType.cs @@ -12,10 +12,26 @@ /// /// 道路运输证IC卡读卡器 /// - 道路运输证IC卡读卡器 = 12, + 道路运输证IC卡读卡器 = 0x0C, /// /// 北斗卫星定位模块 /// - 北斗卫星定位模块 = 52, + 北斗卫星定位模块 = 0x34, + /// + /// 粤标主动安全-高级驾驶辅助系统 + /// + 高级驾驶辅助系统 = 0x64, + /// + /// 粤标主动安全-驾驶状态监控系统 + /// + 驾驶状态监控系统 = 0x65, + /// + /// 粤标主动安全-胎压监测系统 + /// + 胎压监测系统 = 0x66, + /// + /// 粤标主动安全-盲点监测系统 + /// + 盲点监测系统 = 0x67, } } diff --git a/src/JT808.Protocol/JT808.Protocol.xml b/src/JT808.Protocol/JT808.Protocol.xml index 73cd840..1fd5c02 100644 --- a/src/JT808.Protocol/JT808.Protocol.xml +++ b/src/JT808.Protocol/JT808.Protocol.xml @@ -1531,6 +1531,26 @@ 取消 + + + 粤标主动安全-未找到目标设备 + + + + + 粤标主动安全-硬件型号不支持 + + + + + 粤标主动安全-软件版本相同 + + + + + 粤标主动安全-软件版本不支持 + + 升级类型 @@ -1551,6 +1571,26 @@ 北斗卫星定位模块 + + + 粤标主动安全-高级驾驶辅助系统 + + + + + 粤标主动安全-驾驶状态监控系统 + + + + + 粤标主动安全-胎压监测系统 + + + + + 粤标主动安全-盲点监测系统 + + JT808版本号 @@ -9726,13 +9766,6 @@ 附加信息长度 - - - 附加信息长度扩展 - 4个字节 - 注意:只适用于已知的协议才行 - - 自定义位置附加信息 @@ -9748,6 +9781,13 @@ 自定义附加信息长度 + + + 附加信息长度扩展 + 4个字节 + 注意:只适用于已知的协议才行 + + 位置信息查询应答 @@ -15169,6 +15209,7 @@ 终端控制 + todo:重搞终端控制,加入自定义扩展 @@ -15295,7 +15336,7 @@ 连接到指定服务器时限 单位:分(min),值非 0 后的有效期截止前,终端应连回原地址。 - 若值为 0,则表示一直连接指 定服务器 + 若值为 0,则表示一直连接指 定服务器 @@ -16895,6 +16936,7 @@ 保存标志 1:保存;0:实时上传 + 仅主机拍照时有效 diff --git a/src/JT808.Protocol/MessageBody/JT808_0x0200_BodyBase.cs b/src/JT808.Protocol/MessageBody/JT808_0x0200_BodyBase.cs index 0980e62..c33f307 100644 --- a/src/JT808.Protocol/MessageBody/JT808_0x0200_BodyBase.cs +++ b/src/JT808.Protocol/MessageBody/JT808_0x0200_BodyBase.cs @@ -17,11 +17,5 @@ namespace JT808.Protocol.MessageBody /// 附加信息长度 /// public abstract byte AttachInfoLength { get; set; } - /// - /// 附加信息长度扩展 - /// 4个字节 - /// 注意:只适用于已知的协议才行 - /// - public virtual uint AttachInfoLengthExtend { get; set; } } } diff --git a/src/JT808.Protocol/MessageBody/JT808_0x0200_CustomBodyBase.cs b/src/JT808.Protocol/MessageBody/JT808_0x0200_CustomBodyBase.cs index f317ba0..e815fb8 100644 --- a/src/JT808.Protocol/MessageBody/JT808_0x0200_CustomBodyBase.cs +++ b/src/JT808.Protocol/MessageBody/JT808_0x0200_CustomBodyBase.cs @@ -16,5 +16,11 @@ namespace JT808.Protocol.MessageBody /// 自定义附加信息长度 /// public abstract byte AttachInfoLength { get; set; } + /// + /// 附加信息长度扩展 + /// 4个字节 + /// 注意:只适用于已知的协议才行 + /// + public virtual uint AttachInfoLengthExtend { get; set; } } } diff --git a/src/JT808.Protocol/MessageBody/JT808_0x8105.cs b/src/JT808.Protocol/MessageBody/JT808_0x8105.cs index 57dbd44..c1d7af1 100644 --- a/src/JT808.Protocol/MessageBody/JT808_0x8105.cs +++ b/src/JT808.Protocol/MessageBody/JT808_0x8105.cs @@ -3,12 +3,14 @@ using JT808.Protocol.Formatters; using JT808.Protocol.Interfaces; using JT808.Protocol.MessagePack; using System; +using System.Collections.Generic; using System.Text.Json; namespace JT808.Protocol.MessageBody { /// /// 终端控制 + /// todo:重搞终端控制,加入自定义扩展 /// public class JT808_0x8105 : JT808Bodies, IJT808MessagePackFormatter, IJT808Analyze, IJT808_2019_Version { @@ -270,9 +272,12 @@ namespace JT808.Protocol.MessageBody /// /// 连接到指定服务器时限 /// 单位:分(min),值非 0 后的有效期截止前,终端应连回原地址。 - /// 若值为 0,则表示一直连接指 定服务器 + /// 若值为 0,则表示一直连接指 定服务器 /// public ushort? ConnectTimeLimit { get; set; } + + public List Ext { get; set; } + /// /// /// diff --git a/src/JT808.Protocol/MessageBody/JT808_0x8801.cs b/src/JT808.Protocol/MessageBody/JT808_0x8801.cs index 9605151..11b5a43 100644 --- a/src/JT808.Protocol/MessageBody/JT808_0x8801.cs +++ b/src/JT808.Protocol/MessageBody/JT808_0x8801.cs @@ -38,6 +38,7 @@ namespace JT808.Protocol.MessageBody /// /// 保存标志 /// 1:保存;0:实时上传 + /// 仅主机拍照时有效 /// public byte SaveFlag { get; set; } ///