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
Fork of mbed_serial_test by
main.cpp@1:5c5cd69a3cf8, 2015-09-01 (annotated)
- Committer:
- AlpNov
- Date:
- Tue Sep 01 02:36:31 2015 +0000
- Revision:
- 1:5c5cd69a3cf8
- Parent:
- 0:47c7262c17ac
Basic send and receive done;
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| AlpNov | 0:47c7262c17ac | 1 | #include "mbed.h" |
| AlpNov | 0:47c7262c17ac | 2 | |
| AlpNov | 0:47c7262c17ac | 3 | Serial pc(USBTX, USBRX); |
| AlpNov | 0:47c7262c17ac | 4 | Serial BLEmate(p9,p10); //tx,rx |
| AlpNov | 0:47c7262c17ac | 5 | |
| AlpNov | 0:47c7262c17ac | 6 | DigitalOut led1(LED1); |
| AlpNov | 0:47c7262c17ac | 7 | |
| AlpNov | 0:47c7262c17ac | 8 | |
| AlpNov | 0:47c7262c17ac | 9 | void BLEmateready(); |
| AlpNov | 0:47c7262c17ac | 10 | |
| AlpNov | 0:47c7262c17ac | 11 | int main() { |
| AlpNov | 1:5c5cd69a3cf8 | 12 | char pcin; |
| AlpNov | 1:5c5cd69a3cf8 | 13 | char BLEin; |
| AlpNov | 0:47c7262c17ac | 14 | pc.printf("Something from mbed to PC\n\r"); |
| AlpNov | 0:47c7262c17ac | 15 | while (1) { |
| AlpNov | 1:5c5cd69a3cf8 | 16 | if ( pc.readable() ) { |
| AlpNov | 1:5c5cd69a3cf8 | 17 | BLEmate.printf("SND "); |
| AlpNov | 1:5c5cd69a3cf8 | 18 | while ( pcin != '\n' && pcin != '\r' ) |
| AlpNov | 1:5c5cd69a3cf8 | 19 | BLEmate.putc(pcin = pc.getc()); |
| AlpNov | 1:5c5cd69a3cf8 | 20 | pcin = 0; |
| AlpNov | 1:5c5cd69a3cf8 | 21 | } |
| AlpNov | 1:5c5cd69a3cf8 | 22 | |
| AlpNov | 1:5c5cd69a3cf8 | 23 | if ( BLEmate.readable() ) { |
| AlpNov | 1:5c5cd69a3cf8 | 24 | pc.printf("phone sends: "); |
| AlpNov | 1:5c5cd69a3cf8 | 25 | while ( BLEmate.readable() || BLEin != '\r') |
| AlpNov | 1:5c5cd69a3cf8 | 26 | pc.putc(BLEin = BLEmate.getc()); |
| AlpNov | 1:5c5cd69a3cf8 | 27 | pc.printf("\n\r"); |
| AlpNov | 1:5c5cd69a3cf8 | 28 | BLEin = 0; |
| AlpNov | 1:5c5cd69a3cf8 | 29 | } |
| AlpNov | 0:47c7262c17ac | 30 | } |
| AlpNov | 0:47c7262c17ac | 31 | } |
