예제 #1
0
        private bool SendPacket(XBeePacket packet)
        {
            byte[] bytes = packet.GetBytes();

            try
            {
                _serialPort.Write(bytes, 0, bytes.Length);
            }
            catch (Exception ex)
            {
                //TODO: Tratar a Exceção
                System.Windows.MessageBox.Show(ex.Message, "Erro no envio do comando");
                return(false);
            }

            return(true);
        }
예제 #2
0
        protected void SendRequest(XBeeRequest request)
        {
            IsRequestSupported(request);

            if (_addressLookupEnabled)
            {
                _currentRequest = request;
            }

            if (Logger.IsActive(LogLevel.Debug))
            {
                Logger.Debug("Sending " + request.GetType().Name + ": " + request);
            }

            var bytes = XBeePacket.GetBytes(request);

            if (Logger.IsActive(LogLevel.LowDebug))
            {
                Logger.LowDebug("Sending " + ByteUtils.ToBase16(bytes));
            }

            _connection.Send(bytes);
        }