A library allowing basic functions of the XBEE pro to be used. Currently supported are: Enter/exit config mode, reading device serial number, setting encryption key, writing settings to non volatile memory and sending data strings.
Dependents: Seeed_XBee_Shield Seeed_XBee_Shield-2
Fork of xbee_lib by
Revision 1:c3d9bdcb0b03, committed 2012-08-29
- Comitter:
- tristanjph
- Date:
- Wed Aug 29 10:39:42 2012 +0000
- Parent:
- 0:2656fb225c5d
- Child:
- 2:cb627ea9b817
- Commit message:
- Added receive data and documentation
Changed in this revision
xbee.cpp | Show annotated file Show diff for this revision Revisions of this file |
xbee.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/xbee.cpp Tue Aug 28 14:00:33 2012 +0000 +++ b/xbee.cpp Wed Aug 29 10:39:42 2012 +0000 @@ -90,3 +90,15 @@ return 1; } +void xbee::RecieveData(int numchar) +{ + int count=0; + Serial DATA(_tx,_rx); + while(numchar!=count) { + if(DATA.readable()) { + readData[count] = DATA.getc(); + count++; + } + + } +
--- a/xbee.h Tue Aug 28 14:00:33 2012 +0000 +++ b/xbee.h Wed Aug 29 10:39:42 2012 +0000 @@ -1,21 +1,48 @@ #include "mbed.h" - +/** Xbee interface class for configuring, sending and recieving data using an Xbee */ class xbee { private: PinName _tx; PinName _rx; public: - xbee(PinName _tx, PinName _rx); + /** Configure serial data pin + * @param tx The serial tx pin the xbee is conected to + * @param rx The serial rx pin the xbee is conected to + */ + xbee(PinName tx, PinName rx); ~xbee(); + /** Puts the Xbee into config mode + * @return Returns 1 on success + */ int ConfigMode(); + /** Gets the serial number of the Xbee + * @return Returns 1 on success + */ int GetSerial(); + /** Sets the encryption key for the Xbee + * @return Returns 1 on success + */ int SetKey(); + /** Writes the settings to the Non volatile memory on the Xbee + * @return Returns 1 on success + */ int WriteSettings(); + /** Exits config mode + * @return Returns 1 on success + */ int ExitConfigMode(); + /** Sends data in the sendData buffer + * @return Returns 1 on success + */ int SendData(); + /** Recieves data and puts it into the recieveData buffer. Will over write anything already in the buffer + * @param numchar Number of characters to read + */ + void RecieveData(int numchar); int serial_no[8]; int security_key[16]; char sendData[202]; + char readData[202]; }; \ No newline at end of file