Example #1
0
        /// <summary>
        /// Get the characterisitcs associated to a node
        /// </summary>
        /// <param name="shortAddress">the address of the node</param>
        /// <returns>the characteristic if present, null otherwise</returns>
        private TransmissionCharacteristic GetNodeCharacteristic(UInt16 shortAddress)
        {
            lock (_lock)
            {
                int sqnArrayCount = _sqnArray.Count;
                for (int i = 0; i < sqnArrayCount; i++)
                {
                    TransmissionCharacteristic holder = (TransmissionCharacteristic)_sqnArray[i];
                    if (holder.ShortAddress == shortAddress)
                    {
                        return(holder);
                    }
                }

                return(null);
            }
        }
Example #2
0
 /// <summary>
 /// Set transmission characteristic (including sequence number).
 /// </summary>
 public void SetTransmissionCharacteristic(UInt16 shortAddress, byte sqn, uint timeoutForResending, uint maxFragmentsSentBeforeAck)
 {
     lock (_lock)
     {
         TransmissionCharacteristic holder = GetNodeCharacteristic(shortAddress);
         if (holder != null)
         {
             holder.MessageSeqNumber          = sqn;
             holder.TimeoutForResending       = timeoutForResending;
             holder.MaxFragmentsSentBeforeAck = maxFragmentsSentBeforeAck;
         }
         else
         {
             holder = new TransmissionCharacteristic(shortAddress, sqn, timeoutForResending, maxFragmentsSentBeforeAck);
             _sqnArray.Add(holder);
         }
     }
 }
Example #3
0
        /// <summary>
        /// Set transmission characteristic.
        /// <returns>true if update was successful and false otherwise</returns>
        /// </summary>
        public bool UpdateTransmissionCharacteristic(UInt16 shortAddress, uint timeoutForResending, uint maxFragmentsSentBeforeAck)
        {
            lock (_lock)
            {
                TransmissionCharacteristic holder = GetNodeCharacteristic(shortAddress);
                if (holder != null)
                {
#if PRINTALL
                    Trace.Print("Updating trans. char for node " + shortAddress + ": timeoutForResend = " + timeoutForResending + ", maxFrag = " + maxFragmentsSentBeforeAck);
#endif

                    holder.TimeoutForResending       = timeoutForResending;
                    holder.MaxFragmentsSentBeforeAck = maxFragmentsSentBeforeAck;
                    return(true);
                }

                return(false);
            }
        }
Example #4
0
        /// <summary>
        /// Get the seq. number associated to a node.
        /// </summary>
        public bool GetTransmissionCharacteristic(UInt16 shortAddress, out byte messageSeqNumber, out uint timeoutForResending, out uint maxFragmentsSentBeforeAck)
        {
            lock (_lock)
            {
                TransmissionCharacteristic holder = GetNodeCharacteristic(shortAddress);
                if (holder != null)
                {
                    messageSeqNumber          = holder.MessageSeqNumber;
                    timeoutForResending       = holder.TimeoutForResending;
                    maxFragmentsSentBeforeAck = holder.MaxFragmentsSentBeforeAck;
                    return(true);
                }

                messageSeqNumber          = 0;
                timeoutForResending       = 0;
                maxFragmentsSentBeforeAck = 0;
                return(false);
            }
        }
 /// <summary>
 /// Set transmission characteristic (including sequence number).
 /// </summary>
 public void SetTransmissionCharacteristic(UInt16 shortAddress, byte sqn, uint timeoutForResending, uint maxFragmentsSentBeforeAck)
 {
     lock (_lock)
     {
         TransmissionCharacteristic holder = GetNodeCharacteristic(shortAddress);
         if (holder != null)
         {
             holder.MessageSeqNumber = sqn;
             holder.TimeoutForResending = timeoutForResending;
             holder.MaxFragmentsSentBeforeAck = maxFragmentsSentBeforeAck;
         }
         else
         {
             holder = new TransmissionCharacteristic(shortAddress, sqn, timeoutForResending, maxFragmentsSentBeforeAck);
             _sqnArray.Add(holder);
         }
     }
 }