|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.rapplogic.xbee.api.XBee
public class XBee
This is an API for communicating with Digi XBee 802.15.4 and ZigBee radios via the serial port
Constructor Summary | |
---|---|
XBee()
|
|
XBee(XBeeConfiguration conf)
|
Method Summary | |
---|---|
void |
addPacketListener(PacketListener packetListener)
|
void |
clearResponseQueue()
Removes all packets off of the response queue |
void |
close()
Shuts down RXTX and packet parser thread |
java.util.List<? extends XBeeResponse> |
collectResponses(int wait)
Collects responses for wait milliseconds and returns responses as List |
java.util.List<? extends XBeeResponse> |
collectResponses(int wait,
CollectTerminator terminator)
Collects responses until the timeout is reached or the CollectTerminator returns true |
int |
getCurrentFrameId()
|
int |
getNextFrameId()
This is useful for obtaining a frame id when composing your XBeeRequest. |
XBeeResponse |
getResponse()
Same as getResponse(int) but does not timeout. |
XBeeResponse |
getResponse(int timeout)
This method returns an XBeeResponse from the queue, if available, or waits up to "timeout" milliseconds for a response. |
int |
getResponseQueueSize()
Returns the number of packets available in the response queue for immediate consumption |
void |
initProviderConnection(XBeeConnection connection)
Allows a protocol specific implementation of XBeeConnection to be used instead of the default RXTX connection. |
boolean |
isConnected()
Indicates if serial port connection has been established. |
void |
open(java.lang.String port,
int baudRate)
If XBeeConnection.startUpChecks is set to true (default), this method will check if the AP parameter is set correctly and attempt to update if AP=1. |
static void |
registerResponseHandler(int apiId,
java.lang.Class<? extends XBeeResponse> clazz)
|
void |
removePacketListener(PacketListener packetListener)
|
void |
sendAsynchronous(XBeeRequest request)
Sends an XBeeRequest though the XBee interface in an asynchronous manner, such that it will return immediately, without waiting for a response. |
AtCommandResponse |
sendAtCommand(AtCommand command)
Deprecated. Use this.sendSynchronous(command, timeout); |
void |
sendPacket(int[] packet)
This exists solely for the XMPP project. |
void |
sendPacket(XBeePacket packet)
It's possible for packets to get interspersed if multiple threads send simultaneously. |
void |
sendRequest(XBeeRequest request)
|
XBeeResponse |
sendSynchronous(XBeeRequest request)
Uses sendSynchronous timeout defined in XBeeConfiguration (default is 5000ms) |
XBeeResponse |
sendSynchronous(XBeeRequest xbeeRequest,
int timeout)
Synchronous method for sending an XBeeRequest and obtaining the corresponding response (response that has same frame id). |
static void |
unRegisterResponseHandler(int apiId)
|
void |
updateFrameId(int val)
Updates the frame id. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public XBee()
public XBee(XBeeConfiguration conf)
Method Detail |
---|
public void open(java.lang.String port, int baudRate) throws XBeeException
open
in interface IXBee
XBeeException
public static void registerResponseHandler(int apiId, java.lang.Class<? extends XBeeResponse> clazz)
public static void unRegisterResponseHandler(int apiId)
public void initProviderConnection(XBeeConnection connection) throws XBeeException
XBeeException
public void addPacketListener(PacketListener packetListener)
addPacketListener
in interface IXBee
public void removePacketListener(PacketListener packetListener)
removePacketListener
in interface IXBee
public void sendRequest(XBeeRequest request) throws java.io.IOException
java.io.IOException
public void sendPacket(XBeePacket packet) throws java.io.IOException
sendPacket
in interface IXBee
packet
-
java.io.IOException
public void sendPacket(int[] packet) throws java.io.IOException
sendPacket
in interface IXBee
packet
-
java.lang.RuntimeException
- when serial device is disconnected
java.io.IOException
public void sendAsynchronous(XBeeRequest request) throws XBeeException
sendAsynchronous
in interface IXBee
request
-
XBeeException
public AtCommandResponse sendAtCommand(AtCommand command) throws XBeeException
command
-
XBeeException
public XBeeResponse sendSynchronous(XBeeRequest xbeeRequest, int timeout) throws XBeeTimeoutException, XBeeException
sendSynchronous
in interface IXBee
xbeeRequest
-
XBeeException
XBeeTimeoutException
- thrown if no matching response is identifiedpublic XBeeResponse sendSynchronous(XBeeRequest request) throws XBeeTimeoutException, XBeeException
XBeeTimeoutException
XBeeException
public XBeeResponse getResponse() throws XBeeException
getResponse
in interface IXBee
XBeeException
public XBeeResponse getResponse(int timeout) throws XBeeException, XBeeTimeoutException
getResponse
in interface IXBee
timeout
- milliseconds to wait for a response. A value of zero disables the timeout
XBeeException
XBeeTimeoutException
- if timeout occurs before a response is receivedpublic java.util.List<? extends XBeeResponse> collectResponses(int wait, CollectTerminator terminator) throws XBeeException
collectResponses
in interface IXBee
wait
- terminator
-
XBeeException
public java.util.List<? extends XBeeResponse> collectResponses(int wait) throws XBeeException
wait
-
XBeeException
public int getResponseQueueSize()
public void close()
close
in interface IXBee
public boolean isConnected()
isConnected
in interface IXBee
public int getCurrentFrameId()
getCurrentFrameId
in interface IXBee
public int getNextFrameId()
getNextFrameId
in interface IXBee
public void updateFrameId(int val)
updateFrameId
in interface IXBee
val
- Jan 24, 2009public void clearResponseQueue()
clearResponseQueue
in interface IXBee
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |