The library for waveshare ZBee Core2530 (B):
Dependents: zbee_rx_analog zbee_tx_analog simple_zb_rx simple_zb_tx
zbee.h@2:186e6cce954b, 2016-04-06 (annotated)
- Committer:
- ruslylove
- Date:
- Wed Apr 06 15:50:27 2016 +0000
- Revision:
- 2:186e6cce954b
- Parent:
- 1:86542d0d3c89
bug fixed
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ruslylove | 0:5092dcc261f2 | 1 | /* Copyright (c) 2016 Ruslee Sutthaweekul, MIT License |
ruslylove | 0:5092dcc261f2 | 2 | * |
ruslylove | 0:5092dcc261f2 | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
ruslylove | 0:5092dcc261f2 | 4 | * and associated documentation files (the "Software"), to deal in the Software without restriction, |
ruslylove | 0:5092dcc261f2 | 5 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, |
ruslylove | 0:5092dcc261f2 | 6 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is |
ruslylove | 0:5092dcc261f2 | 7 | * furnished to do so, subject to the following conditions: |
ruslylove | 0:5092dcc261f2 | 8 | * |
ruslylove | 0:5092dcc261f2 | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
ruslylove | 0:5092dcc261f2 | 10 | * substantial portions of the Software. |
ruslylove | 0:5092dcc261f2 | 11 | * |
ruslylove | 0:5092dcc261f2 | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
ruslylove | 0:5092dcc261f2 | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
ruslylove | 0:5092dcc261f2 | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
ruslylove | 0:5092dcc261f2 | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
ruslylove | 0:5092dcc261f2 | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
ruslylove | 0:5092dcc261f2 | 17 | */ |
ruslylove | 0:5092dcc261f2 | 18 | |
ruslylove | 0:5092dcc261f2 | 19 | #include "mbed.h" |
ruslylove | 0:5092dcc261f2 | 20 | #define ZBEE_BAUD 38400 |
ruslylove | 0:5092dcc261f2 | 21 | |
ruslylove | 0:5092dcc261f2 | 22 | /** Zbee interface class for configuring, sending and recieving data using an waveshare Zbee */ |
ruslylove | 0:5092dcc261f2 | 23 | |
ruslylove | 0:5092dcc261f2 | 24 | class zbee |
ruslylove | 0:5092dcc261f2 | 25 | { |
ruslylove | 0:5092dcc261f2 | 26 | private: |
ruslylove | 0:5092dcc261f2 | 27 | PinName _tx; |
ruslylove | 0:5092dcc261f2 | 28 | PinName _rx; |
ruslylove | 0:5092dcc261f2 | 29 | PinName _reset; |
ruslylove | 0:5092dcc261f2 | 30 | int _baud; |
ruslylove | 0:5092dcc261f2 | 31 | |
ruslylove | 0:5092dcc261f2 | 32 | public: |
ruslylove | 0:5092dcc261f2 | 33 | /** Configure serial data pin. |
ruslylove | 0:5092dcc261f2 | 34 | * @param tx The serial tx pin the xbee is conected to. |
ruslylove | 0:5092dcc261f2 | 35 | * @param rx The serial rx pin the xbee is conected to. |
ruslylove | 0:5092dcc261f2 | 36 | * @param reset The pin connected to the Xbee reset pin. |
ruslylove | 0:5092dcc261f2 | 37 | */ |
ruslylove | 0:5092dcc261f2 | 38 | zbee(PinName tx, PinName rx, int baud); |
ruslylove | 0:5092dcc261f2 | 39 | ~zbee(); |
ruslylove | 0:5092dcc261f2 | 40 | /** Puts the Xbee into config mode. |
ruslylove | 0:5092dcc261f2 | 41 | * @return Returns 1 on success. |
ruslylove | 0:5092dcc261f2 | 42 | */ |
ruslylove | 0:5092dcc261f2 | 43 | |
ruslylove | 0:5092dcc261f2 | 44 | int GetAddr(char*); |
ruslylove | 0:5092dcc261f2 | 45 | /** Sets the encryption key to the one stored in security_key. |
ruslylove | 0:5092dcc261f2 | 46 | * @param key Pointer to the network key to set. |
ruslylove | 0:5092dcc261f2 | 47 | * @return Returns 1 on success. |
ruslylove | 0:5092dcc261f2 | 48 | */ |
ruslylove | 0:5092dcc261f2 | 49 | int GetPanId(char*); |
ruslylove | 0:5092dcc261f2 | 50 | /** Sets the encryption key to the one stored in security_key. |
ruslylove | 0:5092dcc261f2 | 51 | * @param key Pointer to the network key to set. |
ruslylove | 0:5092dcc261f2 | 52 | * @return Returns 1 on success. |
ruslylove | 0:5092dcc261f2 | 53 | */ |
ruslylove | 0:5092dcc261f2 | 54 | int SetPanId(int); |
ruslylove | 0:5092dcc261f2 | 55 | /** Sets the encryption key to the one stored in security_key. |
ruslylove | 0:5092dcc261f2 | 56 | * @param PanId Pointer to the network key to set. |
ruslylove | 0:5092dcc261f2 | 57 | * @return Returns 1 on success. |
ruslylove | 0:5092dcc261f2 | 58 | */ |
ruslylove | 0:5092dcc261f2 | 59 | |
ruslylove | 0:5092dcc261f2 | 60 | int SendData(char*); |
ruslylove | 0:5092dcc261f2 | 61 | /** Recieves data sent to the xbee. |
ruslylove | 0:5092dcc261f2 | 62 | * @param data_buf Pointer to the buffer to put recieved data into. |
ruslylove | 0:5092dcc261f2 | 63 | * @param numchar Number of characters to read. If 0, will use the size of data_buf. |
ruslylove | 0:5092dcc261f2 | 64 | */ |
ruslylove | 1:86542d0d3c89 | 65 | void ReceiveData(char*, int); |
ruslylove | 0:5092dcc261f2 | 66 | /** Resets the Xbee. |
ruslylove | 0:5092dcc261f2 | 67 | */ |
ruslylove | 0:5092dcc261f2 | 68 | void Reset(); |
ruslylove | 0:5092dcc261f2 | 69 | |
ruslylove | 0:5092dcc261f2 | 70 | }; |