/** * Sets the digital value (high or low) to the provided IO line of this * XBee device. * * @param ioLine The IO line to set its value. * @param ioValue The IOValue to set to the IO line ({@code HIGH} or * {@code LOW}). * * @throws InterfaceNotOpenException if this device connection is not open. * @throws ArgumentNullException if {@code ioLine == null} or * if {@code ioValue == null}. * @throws TimeoutException if there is a timeout sending the set DIO * command. * @throws XBeeException if there is any other XBee related exception. * * @see #getIOConfiguration(IOLine) * @see #setIOConfiguration(IOLine, IOMode) * @see com.digi.xbee.api.io.IOLine * @see com.digi.xbee.api.io.IOValue * @see com.digi.xbee.api.io.IOMode#DIGITAL_OUT_HIGH * @see com.digi.xbee.api.io.IOMode#DIGITAL_OUT_LOW */ public void setDIOValue(IOLine ioLine, IOValue ioValue)/*throws TimeoutException, XBeeException */{ // Check IO line. if (ioLine == null) throw new ArgumentNullException("IO line cannot be null."); // Check IO value. if (ioValue == null) throw new ArgumentNullException("IO value cannot be null."); // Check connection. if (!connectionInterface.SerialPort.IsOpen) throw new InterfaceNotOpenException(); SetParameter(ioLine.GetConfigurationATCommand(), new byte[] { (byte)ioValue.GetID() }); }
/** * Returns the configuration mode of the provided IO line of this XBee * device. * * @param ioLine The IO line to get its configuration. * * @return The IO mode (configuration) of the provided IO line. * * @throws InterfaceNotOpenException if this device connection is not open. * @throws ArgumentNullException if {@code ioLine == null}. * @throws TimeoutException if there is a timeout sending the get * configuration command. * @throws XBeeException if there is any other XBee related exception. * * @see #setIOConfiguration(IOLine, IOMode) * @see com.digi.xbee.api.io.IOLine * @see com.digi.xbee.api.io.IOMode */ public IOMode GetIOConfiguration(IOLine ioLine)/*throws TimeoutException, XBeeException */{ // Check IO line. if (ioLine == null) throw new ArgumentNullException("DIO pin cannot be null."); // Check connection. if (!connectionInterface.SerialPort.IsOpen) throw new InterfaceNotOpenException(); // Check if the received configuration mode is valid. int ioModeValue = GetParameter(ioLine.GetConfigurationATCommand())[0]; IOMode dioMode = IOMode.UNKOWN.GetIOMode(ioModeValue, ioLine); if (dioMode == null) throw new OperationNotSupportedException("Received configuration mode '" + HexUtils.IntegerToHexString(ioModeValue, 1) + "' is not valid."); // Return the configuration mode. return dioMode; }