mbed and BLEmate / Mbed 2 deprecated mbed_serial_test

Dependencies:   mbed

Fork of mbed_serial_test by An Nguyen

main.cpp

Committer:
AlpNov
Date:
2015-09-01
Revision:
1:5c5cd69a3cf8
Parent:
0:47c7262c17ac

File content as of revision 1:5c5cd69a3cf8:

#include "mbed.h"   

Serial pc(USBTX, USBRX);
Serial BLEmate(p9,p10); //tx,rx

DigitalOut led1(LED1);


void BLEmateready();
 
int main() {
    char pcin;
    char BLEin;
    pc.printf("Something from mbed to PC\n\r");
    while (1) {
        if ( pc.readable() ) {
            BLEmate.printf("SND ");
            while ( pcin != '\n' && pcin != '\r' )
                BLEmate.putc(pcin = pc.getc());
            pcin = 0;
        }
        
        if ( BLEmate.readable() ) {
            pc.printf("phone sends: ");
            while ( BLEmate.readable() || BLEin != '\r')
                pc.putc(BLEin = BLEmate.getc());
            pc.printf("\n\r");
            BLEin = 0;
        }
    }
}