Skip to content

Commit 36ab282

Browse files
Add ZBExplicitRxResponse
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.
1 parent 4abe6a1 commit 36ab282

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

XBee.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,43 @@ void XBeeResponse::getZBRxResponse(XBeeResponse &rxResponse) {
176176
zb->getRemoteAddress64().setLsb((uint32_t(getFrameData()[4]) << 24) + (uint32_t(getFrameData()[5]) << 16) + (uint16_t(getFrameData()[6]) << 8) + (getFrameData()[7]));
177177
}
178178

179+
ZBExplicitRxResponse::ZBExplicitRxResponse(): ZBRxResponse() {
180+
}
181+
182+
uint8_t ZBExplicitRxResponse::getSrcEndpoint() {
183+
return getFrameData()[10];
184+
}
185+
186+
uint8_t ZBExplicitRxResponse::getDstEndpoint() {
187+
return getFrameData()[11];
188+
}
189+
190+
uint16_t ZBExplicitRxResponse::getClusterId() {
191+
return (uint16_t)(getFrameData()[12]) << 8 | getFrameData()[13];
192+
}
193+
194+
uint16_t ZBExplicitRxResponse::getProfileId() {
195+
return (uint16_t)(getFrameData()[14]) << 8 | getFrameData()[15];
196+
}
197+
198+
uint8_t ZBExplicitRxResponse::getOption() {
199+
return getFrameData()[16];
200+
}
201+
202+
// markers to read data from packet array.
203+
uint8_t ZBExplicitRxResponse::getDataOffset() {
204+
return 17;
205+
}
206+
207+
uint8_t ZBExplicitRxResponse::getDataLength() {
208+
return getPacketLength() - getDataOffset() - 1;
209+
}
210+
211+
void XBeeResponse::getZBExplicitRxResponse(XBeeResponse &rxResponse) {
212+
// Nothing to add to that
213+
getZBRxResponse(rxResponse);
214+
}
215+
179216

180217
ZBRxIoSampleResponse::ZBRxIoSampleResponse() : ZBRxResponse() {
181218

XBee.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,11 @@ class XBeeResponse {
223223
* to populate response
224224
*/
225225
void getZBRxResponse(XBeeResponse &response);
226+
/**
227+
* Call with instance of ZBExplicitRxResponse class only if getApiId() == ZB_EXPLICIT_RX_RESPONSE
228+
* to populate response
229+
*/
230+
void getZBExplicitRxResponse(XBeeResponse &response);
226231
/**
227232
* Call with instance of ZBRxIoSampleResponse class only if getApiId() == ZB_IO_SAMPLE_RESPONSE
228233
* to populate response
@@ -395,6 +400,25 @@ class ZBRxResponse : public RxDataResponse {
395400
XBeeAddress64 _remoteAddress64;
396401
};
397402

403+
/**
404+
* Represents a Series 2 Explicit RX packet
405+
*
406+
* Note: The receive these responses, set AO=1. With the default AO=0,
407+
* you will receive ZBRxResponses, not knowing exact details.
408+
*/
409+
class ZBExplicitRxResponse : public ZBRxResponse {
410+
public:
411+
ZBExplicitRxResponse();
412+
uint8_t getSrcEndpoint();
413+
uint8_t getDstEndpoint();
414+
uint16_t getClusterId();
415+
uint16_t getProfileId();
416+
uint8_t getOption();
417+
uint8_t getDataLength();
418+
// frame position where data starts
419+
uint8_t getDataOffset();
420+
};
421+
398422
/**
399423
* Represents a Series 2 RX I/O Sample packet
400424
*/

0 commit comments

Comments
 (0)