The purpose of this project was to create a system that would allow users to monitor a locked device using a Bluetooth device. This Bluetooth device will show the last user that unlocked the device, and also allows the user to unlock the device using the Bluetooth device. This device can be physically unlocked using a capacitive touch keypad sensor.
Dependencies: mbed Motor Servo
Fork of SerialPassthrough_LPC1768 by
main.cpp@2:a8dcb07a1d00, 2015-04-27 (annotated)
- Committer:
- mbedAustin
- Date:
- Mon Apr 27 20:37:15 2015 +0000
- Revision:
- 2:a8dcb07a1d00
- Parent:
- 1:a76360ca4001
- Child:
- 3:0393f97fd8cf
It works for doing serial terminal to board and back again.;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbedAustin | 0:59bec1fd956e | 1 | #include "mbed.h" |
mbedAustin | 2:a8dcb07a1d00 | 2 | |
mbedAustin | 2:a8dcb07a1d00 | 3 | Serial pc(USBTX, USBRX); // computer to mbed board |
mbedAustin | 2:a8dcb07a1d00 | 4 | Serial esp(D1, D0); // mbed board to target board |
mbedAustin | 2:a8dcb07a1d00 | 5 | |
mbedAustin | 2:a8dcb07a1d00 | 6 | int |
mbedAustin | 2:a8dcb07a1d00 | 7 | main() |
mbedAustin | 2:a8dcb07a1d00 | 8 | { |
mbedAustin | 2:a8dcb07a1d00 | 9 | pc.baud(115200); |
mbedAustin | 2:a8dcb07a1d00 | 10 | esp.baud(9600); |
mbedAustin | 2:a8dcb07a1d00 | 11 | wait(0.1); |
mbedAustin | 2:a8dcb07a1d00 | 12 | pc.printf("\r\n########### ready ###########\r\n"); |
mbedAustin | 2:a8dcb07a1d00 | 13 | esp.printf("AT+RST\r\n"); |
mbedAustin | 2:a8dcb07a1d00 | 14 | while(1) { |
mbedAustin | 2:a8dcb07a1d00 | 15 | if(pc.readable()) { |
mbedAustin | 2:a8dcb07a1d00 | 16 | char c = pc.getc(); |
mbedAustin | 2:a8dcb07a1d00 | 17 | //pc.putc(c); // echo character back to computer for sanity |
mbedAustin | 2:a8dcb07a1d00 | 18 | //if(c == '\r'){ |
mbedAustin | 2:a8dcb07a1d00 | 19 | // esp.printf("\r\n"); |
mbedAustin | 2:a8dcb07a1d00 | 20 | // } |
mbedAustin | 2:a8dcb07a1d00 | 21 | // else{ |
mbedAustin | 2:a8dcb07a1d00 | 22 | esp.putc(c); |
mbedAustin | 2:a8dcb07a1d00 | 23 | // } |
mbedAustin | 2:a8dcb07a1d00 | 24 | } |
mbedAustin | 2:a8dcb07a1d00 | 25 | if(esp.readable()) { |
mbedAustin | 2:a8dcb07a1d00 | 26 | char c = esp.getc(); |
mbedAustin | 2:a8dcb07a1d00 | 27 | //if(c == '\n'){ |
mbedAustin | 2:a8dcb07a1d00 | 28 | // pc.printf("\\n"); |
mbedAustin | 2:a8dcb07a1d00 | 29 | // } |
mbedAustin | 2:a8dcb07a1d00 | 30 | // if(c == '\r'){ |
mbedAustin | 2:a8dcb07a1d00 | 31 | // pc.printf("\\r"); |
mbedAustin | 2:a8dcb07a1d00 | 32 | // } |
mbedAustin | 2:a8dcb07a1d00 | 33 | |
mbedAustin | 2:a8dcb07a1d00 | 34 | pc.putc(c); |
mbedAustin | 2:a8dcb07a1d00 | 35 | } |
mbedAustin | 0:59bec1fd956e | 36 | } |
mbedAustin | 0:59bec1fd956e | 37 | } |