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 Tristan Hughes

Committer:
tristanjph
Date:
Wed Aug 29 13:27:02 2012 +0000
Revision:
2:cb627ea9b817
Parent:
1:c3d9bdcb0b03
Child:
3:682615a0717e
Update send/receive added setting network pan id

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tristanjph 0:2656fb225c5d 1 #include "mbed.h"
tristanjph 0:2656fb225c5d 2
tristanjph 1:c3d9bdcb0b03 3 /** Xbee interface class for configuring, sending and recieving data using an Xbee */
tristanjph 2:cb627ea9b817 4 class xbee
tristanjph 2:cb627ea9b817 5 {
tristanjph 0:2656fb225c5d 6 private:
tristanjph 0:2656fb225c5d 7 PinName _tx;
tristanjph 0:2656fb225c5d 8 PinName _rx;
tristanjph 0:2656fb225c5d 9 public:
tristanjph 2:cb627ea9b817 10 /** Configure serial data pin.
tristanjph 2:cb627ea9b817 11 * @param tx The serial tx pin the xbee is conected to.
tristanjph 2:cb627ea9b817 12 * @param rx The serial rx pin the xbee is conected to.
tristanjph 1:c3d9bdcb0b03 13 */
tristanjph 1:c3d9bdcb0b03 14 xbee(PinName tx, PinName rx);
tristanjph 0:2656fb225c5d 15 ~xbee();
tristanjph 2:cb627ea9b817 16 /** Puts the Xbee into config mode.
tristanjph 2:cb627ea9b817 17 * @return Returns 1 on success.
tristanjph 1:c3d9bdcb0b03 18 */
tristanjph 0:2656fb225c5d 19 int ConfigMode();
tristanjph 2:cb627ea9b817 20 /** Gets the serial number/mac address of the Xbee and places it into serial_no.
tristanjph 2:cb627ea9b817 21 * @param serial_no array to store the serial of Xbee (must be 8 long).
tristanjph 2:cb627ea9b817 22 * @return Returns 1 on success.
tristanjph 2:cb627ea9b817 23 */
tristanjph 2:cb627ea9b817 24 int GetSerial(int*);
tristanjph 2:cb627ea9b817 25 /** Sets the encryption key to the one stored in security_key.
tristanjph 2:cb627ea9b817 26 * @param key Pointer to the network key to set.
tristanjph 2:cb627ea9b817 27 * @return Returns 1 on success.
tristanjph 1:c3d9bdcb0b03 28 */
tristanjph 2:cb627ea9b817 29 int SetKey(char*);
tristanjph 2:cb627ea9b817 30 /** Sets the id of the PAN network for the Xbee to use
tristanjph 2:cb627ea9b817 31 * @param pan_id The id of the PAN for the Xbee to use.
tristanjph 2:cb627ea9b817 32 * @return Returns 1 on success.
tristanjph 1:c3d9bdcb0b03 33 */
tristanjph 2:cb627ea9b817 34 int SetPanId(int);
tristanjph 2:cb627ea9b817 35 /** Writes the settings to the Non volatile memory on the Xbee
tristanjph 2:cb627ea9b817 36 * @param key Pointer to the network key to set.
tristanjph 2:cb627ea9b817 37 * @return Returns 1 on success.
tristanjph 1:c3d9bdcb0b03 38 */
tristanjph 0:2656fb225c5d 39 int WriteSettings();
tristanjph 1:c3d9bdcb0b03 40 /** Exits config mode
tristanjph 2:cb627ea9b817 41 * @return Returns 1 on success.
tristanjph 1:c3d9bdcb0b03 42 */
tristanjph 0:2656fb225c5d 43 int ExitConfigMode();
tristanjph 2:cb627ea9b817 44 /** Sends data in the send_Data buffer.
tristanjph 2:cb627ea9b817 45 * @param data_buf Pointer to the buffer of data to send.
tristanjph 2:cb627ea9b817 46 * @returns 1 on success.
tristanjph 1:c3d9bdcb0b03 47 */
tristanjph 2:cb627ea9b817 48 int SendData(char*);
tristanjph 2:cb627ea9b817 49 /** Recieves data sent to the xbee.
tristanjph 2:cb627ea9b817 50 * @param data_buf Pointer to the buffer to put recieved data into.
tristanjph 2:cb627ea9b817 51 * @param numchar Number of characters to read. If 0, will use the size of data_buf.
tristanjph 2:cb627ea9b817 52 */
tristanjph 2:cb627ea9b817 53 void RecieveData(char*, int);
tristanjph 2:cb627ea9b817 54
tristanjph 0:2656fb225c5d 55 };