Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Xbee.cpp@4:58f5ff5eb15b, 2015-11-22 (annotated)
- Committer:
- Xiaofei
- Date:
- Sun Nov 22 01:58:07 2015 +0000
- Revision:
- 4:58f5ff5eb15b
- Parent:
- 3:fe623a260bf5
- Child:
- 5:d14636b861ff
ccc
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Xiaofei | 0:633baa9653b0 | 1 | #pragma once |
Xiaofei | 0:633baa9653b0 | 2 | #include "Xbee.h" |
Xiaofei | 0:633baa9653b0 | 3 | |
Xiaofei | 2:33462c1e9f45 | 4 | Xbee::Xbee(PinName tx, PinName rx , PinName rst):_xbee(tx,rx),_rst(rst) |
Xiaofei | 2:33462c1e9f45 | 5 | { |
Xiaofei | 2:33462c1e9f45 | 6 | _rst = 0; |
Xiaofei | 2:33462c1e9f45 | 7 | wait(0.01); |
Xiaofei | 2:33462c1e9f45 | 8 | _rst = 1; |
Xiaofei | 2:33462c1e9f45 | 9 | wait(0.01); |
Xiaofei | 2:33462c1e9f45 | 10 | } |
Xiaofei | 2:33462c1e9f45 | 11 | |
Xiaofei | 2:33462c1e9f45 | 12 | |
Xiaofei | 0:633baa9653b0 | 13 | void Xbee::Send(const char* buffer) |
Xiaofei | 0:633baa9653b0 | 14 | { |
Xiaofei | 3:fe623a260bf5 | 15 | while(!_xbee.readable()) |
Xiaofei | 3:fe623a260bf5 | 16 | { |
Xiaofei | 3:fe623a260bf5 | 17 | _xbee.puts(buffer); |
Xiaofei | 4:58f5ff5eb15b | 18 | wait(0.05); |
Xiaofei | 3:fe623a260bf5 | 19 | } |
Xiaofei | 0:633baa9653b0 | 20 | } |
Xiaofei | 0:633baa9653b0 | 21 | |
Xiaofei | 0:633baa9653b0 | 22 | void Xbee::Recv(char* buffer, const size_t& sz) |
Xiaofei | 0:633baa9653b0 | 23 | { |
Xiaofei | 3:fe623a260bf5 | 24 | while(!_xbee.readable()); |
Xiaofei | 3:fe623a260bf5 | 25 | _xbee.gets(buffer,sz); |
Xiaofei | 3:fe623a260bf5 | 26 | _xbee.puts("."); |
Xiaofei | 0:633baa9653b0 | 27 | } |