edu.uiuc.cs.seclab.modem.xbee
Class XBeeApiPacket

java.lang.Object
  extended by edu.uiuc.cs.seclab.modem.ModemPacket
      extended by edu.uiuc.cs.seclab.modem.xbee.XBeeApiPacket

public class XBeeApiPacket
extends ModemPacket

API-mode packet for XBee modems


Field Summary
static int DAT_OFFSET
           
static int EXTRA_BYTES
           
protected  XBeeApiPacketImpl impl
           
static int MAX_LEN
           
static char START_DELIM
           
 
Fields inherited from class edu.uiuc.cs.seclab.modem.ModemPacket
cksum, data
 
Constructor Summary
XBeeApiPacket(byte[] data, boolean stripped)
           
XBeeApiPacket(java.lang.String data, boolean stripped)
          Create an XBee API packet from raw data.
XBeeApiPacket(XBeeApiPacketImpl impl_)
           
 
Method Summary
 void acceptVisitor(XBeeApiPacketVisitor visitor)
           
private static byte[] createData(byte[] data)
          Wrap an API packet payload so that it conforms to the following format: Start delim.
private  void createImpl(byte[] bytes, int offset, int len)
          Create an API packet implementation based on the command ID in the packet
 XBeeApiPacketImpl getImpl()
           
private  void parse(boolean stripped)
          Parse an API packet formatted as explained in previous methods comment and create an appropriate packet implementation.
 java.lang.String toString()
           
 
Methods inherited from class edu.uiuc.cs.seclab.modem.ModemPacket
append, calcCksum, getCksum, getData, setData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DAT_OFFSET

public static final int DAT_OFFSET
See Also:
Constant Field Values

EXTRA_BYTES

public static final int EXTRA_BYTES
See Also:
Constant Field Values

impl

protected XBeeApiPacketImpl impl

MAX_LEN

public static final int MAX_LEN
See Also:
Constant Field Values

START_DELIM

public static final char START_DELIM
See Also:
Constant Field Values
Constructor Detail

XBeeApiPacket

public XBeeApiPacket(byte[] data,
                     boolean stripped)
              throws ModemException
Throws:
ModemException

XBeeApiPacket

public XBeeApiPacket(java.lang.String data,
                     boolean stripped)
              throws ModemException
Create an XBee API packet from raw data.

Parameters:
data -
b -
full - Set to false if to have the extra bytes automatically added
Throws:
ModemException

XBeeApiPacket

public XBeeApiPacket(XBeeApiPacketImpl impl_)
              throws ModemException
Throws:
ModemException
Method Detail

acceptVisitor

public void acceptVisitor(XBeeApiPacketVisitor visitor)

createData

private static byte[] createData(byte[] data)
                          throws ModemException
Wrap an API packet payload so that it conforms to the following format: Start delim. Length [----0x7E----] [MSB][LSB] [payload] [8-bit cksum]

Throws:
ModemException

createImpl

private void createImpl(byte[] bytes,
                        int offset,
                        int len)
                 throws ModemException
Create an API packet implementation based on the command ID in the packet

Throws:
ModemException

getImpl

public XBeeApiPacketImpl getImpl()

parse

private void parse(boolean stripped)
            throws ModemException
Parse an API packet formatted as explained in previous methods comment and create an appropriate packet implementation.

Parameters:
stripped - - Set to true if delimiter and length have already been stripped
Throws:
ModemException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object