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

Fork of xbee_lib by Tristan Hughes

Committer:
tristanjph
Date:
Wed Aug 29 14:04:27 2012 +0000
Revision:
3:682615a0717e
Parent:
2:cb627ea9b817
Child:
4:ede20c047d8b
Added reset, general fixes

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 3:682615a0717e 9 PinName _reset;
tristanjph 0:2656fb225c5d 10 public:
tristanjph 2:cb627ea9b817 11 /** Configure serial data pin.
tristanjph 2:cb627ea9b817 12 * @param tx The serial tx pin the xbee is conected to.
tristanjph 2:cb627ea9b817 13 * @param rx The serial rx pin the xbee is conected to.
tristanjph 3:682615a0717e 14 * @param reset The pin connected to the Xbee reset pin.
tristanjph 1:c3d9bdcb0b03 15 */
tristanjph 3:682615a0717e 16 xbee(PinName tx, PinName rx, PinName reset);
tristanjph 0:2656fb225c5d 17 ~xbee();
tristanjph 2:cb627ea9b817 18 /** Puts the Xbee into config mode.
tristanjph 2:cb627ea9b817 19 * @return Returns 1 on success.
tristanjph 1:c3d9bdcb0b03 20 */
tristanjph 0:2656fb225c5d 21 int ConfigMode();
tristanjph 2:cb627ea9b817 22 /** Gets the serial number/mac address of the Xbee and places it into serial_no.
tristanjph 2:cb627ea9b817 23 * @param serial_no array to store the serial of Xbee (must be 8 long).
tristanjph 2:cb627ea9b817 24 * @return Returns 1 on success.
tristanjph 2:cb627ea9b817 25 */
tristanjph 2:cb627ea9b817 26 int GetSerial(int*);
tristanjph 2:cb627ea9b817 27 /** Sets the encryption key to the one stored in security_key.
tristanjph 2:cb627ea9b817 28 * @param key Pointer to the network key to set.
tristanjph 2:cb627ea9b817 29 * @return Returns 1 on success.
tristanjph 1:c3d9bdcb0b03 30 */
tristanjph 3:682615a0717e 31 int SetKey(int*);
tristanjph 2:cb627ea9b817 32 /** Sets the id of the PAN network for the Xbee to use
tristanjph 2:cb627ea9b817 33 * @param pan_id The id of the PAN for the Xbee to use.
tristanjph 2:cb627ea9b817 34 * @return Returns 1 on success.
tristanjph 1:c3d9bdcb0b03 35 */
tristanjph 2:cb627ea9b817 36 int SetPanId(int);
tristanjph 2:cb627ea9b817 37 /** Writes the settings to the Non volatile memory on the Xbee
tristanjph 2:cb627ea9b817 38 * @param key Pointer to the network key to set.
tristanjph 2:cb627ea9b817 39 * @return Returns 1 on success.
tristanjph 1:c3d9bdcb0b03 40 */
tristanjph 0:2656fb225c5d 41 int WriteSettings();
tristanjph 1:c3d9bdcb0b03 42 /** Exits config mode
tristanjph 2:cb627ea9b817 43 * @return Returns 1 on success.
tristanjph 1:c3d9bdcb0b03 44 */
tristanjph 0:2656fb225c5d 45 int ExitConfigMode();
tristanjph 2:cb627ea9b817 46 /** Sends data in the send_Data buffer.
tristanjph 2:cb627ea9b817 47 * @param data_buf Pointer to the buffer of data to send.
tristanjph 2:cb627ea9b817 48 * @returns 1 on success.
tristanjph 1:c3d9bdcb0b03 49 */
tristanjph 2:cb627ea9b817 50 int SendData(char*);
tristanjph 2:cb627ea9b817 51 /** Recieves data sent to the xbee.
tristanjph 2:cb627ea9b817 52 * @param data_buf Pointer to the buffer to put recieved data into.
tristanjph 2:cb627ea9b817 53 * @param numchar Number of characters to read. If 0, will use the size of data_buf.
tristanjph 2:cb627ea9b817 54 */
tristanjph 2:cb627ea9b817 55 void RecieveData(char*, int);
tristanjph 3:682615a0717e 56 /** Resets the Xbee.
tristanjph 3:682615a0717e 57 */
tristanjph 3:682615a0717e 58 void Reset();
tristanjph 2:cb627ea9b817 59
tristanjph 0:2656fb225c5d 60 };