public class DeviceResponsePacket extends XBeeAPIPacket
This frame type is sent to the serial port by the host in response to the
DeviceRequestPacket
. It should be sent within five seconds to avoid
a timeout error.
DeviceRequestPacket
,
XBeeAPIPacket
NO_FRAME_ID
Constructor and Description |
---|
DeviceResponsePacket(int frameID,
int requestID,
byte[] responseData)
Class constructor.
|
Modifier and Type | Method and Description |
---|---|
static DeviceResponsePacket |
createPacket(byte[] payload)
Creates a new
DeviceResponsePacket object from the given payload. |
LinkedHashMap<String,String> |
getAPIPacketParameters()
Returns a map with the XBee packet parameters and their values.
|
int |
getRequestID()
Retrieves the ID of the device response.
|
byte[] |
getResponseData()
Retrieves the data of the device response.
|
boolean |
isBroadcast()
Returns whether or not the packet is a broadcast packet.
|
boolean |
needsAPIFrameID()
Returns whether the API packet needs API Frame ID or not.
|
void |
setRequestID(int requestID)
Sets ID of the device response.
|
void |
setResponseData(byte[] responseData)
Sets the data of the device response.
|
checkFrameID, getAPIData, getFrameID, getFrameType, getFrameTypeValue, getPacketData, setFrameID
equals, generateByteArray, generateByteArrayEscaped, getChecksum, getPacketLength, getParameters, hashCode, parsePacket, parsePacket, toPrettyString, toString
public DeviceResponsePacket(int frameID, int requestID, byte[] responseData)
DeviceResponsePacket
object
with the given parameters.frameID
- Frame ID.requestID
- Device Request ID. This number should match the device
request ID in the device request. Otherwise, an error
will occur. (0 has no special meaning in this case.)responseData
- Data of the response.IllegalArgumentException
- if frameID < 0
or
if frameID > 255
or
if requestID < 0
or
if requestID > 255
.public static DeviceResponsePacket createPacket(byte[] payload)
DeviceResponsePacket
object from the given payload.payload
- The API frame payload. It must start with the frame type
corresponding to a Device Response packet (0x2A
).
The byte array must be in OperatingMode.API
mode.IllegalArgumentException
- if payload[0] != APIFrameType.DEVICE_RESPONSE.getValue()
or
if payload.length <
.NullPointerException
- if payload == null
.public LinkedHashMap<String,String> getAPIPacketParameters()
XBeeAPIPacket
public int getRequestID()
setRequestID(int)
public byte[] getResponseData()
setResponseData(byte[])
public boolean isBroadcast()
XBeeAPIPacket
isBroadcast
in class XBeeAPIPacket
true
if the packet is a broadcast packet, false
otherwise.public boolean needsAPIFrameID()
XBeeAPIPacket
needsAPIFrameID
in class XBeeAPIPacket
true
if the packet needs API Frame ID, false
otherwise.public void setRequestID(int requestID)
requestID
- ID of the device response.IllegalArgumentException
- if requestID < 0
or
if requestID > 255
.getRequestID()
public void setResponseData(byte[] responseData)
responseData
- Data of the device response.getResponseData()
© Copyright 2014 - 2024 Digi International Inc. All rights reserved.