tristanjph with include guard

Fork of xbee_lib by Tristan Hughes

Committer:
avachen
Date:
Thu Mar 10 18:38:37 2016 +0000
Revision:
7:accd25ecfeb9
Parent:
6:6455a079bdb3
added include guards

Who changed what in which revision?

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