xbee in api mode library

Fork of xbee_lib by Tristan Hughes

Committer:
noname77
Date:
Sun Jan 26 17:19:28 2014 +0000
Revision:
10:61e607fa8621
Parent:
7:8e5855f18ad3
some working code

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tristanjph 4:ede20c047d8b 1 /* Copyright (c) 2012 Tristan Hughes, MIT License
tristanjph 4:ede20c047d8b 2 *
tristanjph 4:ede20c047d8b 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
tristanjph 4:ede20c047d8b 4 * and associated documentation files (the "Software"), to deal in the Software without restriction,
tristanjph 4:ede20c047d8b 5 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
tristanjph 4:ede20c047d8b 6 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
tristanjph 4:ede20c047d8b 7 * furnished to do so, subject to the following conditions:
tristanjph 4:ede20c047d8b 8 *
tristanjph 4:ede20c047d8b 9 * The above copyright notice and this permission notice shall be included in all copies or
tristanjph 4:ede20c047d8b 10 * substantial portions of the Software.
tristanjph 4:ede20c047d8b 11 *
tristanjph 4:ede20c047d8b 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
tristanjph 4:ede20c047d8b 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
tristanjph 4:ede20c047d8b 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
tristanjph 4:ede20c047d8b 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
tristanjph 4:ede20c047d8b 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
tristanjph 4:ede20c047d8b 17 */
tristanjph 0:2656fb225c5d 18 #include "mbed.h"
tristanjph 0:2656fb225c5d 19
tristanjph 1:c3d9bdcb0b03 20 /** Xbee interface class for configuring, sending and recieving data using an Xbee */
tristanjph 2:cb627ea9b817 21 class xbee
tristanjph 2:cb627ea9b817 22 {
tristanjph 0:2656fb225c5d 23 private:
tristanjph 0:2656fb225c5d 24 PinName _tx;
tristanjph 0:2656fb225c5d 25 PinName _rx;
tristanjph 3:682615a0717e 26 PinName _reset;
noname77 7:8e5855f18ad3 27
tristanjph 0:2656fb225c5d 28 public:
tristanjph 2:cb627ea9b817 29 /** Configure serial data pin.
tristanjph 2:cb627ea9b817 30 * @param tx The serial tx pin the xbee is conected to.
tristanjph 2:cb627ea9b817 31 * @param rx The serial rx pin the xbee is conected to.
tristanjph 3:682615a0717e 32 * @param reset The pin connected to the Xbee reset pin.
tristanjph 1:c3d9bdcb0b03 33 */
tristanjph 3:682615a0717e 34 xbee(PinName tx, PinName rx, PinName reset);
tristanjph 0:2656fb225c5d 35 ~xbee();
tristanjph 2:cb627ea9b817 36 /** Puts the Xbee into config mode.
tristanjph 2:cb627ea9b817 37 * @return Returns 1 on success.
tristanjph 1:c3d9bdcb0b03 38 */
tristanjph 0:2656fb225c5d 39 int ConfigMode();
tristanjph 2:cb627ea9b817 40 /** Gets the serial number/mac address of the Xbee and places it into serial_no.
tristanjph 2:cb627ea9b817 41 * @param serial_no array to store the serial of Xbee (must be 8 long).
tristanjph 2:cb627ea9b817 42 * @return Returns 1 on success.
tristanjph 2:cb627ea9b817 43 */
tristanjph 2:cb627ea9b817 44 int GetSerial(int*);
tristanjph 2:cb627ea9b817 45 /** Sets the encryption key to the one stored in security_key.
tristanjph 2:cb627ea9b817 46 * @param key Pointer to the network key to set.
tristanjph 2:cb627ea9b817 47 * @return Returns 1 on success.
tristanjph 1:c3d9bdcb0b03 48 */
tristanjph 3:682615a0717e 49 int SetKey(int*);
tristanjph 2:cb627ea9b817 50 /** Sets the id of the PAN network for the Xbee to use
tristanjph 2:cb627ea9b817 51 * @param pan_id The id of the PAN for the Xbee to use.
tristanjph 2:cb627ea9b817 52 * @return Returns 1 on success.
tristanjph 1:c3d9bdcb0b03 53 */
tristanjph 2:cb627ea9b817 54 int SetPanId(int);
tristanjph 2:cb627ea9b817 55 /** Writes the settings to the Non volatile memory on the Xbee
tristanjph 2:cb627ea9b817 56 * @param key Pointer to the network key to set.
tristanjph 2:cb627ea9b817 57 * @return Returns 1 on success.
tristanjph 1:c3d9bdcb0b03 58 */
tristanjph 0:2656fb225c5d 59 int WriteSettings();
tristanjph 1:c3d9bdcb0b03 60 /** Exits config mode
tristanjph 2:cb627ea9b817 61 * @return Returns 1 on success.
tristanjph 1:c3d9bdcb0b03 62 */
tristanjph 0:2656fb225c5d 63 int ExitConfigMode();
tristanjph 2:cb627ea9b817 64 /** Sends data in the send_Data buffer.
tristanjph 2:cb627ea9b817 65 * @param data_buf Pointer to the buffer of data to send.
tristanjph 2:cb627ea9b817 66 * @returns 1 on success.
tristanjph 1:c3d9bdcb0b03 67 */
tristanjph 2:cb627ea9b817 68 int SendData(char*);
tristanjph 2:cb627ea9b817 69 /** Recieves data sent to the xbee.
tristanjph 2:cb627ea9b817 70 * @param data_buf Pointer to the buffer to put recieved data into.
tristanjph 2:cb627ea9b817 71 * @param numchar Number of characters to read. If 0, will use the size of data_buf.
tristanjph 2:cb627ea9b817 72 */
tristanjph 2:cb627ea9b817 73 void RecieveData(char*, int);
tristanjph 3:682615a0717e 74 /** Resets the Xbee.
tristanjph 3:682615a0717e 75 */
tristanjph 3:682615a0717e 76 void Reset();
tristanjph 0:2656fb225c5d 77 };