private static void SendResponse(MessageInput input, long id)
        {
            string head     = $"{0:X4}";
            string body     = $"4CBF{id:X8}{0:X4}";
            string checksum = Crc.ComputeHash(HexUtil.ConvertHexStringToByteArray(body), CrcAlgorithm.Crc16CcittFalse);
            string response = $"{head}{body}{checksum}";

            input.NetworkStream.Write(HexUtil.ConvertHexStringToByteArray(response));
        }
Exemple #2
0
        private static void HandleMessage(MessageInput input, MeiligaoInputMessage inputMessage)
        {
            if (inputMessage.Command == MeiligaoCommands.Login)
            {
                MeiligaoOutputMessage reply =
                    new MeiligaoOutputMessage(MeiligaoCommands.LoginConfirmation, inputMessage.DeviceIdHex, "01");

                input.NetworkStream.Write(HexUtil.ConvertHexStringToByteArray(reply.PacketBodyWithChecksum));
            }
        }
        private static void SendResponse(MessageInput input)
        {
            // ReSharper disable once PossiblyMistakenUseOfInterpolatedStringInsert
            string       packetLength = $"{2:X4}";
            const string command      = "64";
            const string ack          = "01";
            string       checksum     = Crc.ComputeHash(HexUtil.ConvertHexStringToByteArray($"{command}{ack}"),
                                                        CrcAlgorithm.Crc16Kermit);
            string fullReply = $"{packetLength}{command}{ack}{checksum}";

            input.NetworkStream.Write(HexUtil.ConvertHexStringToByteArray(fullReply));
        }
Exemple #4
0
        private static void SimulateTeltonika()
        {
            TcpClient tcpClient = new TcpClient();

            tcpClient.Connect(IPAddress.Loopback, 7002);
            NetworkStream networkStream = tcpClient.GetStream();

            networkStream.Write(HexUtil.ConvertHexStringToByteArray("000F333532383438303236333839393631"));
            networkStream.Write(HexUtil.ConvertHexStringToByteArray("00000000000003E108120000011733FAD2C80000000000000000000000000000000000080301014501F00003B60000422F5343004002C700000000F100005852000000011733FAAB2C0000000000000000000000000000000000080301014501F00003B60000422F7A43004602C700000000F100005852000000011733FA83720000000000000000000000000000000000080301014501F00003B60000422F6E43003D02C700000000F100005852000000011733FA5BD60000000000000000000000000000000000080301014501F00003B60000422F7843004902C700000000F100005852000000011733FA343A0000000000000000000000000000000000080301014501F00003B60000422F6D43004D02C700000000F100000000000000011733FA0C940000000000000000000000000000000000080301014501F00003B60000422F7643004302C700000000F100000000000000011733F9E4EE0000000000000000000000000000000000080301014501F00003B60000422F7B43004202C700000000F100000000000000011733F9BD520000000000000000000000000000000000080301014501F00003B60000422F7E43004602C700000000F100000000000000011733F995990000000000000000000000000000000000080301014501F00003B60000422F7543004102C700000000F100005852000000011733F96DE80000000000000000000000000000000000080301014501F00003B60000422F6743003E02C700000000F100005852000000011733F9464C0000000000000000000000000000000000080301014501F00003B60000422F6E43004A02C700000000F100005852000000011733F91E9C0000000000000000000000000000000000080301014501F00003B60000422F6943004602C700000000F100000000000000011733F8F6F60000000000000000000000000000000000080301014501F00003B60000422F7643004602C700000000F100000000000000011733F8CF5A0000000000000000000000000000000000080301014501F00003B60000422F6443004902C700000000F100000000000000011733F8A7B40000000000000000000000000000000000080301014501F00003B60000422F7B43004102C700000000F100000000000000011733F8800E0000000000000000000000000000000000080301014501F00003B60000422F6F43005002C700000000F100005852000000011733F8586A0000000000000000000000000000000000080301014501F00003B60000422F4F43004002C700000000F100005852000000011733F830C20000000000000000000000000000000000080301014501F00003B60000422F7643004102C700000000F100005852001200004EC8"));

            networkStream.Close();
            tcpClient.Close();
        }
Exemple #5
0
 public void SendHexFromDevice(string value)
 {
     SendBytesFromDevice(HexUtil.ConvertHexStringToByteArray(value.Replace(" ", "")));
 }