Exemplo 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;
        }
Exemplo 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));
        }
Exemplo 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));
        }
Exemplo 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));
        }
Exemplo 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);
 }
Exemplo n.º 6
0
 public NodeAddress(LongAddress longAddress) : this(longAddress, ShortAddress.Broadcast)
 {
 }
Exemplo n.º 7
0
 public NodeAddress(LongAddress longAddress, ShortAddress shortAddress)
 {
     LongAddress  = longAddress;
     ShortAddress = shortAddress;
 }
Exemplo n.º 8
0
 public override int GetHashCode()
 {
     return(LongAddress != null?LongAddress.GetHashCode() : 0);
 }
Exemplo n.º 9
0
 public NodeAddress(LongAddress longAddress) : this(longAddress, ShortAddress.Disabled)
 {
 }
Exemplo n.º 10
0
 public async Task SetDestinationAddress(LongAddress address)
 {
     await SetDestinationAddressAsync(address);
 }