Transparent data mode for Bluetooth HC05
Notebook page HERE
Diff: main.cpp
- Revision:
- 1:8c500bcdcbc4
- Parent:
- 0:44f245e8b430
- Child:
- 2:f76f36540871
--- a/main.cpp Wed Jul 11 18:28:07 2012 +0000 +++ b/main.cpp Fri Oct 18 21:28:08 2013 +0000 @@ -1,87 +1,46 @@ +/* + * Author: Edoardo De Marchi + * Date: 02-07-13 + * Notes: HC05 Trasparent Mode +*/ + #include "mbed.h" +#define SERIAL_2 + + Serial pc(USBTX, USBRX); -Serial blue(p9,p10); // BTM400 == CH05 +#ifdef SERIAL_1 +Serial blue(p9,p10); // HC05 +#endif +#ifdef SERIAL_2 +Serial blue(p13,p14); // TX = P14 RX = P13 +#endif + DigitalOut myled(LED1); DigitalOut myled4(LED4); -int main() { +int main() +{ blue.baud(9600); pc.baud(9600); - - // echo back characters, toggle the LED - while (1) { - if (blue.readable()) { + pc.printf("Bluetooth Start\r\n"); + + // echo back characters and toggle the LED + while (1) + { + if (blue.readable()) + { pc.putc(blue.getc()); myled = !myled; } - if (pc.readable()) { + if (pc.readable()) + { blue.putc(pc.getc()); myled4 = !myled4; } } -} - - - -/* -void commandAT(char *v) -{ - int i=0; - while(v[i] != '\n') - { - blue.putc(v[i]); - i++; - } - blue.putc('\n'); -} - -void readResponse() -{ - int a = blue.readable(); - pc.printf("Caratteri disponibili: "); - pc.putc(a); - if(a > 0){ - for(int i=0; i < a; i++){ - - char data = (char)blue.getc(); - - pc.putc(data); - wait_us(100); - - } - } - - -} - -int main() -{ - - blue.baud(38400); - pc.baud(9600); - pc.printf("Inizializzo sistema... \n"); - - - //Comando AT da inviare - char s[] = "AT\r\n"; - pc.printf("Scrivo comando: "); - pc.printf(s); - - wait_us(50); - - //Invio comando all'antenna - commandAT(s); - wait_us(50); - - //Leggo la risposta - readResponse(); -}*/ - - - - - +} \ No newline at end of file