示例#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;
        }
示例#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));
        }
示例#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));
        }
示例#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));
        }
示例#5
0
文件: XBeeNode.cs 项目: alamus/XBee
 /// <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);
 }
示例#6
0
 public NodeAddress(LongAddress longAddress) : this(longAddress, ShortAddress.Broadcast)
 {
 }
示例#7
0
 public NodeAddress(LongAddress longAddress, ShortAddress shortAddress)
 {
     LongAddress  = longAddress;
     ShortAddress = shortAddress;
 }
示例#8
0
 public override int GetHashCode()
 {
     return(LongAddress != null?LongAddress.GetHashCode() : 0);
 }
示例#9
0
 public NodeAddress(LongAddress longAddress) : this(longAddress, ShortAddress.Disabled)
 {
 }
示例#10
0
 public async Task SetDestinationAddress(LongAddress address)
 {
     await SetDestinationAddressAsync(address);
 }