Ejemplo n.º 1
0
        public void Begin(byte channel, ushort nodeAddress)
        {
            if (!NetworkAddressing.IsValidAddress(nodeAddress))
            {
                return;
            }
            NetworkAddressing.NodeAddress = nodeAddress;
            if (channel != Configuration.UseCurrentChannel)
            {
                _radio.Configuration.Channel = channel;
            }
            _radio.RegisterContainer.EnableAutoAcknowledgementRegister.EnableAutoAcknowledgementPipe0 = false;
            _radio.RegisterContainer.EnableAutoAcknowledgementRegister.Save();

            _radio.Configuration.DynamicPayloadLengthEnabled = true;

            AutoRetransmitDelays retryVar = (AutoRetransmitDelays)((((nodeAddress % 6) + 1) * 2) + 3);

            _radio.Configuration.AutoRetransmitDelay = retryVar;
            _radio.Configuration.AutoRetransmitCount = 5;

            TransmitTimeout = 25;
            RouteTimeout    = TransmitTimeout * 3;

            NetworkAddressing.SetupAddress();

            byte i = 6;

            while (i-- > 0)
            {
                IReceivePipe receivePipe = _radio.ReceivePipes[i];
                receivePipe.Address = BitConverter.GetBytes(NetworkAddressing.PipeAddress(nodeAddress, i)).ReverseBytes();
                receivePipe.Enabled = true;
            }

            _radio.OperatingMode = OperatingModes.ReceiveMode;
        }
 public static string GetName(this AutoRetransmitDelays autoRetransmitDelay)
 {
     return(AutoRetransmitDelay[(int)autoRetransmitDelay]);
 }