Esempio n. 1
0
        public static byte[] SendCommand_88_SendGatewayData(bool needACK, int frame_position, byte[] dataPayload, byte length, ushort Framecount)
        {
            #region 构建串口帧
            IntranetFrame frame = new IntranetFrame(dataPayload, Convert.ToByte(dataPayload.Length));
            if (frame_position == 0)
            {
                frame.TransferState = IntranetFrame.FrameState.FirstFrame;
            }
            else if (frame_position == 1)
            {
                frame.TransferState = IntranetFrame.FrameState.MidFrame;
            }
            else if (frame_position == 2)
            {
                frame.TransferState = IntranetFrame.FrameState.LastFrame;
            }
            frame.NeedAnswer       = needACK;
            frameNum               = Framecount;
            frame.FrameCount       = Framecount;
            frame.CommunicationWay = IntranetFrame.Communication.InnerNet;
            byte[] intranetFrame = frame.Send();//形成串口通信帧
            #endregion

            #region 构建网络通信帧

            /* 构建网络通信帧 */
            NetCommunicationFrame netFrame = new NetCommunicationFrame(intranetFrame, Convert.ToByte(intranetFrame.Length));
            netFrame.Encryption  = false;
            netFrame.NeedAnswer  = false;
            netFrame.FrameFormat = NetCommunicationFrame.FrameType.DataFrame;
            receiveByte();
            netFrame.MobilePhoneMAC        = PhoneMAC;
            netFrame.GatewayClassification = GatewayType;
            netFrame.GatewayMAC            = GatewayMAC;
            netFrame.FrameCount            = 0;

            if (packetFrameType == FrameType.OutterNet)
            {
                netFrame.TransferDirection = NetCommunicationFrame.Direction.MobilePhone2Server2Gateway;
                netFrame.ServerIP          = SeverIp;
            }
            if (packetFrameType == FrameType.InnerNet)
            {
                netFrame.TransferDirection = NetCommunicationFrame.Direction.Mobile2Gateway;
            }
            if (packetFrameType == FrameType.Serial)
            {
                netFrame.TransferDirection = NetCommunicationFrame.Direction.Computer2Gateway;
            }

            return(netFrame.Send());

            #endregion
        }
Esempio n. 2
0
        /// <summary>
        /// 发送最终目的地是网关的命令帧.
        /// </summary>
        /// <param name="length">命令总长度.</param>
        /// <param name="commandID">命令标识.</param>
        /// <param name="commandPayload">命令负载.</param>
        /// <returns></returns>
        public static byte[] SendCommand_88(byte length, byte[] commandID, byte[] commandPayload)
        {
            #region 构建88帧
            /* 构建内网通信88帧 */
            IntranetFrame frame         = new IntranetFrame(commandID, commandPayload, length);
            byte[]        innerNetFrame = frame.Send();//形成内网通信帧
            #endregion

            #region 构建网络通信
            /* 构建网络通信帧 */
            NetCommunicationFrame netFrame = new NetCommunicationFrame(innerNetFrame, Convert.ToByte(innerNetFrame.Length));
            netFrame.Encryption  = false;
            netFrame.NeedAnswer  = false;
            netFrame.FrameFormat = NetCommunicationFrame.FrameType.DataFrame;
            //
            receiveByte();
            netFrame.MobilePhoneMAC        = PhoneMAC;
            netFrame.GatewayClassification = GatewayType;
            netFrame.GatewayMAC            = GatewayMAC;
            //
            netFrame.FrameCount = 0;

            if (packetFrameType == FrameType.OutterNet)
            {
                netFrame.TransferDirection = NetCommunicationFrame.Direction.MobilePhone2Server;
                netFrame.ServerIP          = SeverIp;
            }
            if (packetFrameType == FrameType.InnerNet)
            {
                netFrame.TransferDirection = NetCommunicationFrame.Direction.Mobile2Gateway;
            }

            return(netFrame.Send());

            #endregion
        }