Ava Chen / xbeelib

Fork of xbee_lib by Tristan Hughes

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers xbee.h Source File

xbee.h

00001 #ifndef XBEE_H
00002 #define XBEE_H
00003 
00004 /* Copyright (c) 2012 Tristan Hughes, MIT License
00005  *
00006  * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 
00007  * and associated documentation files (the "Software"), to deal in the Software without restriction, 
00008  * including without limitation the rights to use, copy, modify, merge, publish, distribute, 
00009  * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 
00010  * furnished to do so, subject to the following conditions:
00011  *
00012  * The above copyright notice and this permission notice shall be included in all copies or 
00013  * substantial portions of the Software.
00014  *
00015  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 
00016  * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
00017  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 
00018  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
00019  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00020  */
00021 #include "mbed.h"
00022 
00023 /** Xbee interface class for configuring, sending and recieving data using an Xbee */
00024 class xbee
00025 {
00026 private:
00027     PinName _tx;
00028     PinName _rx;
00029     PinName _reset;
00030 public:
00031     /** Configure serial data pin.
00032       * @param tx The serial tx pin the xbee is conected to.
00033       * @param rx The serial rx pin the xbee is conected to.
00034       * @param reset The pin connected to the Xbee reset pin.
00035       */
00036     xbee(PinName tx, PinName rx, PinName reset);
00037     ~xbee();
00038     /** Puts the Xbee into config mode.
00039       * @return Returns 1 on success.
00040       */
00041     int ConfigMode();
00042     /** Gets the serial number/mac address of the Xbee and places it into serial_no.
00043       * @param serial_no array to store the serial of Xbee (must be 8 long).
00044       * @return Returns 1 on success.
00045       */
00046     int GetSerial(int*);
00047     /** Sets the encryption key. This should be a 128-bit key.
00048       * @param key Pointer to the network key to set.
00049       * @return Returns 1 on success.
00050       */
00051     int SetKey(char*);
00052     /** Sets the id of the PAN network for the Xbee to use
00053       * @param pan_id The id of the PAN for the Xbee to use.
00054       * @return Returns 1 on success.
00055       */
00056     int SetPanId(int);
00057     /** Writes the settings to the Non volatile memory on the Xbee
00058       * @param key Pointer to the network key to set.
00059       * @return Returns 1 on success.
00060       */
00061     int WriteSettings();
00062     /** Exits config mode
00063       * @return Returns 1 on success.
00064       */
00065     int ExitConfigMode();
00066     /** Sends data in the send_Data buffer.
00067       * @param data_buf Pointer to the buffer of data to send.
00068       * @returns 1 on success.
00069       */
00070     int SendData(char*);
00071     /** Recieves data sent to the xbee.
00072       * @param data_buf Pointer to the buffer to put recieved data into.
00073       * @param numchar Number of characters to read. If 0, will use the size of data_buf.
00074       */
00075     void RecieveData(char*, int);
00076         /** Resets the Xbee.
00077       */
00078     void Reset();
00079 
00080 };
00081 #endif