Exemplo n.º 1
0
        public void Test2()
        {
            byte[]       bodys             = "34 35 36 31 32".ToHexBytes();
            JT808_0x0102 jT808LoginRequest = JT808Serializer.Deserialize <JT808_0x0102>(bodys);

            Assert.Equal("45612", jT808LoginRequest.Code);
        }
Exemplo n.º 2
0
        public void Test1()
        {
            JT808_0x0102 jT808LoginRequestProperty = new JT808_0x0102();

            jT808LoginRequestProperty.Code = "45612";
            string hex = JT808Serializer.Serialize(jT808LoginRequestProperty).ToHexString();
        }
        /// <summary>
        /// 终端鉴权
        /// </summary>
        /// <param name="client"></param>
        /// <param name="bodies"></param>
        /// <param name="minBufferSize"></param>
        public static void Send(this JT808TcpClient client, JT808_0x0102 bodies, int minBufferSize = 100)
        {
            JT808Header header = new JT808Header();

            header.MsgId = JT808MsgId.终端鉴权.ToUInt16Value();
            client.Send(header, bodies, minBufferSize);
        }
Exemplo n.º 4
0
        public void Test2019_2()
        {
            byte[]       bodys             = "05343536313231323334353637383930616263646576322E302E303030303030303030303030303030".ToHexBytes();
            JT808_0x0102 jT808LoginRequest = JT808Serializer.Deserialize <JT808_0x0102>(bodys, JT808Version.JTT2019);

            Assert.Equal("45612", jT808LoginRequest.Code);
            Assert.Equal(5, jT808LoginRequest.CodeLength);
            Assert.Equal("1234567890abcde", jT808LoginRequest.IMEI);
            Assert.Equal("v2.0.0".PadRight(20, '0'), jT808LoginRequest.SoftwareVersion);
        }
Exemplo n.º 5
0
        public void Test1()
        {
            JT808_0x0102 jT808LoginRequestProperty = new JT808_0x0102
            {
                Code = "45612"
            };
            string hex = JT808Serializer.Serialize(jT808LoginRequestProperty).ToHexString();

            Assert.Equal("3435363132", hex);
        }
Exemplo n.º 6
0
        public void Test2019_1()
        {
            JT808_0x0102 jT808LoginRequestProperty = new JT808_0x0102
            {
                Code            = "45612",
                IMEI            = "1234567890abcde",
                SoftwareVersion = "v2.0.0"
            };
            string hex = JT808Serializer.Serialize(jT808LoginRequestProperty, JT808Version.JTT2019).ToHexString();

            Assert.Equal("05343536313231323334353637383930616263646576322E302E303030303030303030303030303030", hex);
        }
Exemplo n.º 7
0
        public void Test4()
        {
            byte[]       bodys             = "7E 01 02 00 09 01 23 45 67 89 00 30 39 34 35 36 31 32 31 31 31 31 BE 7E".ToHexBytes();
            JT808Package jT808LoginRequest = JT808Serializer.Deserialize <JT808Package>(bodys);

            Assert.Equal(Enums.JT808MsgId.终端鉴权.ToUInt16Value(), jT808LoginRequest.Header.MsgId);
            Assert.Equal(12345, jT808LoginRequest.Header.MsgNum);
            Assert.Equal("12345678900", jT808LoginRequest.Header.TerminalPhoneNo);

            JT808_0x0102 JT808Bodies = (JT808_0x0102)jT808LoginRequest.Bodies;

            Assert.Equal("456121111", JT808Bodies.Code);
        }
Exemplo n.º 8
0
        public byte[] Sign(string code)
        {
            JT808Package jT808Package = new JT808Package();

            jT808Package.Header = new JT808Header
            {
                MsgId           = JT808.Protocol.Enums.JT808MsgId.终端鉴权.ToUInt16Value(),
                MsgNum          = 126,
                TerminalPhoneNo = "123456789012"
            };

            JT808_0x0102 jT808_0x0200 = new JT808_0x0102
            {
                Code = code
            };

            jT808Package.Bodies = jT808_0x0200;

            return(_JT808Serializer.Serialize(jT808Package));
        }