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