kh
Dependencies: mbed PinDetect Servo
Diff: authentication.cpp
- Revision:
- 2:04bbd14722bd
- Parent:
- 1:2c365f6da61d
- Child:
- 3:2f7a7e2cd49e
diff -r 2c365f6da61d -r 04bbd14722bd authentication.cpp --- a/authentication.cpp Sat Nov 10 20:08:46 2018 +0000 +++ b/authentication.cpp Mon Nov 12 23:36:11 2018 +0000 @@ -18,13 +18,15 @@ int entryNum4; -Serial blue(p28,p27); - AnalogIn pot1(p18); AnalogIn pot2(p18); AnalogIn pot3(p20); AnalogIn pot4(p20); +bool bluetoothCode = false; +bool bluetoothSetup = false; +Serial blue(p28,p27); + /* * Function: setEntrySequence * -------------------- @@ -47,10 +49,14 @@ * */ bool CorrectEntrySequenceAttempt() { - p1 = float(pot1) * 10; - p2 = float(pot2) * 10; - p3 = float(pot3) * 10; - p4 = float(pot4) * 10; + if (bluetoothCode) { + return true; + + } + p1 = float(pot1) * 6; + p2 = float(pot2) * 6; + p3 = float(pot3) * 6; + p4 = float(pot4) * 6; return (checkPot(p1,entryNum1) && checkPot(p2,entryNum2) && checkPot(p3,entryNum3) && checkPot(p3,entryNum3)); } @@ -60,20 +66,43 @@ } +bool checkBluetooth() { + if (bluetoothSetup) { + bluetoothSetup = false; + return true; + } + return false; +} + /* -* Function: bluetooth +* Function: parse_bluetooth * -------------------- * bluetooth stuff EDIT LATER * * returns: * */ -void bluetooth() { - +void parse_bluetooth() +{ + switch (blue.getc()) { + case 'o': + bluetoothCode = true; + break; + case 'l': + bluetoothCode = false; + break; + case 's': + bluetoothSetup = true; + break; + } + } +void start_bluetooth() { + blue.attach(&parse_bluetooth, Serial::RxIrq); +} /* * Function: sdCard @@ -87,3 +116,4 @@ } +