a

Dependents:   IOT_Sockets

Fork of xbee_api by Wiktor Grajkowski

Committer:
ammanvedi
Date:
Sat Feb 01 17:29:36 2014 +0000
Revision:
11:c8737cf52430
Parent:
10:61e607fa8621
added ifdef declarations

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 */
ammanvedi 11:c8737cf52430 18 #ifndef XBEE_H
ammanvedi 11:c8737cf52430 19 #define XBEE_H
ammanvedi 11:c8737cf52430 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;
noname77 7:8e5855f18ad3 30
tristanjph 0:2656fb225c5d 31 public:
tristanjph 2:cb627ea9b817 32 /** Configure serial data pin.
tristanjph 2:cb627ea9b817 33 * @param tx The serial tx pin the xbee is conected to.
tristanjph 2:cb627ea9b817 34 * @param rx The serial rx pin the xbee is conected to.
tristanjph 3:682615a0717e 35 * @param reset The pin connected to the Xbee reset pin.
tristanjph 1:c3d9bdcb0b03 36 */
tristanjph 3:682615a0717e 37 xbee(PinName tx, PinName rx, PinName reset);
tristanjph 0:2656fb225c5d 38 ~xbee();
tristanjph 2:cb627ea9b817 39 /** Puts the Xbee into config mode.
tristanjph 2:cb627ea9b817 40 * @return Returns 1 on success.
tristanjph 1:c3d9bdcb0b03 41 */
tristanjph 0:2656fb225c5d 42 int ConfigMode();
tristanjph 2:cb627ea9b817 43 /** Gets the serial number/mac address of the Xbee and places it into serial_no.
tristanjph 2:cb627ea9b817 44 * @param serial_no array to store the serial of Xbee (must be 8 long).
tristanjph 2:cb627ea9b817 45 * @return Returns 1 on success.
tristanjph 2:cb627ea9b817 46 */
tristanjph 2:cb627ea9b817 47 int GetSerial(int*);
tristanjph 2:cb627ea9b817 48 /** Sets the encryption key to the one stored in security_key.
tristanjph 2:cb627ea9b817 49 * @param key Pointer to the network key to set.
tristanjph 2:cb627ea9b817 50 * @return Returns 1 on success.
tristanjph 1:c3d9bdcb0b03 51 */
tristanjph 3:682615a0717e 52 int SetKey(int*);
tristanjph 2:cb627ea9b817 53 /** Sets the id of the PAN network for the Xbee to use
tristanjph 2:cb627ea9b817 54 * @param pan_id The id of the PAN for the Xbee to use.
tristanjph 2:cb627ea9b817 55 * @return Returns 1 on success.
tristanjph 1:c3d9bdcb0b03 56 */
tristanjph 2:cb627ea9b817 57 int SetPanId(int);
tristanjph 2:cb627ea9b817 58 /** Writes the settings to the Non volatile memory on the Xbee
tristanjph 2:cb627ea9b817 59 * @param key Pointer to the network key to set.
tristanjph 2:cb627ea9b817 60 * @return Returns 1 on success.
tristanjph 1:c3d9bdcb0b03 61 */
tristanjph 0:2656fb225c5d 62 int WriteSettings();
tristanjph 1:c3d9bdcb0b03 63 /** Exits config mode
tristanjph 2:cb627ea9b817 64 * @return Returns 1 on success.
tristanjph 1:c3d9bdcb0b03 65 */
tristanjph 0:2656fb225c5d 66 int ExitConfigMode();
tristanjph 2:cb627ea9b817 67 /** Sends data in the send_Data buffer.
tristanjph 2:cb627ea9b817 68 * @param data_buf Pointer to the buffer of data to send.
tristanjph 2:cb627ea9b817 69 * @returns 1 on success.
tristanjph 1:c3d9bdcb0b03 70 */
tristanjph 2:cb627ea9b817 71 int SendData(char*);
tristanjph 2:cb627ea9b817 72 /** Recieves data sent to the xbee.
tristanjph 2:cb627ea9b817 73 * @param data_buf Pointer to the buffer to put recieved data into.
tristanjph 2:cb627ea9b817 74 * @param numchar Number of characters to read. If 0, will use the size of data_buf.
tristanjph 2:cb627ea9b817 75 */
tristanjph 2:cb627ea9b817 76 void RecieveData(char*, int);
tristanjph 3:682615a0717e 77 /** Resets the Xbee.
tristanjph 3:682615a0717e 78 */
tristanjph 3:682615a0717e 79 void Reset();
ammanvedi 11:c8737cf52430 80 };
ammanvedi 11:c8737cf52430 81
ammanvedi 11:c8737cf52430 82 #endif