I would like to check frame ID of the status response.
One thing I'm not clear is if i send the packet with frameID 4 (eg.,) , status response for that packet will also contain frame ID of 4 or not. Following codes have been use to check it. Although I incremented frameID for each pacekt, status response Frame ID shows only '0'. Are there any mistake in my code. I have make it my codes 'bold' where I put the codes for checking frame ID.
Your kind response is highly appreciated.
#include <XBee.h>
XBee xbee = XBee();
XBeeResponse response = XBeeResponse();
ZBRxResponse rx = ZBRxResponse();
ModemStatusResponse msr = ModemStatusResponse();
FrameIdResponse frame=FrameIdResponse(); //to check frame ID for status response
uint8_t location[]={2,0,10,0};
uint8_t frameid=4;
void setup()
{
Serial.begin(9600);
xbee.begin(Serial);
delay(2000);
}
void loop(){
broadcast(location);
}
void broadcast(uint8_t location[])
{
Serial.print("\n Broadcasting\n");
uint8_t pay[] = {location[0],location[1],location[2],location[3]};
XBeeAddress64 addr64=XBeeAddress64(0x00000000, 0x0000ffff);
uint16_t addr16=0xFFFE;
uint8_t broadcastradius=1;
uint8_t option=0;
//Broadcasting with Frame ID
ZBTxRequest zbTX=ZBTxRequest(addr64,addr16,broadcastradius,option,pay,sizeof(pay),frameid);
ZBTxStatusResponse txStatus=ZBTxStatusResponse();
xbee.send(zbTX);
if (xbee.readPacket(5000)) {
Serial.print("\nGot a reply packet for broadcast");
if (xbee.getResponse().getApiId() == ZB_TX_STATUS_RESPONSE)
{
Serial.print("\n Got transmit status response");
xbee.getResponse().getZBTxStatusResponse(txStatus);
if (txStatus.getDeliveryStatus() == SUCCESS)
{
Serial.print("\nBroadcasting success!");
Serial.print("\n Status for frameID:");
uint8_t fid=frame.getFrameId(); // Check frame ID of status response.
Serial.print(fid);
} else
{
Serial.print("\nBroadcasting error!");
}
}
} else if (xbee.getResponse().isError()) {
Serial.print("Error reading packet. Error code: ");
Serial.println(xbee.getResponse().getErrorCode());
} else {
Serial.print("\nlocal XBee did not provide a timely TX Status Response -- should not happen");
}
frameid++;
delay(5000);
}