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@10:c6100f1f2265, 2015-11-22 (annotated)
- Committer:
- Xiaofei
- Date:
- Sun Nov 22 02:56:41 2015 +0000
- Revision:
- 10:c6100f1f2265
- Parent:
- 9:c0955550ca13
- Child:
- 11:4e806bf0fb3d
c
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 | 5:d14636b861ff | 10 | |
Xiaofei | 5:d14636b861ff | 11 | _xbee.baud(9600); |
Xiaofei | 2:33462c1e9f45 | 12 | } |
Xiaofei | 2:33462c1e9f45 | 13 | |
Xiaofei | 2:33462c1e9f45 | 14 | |
Xiaofei | 0:633baa9653b0 | 15 | void Xbee::Send(const char* buffer) |
Xiaofei | 0:633baa9653b0 | 16 | { |
Xiaofei | 9:c0955550ca13 | 17 | while(1) |
Xiaofei | 3:fe623a260bf5 | 18 | { |
Xiaofei | 9:c0955550ca13 | 19 | _xbee.putc('.'); |
Xiaofei | 9:c0955550ca13 | 20 | _xbee.puts(buffer); |
Xiaofei | 8:6fd7091e1478 | 21 | if(_xbee.getc() == '.') |
Xiaofei | 8:6fd7091e1478 | 22 | { |
Xiaofei | 8:6fd7091e1478 | 23 | break; |
Xiaofei | 8:6fd7091e1478 | 24 | } |
Xiaofei | 3:fe623a260bf5 | 25 | } |
Xiaofei | 0:633baa9653b0 | 26 | } |
Xiaofei | 0:633baa9653b0 | 27 | |
Xiaofei | 0:633baa9653b0 | 28 | void Xbee::Recv(char* buffer, const size_t& sz) |
Xiaofei | 0:633baa9653b0 | 29 | { |
Xiaofei | 6:9f2db7a38f19 | 30 | while(_xbee.readable()) |
Xiaofei | 6:9f2db7a38f19 | 31 | { |
Xiaofei | 7:922bf2a611b1 | 32 | if(_xbee.getc() == '.') |
Xiaofei | 7:922bf2a611b1 | 33 | { |
Xiaofei | 7:922bf2a611b1 | 34 | _xbee.gets(buffer,sz); |
Xiaofei | 10:c6100f1f2265 | 35 | _xbee.putc('.'); |
Xiaofei | 10:c6100f1f2265 | 36 | break; |
Xiaofei | 7:922bf2a611b1 | 37 | } |
Xiaofei | 10:c6100f1f2265 | 38 | |
Xiaofei | 6:9f2db7a38f19 | 39 | } |
Xiaofei | 0:633baa9653b0 | 40 | } |