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.
Dependencies: mbed
bluetooth.cpp@0:f5f49d8b55da, 2014-03-06 (annotated)
- Committer:
- n6martin
- Date:
- Thu Mar 06 20:52:46 2014 +0000
- Revision:
- 0:f5f49d8b55da
bluetooth
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| n6martin | 0:f5f49d8b55da | 1 | #include <mbed.h> |
| n6martin | 0:f5f49d8b55da | 2 | |
| n6martin | 0:f5f49d8b55da | 3 | Serial pc(USBTX, USBRX); // tx, rx |
| n6martin | 0:f5f49d8b55da | 4 | Serial BluetoothSerial(p13, p14); // tx, rx |
| n6martin | 0:f5f49d8b55da | 5 | |
| n6martin | 0:f5f49d8b55da | 6 | char x; |
| n6martin | 0:f5f49d8b55da | 7 | |
| n6martin | 0:f5f49d8b55da | 8 | int main() { |
| n6martin | 0:f5f49d8b55da | 9 | BluetoothSerial.baud(9600); |
| n6martin | 0:f5f49d8b55da | 10 | do { |
| n6martin | 0:f5f49d8b55da | 11 | if (pc.readable()) { |
| n6martin | 0:f5f49d8b55da | 12 | x=pc.getc(); |
| n6martin | 0:f5f49d8b55da | 13 | // Receive keyboard entry and send to Bluetooth channel |
| n6martin | 0:f5f49d8b55da | 14 | BluetoothSerial.putc(x); |
| n6martin | 0:f5f49d8b55da | 15 | pc.putc(x); //Echo keyboard entry |
| n6martin | 0:f5f49d8b55da | 16 | } |
| n6martin | 0:f5f49d8b55da | 17 | if (BluetoothSerial.readable()) { |
| n6martin | 0:f5f49d8b55da | 18 | x=BluetoothSerial.getc(); |
| n6martin | 0:f5f49d8b55da | 19 | pc.putc(x); |
| n6martin | 0:f5f49d8b55da | 20 | BluetoothSerial.putc(x); |
| n6martin | 0:f5f49d8b55da | 21 | } |
| n6martin | 0:f5f49d8b55da | 22 | } |
| n6martin | 0:f5f49d8b55da | 23 | while (x!='q'); |
| n6martin | 0:f5f49d8b55da | 24 | } |