Xbee S2C TX problems XBeeRequest invalid

Hello,

i'm trying to make a communication using 2 xbee module S2C using the library of andrewrapp in APi Mode. I have made a program base on the different examples of this lib. When i used the RX examples, there was no problems but now with the TX examples, i don't have any result. i got this message in my Arduino Compiler :

invalid cast to abstract class type 'XBeeRequest' "

This is the only line in my code that is related to this error :

XBeeRequest request = XBeeRequest(1,5);

And here is the class XBeeRequest in the library :

class XBeeRequest {
public:
	/**
	 * Constructor
	 * TODO make protected
	 */
	XBeeRequest(uint8_t apiId, uint8_t frameId);
	/**
	 * Sets the frame id.  Must be between 1 and 255 inclusive to get a TX status response.
	 */
	void setFrameId(uint8_t frameId);
	/**
	 * Returns the frame id
	 */
	uint8_t getFrameId();
	/**
	 * Returns the API id
	 */
	uint8_t getApiId();
	// setting = 0 makes this a pure virtual function, meaning the subclass must implement, like abstract in java
	/**
	 * Starting after the frame id (pos = 0) and up to but not including the checksum
	 * Note: Unlike Digi's definition of the frame data, this does not start with the API ID.
	 * The reason for this is the API ID and Frame ID are common to all requests, whereas my definition of
	 * frame data is only the API specific data.
	 */
	virtual uint8_t getFrameData(uint8_t pos) = 0;
	/**
	 * Returns the size of the api frame (not including frame id or api id or checksum).
	 */
	virtual uint8_t getFrameDataLength() = 0;
	//void reset();
protected:
	void setApiId(uint8_t apiId);
private:
	uint8_t _apiId;
	uint8_t _frameId;
};

This is kinda of driving me crazy so if somebody have any idea, i'm listening to you :slight_smile:

#include <SoftwareSerial.h>
SoftwareSerial xbee(2, 3);

void setup() {
  xbee.begin (9600);
  Serial.begin(9600);
}

I already did that solution but there is something i still don't understand.
How can i make an unicast request if i have another xbee ( in case of three or more xbees) ?

#include <SoftwareSerial.h>
SoftwareSerial xbee1(2, 3);
SoftwareSerial xbee2(4, 5);

void setup() {
  xbee1.begin (9600);
  xbee2.begin (9600);
  Serial.begin(9600);
}

In your code, if i understand it well, i need to create a new softwareSerial and add the xbee on it. It has to be done on one Arduino.
In my case, i will have two Arduinos and a Raspberry with a Xbee on each module. So i don't understand the new softwareSerial in your message.

three modules on one board, or I don't understand what it mean
aha, I was wrong thinking (x, y) are pins. OK. I don't know this lib. look for other helper.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.