Digital IO lines of an XBee device can be either read or set.

Set digital output value

If your IO line is configured as digital output, you can set its state (high/low). All the XBee device classes provide the method SetDIOValue(IOLine, IOValue) fur such purpose.

Method Description

SetDIOValue(IOLine, IOValue)

Sets the digital value (high or low) to the provided IO line. Arguments are an item of the IOLine enumeration class (line to set its value) and an item of the IOValue enumeration class (the value to be set).
Available IOValue values are:

  • IOValue.LOW

  • IOValue.HIGH

The SetDIOValue(IOLine, IOValue) method may fail for the following reasons:

  • The IO line or IO value arguments are unknown, throwing an ArgumentException.

  • The device is not connected, throwing an InterfaceNotOpenException.

  • There is a timeout setting the DIO value, throwing a TimeoutException.

  • Other errors are caught as XBeeException.

A line must be configured in IOMode.DIGITAL_OUT_LOW or IOMode.DIGITAL_OUT_HIGH mode to set its digital value.
Set digital output value
// Instantiate an XBee device object.
XBeeBLEDevice myXBeeBLEDevice = new XBeeBLEDevice("00:00:00:00:00:00", "password");

// Connect the device.
myXBeeBLEDevice.Connect();

// Configure the DIO1_AD1 line to be Digital output (set high by default).
myXBeeBLEDevice.SetIOConfiguration(IOLine.DIO1_AD1, IOMode.DIGITAL_OUT_HIGH);

// Set the DIO2_AD2 line low.
myXBeeBLEDevice.SetDIOValue(IOLine.DIO1_AD1, IOValue.LOW);

Read digital input value

You can also read the current status of the pin (high/low) by issuing the method GetDIOValue(IOLine).

Method Description

GetDIOValue(IOLine)

Returns the digital value of the provided IO line. Parameter must be an item of the IOLine enumeration class (line to get its value). Returned value is an item of the IOValue enumeration class (the value of the line).

The GetDIOValue(IOLine) method may fail for the following reasons:

  • The IO line argument is unknown, throwing an ArgumentException.

  • The device is not connected, throwing an InterfaceNotOpenException.

  • There is a timeout getting the DIO value, throwing a TimeoutException.

  • Other errors are caught as XBeeException.

A line must be configured in IOMode.DIGITAL_IN mode to read its digital value.
Read digital value
// Instantiate an XBee device object.
XBeeBLEDevice myXBeeBLEDevice = new XBeeBLEDevice("00:00:00:00:00:00", "password");

// Connect the device.
myXBeeBLEDevice.Connect();

// Configure the DIO2_AD2 line to be Digital input.
myXBeeBLEDevice.SetIOConfiguration(IOLine.DIO2_AD2, IOMode.DIGITAL_IN);

// Get the value of the DIO2_AD2.
IOValue value = myXBeeBLEDevice.GetDIOValue(IOLine.DIO2_AD2);