コード例 #1
0
        /// <summary>
        /// Sends the message and returns an ack with payload.
        /// </summary>
        /// <returns>The message.</returns>
        /// <param name="packet">Packet.</param>
        /// <param name="createAckPayload">Ack payload builder/delegate.</param>
        /// <typeparam name="TPacketPayload">Ack payload type.</typeparam>
        public IAckPacket <TAckPacketPayload> SendMessage <TAckPacketPayload>(IPacket packet, CreateAckPayload <TAckPacketPayload> createAckPayload) where TAckPacketPayload : IProvideBytes
        {
            var packetBytes = packet.GetBytes();

            Log.InfoFormat("Sending packet {0} (bytes: {1})", packet, BitConverter.ToString(packetBytes));

            var responseBytes = _crazyradioDriver.SendData(packetBytes);

            if (responseBytes != null)
            {
                var ackResponse = new AckPacket <TAckPacketPayload>(responseBytes, createAckPayload);

                Log.InfoFormat("Sent packet. Got ACK response {0} (bytes: {1})", ackResponse, responseBytes);

                return(ackResponse);
            }
            else
            {
                Log.Warn("Sent packet. Got NULL response.");

                return(null);
            }
        }
コード例 #2
0
        /// <summary>
        /// Sends the message.
        /// </summary>
        /// <returns>The message.</returns>
        /// <param name="packet">Packet.</param>
        public IAckPacket SendMessage(IPacket packet)
        {
            var packetBytes = packet.GetBytes();

            Log.InfoFormat("Sending packet {0} (bytes: {1})", packet, BitConverter.ToString(packetBytes));

            var responseBytes = _crazyradioDriver.SendData(packetBytes);

            if (responseBytes != null)
            {
                var ackResponse = new AckPacket(responseBytes);

                Log.InfoFormat("Sent packet. Got ACK response {0} (bytes: {1})", ackResponse, responseBytes);

                return(ackResponse);
            }
            else
            {
                Log.Warn("Sent packet. Got NULL response.");

                return(null);
            }
        }