XBee C# library API reference

Show / Hide Table of Contents

Class XBeeNetwork

This class represents an XBee Network.

Inheritance
System.Object
XBeeNetwork
DigiMeshNetwork
DigiPointNetwork
Raw802Network
ZigBeeNetwork
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
Namespace: XBeeLibrary.Core
Assembly: XBeeLibrary.Core.dll
Syntax
public class XBeeNetwork
Remarks

The network allows the discovery of remote devices in the same network as the local one and stores them.

Fields

logger

Declaration
protected ILog logger
Field Value
Type Description
Common.Logging.ILog

MAX_SCAN_COUNTER

Declaration
public static readonly int MAX_SCAN_COUNTER
Field Value
Type Description
System.Int32

Properties

Channel

The operating channel of the network.

Declaration
public string Channel { get; }
Property Value
Type Description
System.String

IsDiscoveryRunning

Indicates whether the discovery process is running or not.

Declaration
public bool IsDiscoveryRunning { get; }
Property Value
Type Description
System.Boolean

true if the discovery process is running, false otherwise.

LocalDevice

The local XBee device, to which the network belongs.

Declaration
public XBeeDevice LocalDevice { get; }
Property Value
Type Description
XBeeDevice

PanId

The PAN ID of the network.

Declaration
public string PanId { get; }
Property Value
Type Description
System.String

Methods

AddRemoteDevice(RemoteXBeeDevice)

Adds the given remote device to the network.

Declaration
public RemoteXBeeDevice AddRemoteDevice(RemoteXBeeDevice remoteDevice)
Parameters
Type Name Description
RemoteXBeeDevice remoteDevice

The remote device to be added to the network.

Returns
Type Description
RemoteXBeeDevice

The remote XBee Device instance in the network, null if the device could not be successfully added.

Remarks

Notice that this operation does not join the remote XBee device to the network; it just tells the network that it contains that device. However, the device has only been added to the device list, and may not be physically in the same network.

The way of adding a device to the network is based on the 64-bit address. If it is not configured:

  • For 802.15.4 and ZigBee devices, it will use the 16-bit address.
  • For the rest will return true as the result of the addition.
Exceptions
Type Condition
System.ArgumentNullException

If remoteDevice == null.

AddRemoteDevices(IList<RemoteXBeeDevice>)

Adds the given list of remote devices to the network.

Declaration
public List<RemoteXBeeDevice> AddRemoteDevices(IList<RemoteXBeeDevice> list)
Parameters
Type Name Description
System.Collections.Generic.IList<RemoteXBeeDevice> list

The list of remote devices to be added to the network.

Returns
Type Description
System.Collections.Generic.List<RemoteXBeeDevice>

A list with the successfully added devices to the network.

Remarks

Notice that this operation does not join the remote XBee devices to the network; it just tells the network that it contains those devices. However, the devices have only been added to the device list, and may not be physically in the same network.

The way of adding a device to the network is based on the 64-bit address. If it is not configured:

  • For 802.15.4 and ZigBee devices, the 16-bit address will be used instead.
  • For the rest will return true as the result of the addition.
Exceptions
Type Condition
System.ArgumentNullException

If list == null.

ClearDeviceList()

Removes all the devices from this network.

Declaration
public void ClearDeviceList()
Remarks

The network will be empty after this call returns.

Notice that this does not imply removing the XBee devices from the actual XBee network; it just tells the object that the list should be empty now. Next time a discovery is performed, the list could be filled with the remote XBee devices found.

DiscoverDevice(String)

Discovers and reports the first remote XBee device that matches the supplied identifier.

Declaration
public RemoteXBeeDevice DiscoverDevice(string id)
Parameters
Type Name Description
System.String id

The identifier of the device to be discovered.

Returns
Type Description
RemoteXBeeDevice

The discovered remote XBee device with the given identifier, null if the timeout expires and the device was not found.

Remarks

This method blocks until the device is discovered or the configured timeout expires. To configure the discovery timeout, use the SetDiscoveryTimeout(Int64) method.

To configure the discovery options, use the SetDiscoveryOptions(ISet<DiscoveryOptions>) method.

Exceptions
Type Condition
System.ArgumentException

If id is empty.

System.ArgumentNullException

If id == null.

InterfaceNotOpenException

If this device connection is not open.

XBeeException

If there is an error discovering the device.

DiscoverDevices(IList<String>)

Discovers and reports all remote XBee devices that match the supplied identifiers.

Declaration
public List<RemoteXBeeDevice> DiscoverDevices(IList<string> ids)
Parameters
Type Name Description
System.Collections.Generic.IList<System.String> ids

List which contains the identifiers of the devices to be discovered

Returns
Type Description
System.Collections.Generic.List<RemoteXBeeDevice>

A list of the discovered remote XBee devices with the given identifiers.

Remarks

This method blocks until the configured timeout expires. To configure the discovery timeout, use the method SetDiscoveryTimeout(Int64).

To configure the discovery options, use the SetDiscoveryOptions(ISet<DiscoveryOptions>) method.

Exceptions
Type Condition
System.ArgumentException

If ids is empty.

System.ArgumentNullException

If ids == null.

InterfaceNotOpenException

If this device connection is not open.

XBeeException

If there is an error discovering the devices.

GetDevice(String)

Returns the first remote device that matches the supplied identifier.

Declaration
public RemoteXBeeDevice GetDevice(string id)
Parameters
Type Name Description
System.String id

The identifier of the device to be retrieved.

Returns
Type Description
RemoteXBeeDevice

The remote XBee device contained in the network with the given identifier, null if the network does not contain any device with that Node ID.

Remarks

Note that this method does not perform a discovery, only returns the device that has been previously discovered.

Exceptions
Type Condition
System.ArgumentException

If id is empty.

System.ArgumentNullException

If id == null.

GetDevice(XBee16BitAddress)

Returns the remote device already contained in the network whose 16-bit address matches the given one.

Declaration
public RemoteXBeeDevice GetDevice(XBee16BitAddress address)
Parameters
Type Name Description
XBee16BitAddress address

The 16-bit address of the device to be retrieved.

Returns
Type Description
RemoteXBeeDevice

The remote device in the network or null if it is not found.

Remarks

Note that this method does not perform a discovery, only returns the device that has been previously discovered.

Exceptions
Type Condition
System.ArgumentException

If address is UNKNOWN_ADDRESS.

System.ArgumentNullException

If address == null.

OperationNotSupportedException

If the protocol of localDevice is DIGI_MESH or if it is DIGI_POINT

GetDevice(XBee64BitAddress)

Returns the remote device already contained in the network whose 64-bit address matches the given one.

Declaration
public RemoteXBeeDevice GetDevice(XBee64BitAddress address)
Parameters
Type Name Description
XBee64BitAddress address

The 64-bit address of the device to be retrieved.

Returns
Type Description
RemoteXBeeDevice

The remote device in the network or null if it is not found.

Remarks

Note that this method does not perform a discovery, only returns the device that has been previously discovered.

Exceptions
Type Condition
System.ArgumentException

If address is UNKNOWN_ADDRESS.

System.ArgumentNullException

If address == null.

GetDevices()

Returns all remote devices already contained in the network.

Declaration
public IList<RemoteXBeeDevice> GetDevices()
Returns
Type Description
System.Collections.Generic.IList<RemoteXBeeDevice>

A list with all XBee devices in the network.

Remarks

Note that this method does not perform a discovery, only returns the devices that have been previously discovered.

GetDevices(String)

Returns all remote devices that match the supplied identifier.

Declaration
public List<RemoteXBeeDevice> GetDevices(string id)
Parameters
Type Name Description
System.String id

The identifier of the devices to be retrieved.

Returns
Type Description
System.Collections.Generic.List<RemoteXBeeDevice>

A list of the remote XBee devices contained in the network with the given identifier.

Remarks

Note that this method does not perform a discovery, only returns the devices that have been previously discovered.

Exceptions
Type Condition
System.ArgumentException

If id is empty.

System.ArgumentNullException

If id == null.

GetNumberOfDevices()

Returns the number of devices already discovered in the network.

Declaration
public int GetNumberOfDevices()
Returns
Type Description
System.Int32

The number of devices already discovered in the network.

GetProtocol()

Returns the protocol of the Network.

Declaration
public XBeeProtocol GetProtocol()
Returns
Type Description
XBeeProtocol

The protocol of the Network.

RemoveRemoteDevice(RemoteXBeeDevice)

Removes the given remote XBee device from the network.

Declaration
public void RemoveRemoteDevice(RemoteXBeeDevice remoteDevice)
Parameters
Type Name Description
RemoteXBeeDevice remoteDevice

The remote device to be removed from the network.

Remarks

Notice that this operation does not remove the remote XBee device from the actual XBee network; it just tells the network object that it will no longer contain that device. However, next time a discovery is performed, it could be added again automatically.

This method will check for a device that matches the 64-bit address of the provided one, if found, that device will be removed from the corresponding list. In case the 64-bit address is not defined, it will use the 16-bit address for DigiMesh and ZigBee devices.

Exceptions
Type Condition
System.ArgumentNullException

If remoteDevice == null.

SetDiscoveryOptions(ISet<DiscoveryOptions>)

Configures the discovery options (NO parameter) with the given value.

Declaration
public void SetDiscoveryOptions(ISet<DiscoveryOptions> options)
Parameters
Type Name Description
System.Collections.Generic.ISet<DiscoveryOptions> options

New discovery options.

Exceptions
Type Condition
System.ArgumentNullException

If options == null.

XBeeException

If there is any error setting the options.

See Also
DiscoveryOptions

SetDiscoveryTimeout(Int64)

Configures the discovery timeout (NT parameter) with the given value.

Declaration
public void SetDiscoveryTimeout(long timeout)
Parameters
Type Name Description
System.Int64 timeout

New discovery timeout in milliseconds.

Exceptions
Type Condition
System.ArgumentException

If timeout is 0 or lesser.

XBeeException

If there is any error setting the timeout.

StartNodeDiscoveryProcess()

Starts the discovery process with the configured timeout and options.

Declaration
public void StartNodeDiscoveryProcess()
Remarks

To be notified every time an XBee device is discovered, add a DeviceDiscovered event handler before starting the discovery process.

To configure the discovery timeout, use the SetDiscoveryTimeout(Int64) method.

To configure the discovery options, use the SetDiscoveryOptions(ISet<DiscoveryOptions>) method.

Exceptions
Type Condition
InterfaceNotOpenException

If this device connection is not open.

System.InvalidOperationException

If the discovery process is already running.

StopNodeDiscoveryProcess()

Stops the discovery process if it is running.

Declaration
public void StopNodeDiscoveryProcess()
Remarks

Note that DigiMesh/DigiPoint devices are blocked until the discovery time configured (NT parameter) has elapsed, so if you try to get/set any parameter during the discovery process you will receive a timeout exception.

ToString()

Returns a string representation of this object.

Declaration
public override string ToString()
Returns
Type Description
System.String

A string representation of this object.

Overrides
System.Object.ToString()

Events

DeviceDiscovered

Represents the method that will handle the device discovered event.

Declaration
public event EventHandler<DeviceDiscoveredEventArgs> DeviceDiscovered
Event Type
Type Description
System.EventHandler<DeviceDiscoveredEventArgs>
Exceptions
Type Condition
System.ArgumentNullException

If the event handler is null.

See Also
DeviceDiscoveredEventArgs

DiscoveryError

Represents the method that will handle the discovery error event.

Declaration
public event EventHandler<DiscoveryErrorEventArgs> DiscoveryError
Event Type
Type Description
System.EventHandler<DiscoveryErrorEventArgs>
Exceptions
Type Condition
System.ArgumentNullException

If the event handler is null.

See Also
DiscoveryErrorEventArgs

DiscoveryFinished

Represents the method that will handle the discovery finished event.

Declaration
public event EventHandler<DiscoveryFinishedEventArgs> DiscoveryFinished
Event Type
Type Description
System.EventHandler<DiscoveryFinishedEventArgs>
Exceptions
Type Condition
System.ArgumentNullException

If the event handler is null.

See Also
DiscoveryFinishedEventArgs
Product page More documentation Official site About Digi Contact us Support
©2019 Digi International Inc. All rights reserved.
Digi International Inc.