public void Test1() { JT809Package jT809Package = new JT809Package(); jT809Package.Header = new JT809Header { EncryptFlag = JT809Header_Encrypt.Common, MsgSN = 133, EncryptKey = 256178, BusinessType = JT809BusinessType.主链路登录请求消息.ToUInt16Value(), MsgGNSSCENTERID = 20180920, }; JT809_0x1001 jT809_0X1001 = new JT809_0x1001(); jT809_0X1001.UserId = 20180920; jT809_0X1001.Password = "******"; jT809_0X1001.DownLinkIP = "127.0.0.1"; jT809_0X1001.DownLinkPort = 809; jT809Package.Bodies = jT809_0X1001; var hex = JT809Serializer.Serialize(jT809Package).ToHexString(); //"5B 00 00 00 48 00 00 00 85 10 01 01 33 EF B8 01 00 00 01 00 00 16 BB D3 7D 9C C4 90 0C 77 DC 78 F8 67 65 27 D8 AE 12 24 3C FB 64 CC 2F BA 61 9A EF AD 33 AC CB 32 56 F6 7B FF 19 DF 33 09 78 41 09 86 65 70 3F 2E B5 5D" //5B000000480000008510010133EFB8010000010003E8B2 0133EFB832303138303932303132372E302E302E3100000000000000000000000000000000000000000000000329 03C5 5D //5B000000480000008510010133EFB8010000010003E8B2 D37D9CC4900C77DC78F8676527D8AE12243CFB64CC2FBA619AEFAD33ACCB3256F67BFF19DF33097841098665703F E36E 5D Assert.Equal("5B000000480000008510010133EFB8010000010003E8B2D37D9CC4900C77DC78F8676527D8AE12243CFB64CC2FBA619AEFAD33ACCB3256F67BFF19DF33097841098665703FE36E5D", hex); }
public void Test1() { JT809_0x1001 jT809_0X1001 = new JT809_0x1001(); jT809_0X1001.UserId = 20180920; jT809_0X1001.Password = "******"; jT809_0X1001.DownLinkIP = "127.0.0.1"; jT809_0X1001.DownLinkPort = 809; var hex = JT809Serializer.Serialize(jT809_0X1001).ToHexString(); Assert.Equal("0133EFB832303138303932303132372E302E302E3100000000000000000000000000000000000000000000000329", hex); //5B //00 00 00 48 //00 00 00 85 //10 01 //01 33 53 D5 //01 00 00 //00 //00 00 27 0F //01 33 EF B8 //32 30 31 38 30 39 32 30 //31 32 37 2E 30 2E 30 2E 31 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 //03 29 //C3 0D //5D //"01 33 EF B8 //32 30 31 38 30 39 32 30 //31 32 37 2E 30 2E 30 2E 31 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 //03 29" }
public void Test2() { var bytes = "01 33 EF B8 32 30 31 38 30 39 32 30 31 32 37 2E 30 2E 30 2E 31 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 03 29".ToHexBytes(); JT809_0x1001 jT809_0X1001 = JT809Serializer.Deserialize <JT809_0x1001>(bytes); Assert.Equal((uint)20180920, jT809_0X1001.UserId); Assert.Equal("20180920", jT809_0X1001.Password); Assert.Equal("127.0.0.1", jT809_0X1001.DownLinkIP); Assert.Equal((ushort)809, jT809_0X1001.DownLinkPort); }
public void Test_2019_2() { var bytes = "0133EFB8323031383039323002A7DD233132372E302E302E3100000000000000000000000000000000000000000000000329".ToHexBytes(); JT809_0x1001 jT809_0X1001 = JT809_2019_Serializer.Deserialize <JT809_0x1001>(bytes); Assert.Equal(20180920u, jT809_0X1001.UserId); Assert.Equal("20180920", jT809_0X1001.Password); Assert.Equal("127.0.0.1", jT809_0X1001.DownLinkIP); Assert.Equal(809u, jT809_0X1001.DownLinkPort); Assert.Equal(44555555u, jT809_0X1001.MsgGNSSCENTERID); }
public async Task <bool> Login( string ip, int port, JT809_0x1001 jT809_0x1001) { if (disposed) { return(await Task.FromResult(false)); } logger.LogInformation($"ip:{ip},port:{port}"); this._jT809_0x1001 = jT809_0x1001; this.iPEndPoint = new IPEndPoint(IPAddress.Parse(ip), port); bool successed = false; try { //IPAddress[] hostinfo = Dns.GetHostAddresses(host); //IPAddress address = hostinfo[0]; if (channel == null) { channel = await bootstrap.ConnectAsync(iPEndPoint); successed = channel.Open && channel.Active; if (channel.Open && channel.Active) { //JT809.Protocol.MessageBody.JT809_0x1001 jT809_0X1001 = jT809_0X1001 new Protocol.MessageBody.JT809_0x1001(); //jT809_0X1001.DownLinkIP = downLinkIP; //jT809_0X1001.DownLinkPort = downLinkPort; //jT809_0X1001.UserId = userId; //jT809_0X1001.Password = password; var package = Protocol.Enums.JT809BusinessType.主链路登录请求消息.Create(new JT809Header { MsgGNSSCENTERID = config.HeaderOptions.MsgGNSSCENTERID }, _jT809_0x1001); await channel.WriteAndFlushAsync(new JT809Response(package, 256)); //await channel.WriteAsync(new JT809Response(package, 100)); logger.LogInformation("等待登录应答结果..."); manualResetEvent.Pause(); } } } catch (AggregateException ex) { logger.LogError(ex.InnerException, $"ip:{ip},port:{port}"); } catch (Exception ex) { logger.LogError(ex, $"ip:{ip},port:{port}"); } return(await Task.FromResult(successed)); }
public void Test_2019_1() { JT809_0x1001 jT809_0X1001 = new JT809_0x1001(); jT809_0X1001.UserId = 20180920; jT809_0X1001.Password = "******"; jT809_0X1001.MsgGNSSCENTERID = 44555555; jT809_0X1001.DownLinkIP = "127.0.0.1"; jT809_0X1001.DownLinkPort = 809; var hex = JT809_2019_Serializer.Serialize(jT809_0X1001).ToHexString(); Assert.Equal("0133EFB8323031383039323002A7DD233132372E302E302E3100000000000000000000000000000000000000000000000329", hex); }
public void Test1() { var bytes = "5B 00 00 00 48 00 00 00 85 10 01 01 33 EF B8 01 00 00 00 00 00 27 0F 01 33 EF B8 32 30 31 38 30 39 32 30 31 32 37 2E 30 2E 30 2E 31 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 03 29 6A 91 5D".ToHexBytes(); JT809HeaderPackage jT809HeaderPackage = JT809Serializer.Deserialize <JT809HeaderPackage>(bytes); Assert.Equal((uint)72, jT809HeaderPackage.Header.MsgLength); Assert.Equal((uint)133, jT809HeaderPackage.Header.MsgSN); Assert.Equal((uint)9999, jT809HeaderPackage.Header.EncryptKey); Assert.Equal((uint)20180920, jT809HeaderPackage.Header.MsgGNSSCENTERID); Assert.Equal(JT809BusinessType.主链路登录请求消息, (JT809BusinessType)jT809HeaderPackage.Header.BusinessType); Assert.Equal(new JT809Header_Version().ToString(), jT809HeaderPackage.Header.Version.ToString()); JT809_0x1001 jT809_0X1001 = JT809Serializer.Deserialize <JT809_0x1001>(jT809HeaderPackage.Bodies); Assert.Equal((uint)20180920, jT809_0X1001.UserId); Assert.Equal("20180920", jT809_0X1001.Password); Assert.Equal("127.0.0.1", jT809_0X1001.DownLinkIP); Assert.Equal((ushort)809, jT809_0X1001.DownLinkPort); }
public void Test2() { var bytes = "5B000000480000008510010133EFB8010000010003E8B2D37D9CC4900C77DC78F8676527D8AE12243CFB64CC2FBA619AEFAD33ACCB3256F67BFF19DF33097841098665703FE36E5D".ToHexBytes(); JT809Package jT809Package = JT809Serializer.Deserialize(bytes); Assert.Equal(JT809Header_Encrypt.Common, jT809Package.Header.EncryptFlag); Assert.Equal((uint)256178, jT809Package.Header.EncryptKey); Assert.Equal((uint)72, jT809Package.Header.MsgLength); Assert.Equal((uint)133, jT809Package.Header.MsgSN); Assert.Equal((uint)20180920, jT809Package.Header.MsgGNSSCENTERID); Assert.Equal(JT809BusinessType.主链路登录请求消息, jT809Package.Header.BusinessType); Assert.Equal("1.0.0", jT809Package.Header.Version.ToString()); JT809_0x1001 jT809_0X1001 = (JT809_0x1001)jT809Package.Bodies; Assert.Equal((uint)20180920, jT809_0X1001.UserId); Assert.Equal("20180920", jT809_0X1001.Password); Assert.Equal("127.0.0.1", jT809_0X1001.DownLinkIP); Assert.Equal((ushort)809, jT809_0X1001.DownLinkPort); }
public void Test1() { JT809Package jT809Package = new JT809Package(); jT809Package.Header = new JT809Header { MsgSN = 133, EncryptKey = 9999, BusinessType = JT809BusinessType.主链路登录请求消息.ToUInt16Value(), MsgGNSSCENTERID = 20180920, }; JT809_0x1001 jT809_0X1001 = new JT809_0x1001(); jT809_0X1001.UserId = 20180920; jT809_0X1001.Password = "******"; jT809_0X1001.DownLinkIP = "127.0.0.1"; jT809_0X1001.DownLinkPort = 809; jT809Package.Bodies = jT809_0X1001; var hex = JT809Serializer.Serialize(jT809Package).ToHexString(); //5B000000 4800000085 10010133EFB801 000000000027 0F0133EFB8 323031383 039323031 32372 E302E302E31 00000000000000000000000000000000000000000000000329 4055 5D //5B000000 4800000085 10010133EFB801 000000000027 0F0133EFB8 323031383 039323031 32372 E302E302E31 00000000000000000000000000000000000000000000000329 6A91 5D Assert.Equal("5B000000480000008510010133EFB8010000000000270F0133EFB832303138303932303132372E302E302E31000000000000000000000000000000000000000000000003296A915D", hex); //"5B //00 00 00 48 //00 00 00 85 //10 01 //01 33 EF B8 //01 00 00 //00 //00 00 27 0F //01 33 EF B8 //32 30 31 38 30 39 32 30 //31 32 37 2E 30 2E 30 2E 31 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 //03 29 //6A 91 //5D" }