Search in sources :

Example 1 with RemoteATCommandPacket

use of com.digi.xbee.api.packet.common.RemoteATCommandPacket in project JMRI by JMRI.

the class XBeeMessage method getRemoteDoutMessage.

/*
     * Get an XBee Message requesting an digital output pin be turned on or off.
     * @param address XBee Address of the node.  This can be either 
     16 bit or 64 bit.
     * @param pin the DIO Pin on the XBee to use.
     * @param on boolean value stating whether or not the pin should be turned
     *        on (true) or off (false)
     */
@SuppressFBWarnings(value = { "BC_UNCONFIRMED_CAST" }, justification = "The passed address must be either a 16 bit address or a 64 bit address, and we check to see if the address is a 16 bit address, so it is redundant to also check for a 64 bit address")
public static XBeeMessage getRemoteDoutMessage(Object address, int pin, boolean on) {
    byte[] onValue = { 0x5 };
    byte[] offValue = { 0x4 };
    if (address instanceof XBee16BitAddress) {
        return new XBeeMessage(new RemoteATCommandPacket(XBeeAPIPacket.NO_FRAME_ID, XBee64BitAddress.COORDINATOR_ADDRESS, (XBee16BitAddress) address, 0, "D" + pin, on ? onValue : offValue));
    } else {
        return new XBeeMessage(new RemoteATCommandPacket(XBeeAPIPacket.NO_FRAME_ID, (XBee64BitAddress) address, XBee16BitAddress.UNKNOWN_ADDRESS, 0, "D" + pin, on ? onValue : offValue));
    }
}
Also used : XBee64BitAddress(com.digi.xbee.api.models.XBee64BitAddress) XBee16BitAddress(com.digi.xbee.api.models.XBee16BitAddress) RemoteATCommandPacket(com.digi.xbee.api.packet.common.RemoteATCommandPacket) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Aggregations

XBee16BitAddress (com.digi.xbee.api.models.XBee16BitAddress)1 XBee64BitAddress (com.digi.xbee.api.models.XBee64BitAddress)1 RemoteATCommandPacket (com.digi.xbee.api.packet.common.RemoteATCommandPacket)1 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1