@@ -22,7 +22,6 @@ namespace JT808.Protocol.Extensions.GPS51.Test | |||
[Fact] | |||
public void Serializer() | |||
{ | |||
#warning ÓÐÎÊÌâ | |||
JT808_0x0200 jT808UploadLocationRequest = new JT808_0x0200 | |||
{ | |||
AlarmFlag = 1, | |||
@@ -0,0 +1,68 @@ | |||
using JT808.Protocol.Extensions.GPS51.MessageBody; | |||
using JT808.Protocol.MessageBody; | |||
using Microsoft.Extensions.DependencyInjection; | |||
using System; | |||
using System.Collections.Generic; | |||
using Xunit; | |||
namespace JT808.Protocol.Extensions.GPS51.Test | |||
{ | |||
public class JT808_0x0200_0x52_Test | |||
{ | |||
JT808Serializer JT808Serializer; | |||
public JT808_0x0200_0x52_Test() | |||
{ | |||
ServiceCollection serviceDescriptors = new ServiceCollection(); | |||
serviceDescriptors.AddJT808Configure() | |||
.AddGPS51Configure(); | |||
IJT808Config jT808Config = serviceDescriptors.BuildServiceProvider().GetRequiredService<IJT808Config>(); | |||
JT808Serializer = new JT808Serializer(jT808Config); | |||
} | |||
[Fact] | |||
public void Serializer() | |||
{ | |||
JT808_0x0200 jT808UploadLocationRequest = new JT808_0x0200 | |||
{ | |||
AlarmFlag = 1, | |||
Altitude = 40, | |||
GPSTime = DateTime.Parse("2018-07-15 10:10:10"), | |||
Lat = 12222222, | |||
Lng = 132444444, | |||
Speed = 60, | |||
Direction = 0, | |||
StatusFlag = 2, | |||
CustomLocationAttachData = new Dictionary<byte, JT808_0x0200_CustomBodyBase>() | |||
}; | |||
jT808UploadLocationRequest.CustomLocationAttachData.Add(JT808_GPS51_Constants.JT808_0x0200_0x52, new JT808_0x0200_0x52 | |||
{ | |||
AttachInfoId = 0x52, | |||
AttachInfoLength = 1, | |||
Direction = 2 | |||
}); | |||
var hex = JT808Serializer.Serialize<JT808_0x0200>(jT808UploadLocationRequest).ToHexString(); | |||
Assert.Equal("000000010000000200BA7F0E07E4F11C0028003C0000180715101010520102", hex); | |||
} | |||
[Fact] | |||
public void Deserialize() | |||
{ | |||
var jt808_0x0200 = JT808Serializer.Deserialize<JT808_0x0200>("000000010000000200BA7F0E07E4F11C0028003C0000180715101010520102".ToHexBytes()); | |||
jt808_0x0200.CustomLocationAttachData.TryGetValue(JT808_GPS51_Constants.JT808_0x0200_0x52, out var value); | |||
var jt808_0x0200_0x52 = value as JT808_0x0200_0x52; | |||
Assert.Equal(0x02, jt808_0x0200_0x52.Direction); | |||
} | |||
[Fact] | |||
public void Deserialize1() | |||
{ | |||
//gps51 demo | |||
var jT808UploadLocationRequest = JT808Serializer.Deserialize<JT808Package>("7e020000470412106280030233000000000000200201d365df072f15d500280000002d21091719155801040002a10f2a0200042b049203a46f520103eb06000100ce0a5730011b31010951080000000000000000ca7e".ToHexBytes()); | |||
var body0200 = jT808UploadLocationRequest.Bodies as JT808_0x0200; | |||
body0200.CustomLocationAttachData.TryGetValue(JT808_GPS51_Constants.JT808_0x0200_0x52 ,out var value); | |||
var jt808_0x0200_0x52 = value as JT808_0x0200_0x52; | |||
Assert.Equal(0x03, jt808_0x0200_0x52.Direction); | |||
} | |||
} | |||
} |
@@ -0,0 +1,82 @@ | |||
using JT808.Protocol.Extensions.GPS51.MessageBody; | |||
using JT808.Protocol.MessageBody; | |||
using Microsoft.Extensions.DependencyInjection; | |||
using System; | |||
using System.Collections.Generic; | |||
using Xunit; | |||
namespace JT808.Protocol.Extensions.GPS51.Test | |||
{ | |||
public class JT808_0x0200_0x54_Test | |||
{ | |||
JT808Serializer JT808Serializer; | |||
public JT808_0x0200_0x54_Test() | |||
{ | |||
ServiceCollection serviceDescriptors = new ServiceCollection(); | |||
serviceDescriptors.AddJT808Configure() | |||
.AddGPS51Configure(); | |||
IJT808Config jT808Config = serviceDescriptors.BuildServiceProvider().GetRequiredService<IJT808Config>(); | |||
JT808Serializer = new JT808Serializer(jT808Config); | |||
} | |||
[Fact] | |||
public void Serializer() | |||
{ | |||
JT808_0x0200 jT808UploadLocationRequest = new JT808_0x0200 | |||
{ | |||
AlarmFlag = 1, | |||
Altitude = 40, | |||
GPSTime = DateTime.Parse("2018-07-15 10:10:10"), | |||
Lat = 12222222, | |||
Lng = 132444444, | |||
Speed = 60, | |||
Direction = 0, | |||
StatusFlag = 2, | |||
CustomLocationAttachData = new Dictionary<byte, JT808_0x0200_CustomBodyBase>() | |||
}; | |||
jT808UploadLocationRequest.CustomLocationAttachData.Add(JT808_GPS51_Constants.JT808_0x0200_0x54, new JT808_0x0200_0x54 | |||
{ | |||
AttachInfoId = 0x54, | |||
AttachInfoLength = 1, | |||
Count = 1, | |||
WifiInfos = new List<WifiInfo> { | |||
new WifiInfo{ | |||
SingnalStrength=12, | |||
WifiMac="E4FDA120FFF1" | |||
} | |||
} | |||
}); | |||
var hex = JT808Serializer.Serialize<JT808_0x0200>(jT808UploadLocationRequest).ToHexString(); | |||
Assert.Equal("000000010000000200BA7F0E07E4F11C0028003C0000180715101010540001E4FDA120FFF10C", hex); | |||
} | |||
[Fact] | |||
public void Deserialize() | |||
{ | |||
var jt808_0x0200 = JT808Serializer.Deserialize<JT808_0x0200>("000000010000000200BA7F0E07E4F11C0028003C0000180715101010540001E4FDA120FFF10C".ToHexBytes()); | |||
jt808_0x0200.CustomLocationAttachData.TryGetValue(JT808_GPS51_Constants.JT808_0x0200_0x54, out var value); | |||
var jt808_0x0200_0x54 = value as JT808_0x0200_0x54; | |||
Assert.Equal(12, jt808_0x0200_0x54.WifiInfos[0].SingnalStrength); | |||
Assert.Equal("E4FDA120FFF1", jt808_0x0200_0x54.WifiInfos[0].WifiMac); | |||
} | |||
[Fact] | |||
public void Deserialize1() | |||
{ | |||
//gps51 demo | |||
var jT808UploadLocationRequest = JT808Serializer.Deserialize<JT808Package>("7e020100f503570526020700331aa900000000200c00000159236c06cc037c007d020000010c21112213040001040000056f300119603d0601cc0024a402bb25153b01cc0024a40d1d0f4b0001cc0024a402bb25010001cc0024a40d1d0f4e0001cc0024a40d1d0f4f0001cc0024a40996ab4300542405f092b4a22a39ca70af6a1cc981c98ca6df48ce12c888403b68e784c7e4fda120fff0c4f026e60b05f092b4a22a39ca70af6a1cc981c98ca6df48ce12c888403b68e784c7e4fda120fff0c4fe3fe60200014807002a573130305f56312e3033443b4c54453a32353b47423a302c313b4d323a33302c3330303b423a342e303020000a898604811920701659546b7e".ToHexBytes()); | |||
var body0201 = jT808UploadLocationRequest.Bodies as JT808_0x0201; | |||
body0201.Position.CustomLocationAttachData.TryGetValue(JT808_GPS51_Constants.JT808_0x0200_0x54 ,out var value); | |||
var jt808_0x0200_0x54 = value as JT808_0x0200_0x54; | |||
Assert.Equal(202, jt808_0x0200_0x54.WifiInfos[0].SingnalStrength); | |||
Assert.Equal("F092B4A22A39", jt808_0x0200_0x54.WifiInfos[0].WifiMac); | |||
Assert.Equal(201, jt808_0x0200_0x54.WifiInfos[1].SingnalStrength); | |||
Assert.Equal("70AF6A1CC981", jt808_0x0200_0x54.WifiInfos[1].WifiMac); | |||
Assert.Equal(200, jt808_0x0200_0x54.WifiInfos[2].SingnalStrength); | |||
Assert.Equal("8CA6DF48CE12", jt808_0x0200_0x54.WifiInfos[2].WifiMac); | |||
Assert.Equal(199, jt808_0x0200_0x54.WifiInfos[3].SingnalStrength); | |||
Assert.Equal("88403B68E784", jt808_0x0200_0x54.WifiInfos[3].WifiMac); | |||
Assert.Equal(196, jt808_0x0200_0x54.WifiInfos[4].SingnalStrength); | |||
Assert.Equal("E4FDA120FFF0", jt808_0x0200_0x54.WifiInfos[4].WifiMac); | |||
} | |||
} | |||
} |
@@ -0,0 +1,69 @@ | |||
using JT808.Protocol.Extensions.GPS51.MessageBody; | |||
using JT808.Protocol.MessageBody; | |||
using Microsoft.Extensions.DependencyInjection; | |||
using System; | |||
using System.Collections.Generic; | |||
using Xunit; | |||
namespace JT808.Protocol.Extensions.GPS51.Test | |||
{ | |||
public class JT808_0x0200_0x58_Test | |||
{ | |||
JT808Serializer JT808Serializer; | |||
public JT808_0x0200_0x58_Test() | |||
{ | |||
ServiceCollection serviceDescriptors = new ServiceCollection(); | |||
serviceDescriptors.AddJT808Configure() | |||
.AddGPS51Configure(); | |||
IJT808Config jT808Config = serviceDescriptors.BuildServiceProvider().GetRequiredService<IJT808Config>(); | |||
JT808Serializer = new JT808Serializer(jT808Config); | |||
} | |||
[Fact] | |||
public void Serializer() | |||
{ | |||
JT808_0x0200 jT808UploadLocationRequest = new JT808_0x0200 | |||
{ | |||
AlarmFlag = 1, | |||
Altitude = 40, | |||
GPSTime = DateTime.Parse("2018-07-15 10:10:10"), | |||
Lat = 12222222, | |||
Lng = 132444444, | |||
Speed = 60, | |||
Direction = 0, | |||
StatusFlag = 2, | |||
CustomLocationAttachData = new Dictionary<byte, JT808_0x0200_CustomBodyBase>() | |||
}; | |||
jT808UploadLocationRequest.CustomLocationAttachData.Add(JT808_GPS51_Constants.JT808_0x0200_0x58, new JT808_0x0200_0x58 | |||
{ | |||
AttachInfoId = 0x58, | |||
AttachInfoLength = 1, | |||
Humiditys=new List<ushort> { | |||
12,34 | |||
} | |||
}); | |||
var hex = JT808Serializer.Serialize<JT808_0x0200>(jT808UploadLocationRequest).ToHexString(); | |||
Assert.Equal("000000010000000200BA7F0E07E4F11C0028003C00001807151010105804000C0022", hex); | |||
} | |||
[Fact] | |||
public void Deserialize() | |||
{ | |||
var jt808_0x0200 = JT808Serializer.Deserialize<JT808_0x0200>("000000010000000200BA7F0E07E4F11C0028003C00001807151010105804000C0022".ToHexBytes()); | |||
jt808_0x0200.CustomLocationAttachData.TryGetValue(JT808_GPS51_Constants.JT808_0x0200_0x58, out var value); | |||
var jt808_0x0200_0x58 = value as JT808_0x0200_0x58; | |||
Assert.Equal(new List<ushort> {12,34 }, jt808_0x0200_0x58.Humiditys.ToArray()); | |||
} | |||
[Fact] | |||
public void Deserialize1() | |||
{ | |||
//gps51 demo | |||
var jT808UploadLocationRequest = JT808Serializer.Deserialize<JT808Package>("7E0200005B0138916061090003000000000000000301595D5206C8EE4C038E000100001710191146400104000000942504000000005110010001010104010301040103010401045708000000000000000058100285026302700298029A027B02860281520103F300EB7E".ToHexBytes()); | |||
var body0200 = jT808UploadLocationRequest.Bodies as JT808_0x0200; | |||
body0200.CustomLocationAttachData.TryGetValue(JT808_GPS51_Constants.JT808_0x0200_0x58 ,out var value); | |||
var jt808_0x0200_0x58 = value as JT808_0x0200_0x58; | |||
//Assert.Equal(0x03, jt808_0x0200_0x58.Direction); | |||
Assert.Equal(new List<ushort> { 645, 611, 624, 664, 666, 635, 646, 641 }, jt808_0x0200_0x58.Humiditys.ToArray()); | |||
} | |||
} | |||
} |
@@ -0,0 +1,68 @@ | |||
using JT808.Protocol.Extensions.GPS51.MessageBody; | |||
using JT808.Protocol.MessageBody; | |||
using Microsoft.Extensions.DependencyInjection; | |||
using System; | |||
using System.Collections.Generic; | |||
using Xunit; | |||
namespace JT808.Protocol.Extensions.GPS51.Test | |||
{ | |||
public class JT808_0x0200_0x61_Test | |||
{ | |||
JT808Serializer JT808Serializer; | |||
public JT808_0x0200_0x61_Test() | |||
{ | |||
ServiceCollection serviceDescriptors = new ServiceCollection(); | |||
serviceDescriptors.AddJT808Configure() | |||
.AddGPS51Configure(); | |||
IJT808Config jT808Config = serviceDescriptors.BuildServiceProvider().GetRequiredService<IJT808Config>(); | |||
JT808Serializer = new JT808Serializer(jT808Config); | |||
} | |||
[Fact] | |||
public void Serializer() | |||
{ | |||
JT808_0x0200 jT808UploadLocationRequest = new JT808_0x0200 | |||
{ | |||
AlarmFlag = 1, | |||
Altitude = 40, | |||
GPSTime = DateTime.Parse("2018-07-15 10:10:10"), | |||
Lat = 12222222, | |||
Lng = 132444444, | |||
Speed = 60, | |||
Direction = 0, | |||
StatusFlag = 2, | |||
CustomLocationAttachData = new Dictionary<byte, JT808_0x0200_CustomBodyBase>() | |||
}; | |||
jT808UploadLocationRequest.CustomLocationAttachData.Add(JT808_GPS51_Constants.JT808_0x0200_0x61, new JT808_0x0200_0x61 | |||
{ | |||
AttachInfoId = 0x61, | |||
AttachInfoLength = 1, | |||
Volage = 200 | |||
}); | |||
var hex = JT808Serializer.Serialize<JT808_0x0200>(jT808UploadLocationRequest).ToHexString(); | |||
Assert.Equal("000000010000000200BA7F0E07E4F11C0028003C0000180715101010610100C8", hex); | |||
} | |||
[Fact] | |||
public void Deserialize() | |||
{ | |||
var jt808_0x0200 = JT808Serializer.Deserialize<JT808_0x0200>("000000010000000200BA7F0E07E4F11C0028003C0000180715101010610100C8".ToHexBytes()); | |||
jt808_0x0200.CustomLocationAttachData.TryGetValue(JT808_GPS51_Constants.JT808_0x0200_0x61, out var value); | |||
var jt808_0x0200_0x61 = value as JT808_0x0200_0x61; | |||
Assert.Equal(200, jt808_0x0200_0x61.Volage); | |||
} | |||
[Fact] | |||
public void Deserialize1() | |||
{ | |||
//gps51 demo | |||
var jT808UploadLocationRequest = JT808Serializer.Deserialize<JT808Package>("7e0200002c0138083582460440000000000000000301d37b35063f5e4901a0014a011b210917171126010400000c4530011531010461021d74a27e".ToHexBytes()); | |||
var body0200 = jT808UploadLocationRequest.Bodies as JT808_0x0200; | |||
body0200.CustomLocationAttachData.TryGetValue(JT808_GPS51_Constants.JT808_0x0200_0x61 ,out var value); | |||
var jt808_0x0200_0x61= value as JT808_0x0200_0x61; | |||
Assert.Equal(0x1d74, jt808_0x0200_0x61.Volage); | |||
} | |||
} | |||
} |
@@ -0,0 +1,80 @@ | |||
using JT808.Protocol.Extensions.GPS51.MessageBody; | |||
using JT808.Protocol.MessageBody; | |||
using Microsoft.Extensions.DependencyInjection; | |||
using System; | |||
using System.Collections.Generic; | |||
using Xunit; | |||
namespace JT808.Protocol.Extensions.GPS51.Test | |||
{ | |||
public class JT808_0x0200_0xe1_Test | |||
{ | |||
JT808Serializer JT808Serializer; | |||
public JT808_0x0200_0xe1_Test() | |||
{ | |||
ServiceCollection serviceDescriptors = new ServiceCollection(); | |||
serviceDescriptors.AddJT808Configure() | |||
.AddGPS51Configure(); | |||
IJT808Config jT808Config = serviceDescriptors.BuildServiceProvider().GetRequiredService<IJT808Config>(); | |||
JT808Serializer = new JT808Serializer(jT808Config); | |||
} | |||
[Fact] | |||
public void Serializer() | |||
{ | |||
JT808_0x0200 jT808UploadLocationRequest = new JT808_0x0200 | |||
{ | |||
AlarmFlag = 1, | |||
Altitude = 40, | |||
GPSTime = DateTime.Parse("2018-07-15 10:10:10"), | |||
Lat = 12222222, | |||
Lng = 132444444, | |||
Speed = 60, | |||
Direction = 0, | |||
StatusFlag = 2, | |||
CustomLocationAttachData = new Dictionary<byte, JT808_0x0200_CustomBodyBase>() | |||
}; | |||
jT808UploadLocationRequest.CustomLocationAttachData.Add(JT808_GPS51_Constants.JT808_0x0200_0xe1, new JT808_0x0200_0xe1 | |||
{ | |||
AttachInfoId = 0xe1, | |||
AttachInfoLength = 1, | |||
MCC = 1, | |||
MNC = 2, | |||
BaseStations = new List<BaseStation> { | |||
new BaseStation { | |||
LAC=3, | |||
CI=4, | |||
Signal=5, | |||
} | |||
} | |||
}); | |||
var hex = JT808Serializer.Serialize<JT808_0x0200>(jT808UploadLocationRequest).ToHexString(); | |||
Assert.Equal("000000010000000200BA7F0E07E4F11C0028003C0000180715101010E10A00010002000300000004", hex); | |||
} | |||
[Fact] | |||
public void Deserialize() | |||
{ | |||
var jt808_0x0200 = JT808Serializer.Deserialize<JT808_0x0200>("000000010000000200BA7F0E07E4F11C0028003C0000180715101010E10A00010002000300000004".ToHexBytes()); | |||
jt808_0x0200.CustomLocationAttachData.TryGetValue(JT808_GPS51_Constants.JT808_0x0200_0xe1, out var value); | |||
var jt808_0x0200_0xe1 = value as JT808_0x0200_0xe1; | |||
Assert.Equal(1, jt808_0x0200_0xe1.MCC); | |||
Assert.Equal(2, jt808_0x0200_0xe1.MNC); | |||
Assert.Equal(3, jt808_0x0200_0xe1.BaseStations[0].LAC); | |||
Assert.Equal<uint>(4, jt808_0x0200_0xe1.BaseStations[0].CI); | |||
if (jt808_0x0200_0xe1.BaseStations.Count != 1) { | |||
Assert.Equal(5, jt808_0x0200_0xe1.BaseStations[0].Signal); | |||
} | |||
} | |||
[Fact] | |||
public void Deserialize1() | |||
{ | |||
//gps51 demo | |||
var jT808UploadLocationRequest = JT808Serializer.Deserialize<JT808Package>("7e020000440186070970130dfe0000000000040002019279fa06d5f408001a00000000210917084332e10a01cc0000696a0863a8d0e41701000000000000810e3c756e6b6e6f776e20737369643e3101393f7e".ToHexBytes()); | |||
var body0200 = jT808UploadLocationRequest.Bodies as JT808_0x0200; | |||
body0200.CustomLocationAttachData.TryGetValue(JT808_GPS51_Constants.JT808_0x0200_0xe1 ,out var value); | |||
var jt808_0x0200_0xe1= value as JT808_0x0200_0xe1; | |||
Assert.Equal(Newtonsoft.Json.JsonConvert.SerializeObject(jt808_0x0200_0xe1), "{\"AttachInfoId\":225,\"AttachInfoLength\":10,\"MCC\":460,\"MNC\":0,\"BaseStations\":[{\"LAC\":26986,\"CI\":140749008,\"Signal\":0}]}"); | |||
} | |||
} | |||
} |
@@ -0,0 +1,68 @@ | |||
using JT808.Protocol.Extensions.GPS51.MessageBody; | |||
using JT808.Protocol.MessageBody; | |||
using Microsoft.Extensions.DependencyInjection; | |||
using System; | |||
using System.Collections.Generic; | |||
using Xunit; | |||
namespace JT808.Protocol.Extensions.GPS51.Test | |||
{ | |||
public class JT808_0x0200_0xe2_Test | |||
{ | |||
JT808Serializer JT808Serializer; | |||
public JT808_0x0200_0xe2_Test() | |||
{ | |||
ServiceCollection serviceDescriptors = new ServiceCollection(); | |||
serviceDescriptors.AddJT808Configure() | |||
.AddGPS51Configure(); | |||
IJT808Config jT808Config = serviceDescriptors.BuildServiceProvider().GetRequiredService<IJT808Config>(); | |||
JT808Serializer = new JT808Serializer(jT808Config); | |||
} | |||
[Fact] | |||
public void Serializer() | |||
{ | |||
JT808_0x0200 jT808UploadLocationRequest = new JT808_0x0200 | |||
{ | |||
AlarmFlag = 1, | |||
Altitude = 40, | |||
GPSTime = DateTime.Parse("2018-07-15 10:10:10"), | |||
Lat = 12222222, | |||
Lng = 132444444, | |||
Speed = 60, | |||
Direction = 0, | |||
StatusFlag = 2, | |||
CustomLocationAttachData = new Dictionary<byte, JT808_0x0200_CustomBodyBase>() | |||
}; | |||
jT808UploadLocationRequest.CustomLocationAttachData.Add(JT808_GPS51_Constants.JT808_0x0200_0xe2, new JT808_0x0200_0xe2 | |||
{ | |||
AttachInfoId = 0xe2, | |||
AttachInfoLength = 1, | |||
Version = "123123" | |||
}); | |||
var hex = JT808Serializer.Serialize<JT808_0x0200>(jT808UploadLocationRequest).ToHexString(); | |||
Assert.Equal("000000010000000200BA7F0E07E4F11C0028003C0000180715101010E206313233313233", hex); | |||
} | |||
[Fact] | |||
public void Deserialize() | |||
{ | |||
var jt808_0x0200 = JT808Serializer.Deserialize<JT808_0x0200>("000000010000000200BA7F0E07E4F11C0028003C0000180715101010E206313233313233".ToHexBytes()); | |||
jt808_0x0200.CustomLocationAttachData.TryGetValue(JT808_GPS51_Constants.JT808_0x0200_0xe2, out var value); | |||
var jt808_0x0200_0xe2 = value as JT808_0x0200_0xe2; | |||
Assert.Equal("123123", jt808_0x0200_0xe2.Version); | |||
} | |||
[Fact] | |||
public void Deserialize1() | |||
{ | |||
//gps51 demo | |||
var jT808UploadLocationRequest = JT808Serializer.Deserialize<JT808Package>("7e02004043010000086061575429591701bc00000000000c00030158ae9606c9069600000000006b21091717255901040000000130011931010a610204dce21547423230312d47534d2d32313030312d312e312e31c57e".ToHexBytes()); | |||
var body0200 = jT808UploadLocationRequest.Bodies as JT808_0x0200; | |||
body0200.CustomLocationAttachData.TryGetValue(JT808_GPS51_Constants.JT808_0x0200_0xe2 ,out var value); | |||
var jt808_0x0200_0xe2 = value as JT808_0x0200_0xe2; | |||
Assert.Equal("GB201-GSM-21001-1.1.1", jt808_0x0200_0xe2.Version); | |||
} | |||
} | |||
} |
@@ -0,0 +1,68 @@ | |||
using JT808.Protocol.Extensions.GPS51.MessageBody; | |||
using JT808.Protocol.MessageBody; | |||
using Microsoft.Extensions.DependencyInjection; | |||
using System; | |||
using System.Collections.Generic; | |||
using Xunit; | |||
namespace JT808.Protocol.Extensions.GPS51.Test | |||
{ | |||
public class JT808_0x0200_0xf1_Test | |||
{ | |||
JT808Serializer JT808Serializer; | |||
public JT808_0x0200_0xf1_Test() | |||
{ | |||
ServiceCollection serviceDescriptors = new ServiceCollection(); | |||
serviceDescriptors.AddJT808Configure() | |||
.AddGPS51Configure(); | |||
IJT808Config jT808Config = serviceDescriptors.BuildServiceProvider().GetRequiredService<IJT808Config>(); | |||
JT808Serializer = new JT808Serializer(jT808Config); | |||
} | |||
[Fact] | |||
public void Serializer() | |||
{ | |||
JT808_0x0200 jT808UploadLocationRequest = new JT808_0x0200 | |||
{ | |||
AlarmFlag = 1, | |||
Altitude = 40, | |||
GPSTime = DateTime.Parse("2018-07-15 10:10:10"), | |||
Lat = 12222222, | |||
Lng = 132444444, | |||
Speed = 60, | |||
Direction = 0, | |||
StatusFlag = 2, | |||
CustomLocationAttachData = new Dictionary<byte, JT808_0x0200_CustomBodyBase>() | |||
}; | |||
jT808UploadLocationRequest.CustomLocationAttachData.Add(JT808_GPS51_Constants.JT808_0x0200_0xf1, new JT808_0x0200_0xf1 | |||
{ | |||
AttachInfoId = 0xf1, | |||
AttachInfoLength = 1, | |||
ICCID = "123456789" | |||
}); | |||
var hex = JT808Serializer.Serialize<JT808_0x0200>(jT808UploadLocationRequest).ToHexString(); | |||
Assert.Equal("000000010000000200BA7F0E07E4F11C0028003C0000180715101010F109313233343536373839", hex); | |||
} | |||
[Fact] | |||
public void Deserialize() | |||
{ | |||
var jt808_0x0200 = JT808Serializer.Deserialize<JT808_0x0200>("000000010000000200BA7F0E07E4F11C0028003C0000180715101010F109313233343536373839".ToHexBytes()); | |||
jt808_0x0200.CustomLocationAttachData.TryGetValue(JT808_GPS51_Constants.JT808_0x0200_0xf1, out var value); | |||
var jt808_0x0200_0xf1 = value as JT808_0x0200_0xf1; | |||
Assert.Equal("123456789", jt808_0x0200_0xf1.ICCID); | |||
} | |||
[Fact] | |||
public void Deserialize1() | |||
{ | |||
//gps51 demo | |||
var jT808UploadLocationRequest = JT808Serializer.Deserialize<JT808Package>("7e0200003e0112036008780002000000000000000202728ebb07228d4e013c0000000021091700003301040003ab262b0400000000f1143839383630343032313032303930393737303032e77e".ToHexBytes()); | |||
var body0200 = jT808UploadLocationRequest.Bodies as JT808_0x0200; | |||
body0200.CustomLocationAttachData.TryGetValue(JT808_GPS51_Constants.JT808_0x0200_0xf1 ,out var value); | |||
var jt808_0x0200_0xf1 = value as JT808_0x0200_0xf1; | |||
Assert.Equal("89860402102090977002", jt808_0x0200_0xf1.ICCID); | |||
} | |||
} | |||
} |
@@ -0,0 +1,62 @@ | |||
using JT808.Protocol.Extensions.GPS51.MessageBody; | |||
using JT808.Protocol.MessageBody; | |||
using Microsoft.Extensions.DependencyInjection; | |||
using System; | |||
using System.Collections.Generic; | |||
using Xunit; | |||
namespace JT808.Protocol.Extensions.GPS51.Test | |||
{ | |||
public class JT808_0x0200_0xf6_Test | |||
{ | |||
JT808Serializer JT808Serializer; | |||
public JT808_0x0200_0xf6_Test() | |||
{ | |||
ServiceCollection serviceDescriptors = new ServiceCollection(); | |||
serviceDescriptors.AddJT808Configure() | |||
.AddGPS51Configure(); | |||
IJT808Config jT808Config = serviceDescriptors.BuildServiceProvider().GetRequiredService<IJT808Config>(); | |||
JT808Serializer = new JT808Serializer(jT808Config); | |||
} | |||
[Fact] | |||
public void Serializer() | |||
{ | |||
JT808_0x0200 jT808UploadLocationRequest = new JT808_0x0200 | |||
{ | |||
AlarmFlag = 1, | |||
Altitude = 40, | |||
GPSTime = DateTime.Parse("2018-07-15 10:10:10"), | |||
Lat = 12222222, | |||
Lng = 132444444, | |||
Speed = 60, | |||
Direction = 0, | |||
StatusFlag = 2, | |||
CustomLocationAttachData = new Dictionary<byte, JT808_0x0200_CustomBodyBase>() | |||
}; | |||
jT808UploadLocationRequest.CustomLocationAttachData.Add(JT808_GPS51_Constants.JT808_0x0200_0xf6, new JT808_0x0200_0xf6 | |||
{ | |||
AttachInfoId = 0xf6, | |||
AttachInfoLength = 1, | |||
IMEI = "12345678" | |||
}); | |||
var hex = JT808Serializer.Serialize<JT808_0x0200>(jT808UploadLocationRequest).ToHexString(); | |||
Assert.Equal("000000010000000200BA7F0E07E4F11C0028003C0000180715101010F6083132333435363738", hex); | |||
} | |||
[Fact] | |||
public void Deserialize() | |||
{ | |||
var jt808_0x0200 = JT808Serializer.Deserialize<JT808_0x0200>("000000010000000200BA7F0E07E4F11C0028003C0000180715101010F6083132333435363738".ToHexBytes()); | |||
jt808_0x0200.CustomLocationAttachData.TryGetValue(JT808_GPS51_Constants.JT808_0x0200_0xf6, out var value); | |||
var jt808_0x0200_0xf6 = value as JT808_0x0200_0xf6; | |||
Assert.Equal("12345678", jt808_0x0200_0xf6.IMEI); | |||
} | |||
[Fact] | |||
public void Deserialize1() | |||
{ | |||
//gps51 demo | |||
} | |||
} | |||
} |
@@ -0,0 +1,67 @@ | |||
using JT808.Protocol.Extensions.GPS51.MessageBody; | |||
using JT808.Protocol.MessageBody; | |||
using Microsoft.Extensions.DependencyInjection; | |||
using System; | |||
using System.Collections.Generic; | |||
using Xunit; | |||
namespace JT808.Protocol.Extensions.GPS51.Test | |||
{ | |||
public class JT808_0x0200_0xfa_Test | |||
{ | |||
JT808Serializer JT808Serializer; | |||
public JT808_0x0200_0xfa_Test() | |||
{ | |||
ServiceCollection serviceDescriptors = new ServiceCollection(); | |||
serviceDescriptors.AddJT808Configure() | |||
.AddGPS51Configure(); | |||
IJT808Config jT808Config = serviceDescriptors.BuildServiceProvider().GetRequiredService<IJT808Config>(); | |||
JT808Serializer = new JT808Serializer(jT808Config); | |||
} | |||
[Fact] | |||
public void Serializer() | |||
{ | |||
JT808_0x0200 jT808UploadLocationRequest = new JT808_0x0200 | |||
{ | |||
AlarmFlag = 1, | |||
Altitude = 40, | |||
GPSTime = DateTime.Parse("2018-07-15 10:10:10"), | |||
Lat = 12222222, | |||
Lng = 132444444, | |||
Speed = 60, | |||
Direction = 0, | |||
StatusFlag = 2, | |||
CustomLocationAttachData = new Dictionary<byte, JT808_0x0200_CustomBodyBase>() | |||
}; | |||
jT808UploadLocationRequest.CustomLocationAttachData.Add(JT808_GPS51_Constants.JT808_0x0200_0xfa, new JT808_0x0200_0xfa | |||
{ | |||
AttachInfoId = 0xfa, | |||
AttachInfoLength = 1, | |||
Alarm = 1234 | |||
}); | |||
var hex = JT808Serializer.Serialize<JT808_0x0200>(jT808UploadLocationRequest).ToHexString(); | |||
Assert.Equal("000000010000000200BA7F0E07E4F11C0028003C0000180715101010FA04000004D2", hex); | |||
} | |||
[Fact] | |||
public void Deserialize() | |||
{ | |||
var jt808_0x0200 = JT808Serializer.Deserialize<JT808_0x0200>("000000010000000200BA7F0E07E4F11C0028003C0000180715101010FA04000004D2".ToHexBytes()); | |||
jt808_0x0200.CustomLocationAttachData.TryGetValue(JT808_GPS51_Constants.JT808_0x0200_0xfa, out var value); | |||
var jt808_0x0200_0xfa = value as JT808_0x0200_0xfa; | |||
Assert.Equal(1234u, jt808_0x0200_0xfa.Alarm); | |||
} | |||
[Fact] | |||
public void Deserialize1() | |||
{ | |||
//gps51 demo | |||
var jT808UploadLocationRequest = JT808Serializer.Deserialize<JT808Package>("7e0200006701300001111100d200010000800c00c101585b2406c96b7000000000000021101117593601040012d6ee0202000003020000140480000005150400000008160400000000170200072504000000002b040000000030011f310100ef0d49249249260049249202221103fa0400000001937e".ToHexBytes()); | |||
var body0200 = jT808UploadLocationRequest.Bodies as JT808_0x0200; | |||
body0200.CustomLocationAttachData.TryGetValue(JT808_GPS51_Constants.JT808_0x0200_0xfa ,out var value); | |||
var jt808_0x0200_0xfa = value as JT808_0x0200_0xfa; | |||
Assert.Equal(1u, jt808_0x0200_0xfa.Alarm); | |||
} | |||
} | |||
} |
@@ -0,0 +1,72 @@ | |||
using JT808.Protocol.Extensions.GPS51.MessageBody; | |||
using JT808.Protocol.MessageBody; | |||
using Microsoft.Extensions.DependencyInjection; | |||
using System; | |||
using System.Collections.Generic; | |||
using Xunit; | |||
namespace JT808.Protocol.Extensions.GPS51.Test | |||
{ | |||
public class JT808_0x0200_0xfb_Test | |||
{ | |||
JT808Serializer JT808Serializer; | |||
public JT808_0x0200_0xfb_Test() | |||
{ | |||
ServiceCollection serviceDescriptors = new ServiceCollection(); | |||
serviceDescriptors.AddJT808Configure() | |||
.AddGPS51Configure(); | |||
IJT808Config jT808Config = serviceDescriptors.BuildServiceProvider().GetRequiredService<IJT808Config>(); | |||
JT808Serializer = new JT808Serializer(jT808Config); | |||
} | |||
[Fact] | |||
public void Serializer() | |||
{ | |||
JT808_0x0200 jT808UploadLocationRequest = new JT808_0x0200 | |||
{ | |||
AlarmFlag = 1, | |||
Altitude = 40, | |||
GPSTime = DateTime.Parse("2018-07-15 10:10:10"), | |||
Lat = 12222222, | |||
Lng = 132444444, | |||
Speed = 60, | |||
Direction = 0, | |||
StatusFlag = 2, | |||
CustomLocationAttachData = new Dictionary<byte, JT808_0x0200_CustomBodyBase>() | |||
}; | |||
jT808UploadLocationRequest.CustomLocationAttachData.Add(JT808_GPS51_Constants.JT808_0x0200_0xfb, new JT808_0x0200_0xfb | |||
{ | |||
AttachInfoId = 0xfb, | |||
AttachInfoLength = 1, | |||
Power = 1234, | |||
PowerPercent=90, | |||
Status=3, | |||
}); | |||
var hex = JT808Serializer.Serialize<JT808_0x0200>(jT808UploadLocationRequest).ToHexString(); | |||
Assert.Equal("000000010000000200BA7F0E07E4F11C0028003C0000180715101010FB045A04D203", hex); | |||
} | |||
[Fact] | |||
public void Deserialize() | |||
{ | |||
var jt808_0x0200 = JT808Serializer.Deserialize<JT808_0x0200>("000000010000000200BA7F0E07E4F11C0028003C0000180715101010FB045A04D203".ToHexBytes()); | |||
jt808_0x0200.CustomLocationAttachData.TryGetValue(JT808_GPS51_Constants.JT808_0x0200_0xfb, out var value); | |||
var jt808_0x0200_0xfb = value as JT808_0x0200_0xfb; | |||
Assert.Equal(1234, jt808_0x0200_0xfb.Power); | |||
Assert.Equal(90, jt808_0x0200_0xfb.PowerPercent); | |||
Assert.Equal(3, jt808_0x0200_0xfb.Status); | |||
} | |||
[Fact] | |||
public void Deserialize1() | |||
{ | |||
//gps51 demo | |||
var jT808UploadLocationRequest = JT808Serializer.Deserialize<JT808Package>("7e0200002f04121051313003940000000000002002015fe78006c325d50013000a00a0210924172909010400029d0f2a0200042b0450680014520103fb045F050701097e".ToHexBytes()); | |||
var body0200 = jT808UploadLocationRequest.Bodies as JT808_0x0200; | |||
body0200.CustomLocationAttachData.TryGetValue(JT808_GPS51_Constants.JT808_0x0200_0xfb ,out var value); | |||
var jt808_0x0200_0xfb = value as JT808_0x0200_0xfb; | |||
Assert.Equal(0x5F, jt808_0x0200_0xfb.PowerPercent); | |||
Assert.Equal(0x0507, jt808_0x0200_0xfb.Power); | |||
Assert.Equal(0x01, jt808_0x0200_0xfb.Status); | |||
} | |||
} | |||
} |
@@ -376,6 +376,11 @@ | |||
<param name="value"></param> | |||
<param name="config"></param> | |||
</member> | |||
<member name="P:JT808.Protocol.Extensions.GPS51.MessageBody.WifiInfo.WifiMac"> | |||
<summary> | |||
wifimac | |||
</summary> | |||
</member> | |||
<member name="P:JT808.Protocol.Extensions.GPS51.MessageBody.WifiInfo.SingnalStrength"> | |||
<summary> | |||
信号轻度 | |||
@@ -48,12 +48,18 @@ namespace JT808.Protocol.Extensions.GPS51.MessageBody | |||
value.AttachInfoLength = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.AttachInfoLength.ReadNumber()}]附加信息长度", value.AttachInfoLength); | |||
value.Count = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.Count.ReadNumber()}]Wifi数量", value.Count); | |||
writer.WriteStartArray(); | |||
for (int i = 0; i < value.Count; i++) | |||
{ | |||
// writer.WriteString($"[{value.Direction.ReadNumber()}]正反转", "未知"); | |||
writer.WriteStartObject(); | |||
var wifimac = reader.ReadArray(6).ToArray().ToHexString(); | |||
writer.WriteString($"[{wifimac}]WifiMac", wifimac); | |||
var signalstrength = reader.ReadByte(); | |||
writer.WriteNumber($"[{signalstrength.ReadNumber()}]信号强度", signalstrength); | |||
writer.WriteEndObject(); | |||
} | |||
writer.WriteEndArray(); | |||
} | |||
/// <summary> | |||
/// | |||
@@ -67,11 +73,14 @@ namespace JT808.Protocol.Extensions.GPS51.MessageBody | |||
value.AttachInfoId = reader.ReadByte(); | |||
value.AttachInfoLength = reader.ReadByte(); | |||
value.Count = reader.ReadByte(); | |||
value.WifiInfos = new List<WifiInfo>(); | |||
for (int i = 0; i < value.Count; i++) | |||
{ | |||
// | |||
value.WifiInfos.Add(new WifiInfo | |||
{ | |||
WifiMac = reader.ReadArray(6).ToArray().ToHexString(), | |||
SingnalStrength = reader.ReadByte() | |||
}); | |||
} | |||
return value; | |||
} | |||
@@ -84,17 +93,21 @@ namespace JT808.Protocol.Extensions.GPS51.MessageBody | |||
public override void Serialize(ref JT808MessagePackWriter writer, JT808_0x0200_0x54 value, IJT808Config config) | |||
{ | |||
writer.WriteByte(value.AttachInfoId); | |||
writer.WriteByte(1); | |||
writer.Skip(1,out int position); | |||
writer.WriteByte((byte)value.WifiInfos.Count); | |||
foreach (var wifi in value.WifiInfos) | |||
{ | |||
writer.WriteArray(wifi.WifiMac.ToHexBytes()); | |||
writer.WriteByte(wifi.SingnalStrength); | |||
} | |||
} | |||
} | |||
public class WifiInfo { | |||
/// <summary> | |||
/// wifimac | |||
/// </summary> | |||
public string WifiMac { get; set; } | |||
/// <summary> | |||
/// 信号轻度 | |||
/// </summary> | |||
@@ -45,7 +45,7 @@ namespace JT808.Protocol.Extensions.GPS51.MessageBody | |||
writer.WriteNumber($"[{value.AttachInfoLength.ReadNumber()}]附加信息长度", value.AttachInfoLength); | |||
writer.WriteNumber($"[{reader.ReadContent(value.AttachInfoLength).ToArray().ToHexString()}]湿度列表", value.AttachInfoLength / 2); | |||
writer.WriteStartArray(); | |||
while (reader.ReadCurrentRemainContentLength() > 0) { | |||
for (int i = 0; i < value.AttachInfoLength / 2; i++) { | |||
writer.WriteNumber($"[{reader.ReadUInt16().ReadNumber()}]附加信息长度", reader.ReadUInt16()); | |||
} | |||
writer.WriteStartArray(); | |||
@@ -63,7 +63,7 @@ namespace JT808.Protocol.Extensions.GPS51.MessageBody | |||
value.AttachInfoId = reader.ReadByte(); | |||
value.AttachInfoLength = reader.ReadByte(); | |||
value.Humiditys = new List<ushort>(); | |||
while (reader.ReadCurrentRemainContentLength() > 0) | |||
for (int i = 0; i < value.AttachInfoLength/2; i++) | |||
{ | |||
value.Humiditys.Add(reader.ReadUInt16()); | |||
} | |||
@@ -48,21 +48,27 @@ namespace JT808.Protocol.Extensions.GPS51.MessageBody | |||
value.AttachInfoId = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.AttachInfoId.ReadNumber()}]附加信息Id", value.AttachInfoId); | |||
value.AttachInfoLength = reader.ReadByte(); | |||
int length = value.AttachInfoLength; | |||
writer.WriteNumber($"[{value.AttachInfoLength.ReadNumber()}]附加信息长度", value.AttachInfoLength); | |||
value.MCC = reader.ReadUInt16(); | |||
length = length - 2; | |||
writer.WriteNumber($"[{value.MCC.ReadNumber()}]国家编码", value.MCC); | |||
value.MNC=reader.ReadUInt16(); | |||
length = length - 2; | |||
writer.WriteNumber($"[{value.MNC.ReadNumber()}]网络编码", value.MNC); | |||
writer.WriteStartArray("地区编码列表"); | |||
while (reader.ReadCurrentRemainContentLength() > 0) | |||
while (length > 0) | |||
{ | |||
var LAC = reader.ReadUInt16(); | |||
length = length - 2; | |||
writer.WriteNumber($"[{LAC.ReadNumber()}]地区编码", LAC); | |||
var CI = reader.ReadUInt32(); | |||
length = length - 4; | |||
writer.WriteNumber($"[{CI.ReadNumber()}]蜂窝 ID", CI); | |||
if (reader.ReadCurrentRemainContentLength() > 0) | |||
if (length > 0) | |||
{ | |||
var Signal = reader.ReadByte(); | |||
length = length - 1; | |||
writer.WriteNumber($"[{Signal.ReadNumber()}]信号强度", Signal); | |||
} | |||
} | |||
@@ -80,17 +86,23 @@ namespace JT808.Protocol.Extensions.GPS51.MessageBody | |||
JT808_0x0200_0xe1 value = new JT808_0x0200_0xe1(); | |||
value.AttachInfoId = reader.ReadByte(); | |||
value.AttachInfoLength = reader.ReadByte(); | |||
if (value.AttachInfoLength > 0) { | |||
int length = value.AttachInfoLength; | |||
if (length > 0) { | |||
value.MCC = reader.ReadUInt16(); | |||
length= length - 2; | |||
value.MNC = reader.ReadUInt16(); | |||
length = length - 2; | |||
value.BaseStations = new List<BaseStation>(); | |||
while (reader.ReadCurrentRemainContentLength()> 0) | |||
while (length > 0) | |||
{ | |||
BaseStation baseStation = new BaseStation(); | |||
baseStation.LAC = reader.ReadUInt16(); | |||
length = length - 2; | |||
baseStation.CI = reader.ReadUInt32(); | |||
if (reader.ReadCurrentRemainContentLength() > 0) { | |||
length = length - 4; | |||
if (length > 0) { | |||
baseStation.Signal=reader.ReadByte(); | |||
length = length - 1; | |||
} | |||
value.BaseStations.Add(baseStation); | |||
} | |||
@@ -44,7 +44,7 @@ namespace JT808.Protocol.Extensions.GPS51.MessageBody | |||
value.AttachInfoLength = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.AttachInfoLength.ReadNumber()}]附加信息长度", value.AttachInfoLength); | |||
var version = reader.ReadVirtualArray(value.AttachInfoLength); | |||
writer.WriteString($"[{version.ToArray().ToHexString()}]版本号", reader.ReadRemainStringContent()); | |||
writer.WriteString($"[{version.ToArray().ToHexString()}]版本号", reader.ReadString(value.AttachInfoLength)); | |||
} | |||
/// <summary> | |||
/// | |||
@@ -57,7 +57,7 @@ namespace JT808.Protocol.Extensions.GPS51.MessageBody | |||
JT808_0x0200_0xe2 value = new JT808_0x0200_0xe2(); | |||
value.AttachInfoId = reader.ReadByte(); | |||
value.AttachInfoLength = reader.ReadByte(); | |||
value.Version = reader.ReadRemainStringContent(); | |||
value.Version = reader.ReadString(value.AttachInfoLength); | |||
return value; | |||
} | |||
/// <summary> | |||
@@ -45,7 +45,7 @@ namespace JT808.Protocol.Extensions.GPS51.MessageBody | |||
value.AttachInfoLength = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.AttachInfoLength.ReadNumber()}]附加信息长度", value.AttachInfoLength); | |||
var iccid = reader.ReadVirtualArray(value.AttachInfoLength); | |||
writer.WriteString($"[{iccid.ToArray().ToHexString()}]ICCID", reader.ReadRemainStringContent()); | |||
writer.WriteString($"[{iccid.ToArray().ToHexString()}]ICCID", reader.ReadString(value.AttachInfoLength)); | |||
} | |||
/// <summary> | |||
/// | |||
@@ -58,7 +58,7 @@ namespace JT808.Protocol.Extensions.GPS51.MessageBody | |||
JT808_0x0200_0xf1 value = new JT808_0x0200_0xf1(); | |||
value.AttachInfoId = reader.ReadByte(); | |||
value.AttachInfoLength = reader.ReadByte(); | |||
value.ICCID = reader.ReadRemainStringContent(); | |||
value.ICCID = reader.ReadString(value.AttachInfoLength); | |||
return value; | |||
} | |||
/// <summary> | |||
@@ -44,7 +44,7 @@ namespace JT808.Protocol.Extensions.GPS51.MessageBody | |||
value.AttachInfoLength = reader.ReadByte(); | |||
writer.WriteNumber($"[{value.AttachInfoLength.ReadNumber()}]附加信息长度", value.AttachInfoLength); | |||
var imei = reader.ReadVirtualArray(value.AttachInfoLength); | |||
writer.WriteString($"[{imei.ToArray().ToHexString()}]IMEI", reader.ReadRemainStringContent()); | |||
writer.WriteString($"[{imei.ToArray().ToHexString()}]IMEI", reader.ReadString(value.AttachInfoLength)); | |||
} | |||
/// <summary> | |||
/// | |||
@@ -57,7 +57,7 @@ namespace JT808.Protocol.Extensions.GPS51.MessageBody | |||
JT808_0x0200_0xf6 value = new JT808_0x0200_0xf6(); | |||
value.AttachInfoId = reader.ReadByte(); | |||
value.AttachInfoLength = reader.ReadByte(); | |||
value.IMEI = reader.ReadRemainStringContent(); | |||
value.IMEI = reader.ReadString(value.AttachInfoLength); | |||
return value; | |||
} | |||
/// <summary> | |||