Skip to content

Commit

Permalink
Add ZBExplicitRxResponse
Browse files Browse the repository at this point in the history
This allows receiving "ZigBee Explicit Rx Indicator" API frames,
that specify the endpoints, profile id and cluster id for a
received message, e.g. to interact through standard Zigbee protocols.
These API frames are enabled by setting AO=1.
  • Loading branch information
matthijskooijman committed Jul 13, 2015
1 parent 4abe6a1 commit 36ab282
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
37 changes: 37 additions & 0 deletions XBee.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,43 @@ void XBeeResponse::getZBRxResponse(XBeeResponse &rxResponse) {
zb->getRemoteAddress64().setLsb((uint32_t(getFrameData()[4]) << 24) + (uint32_t(getFrameData()[5]) << 16) + (uint16_t(getFrameData()[6]) << 8) + (getFrameData()[7]));
}

ZBExplicitRxResponse::ZBExplicitRxResponse(): ZBRxResponse() {
}

uint8_t ZBExplicitRxResponse::getSrcEndpoint() {
return getFrameData()[10];
}

uint8_t ZBExplicitRxResponse::getDstEndpoint() {
return getFrameData()[11];
}

uint16_t ZBExplicitRxResponse::getClusterId() {
return (uint16_t)(getFrameData()[12]) << 8 | getFrameData()[13];
}

uint16_t ZBExplicitRxResponse::getProfileId() {
return (uint16_t)(getFrameData()[14]) << 8 | getFrameData()[15];
}

uint8_t ZBExplicitRxResponse::getOption() {
return getFrameData()[16];
}

// markers to read data from packet array.
uint8_t ZBExplicitRxResponse::getDataOffset() {
return 17;
}

uint8_t ZBExplicitRxResponse::getDataLength() {
return getPacketLength() - getDataOffset() - 1;
}

void XBeeResponse::getZBExplicitRxResponse(XBeeResponse &rxResponse) {
// Nothing to add to that
getZBRxResponse(rxResponse);
}


ZBRxIoSampleResponse::ZBRxIoSampleResponse() : ZBRxResponse() {

Expand Down
24 changes: 24 additions & 0 deletions XBee.h
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,11 @@ class XBeeResponse {
* to populate response
*/
void getZBRxResponse(XBeeResponse &response);
/**
* Call with instance of ZBExplicitRxResponse class only if getApiId() == ZB_EXPLICIT_RX_RESPONSE
* to populate response
*/
void getZBExplicitRxResponse(XBeeResponse &response);
/**
* Call with instance of ZBRxIoSampleResponse class only if getApiId() == ZB_IO_SAMPLE_RESPONSE
* to populate response
Expand Down Expand Up @@ -395,6 +400,25 @@ class ZBRxResponse : public RxDataResponse {
XBeeAddress64 _remoteAddress64;
};

/**
* Represents a Series 2 Explicit RX packet
*
* Note: The receive these responses, set AO=1. With the default AO=0,
* you will receive ZBRxResponses, not knowing exact details.
*/
class ZBExplicitRxResponse : public ZBRxResponse {
public:
ZBExplicitRxResponse();
uint8_t getSrcEndpoint();
uint8_t getDstEndpoint();
uint16_t getClusterId();
uint16_t getProfileId();
uint8_t getOption();
uint8_t getDataLength();
// frame position where data starts
uint8_t getDataOffset();
};

/**
* Represents a Series 2 RX I/O Sample packet
*/
Expand Down

0 comments on commit 36ab282

Please sign in to comment.