A libery to connect to telegesis zigbee module. Bassed on implemtation of XBEE
Fork of xbee_lib by
xbee.h@4:ede20c047d8b, 2012-08-29 (annotated)
- Committer:
- tristanjph
- Date:
- Wed Aug 29 14:34:53 2012 +0000
- Revision:
- 4:ede20c047d8b
- Parent:
- 3:682615a0717e
- Child:
- 5:714651141a83
Documentation update
Who changed what in which revision?
User | Revision | Line number | New 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; |
tristanjph | 0:2656fb225c5d | 27 | public: |
tristanjph | 2:cb627ea9b817 | 28 | /** Configure serial data pin. |
tristanjph | 2:cb627ea9b817 | 29 | * @param tx The serial tx pin the xbee is conected to. |
tristanjph | 2:cb627ea9b817 | 30 | * @param rx The serial rx pin the xbee is conected to. |
tristanjph | 3:682615a0717e | 31 | * @param reset The pin connected to the Xbee reset pin. |
tristanjph | 1:c3d9bdcb0b03 | 32 | */ |
tristanjph | 3:682615a0717e | 33 | xbee(PinName tx, PinName rx, PinName reset); |
tristanjph | 0:2656fb225c5d | 34 | ~xbee(); |
tristanjph | 2:cb627ea9b817 | 35 | /** Puts the Xbee into config mode. |
tristanjph | 2:cb627ea9b817 | 36 | * @return Returns 1 on success. |
tristanjph | 1:c3d9bdcb0b03 | 37 | */ |
tristanjph | 0:2656fb225c5d | 38 | int ConfigMode(); |
tristanjph | 2:cb627ea9b817 | 39 | /** Gets the serial number/mac address of the Xbee and places it into serial_no. |
tristanjph | 2:cb627ea9b817 | 40 | * @param serial_no array to store the serial of Xbee (must be 8 long). |
tristanjph | 2:cb627ea9b817 | 41 | * @return Returns 1 on success. |
tristanjph | 2:cb627ea9b817 | 42 | */ |
tristanjph | 2:cb627ea9b817 | 43 | int GetSerial(int*); |
tristanjph | 2:cb627ea9b817 | 44 | /** Sets the encryption key to the one stored in security_key. |
tristanjph | 2:cb627ea9b817 | 45 | * @param key Pointer to the network key to set. |
tristanjph | 2:cb627ea9b817 | 46 | * @return Returns 1 on success. |
tristanjph | 1:c3d9bdcb0b03 | 47 | */ |
tristanjph | 3:682615a0717e | 48 | int SetKey(int*); |
tristanjph | 2:cb627ea9b817 | 49 | /** Sets the id of the PAN network for the Xbee to use |
tristanjph | 2:cb627ea9b817 | 50 | * @param pan_id The id of the PAN for the Xbee to use. |
tristanjph | 2:cb627ea9b817 | 51 | * @return Returns 1 on success. |
tristanjph | 1:c3d9bdcb0b03 | 52 | */ |
tristanjph | 2:cb627ea9b817 | 53 | int SetPanId(int); |
tristanjph | 2:cb627ea9b817 | 54 | /** Writes the settings to the Non volatile memory on the Xbee |
tristanjph | 2:cb627ea9b817 | 55 | * @param key Pointer to the network key to set. |
tristanjph | 2:cb627ea9b817 | 56 | * @return Returns 1 on success. |
tristanjph | 1:c3d9bdcb0b03 | 57 | */ |
tristanjph | 0:2656fb225c5d | 58 | int WriteSettings(); |
tristanjph | 1:c3d9bdcb0b03 | 59 | /** Exits config mode |
tristanjph | 2:cb627ea9b817 | 60 | * @return Returns 1 on success. |
tristanjph | 1:c3d9bdcb0b03 | 61 | */ |
tristanjph | 0:2656fb225c5d | 62 | int ExitConfigMode(); |
tristanjph | 2:cb627ea9b817 | 63 | /** Sends data in the send_Data buffer. |
tristanjph | 2:cb627ea9b817 | 64 | * @param data_buf Pointer to the buffer of data to send. |
tristanjph | 2:cb627ea9b817 | 65 | * @returns 1 on success. |
tristanjph | 1:c3d9bdcb0b03 | 66 | */ |
tristanjph | 2:cb627ea9b817 | 67 | int SendData(char*); |
tristanjph | 2:cb627ea9b817 | 68 | /** Recieves data sent to the xbee. |
tristanjph | 2:cb627ea9b817 | 69 | * @param data_buf Pointer to the buffer to put recieved data into. |
tristanjph | 2:cb627ea9b817 | 70 | * @param numchar Number of characters to read. If 0, will use the size of data_buf. |
tristanjph | 2:cb627ea9b817 | 71 | */ |
tristanjph | 2:cb627ea9b817 | 72 | void RecieveData(char*, int); |
tristanjph | 3:682615a0717e | 73 | /** Resets the Xbee. |
tristanjph | 3:682615a0717e | 74 | */ |
tristanjph | 3:682615a0717e | 75 | void Reset(); |
tristanjph | 2:cb627ea9b817 | 76 | |
tristanjph | 0:2656fb225c5d | 77 | }; |