Home/Support/Support Forum/xbee: Receiving data in interrupts

xbee: Receiving data in interrupts

0 votes
I am trying to establish XBee communication using API mode. I wanted to get the data received by XBee using Interrupts. I am using the below code but i could not read data. can any one suggest some way of reading data received by XBee using Interrupts
#include <SoftwareSerial.h> #include <XBee.h> #include <avr/power.h> #include <avr/sleep.h> XBee xbee = XBee(); XBeeResponse response = XBeeResponse(); ZBRxResponse rx = ZBRxResponse(); SoftwareSerial test(2,1); String sample; void setup() { Serial.begin(9600); xbee.begin(test); attachInterrupt(0, receiveData, CHANGE ); } void receiveData() { xbee.readPacket(); if (xbee.getResponse().isAvailable()) { if (xbee.getResponse().getApiId() == ZB_RX_RESPONSE) { xbee.getResponse().getZBRxResponse(rx); for (int i = 0; i < rx.getDataLength(); i++) { sample += (char)rx.getData(i); } } }else if (xbee.getResponse().isError()) { sample += xbee.getResponse().getErrorCode(); } } void loop() { Serial.println(sample); delay(1000); }
asked Jul 14, 2015 in IEEE 802.15.4 by Avinash Babu New to the Community (4 points)

Please log in or register to answer this question.

1 Answer

0 votes
When you refer to an interrupt are you referring to an IO line or the UART data port?
answered Sep 3, 2015 by mvut Veteran of the Digi Community (11,302 points)