Esempio n. 1
0
        public void Test1()
        {
            JT809Package jT809Package = new JT809Package();

            jT809Package.Header = new JT809Header
            {
                MsgSN           = 1666,
                EncryptKey      = 9999,
                EncryptFlag     = JT809Header_Encrypt.None,
                Version         = new JT809Header_Version(1, 0, 0),
                BusinessType    = JT809_JT1078_BusinessType.主链路时效口令业务类.ToUInt16Value(),
                MsgGNSSCENTERID = 20190708,
                Time            = DateTime.Parse("2020-04-26 12:02:00")
            };
            JT808_JT1078_0x1700 bodies = new JT808_JT1078_0x1700
            {
                VehicleNo       = "粤A12345",
                VehicleColor    = JT809VehicleColorType.黄色,
                SubBusinessType = JT809_JT1078_SubBusinessType.时效口令上报消息.ToUInt16Value(),
            };
            JT808_JT1078_0x1700_0x1701 jT808_JT1078_0x1700_0x1701 = new JT808_JT1078_0x1700_0x1701
            {
                PlateFormId = new byte[11] {
                    0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10, 0x11
                },
                AuthorizeCode1 = new byte[64],
                AuthorizeCode2 = new byte[64]
            };

            bodies.SubBodies    = jT808_JT1078_0x1700_0x1701;
            jT809Package.Bodies = bodies;
            var hex = JT809_2019_Serializer.Serialize(jT809Package).ToHexString();

            Assert.Equal("5B000000C9000006821700013415F4010000000000270F000000005E02A507B8D4C1413132333435000000000000000000000000000217010000008B01020304050607080910110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000E7D35D", hex);
        }
Esempio n. 2
0
        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);
        }
 protected override void ChannelRead0(IChannelHandlerContext ctx, byte[] msg)
 {
     try
     {
         JT809Package jT809Package = JT809Serializer.Deserialize(msg);
         jT809AtomicCounterService.MsgSuccessIncrement();
         if (logger.IsEnabled(LogLevel.Debug))
         {
             logger.LogDebug("accept package success count<<<" + jT809AtomicCounterService.MsgSuccessCount.ToString());
         }
         Func <JT809Request, JT809Response> handlerFunc;
         if (handler.HandlerDict.TryGetValue(jT809Package.Header.BusinessType, out handlerFunc))
         {
             JT809Response jT808Response = handlerFunc(new JT809Request(jT809Package, msg));
             if (jT808Response != null)
             {
                 ctx.WriteAndFlushAsync(jT808Response);
             }
         }
     }
     catch (JT809Exception ex)
     {
         jT809AtomicCounterService.MsgFailIncrement();
         logger.LogError("accept package fail count<<<" + jT809AtomicCounterService.MsgFailCount.ToString());
         logger.LogError(ex, "accept msg<<<" + ByteBufferUtil.HexDump(msg));
     }
     catch (Exception ex)
     {
         jT809AtomicCounterService.MsgFailIncrement();
         logger.LogError("accept package fail count<<<" + jT809AtomicCounterService.MsgFailCount.ToString());
         logger.LogError(ex, "accept msg<<<" + ByteBufferUtil.HexDump(msg));
     }
 }
Esempio n. 4
0
        public void Test2()
        {
            var package = new JT809Package
            {
                Header = new JT809Header
                {
                    BusinessType    = 0x1102,
                    MsgGNSSCENTERID = 10086,
                    Time            = DateTime.Parse("2020-07-08 17:46:44"),
                    Version         = new JT809Header_Version(0, 0, 0),
                },
                Bodies = new JT809_0x1102
                {
                    SubBusinessType = 0x1102,
                    DataLength      = 36,
                    PlateformId     = "3000012345",
                    StartTime       = DateTime.Parse("2020-07-08 17:46:44"),
                    EndTime         = DateTime.Parse("2020-07-08 17:46:44"),
                    LoseDymamicSum  = 0,
                    DisconnectNum   = 10,
                    DisconnectTime  = 30,
                }
            };

            Assert.Equal("5B0000004C000000011102000027660000000000000000000000005F0596041102000000243330303030313233343500000000005F059604000000005F059604000000000A0000001E17B45D", JT809_2019_Serializer.Serialize(package).ToHexString());
        }
Esempio n. 5
0
        public void Test2()
        {
            var          bytes        = "5B 00 00 00 92 00 00 06 82 94 00 01 33 EF B8 01 00 00 00 00 00 27 0F D4 C1 41 31 32 33 34 35 00 00 00 00 00 00 00 00 00 00 00 00 00 02 94 01 00 00 00 5C 01 00 02 00 00 00 00 5A 01 AC 3F 40 12 3F FA A1 00 00 00 00 5A 01 AC 4D 50 03 73 6D 61 6C 6C 63 68 69 00 00 00 00 00 00 00 00 31 32 33 34 35 36 37 38 39 30 31 00 00 00 00 00 00 00 00 00 31 32 33 34 35 36 40 71 71 2E 63 6F 6D 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 BA D8 5D".ToHexBytes();
            JT809Package jT809Package = JT809Serializer.Deserialize(bytes);

            Assert.Equal((uint)146, jT809Package.Header.MsgLength);
            Assert.Equal((uint)1666, jT809Package.Header.MsgSN);
            Assert.Equal((uint)9999, jT809Package.Header.EncryptKey);
            Assert.Equal(JT809Header_Encrypt.None, jT809Package.Header.EncryptFlag);
            Assert.Equal((uint)20180920, jT809Package.Header.MsgGNSSCENTERID);
            Assert.Equal(JT809BusinessType.从链路报警信息交互消息, (JT809BusinessType)jT809Package.Header.BusinessType);
            Assert.Equal(new JT809Header_Version().ToString(), jT809Package.Header.Version.ToString());

            JT809_0x9400 jT809_0X400 = (JT809_0x9400)jT809Package.Bodies;

            Assert.Equal("粤A12345", jT809_0X400.VehicleNo);
            Assert.Equal(JT809VehicleColorType.黄色, jT809_0X400.VehicleColor);
            Assert.Equal(JT809SubBusinessType.报警督办请求, (JT809SubBusinessType)jT809_0X400.SubBusinessType);
            Assert.Equal((uint)92, jT809_0X400.DataLength);

            JT809_0x9400_0x9401 jT809_0x9400_0x9401 = (JT809_0x9400_0x9401)jT809_0X400.SubBodies;

            Assert.Equal(JT809WarnSrc.车载终端, jT809_0x9400_0x9401.WarnSrc);
            Assert.Equal(JT809WarnType.疲劳驾驶报警, (JT809WarnType)jT809_0x9400_0x9401.WarnType);
            Assert.Equal(DateTime.Parse("2018-09-27 10:24:00"), jT809_0x9400_0x9401.WarnTime);
            Assert.Equal("123FFAA1", jT809_0x9400_0x9401.SupervisionID);
            Assert.Equal(DateTime.Parse("2018-09-27 11:24:00"), jT809_0x9400_0x9401.SupervisionEndTime);
            Assert.Equal(3, jT809_0x9400_0x9401.SupervisionLevel);
            Assert.Equal("smallchi", jT809_0x9400_0x9401.Supervisor);
            Assert.Equal("12345678901", jT809_0x9400_0x9401.SupervisorTel);
            Assert.Equal("*****@*****.**", jT809_0x9400_0x9401.SupervisorEmail);
        }
Esempio n. 6
0
        public void Test3()
        {
            JT809Serializer JT809SerializerTest3 = new JT809Serializer();
            JT809Package    jT809Package         = JT809BusinessType.从链路报警信息交互消息.Create(new JT809_0x9400
            {
                VehicleNo       = "粤A12345",
                VehicleColor    = JT809VehicleColorType.黄色,
                SubBusinessType = JT809SubBusinessType.报警督办请求.ToUInt16Value(),
                SubBodies       = new JT809_0x9400_0x9401
                {
                    WarnSrc            = JT809WarnSrc.车载终端,
                    WarnType           = JT809WarnType.疲劳驾驶报警.ToUInt16Value(),
                    WarnTime           = DateTime.Parse("2018-09-27 10:24:00"),
                    SupervisionID      = "123FFAA1",
                    SupervisionEndTime = DateTime.Parse("2018-09-27 11:24:00"),
                    SupervisionLevel   = 3,
                    Supervisor         = "smallchi",
                    SupervisorTel      = "12345678901",
                    SupervisorEmail    = "*****@*****.**"
                }
            });

            jT809Package.Header.MsgSN           = 1666;
            jT809Package.Header.EncryptKey      = 9999;
            jT809Package.Header.MsgGNSSCENTERID = 20180920;
            var hex = JT809SerializerTest3.Serialize(jT809Package).ToHexString();

            //"5B000000920000068294000133EFB8010000000000270FD4C1413132333435000000000000000000000000000294010000005C010002000000005A01AC3F40123FFAA1000000005A01AC4D5003736D616C6C636869000000000000000031323334353637383930310000000000000000003132333435364071712E636F6D00000000000000000000000000000000000000BAD85D"
            Assert.Equal("5B000000920000068294000133EFB8010000000000270FD4C1413132333435000000000000000000000000000294010000005C010002000000005A01AC3F40123FFAA1000000005A01AC4D5003736D616C6C636869000000000000000031323334353637383930310000000000000000003132333435364071712E636F6D00000000000000000000000000000000000000BAD85D", hex);
        }
        public JT809Package Msg0x1005(IChannelHandlerContext channelHandlerContext)
        {
            JT809Package heartbeatPackage = JT809BusinessType.主链路连接保持请求消息.Create();

            byte[] sendHeartbeatData = JT809Serializer.Serialize(heartbeatPackage, 100);
            channelHandlerContext.WriteAndFlushAsync(Unpooled.WrappedBuffer(sendHeartbeatData));
            return(heartbeatPackage);
        }
Esempio n. 8
0
        public static JT809Package Create(this ushort jT809BusinessType)
        {
            JT809Package jT809Package = new JT809Package();

            jT809Package.Header = new JT809Header()
            {
                BusinessType = jT809BusinessType,
            };
            return(jT809Package);
        }
Esempio n. 9
0
        public static JT809Package Create <TJT809Bodies>(this JT809BusinessType jT809BusinessType, TJT809Bodies jT809Bodies)
            where TJT809Bodies : JT809Bodies
        {
            JT809Package jT809Package = new JT809Package();

            jT809Package.Bodies = jT809Bodies;
            jT809Package.Header = new JT809Header()
            {
                BusinessType = (ushort)jT809BusinessType
            };
            return(jT809Package);
        }
        public JT809Package Msg0x1003(IChannel channel)
        {
            JT809Package logoutPackage = JT809BusinessType.主链路注销请求消息.Create(new JT809_0x1003
            {
                UserId   = 1234,
                Password = "******",
            });

            byte[] sendLoginData = JT809Serializer.Serialize(logoutPackage, 128);
            channel.WriteAndFlushAsync(Unpooled.WrappedBuffer(sendLoginData));
            Status = ConnectionStatus.级平台主链路已发送注销请求;
            return(logoutPackage);
        }
        public JT809Package Msg0x1003(IChannelHandlerContext channelHandlerContext)
        {
            JT809Package loginPackage = JT809BusinessType.主链路登录请求消息.Create(new JT809_0x1001
            {
                UserId       = 1234,
                Password     = "******",
                DownLinkIP   = "127.0.0.1",
                DownLinkPort = 8091
            });

            byte[] sendLoginData = JT809Serializer.Serialize(loginPackage, 256);
            channelHandlerContext.WriteAndFlushAsync(Unpooled.WrappedBuffer(sendLoginData));
            return(loginPackage);
        }
Esempio n. 12
0
        public void Test1()
        {
            var          bytes = "5B0000002F000004579200000004570101010000000000000000004EBC924F9201000000070400000004000189DA5D".ToHexBytes();
            JT809Package jT809_0X9200_0X9201 = JT809_2019_Serializer.Deserialize(bytes);
            var          body    = jT809_0X9200_0X9201.Bodies as JT809_0x9200;
            var          subBody = body.SubBodies as JT809_0x9200_0x9201;

            Assert.NotNull(body);
            Assert.NotNull(subBody);
            Assert.Equal(JT809VehicleColorType.其他, body.VehicleColor);
            Assert.Equal(JT809_0x9201_Result.审核通过_完成注册, subBody.Result);
            Assert.Equal(1024u, subBody.MsgSn);
            Assert.Equal(1024u, subBody.DataType);
        }
Esempio n. 13
0
        public static JT809Package Create(this JT809BusinessType jT809BusinessType)
        {
            JT809Package jT809Package = new JT809Package();

            jT809Package.Header = new JT809Header()
            {
                BusinessType    = jT809BusinessType,
                MsgSN           = JT809GlobalConfig.Instance.MsgSNDistributed.Increment(),
                EncryptFlag     = JT809GlobalConfig.Instance.HeaderOptions.EncryptFlag,
                EncryptKey      = JT809GlobalConfig.Instance.HeaderOptions.EncryptKey,
                MsgGNSSCENTERID = JT809GlobalConfig.Instance.HeaderOptions.MsgGNSSCENTERID,
                Version         = JT809GlobalConfig.Instance.HeaderOptions.Version
            };
            return(jT809Package);
        }
Esempio n. 14
0
        public static JT809Package Create(this JT809BusinessType jT809BusinessType, JT809Header jT809Header)
        {
            JT809Package jT809Package = new JT809Package();

            jT809Package.Header = new JT809Header()
            {
                BusinessType    = (ushort)jT809BusinessType,
                MsgSN           = jT809Header.MsgSN,
                EncryptFlag     = jT809Header.EncryptFlag,
                EncryptKey      = jT809Header.EncryptKey,
                MsgGNSSCENTERID = jT809Header.MsgGNSSCENTERID,
                Version         = jT809Header.Version
            };
            return(jT809Package);
        }
Esempio n. 15
0
        public void Test1()
        {
            var          bytes        = "5B00000044000004571200000004570101010000000000000000004EBC924FB2E2CAD43131313100000000000000000000000000041205040000000400000000001B735D".ToHexBytes();
            JT809Package jT809Package = JT809_2019_Serializer.Deserialize(bytes);
            var          body         = jT809Package.Bodies as JT809_0x1200;
            var          subBody      = body.SubBodies as JT809_0x1200_0x1205;

            Assert.NotNull(body);
            Assert.NotNull(subBody);
            Assert.Equal("测试1111", body.VehicleNo);
            Assert.Equal(JT809VehicleColorType.白色, body.VehicleColor);
            Assert.Equal(1024u, subBody.SourceDataType);
            Assert.Equal(1024u, subBody.SourceMsgSN);
            Assert.Equal(0u, subBody.DataLength);
        }
Esempio n. 16
0
        public static JT809Package Create <TJT809Bodies>(this ushort jT809BusinessType, JT809Header jT809Header, TJT809Bodies jT809Bodies)
            where TJT809Bodies : JT809Bodies
        {
            JT809Package jT809Package = new JT809Package();

            jT809Package.Bodies = jT809Bodies;
            jT809Package.Header = new JT809Header()
            {
                BusinessType    = jT809BusinessType,
                MsgSN           = jT809Header.MsgSN,
                EncryptFlag     = jT809Header.EncryptFlag,
                EncryptKey      = jT809Header.EncryptKey,
                MsgGNSSCENTERID = jT809Header.MsgGNSSCENTERID,
                Version         = jT809Header.Version
            };
            return(jT809Package);
        }
Esempio n. 17
0
        public void Create_0x1001_Test()
        {
            JT809Package jT809Package = JT809BusinessType.主链路登录请求消息.Create_主链路登录请求消息(new JT809Header
            {
                MsgSN           = 133,
                EncryptKey      = 9999,
                MsgGNSSCENTERID = 20180920,
            }, new MessageBody.JT809_0x1001
            {
                UserId       = 20180920,
                Password     = "******",
                DownLinkIP   = "127.0.0.1",
                DownLinkPort = 809
            });
            var hex = JT809Serializer.Serialize(jT809Package).ToHexString();

            Assert.Equal("5B000000480000008510010133EFB8010000000000270F0133EFB832303138303932303132372E302E302E31000000000000000000000000000000000000000000000003296A915D", hex);
        }
Esempio n. 18
0
        public void Test2()
        {
            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();
            JT809Package jT809Package = JT809Serializer.Deserialize(bytes);

            Assert.Equal((uint)72, jT809Package.Header.MsgLength);
            Assert.Equal((uint)133, jT809Package.Header.MsgSN);
            Assert.Equal((uint)9999, jT809Package.Header.EncryptKey);
            Assert.Equal((uint)20180920, jT809Package.Header.MsgGNSSCENTERID);
            Assert.Equal(JT809BusinessType.主链路登录请求消息, jT809Package.Header.BusinessType);
            Assert.Equal(new JT809Header_Version().ToString(), 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 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);
        }
Esempio n. 20
0
 protected override async void ChannelRead0(IChannelHandlerContext ctx, byte[] msg)
 {
     try
     {
         JT809Package jT809Package = JT809Serializer.Deserialize(msg);
         jT809AtomicCounterService.MsgSuccessIncrement();
         if (logger.IsEnabled(LogLevel.Debug))
         {
             logger.LogDebug("accept package success count<<<" + jT809AtomicCounterService.MsgSuccessCount.ToString());
         }
         SuperiorMainSessionManager.TryAdd(ctx.Channel, jT809Package.Header.MsgGNSSCENTERID);
         Func <JT809Request, JT809Response> handlerFunc;
         if (handler.HandlerDict.TryGetValue(jT809Package.Header.BusinessType, out handlerFunc))
         {
             JT809Response jT808Response = handlerFunc(new JT809Request(jT809Package, msg));
             if (jT808Response != null)
             {
                 var sendData = JT809Serializer.Serialize(jT808Response.Package, jT808Response.MinBufferSize);
                 await ctx.WriteAndFlushAsync(Unpooled.WrappedBuffer(sendData));
             }
         }
     }
     catch (JT809Exception ex)
     {
         jT809AtomicCounterService.MsgFailIncrement();
         if (logger.IsEnabled(LogLevel.Error))
         {
             logger.LogError("accept package fail count<<<" + jT809AtomicCounterService.MsgFailCount.ToString());
             logger.LogError(ex, "accept msg<<<" + ByteBufferUtil.HexDump(msg));
         }
     }
     catch (Exception ex)
     {
         jT809AtomicCounterService.MsgFailIncrement();
         if (logger.IsEnabled(LogLevel.Error))
         {
             logger.LogError("accept package fail count<<<" + jT809AtomicCounterService.MsgFailCount.ToString());
             logger.LogError(ex, "accept msg<<<" + ByteBufferUtil.HexDump(msg));
         }
     }
 }
        public void Test1()
        {
            JT809Package jT809Package = new JT809Package();

            jT809Package.Header = new JT809Header
            {
                MsgSN           = 1666,
                EncryptKey      = 9999,
                EncryptFlag     = JT809Header_Encrypt.None,
                Version         = new JT809Header_Version(1, 0, 0),
                BusinessType    = JT809BusinessType.从链路报警信息交互消息,
                MsgGNSSCENTERID = 20180920,
            };

            JT809_0x9400 bodies = new JT809_0x9400
            {
                VehicleNo       = "粤A12345",
                VehicleColor    = JT809VehicleColorType.黄色,
                SubBusinessType = JT809SubBusinessType.报警督办请求,
            };

            JT809_0x9400_0x9401 jT809_0x9400_0x9401 = new JT809_0x9400_0x9401
            {
                WarnSrc            = JT809WarnSrc.车载终端,
                WarnType           = JT809WarnType.疲劳驾驶报警,
                WarnTime           = DateTime.Parse("2018-09-27 10:24:00"),
                SupervisionID      = "123FFAA1",
                SupervisionEndTime = DateTime.Parse("2018-09-27 11:24:00"),
                SupervisionLevel   = 3,
                Supervisor         = "smallchi",
                SupervisorTel      = "12345678901",
                SupervisorEmail    = "*****@*****.**"
            };

            bodies.SubBodies    = jT809_0x9400_0x9401;
            jT809Package.Bodies = bodies;
            var hex = JT809Serializer.Serialize(jT809Package).ToHexString();

            //"5B 00 00 00 92 00 00 06 82 94 00 01 33 EF B8 01 00 00 00 00 00 27 0F D4 C1 41 31 32 33 34 35 00 00 00 00 00 00 00 00 00 00 00 00 00 02 94 01 00 00 00 5C 01 00 02 00 00 00 00 5A 01 AC 3F 40 12 3F FA A1 00 00 00 00 5A 01 AC 4D 50 03 73 6D 61 6C 6C 63 68 69 00 00 00 00 00 00 00 00 31 32 33 34 35 36 37 38 39 30 31 00 00 00 00 00 00 00 00 00 31 32 33 34 35 36 40 71 71 2E 63 6F 6D 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 BA D8 5D"
            Assert.Equal("5B000000920000068294000133EFB8010000000000270FD4C1413132333435000000000000000000000000000294010000005C010002000000005A01AC3F40123FFAA1000000005A01AC4D5003736D616C6C636869000000000000000031323334353637383930310000000000000000003132333435364071712E636F6D00000000000000000000000000000000000000BAD85D", hex);
        }
Esempio n. 22
0
        public void Test2()
        {
            var          data         = "5B000000C9000006821700013415F4010000000000270F000000005E02A507B8D4C1413132333435000000000000000000000000000217010000008B01020304050607080910110000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000E7D35D".ToHexBytes();
            JT809Package jT809Package = JT809_2019_Serializer.Deserialize(data);

            Assert.Equal((uint)1666, jT809Package.Header.MsgSN);
            Assert.Equal((uint)9999, jT809Package.Header.EncryptKey);
            Assert.Equal(JT809Header_Encrypt.None, jT809Package.Header.EncryptFlag);
            Assert.Equal(new JT809Header_Version(1, 0, 0).ToString(), jT809Package.Header.Version.ToString());
            Assert.Equal(DateTime.Parse("2020-04-26 12:02:00"), jT809Package.Header.Time);
            Assert.Equal(0x1700, jT809Package.Header.BusinessType);
            Assert.Equal((uint)20190708, jT809Package.Header.MsgGNSSCENTERID);
            JT809ExchangeMessageBodies bodies    = jT809Package.Bodies as JT809ExchangeMessageBodies;
            JT808_JT1078_0x1700_0x1701 subBodies = bodies.SubBodies as JT808_JT1078_0x1700_0x1701;

            Assert.Equal(new byte[11] {
                0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10, 0x11
            }, subBodies.PlateFormId);
            Assert.Equal(new byte[64], subBodies.AuthorizeCode1);
            Assert.Equal(new byte[64], subBodies.AuthorizeCode2);
        }
Esempio n. 23
0
        public void Parse809Test1()
        {
            var result = jTToolsController.Parse809(new JT809RequestDto()
            {
                IsEncrypt      = true,
                EncryptOptions = new JT809EncryptOptions
                {
                    IA1 = 96135846,
                    IC1 = 30000000,
                    M1  = 10000079
                },
                HexData = "5B 00 00 00 73 00 00 17 3B 12 00 02 A2 49 7F 01 02 0F 01 00 00 00 01 AC 84 2A 2C 11 20 47 CA 38 E1 DD 75 BE EE F8 03 D5 7A B8 17 C7 C0 43 3C D0 85 6D 94 EA E0 00 5A 01 23 68 A6 D6 DB A1 0B 49 F6 CB 74 C6 61 F6 D6 6A 80 C4 D2 B1 10 40 AE 48 7E 96 3A 8D 0F ED 7A 1B 2D 82 00 41 B9 BE 0A E7 8C D6 AB 7D B7 79 2E 8A 7F 17 AE B8 0A 9F AE AA A2 75 A4 5D"
            });
            JT809Package package      = (JT809Package)result.Value.Data;
            JT809_0x1200 jT809_0X1200 = (JT809_0x1200)package.Bodies;

            Assert.Equal(44190079u, package.Header.MsgGNSSCENTERID);
            Assert.Equal(30116, package.CRCCode);
            Assert.Equal("таSEB408╡Б", jT809_0X1200.VehicleNo);
            Assert.Equal(JT809VehicleColorType.╩фи╚, jT809_0X1200.VehicleColor);
        }
Esempio n. 24
0
        public void JT809_0x9400_0x9401_Package_Serialize_Test()
        {
            for (int i = 0; i < N; i++)
            {
                JT809Package jT809Package = new JT809Package();

                jT809Package.Header = new JT809Header
                {
                    MsgSN           = 1666,
                    EncryptKey      = 9999,
                    EncryptFlag     = JT809Header_Encrypt.None,
                    Version         = new JT809Header_Version(1, 0, 0),
                    BusinessType    = (ushort)JT809BusinessType.从链路报警信息交互消息,
                    MsgGNSSCENTERID = 20180920,
                };

                JT809_0x9400 bodies = new JT809_0x9400
                {
                    VehicleNo       = "粤A12345",
                    VehicleColor    = JT809VehicleColorType.黄色,
                    SubBusinessType = JT809SubBusinessType.报警督办请求消息.ToUInt16Value(),
                };

                JT809_0x9400_0x9401 jT809_0x9400_0x9401 = new JT809_0x9400_0x9401
                {
                    WarnSrc            = JT809WarnSrc.车载终端,
                    WarnType           = JT809WarnType.疲劳驾驶报警.ToUInt16Value(),
                    WarnTime           = DateTime.Parse("2018-09-27 10:24:00"),
                    SupervisionID      = "123FFAA1",
                    SupervisionEndTime = DateTime.Parse("2018-09-27 11:24:00"),
                    SupervisionLevel   = JT809_9401_SupervisionLevel.一般,
                    Supervisor         = "smallchi",
                    SupervisorTel      = "12345678901",
                    SupervisorEmail    = "*****@*****.**"
                };
                bodies.SubBodies    = jT809_0x9400_0x9401;
                jT809Package.Bodies = bodies;
                var hex = JT809Serializer.Serialize(jT809Package);
            }
        }
Esempio n. 25
0
        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"
        }
Esempio n. 26
0
        public void Test_2019_3()
        {
            JT809Package jT809Package = new JT809Package();

            jT809Package.Header = new JT809Header
            {
                MsgSN           = 1666,
                EncryptKey      = 9999,
                EncryptFlag     = JT809Header_Encrypt.None,
                Version         = new JT809Header_Version(1, 0, 0),
                BusinessType    = JT809BusinessType.主链路车辆动态信息交换业务.ToUInt16Value(),
                MsgGNSSCENTERID = 20190708,
                Time            = DateTime.Parse("2020-04-26 12:02:00")
            };
            JT809_0x1200 jT809_0X1200 = new JT809_0x1200();

            jT809_0X1200.VehicleNo       = "粤A12345";
            jT809_0X1200.VehicleColor    = JT809VehicleColorType.蓝色;
            jT809_0X1200.SubBusinessType = JT809SubBusinessType.车辆注册信息.ToUInt16Value();
            jT809_0X1200.DataLength      = 110;
            JT809_0x1200_0x1201 jT809_0X1200_0X1201 = new JT809_0x1200_0x1201
            {
                PlateformId       = "1111111111",
                ProducerId        = "1111111111",
                TerminalId        = "11111AA",
                TerminalModelType = "11111111",
                TerminalSimCode   = "222222222222",
                IMIEId            = "123456789"
            };

            jT809_0X1200.SubBodies = jT809_0X1200_0X1201;
            jT809Package.Bodies    = jT809_0X1200;

            var hex = JT809_2019_Serializer.Serialize(jT809Package).ToHexString();

            Assert.Equal("5B000000AC000006821200013415F4010000000000270F000000005E02A507B8D4C1413132333435000000000000000000000000000112010000006E31313131313131313131003131313131313131313100313131313131313100000000000000000000000000000000000000000000313233343536373839000000000000313131313141410000000000000000000000000000000000000000000000323232323232323232323232006D7A5D", hex);
        }
        public void Create_JT809_0x9400_0x9401_Test()
        {
            JT809Package jT809Package = JT809BusinessType.从链路报警信息交互消息.Create_从链路报警信息交互消息(
                new JT809Header
            {
                MsgSN           = 1666,
                EncryptKey      = 9999,
                EncryptFlag     = JT809Header_Encrypt.None,
                Version         = new JT809Header_Version(1, 0, 0),
                MsgGNSSCENTERID = 20180920,
            }, new JT809_0x9400
            {
                VehicleNo       = "粤A12345",
                VehicleColor    = JT809VehicleColorType.黄色,
                SubBusinessType = JT809SubBusinessType.报警督办请求消息.ToUInt16Value(),
                SubBodies       = JT809SubBusinessType.报警督办请求消息.Create_报警督办请求消息(
                    new JT809_0x9400_0x9401
                {
                    WarnSrc            = JT809WarnSrc.车载终端,
                    WarnType           = JT809WarnType.疲劳驾驶报警.ToUInt16Value(),
                    WarnTime           = DateTime.Parse("2018-09-27 10:24:00"),
                    SupervisionID      = "123FFAA1",
                    SupervisionEndTime = DateTime.Parse("2018-09-27 11:24:00"),
                    SupervisionLevel   = JT809_9401_SupervisionLevel.一般,
                    Supervisor         = "smallchi",
                    SupervisorTel      = "12345678901",
                    SupervisorEmail    = "*****@*****.**"
                })
            }
                );
            var hex = JT809Serializer.Serialize(jT809Package).ToHexString();

            //5B0000007C0000068294000133EFB8010000000000270F94010000005C010002000000005A01AC3F40123FFAA1000000005A01AC4D5003736D616C6C636869000000000000000031323334353637383930310000000000000000003132333435364071712E636F6D00000000000000000000000000000000000000A6565D
            //5B000000920000068294000133EFB8010000000000270FD4C1413132333435000000000000000000000000000294010000005C010002000000005A01AC3F40123FFAA1000000005A01AC4D5003736D616C6C636869000000000000000031323334353637383930310000000000000000003132333435364071712E636F6D00000000000000000000000000000000000000BAD85D
            Assert.Equal("5B000000920000068294000133EFB8010000000000270FD4C1413132333435000000000000000000000000000294010000005C010002000000005A01AC3F40123FFAA1000000005A01AC4D5001736D616C6C636869000000000000000031323334353637383930310000000000000000003132333435364071712E636F6D000000000000000000000000000000000000007AEA5D", hex);
        }
Esempio n. 28
0
        public void Test1()
        {
            var          bytes        = "5B0000004C000000011102000027660000000000000000000000005F0596041102000000243330303030313233343500000000005F059604000000005F059604000000000A0000001E17B45D".ToHexBytes();
            JT809Package jT809Package = JT809_2019_Serializer.Deserialize(bytes);

            Assert.Equal((uint)1, jT809Package.Header.MsgSN);
            Assert.Equal((ushort)0x1102, jT809Package.Header.BusinessType);
            Assert.Equal((uint)10086, jT809Package.Header.MsgGNSSCENTERID);
            Assert.Equal((uint)76, jT809Package.Header.MsgLength);
            Assert.Equal("0.0.0", jT809Package.Header.Version.ToString());
            Assert.Equal(DateTime.Parse("2020-07-08 17:46:44"), jT809Package.Header.Time);

            var body = jT809Package.Bodies as JT809_0x1102;

            Assert.NotNull(body);
            Assert.Equal((ushort)0x1102, body.MsgId);
            Assert.Equal((uint)36, body.DataLength);
            Assert.Equal("3000012345", body.PlateformId);
            Assert.Equal(DateTime.Parse("2020-07-08 17:46:44"), body.StartTime);
            Assert.Equal(DateTime.Parse("2020-07-08 17:46:44"), body.EndTime);
            Assert.Equal((uint)0, body.LoseDymamicSum);
            Assert.Equal((byte)10, body.DisconnectNum);
            Assert.Equal((uint)30, body.DisconnectTime);
        }
Esempio n. 29
0
 public JT809Request(JT809Package package, byte[] originalPackage)
 {
     Package         = package;
     OriginalPackage = originalPackage;
 }
Esempio n. 30
0
        public void Test1()
        {
            JT809Package heartbeatPackage = JT809BusinessType.主链路连接保持请求消息.Create();

            byte[] sendHeartbeatData = JT809Serializer.Serialize(heartbeatPackage, 100);
        }