Esempio n. 1
0
        /// <summary>
        /// Sets the long network address of this node.
        /// </summary>
        /// <param name="address">The long network address</param>
        public async Task SetDestinationAddressAsync(LongAddress address)
        {
            await ExecuteAtCommandAsync(new DestinationAddressHighCommand(address.High));

            Address.LongAddress.High = address.High;
            await ExecuteAtCommandAsync(new DestinationAddressLowCommand(address.Low));

            Address.LongAddress.Low = address.Low;
        }
Esempio n. 2
0
        public bool Equals(NodeAddress other)
        {
            if (Is16BitDisabled)
            {
                return(LongAddress.Equals(other.LongAddress));
            }

            if (LongAddress.Equals(LongAddress.Broadcast))
            {
                return(ShortAddress.Equals(other.ShortAddress));
            }

            return(LongAddress.Equals(other.LongAddress));
        }
Esempio n. 3
0
        /// <summary>
        /// Queries the long network address for this node.
        /// </summary>
        /// <returns>The long network address</returns>
        public virtual async Task <NodeAddress> GetDestinationAddressAsync()
        {
            PrimitiveResponseData <uint> high =
                await ExecuteAtQueryAsync <PrimitiveResponseData <uint> >(new DestinationAddressHighCommand());

            PrimitiveResponseData <uint> low =
                await ExecuteAtQueryAsync <PrimitiveResponseData <uint> >(new DestinationAddressLowCommand());

            var address = new LongAddress(high.Value, low.Value);

            PrimitiveResponseData <ShortAddress> source =
                await ExecuteAtQueryAsync <PrimitiveResponseData <ShortAddress> >(new SourceAddressCommand());

            return(new NodeAddress(address, source.Value));
        }
Esempio n. 4
0
        /// <summary>
        /// Queries the long network address for this node.
        /// </summary>
        /// <returns>The long network address</returns>
        public virtual async Task <NodeAddress> GetAddressAsync()
        {
            PrimitiveResponseData <uint> high =
                await ExecuteAtQueryAsync <PrimitiveResponseData <uint> >(new DestinationAddressHighCommand());

            PrimitiveResponseData <uint> low =
                await ExecuteAtQueryAsync <PrimitiveResponseData <uint> >(new DestinationAddressLowCommand());

            var address = new LongAddress(high.Value, low.Value);

            // we have to do this nonsense because they decided to reuse "MY" for the cellular IP source address
            PrimitiveResponseData <byte[]> source =
                await ExecuteAtQueryAsync <PrimitiveResponseData <byte[]> >(new SourceAddressCommand());

            var leValue            = source.Value.Reverse().ToArray();
            var sourceAddressValue = BitConverter.ToUInt16(leValue, 0);
            var sourceAddress      = new ShortAddress(sourceAddressValue);

            return(new NodeAddress(address, sourceAddress));
        }
Esempio n. 5
0
 /// <summary>
 ///     Sets the long network address of this node.
 /// </summary>
 /// <param name="address">The long network address</param>
 public virtual async Task SetDestinationAddressAsync(LongAddress address)
 {
     await ExecuteAtCommandAsync(new DestinationAddressHighCommand(address.High)).ConfigureAwait(false);
     await ExecuteAtCommandAsync(new DestinationAddressLowCommand(address.Low)).ConfigureAwait(false);
 }
Esempio n. 6
0
 public NodeAddress(LongAddress longAddress) : this(longAddress, ShortAddress.Broadcast)
 {
 }
Esempio n. 7
0
 public NodeAddress(LongAddress longAddress, ShortAddress shortAddress)
 {
     LongAddress  = longAddress;
     ShortAddress = shortAddress;
 }
Esempio n. 8
0
 public override int GetHashCode()
 {
     return(LongAddress != null?LongAddress.GetHashCode() : 0);
 }
Esempio n. 9
0
 public NodeAddress(LongAddress longAddress) : this(longAddress, ShortAddress.Disabled)
 {
 }
Esempio n. 10
0
 public async Task SetDestinationAddress(LongAddress address)
 {
     await SetDestinationAddressAsync(address);
 }