Buzz Access
Dependencies: 4DGL-uLCD-SE KeyPad PinDetect HID_Wiegand mbed-rtos mbed
main.cpp@0:0d31da041b5c, 2015-04-29 (annotated)
- Committer:
- otis22894
- Date:
- Wed Apr 29 23:17:14 2015 +0000
- Revision:
- 0:0d31da041b5c
- Child:
- 1:c41a71a200d6
Commit #1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
otis22894 | 0:0d31da041b5c | 1 | #include "mbed.h" |
otis22894 | 0:0d31da041b5c | 2 | #include "KeyPad.h" |
otis22894 | 0:0d31da041b5c | 3 | #include "rtos.h" |
otis22894 | 0:0d31da041b5c | 4 | #include "uLCD_4DGL.h" |
otis22894 | 0:0d31da041b5c | 5 | #include <iostream> |
otis22894 | 0:0d31da041b5c | 6 | #include "PinDetect.h" |
otis22894 | 0:0d31da041b5c | 7 | #include "Wiegand.h" |
otis22894 | 0:0d31da041b5c | 8 | #include <string> |
otis22894 | 0:0d31da041b5c | 9 | #include <sstream> |
otis22894 | 0:0d31da041b5c | 10 | #define __STDC_FORMAT_MACROS |
otis22894 | 0:0d31da041b5c | 11 | #include <inttypes.h> |
otis22894 | 0:0d31da041b5c | 12 | #define CARDSALLOWED 10 |
otis22894 | 0:0d31da041b5c | 13 | |
otis22894 | 0:0d31da041b5c | 14 | bool checkCode(std::vector<int>,std::vector<int>); |
otis22894 | 0:0d31da041b5c | 15 | void keypad_thread(void const *args); |
otis22894 | 0:0d31da041b5c | 16 | void knock_thread(void const *args); |
otis22894 | 0:0d31da041b5c | 17 | void rfid_thread(void const *args); |
otis22894 | 0:0d31da041b5c | 18 | void changeCode(); |
otis22894 | 0:0d31da041b5c | 19 | void changeSecretKnock(); |
otis22894 | 0:0d31da041b5c | 20 | void captureKnock(); |
otis22894 | 0:0d31da041b5c | 21 | void checkKnocks(); |
otis22894 | 0:0d31da041b5c | 22 | void onCardRead(); |
otis22894 | 0:0d31da041b5c | 23 | int readCardsFromFile(FILE *fp); |
otis22894 | 0:0d31da041b5c | 24 | int readCardsFromFile(); |
otis22894 | 0:0d31da041b5c | 25 | bool isAllowed(const char *card); |
otis22894 | 0:0d31da041b5c | 26 | void storeCard(const char *card); |
otis22894 | 0:0d31da041b5c | 27 | |
otis22894 | 0:0d31da041b5c | 28 | Serial pc(USBTX, USBRX); |
otis22894 | 0:0d31da041b5c | 29 | KeyPad2 keypad(p25, p27, p23, p26, p21, p22, p24); |
otis22894 | 0:0d31da041b5c | 30 | static const int arr[] = {1,2,3,4}; |
otis22894 | 0:0d31da041b5c | 31 | std::vector<int> master(arr, arr + sizeof(arr) / sizeof(arr[0]) ); |
otis22894 | 0:0d31da041b5c | 32 | std::vector<int> keys; |
otis22894 | 0:0d31da041b5c | 33 | std::vector<int> knock; |
otis22894 | 0:0d31da041b5c | 34 | std::vector<int> userKnock; |
otis22894 | 0:0d31da041b5c | 35 | DigitalOut led2(LED2); |
otis22894 | 0:0d31da041b5c | 36 | DigitalOut led1(LED1); |
otis22894 | 0:0d31da041b5c | 37 | uLCD_4DGL lcd(p9, p10, p8); |
otis22894 | 0:0d31da041b5c | 38 | PinDetect pb1(p13); |
otis22894 | 0:0d31da041b5c | 39 | Timer timer; |
otis22894 | 0:0d31da041b5c | 40 | AnalogIn ain(p15); |
otis22894 | 0:0d31da041b5c | 41 | Wiegand rfid(p30, p29, p28, &onCardRead); |
otis22894 | 0:0d31da041b5c | 42 | char **allowedCards; |
otis22894 | 0:0d31da041b5c | 43 | int allowedCount = 0; |
otis22894 | 0:0d31da041b5c | 44 | bool changeCodeBool = false; |
otis22894 | 0:0d31da041b5c | 45 | LocalFileSystem fileSystem("local"); |
otis22894 | 0:0d31da041b5c | 46 | |
otis22894 | 0:0d31da041b5c | 47 | int main() { |
otis22894 | 0:0d31da041b5c | 48 | timer.start(); |
otis22894 | 0:0d31da041b5c | 49 | pc.printf("Start\n"); |
otis22894 | 0:0d31da041b5c | 50 | lcd.printf("Start\n"); |
otis22894 | 0:0d31da041b5c | 51 | //Thread keypadThread(keypad_thread); |
otis22894 | 0:0d31da041b5c | 52 | //Thread knockThread(knock_thread); |
otis22894 | 0:0d31da041b5c | 53 | //Thread rfidThread(rfid_thread); |
otis22894 | 0:0d31da041b5c | 54 | led1 = 0; |
otis22894 | 0:0d31da041b5c | 55 | while(1){ |
otis22894 | 0:0d31da041b5c | 56 | led1 = !led1; |
otis22894 | 0:0d31da041b5c | 57 | Thread::wait(1000); |
otis22894 | 0:0d31da041b5c | 58 | } |
otis22894 | 0:0d31da041b5c | 59 | |
otis22894 | 0:0d31da041b5c | 60 | } |
otis22894 | 0:0d31da041b5c | 61 | |
otis22894 | 0:0d31da041b5c | 62 | void rfid_thread(void const *args){ |
otis22894 | 0:0d31da041b5c | 63 | allowedCards = new char*[CARDSALLOWED]; |
otis22894 | 0:0d31da041b5c | 64 | for (int i = 0; i < CARDSALLOWED; ++i){ |
otis22894 | 0:0d31da041b5c | 65 | allowedCards[i] = new char[11]; |
otis22894 | 0:0d31da041b5c | 66 | } |
otis22894 | 0:0d31da041b5c | 67 | readCardsFromFile(); |
otis22894 | 0:0d31da041b5c | 68 | while(1){ |
otis22894 | 0:0d31da041b5c | 69 | rfid.doEvents(); |
otis22894 | 0:0d31da041b5c | 70 | Thread::wait(100); |
otis22894 | 0:0d31da041b5c | 71 | } |
otis22894 | 0:0d31da041b5c | 72 | } |
otis22894 | 0:0d31da041b5c | 73 | |
otis22894 | 0:0d31da041b5c | 74 | void onCardRead() { |
otis22894 | 0:0d31da041b5c | 75 | /*pc.printf("%d\n",rfid.bitsRead()); |
otis22894 | 0:0d31da041b5c | 76 | uint64_t rawCardData = rfid.getBits(14,33); |
otis22894 | 0:0d31da041b5c | 77 | pc.printf("%" PRIx64 "\n",rawCardData); |
otis22894 | 0:0d31da041b5c | 78 | pc.printf("%" PRIx64 "\n",rfid.getBits(0,34));*/ |
otis22894 | 0:0d31da041b5c | 79 | uint64_t cardData = rfid.getBits(0,34); |
otis22894 | 0:0d31da041b5c | 80 | ostringstream o; |
otis22894 | 0:0d31da041b5c | 81 | string str; |
otis22894 | 0:0d31da041b5c | 82 | o << cardData; |
otis22894 | 0:0d31da041b5c | 83 | str += o.str(); |
otis22894 | 0:0d31da041b5c | 84 | pc.printf("%s\n",str.c_str()); |
otis22894 | 0:0d31da041b5c | 85 | pc.printf("%d\n",isAllowed(str.c_str())); |
otis22894 | 0:0d31da041b5c | 86 | storeCard(str.c_str()); |
otis22894 | 0:0d31da041b5c | 87 | pc.printf("%d\n",isAllowed(str.c_str())); |
otis22894 | 0:0d31da041b5c | 88 | } |
otis22894 | 0:0d31da041b5c | 89 | |
otis22894 | 0:0d31da041b5c | 90 | bool isAllowed(const char *card){ |
otis22894 | 0:0d31da041b5c | 91 | for(int i = 0;i<allowedCount;i++){ |
otis22894 | 0:0d31da041b5c | 92 | for(int j = 0;j<11;j++){ |
otis22894 | 0:0d31da041b5c | 93 | if(card[j]!=allowedCards[i][j]){ |
otis22894 | 0:0d31da041b5c | 94 | break; |
otis22894 | 0:0d31da041b5c | 95 | }else if(j==10){ |
otis22894 | 0:0d31da041b5c | 96 | return true; |
otis22894 | 0:0d31da041b5c | 97 | } |
otis22894 | 0:0d31da041b5c | 98 | } |
otis22894 | 0:0d31da041b5c | 99 | } |
otis22894 | 0:0d31da041b5c | 100 | return false; |
otis22894 | 0:0d31da041b5c | 101 | } |
otis22894 | 0:0d31da041b5c | 102 | |
otis22894 | 0:0d31da041b5c | 103 | void storeCard(const char *card){ |
otis22894 | 0:0d31da041b5c | 104 | if(allowedCount < 10 && !isAllowed(card)){ |
otis22894 | 0:0d31da041b5c | 105 | FILE *fp = fopen("/local/cards.txt", "a"); |
otis22894 | 0:0d31da041b5c | 106 | if(fp==NULL){ |
otis22894 | 0:0d31da041b5c | 107 | pc.printf("NULL"); |
otis22894 | 0:0d31da041b5c | 108 | } |
otis22894 | 0:0d31da041b5c | 109 | fprintf(fp, "%c%c%c%c%c%c%c%c%c%c%c\r\n",card[0],card[1],card[2],card[3],card[4],card[5],card[6],card[7],card[8],card[9],card[10]); |
otis22894 | 0:0d31da041b5c | 110 | fclose(fp); |
otis22894 | 0:0d31da041b5c | 111 | pc.printf("HERE2"); |
otis22894 | 0:0d31da041b5c | 112 | for(int transfer = 0;transfer<11;transfer++){ |
otis22894 | 0:0d31da041b5c | 113 | allowedCards[allowedCount][transfer] = card[transfer]; |
otis22894 | 0:0d31da041b5c | 114 | } |
otis22894 | 0:0d31da041b5c | 115 | allowedCount++; |
otis22894 | 0:0d31da041b5c | 116 | } |
otis22894 | 0:0d31da041b5c | 117 | } |
otis22894 | 0:0d31da041b5c | 118 | |
otis22894 | 0:0d31da041b5c | 119 | int readCardsFromFile(){ |
otis22894 | 0:0d31da041b5c | 120 | FILE *fp = fopen("/local/cards.txt", "r"); |
otis22894 | 0:0d31da041b5c | 121 | int ret = readCardsFromFile(fp); |
otis22894 | 0:0d31da041b5c | 122 | return ret; |
otis22894 | 0:0d31da041b5c | 123 | } |
otis22894 | 0:0d31da041b5c | 124 | |
otis22894 | 0:0d31da041b5c | 125 | int readCardsFromFile(FILE *fp){ |
otis22894 | 0:0d31da041b5c | 126 | int c,transfer = 0; |
otis22894 | 0:0d31da041b5c | 127 | if(fp!=NULL){ |
otis22894 | 0:0d31da041b5c | 128 | c = fgetc(fp); |
otis22894 | 0:0d31da041b5c | 129 | while(c!=EOF){ |
otis22894 | 0:0d31da041b5c | 130 | allowedCards[allowedCount][transfer] = c; |
otis22894 | 0:0d31da041b5c | 131 | transfer++; |
otis22894 | 0:0d31da041b5c | 132 | if(transfer==11){ |
otis22894 | 0:0d31da041b5c | 133 | allowedCount++; |
otis22894 | 0:0d31da041b5c | 134 | if(allowedCount==CARDSALLOWED){ |
otis22894 | 0:0d31da041b5c | 135 | break; |
otis22894 | 0:0d31da041b5c | 136 | } |
otis22894 | 0:0d31da041b5c | 137 | transfer = 0; |
otis22894 | 0:0d31da041b5c | 138 | fgetc(fp); |
otis22894 | 0:0d31da041b5c | 139 | fgetc(fp); |
otis22894 | 0:0d31da041b5c | 140 | } |
otis22894 | 0:0d31da041b5c | 141 | c = fgetc(fp); |
otis22894 | 0:0d31da041b5c | 142 | } |
otis22894 | 0:0d31da041b5c | 143 | fclose(fp); |
otis22894 | 0:0d31da041b5c | 144 | return 1; |
otis22894 | 0:0d31da041b5c | 145 | }else{ |
otis22894 | 0:0d31da041b5c | 146 | return 0; |
otis22894 | 0:0d31da041b5c | 147 | } |
otis22894 | 0:0d31da041b5c | 148 | } |
otis22894 | 0:0d31da041b5c | 149 | |
otis22894 | 0:0d31da041b5c | 150 | void knock_thread(void const *args){ |
otis22894 | 0:0d31da041b5c | 151 | pc.printf("Initializing knock sensor..."); |
otis22894 | 0:0d31da041b5c | 152 | Thread::wait(1000); |
otis22894 | 0:0d31da041b5c | 153 | pc.printf("Ready\n"); |
otis22894 | 0:0d31da041b5c | 154 | changeSecretKnock(); |
otis22894 | 0:0d31da041b5c | 155 | float newval; |
otis22894 | 0:0d31da041b5c | 156 | while(1){ |
otis22894 | 0:0d31da041b5c | 157 | newval = ain.read(); |
otis22894 | 0:0d31da041b5c | 158 | if(newval > 0.508 && newval < 0.538){ |
otis22894 | 0:0d31da041b5c | 159 | pc.printf("Capturing Knock\n"); |
otis22894 | 0:0d31da041b5c | 160 | Thread::wait(50); |
otis22894 | 0:0d31da041b5c | 161 | captureKnock(); |
otis22894 | 0:0d31da041b5c | 162 | checkKnocks(); |
otis22894 | 0:0d31da041b5c | 163 | } |
otis22894 | 0:0d31da041b5c | 164 | Thread::wait(1); |
otis22894 | 0:0d31da041b5c | 165 | } |
otis22894 | 0:0d31da041b5c | 166 | } |
otis22894 | 0:0d31da041b5c | 167 | |
otis22894 | 0:0d31da041b5c | 168 | void checkKnocks(){ |
otis22894 | 0:0d31da041b5c | 169 | if(knock.size() != userKnock.size()){ |
otis22894 | 0:0d31da041b5c | 170 | pc.printf("Access Denied\n"); |
otis22894 | 0:0d31da041b5c | 171 | }else{ |
otis22894 | 0:0d31da041b5c | 172 | bool access = true; |
otis22894 | 0:0d31da041b5c | 173 | for(int i = 0; i<knock.size(); i++){ |
otis22894 | 0:0d31da041b5c | 174 | if(!(abs(1-((float)knock[i])/((float)userKnock[i]))<0.15)){ |
otis22894 | 0:0d31da041b5c | 175 | pc.printf("%d\n",i); |
otis22894 | 0:0d31da041b5c | 176 | access = false; |
otis22894 | 0:0d31da041b5c | 177 | } |
otis22894 | 0:0d31da041b5c | 178 | //pc.printf("%d : %d : %d\n",knock[i],userKnock[i],abs(1-((float)knock[i])/((float)userKnock[i]))<0.15); |
otis22894 | 0:0d31da041b5c | 179 | } |
otis22894 | 0:0d31da041b5c | 180 | if(access){ |
otis22894 | 0:0d31da041b5c | 181 | pc.printf("Access Granted\n"); |
otis22894 | 0:0d31da041b5c | 182 | }else{ |
otis22894 | 0:0d31da041b5c | 183 | pc.printf("Access Denied\n"); |
otis22894 | 0:0d31da041b5c | 184 | } |
otis22894 | 0:0d31da041b5c | 185 | } |
otis22894 | 0:0d31da041b5c | 186 | } |
otis22894 | 0:0d31da041b5c | 187 | |
otis22894 | 0:0d31da041b5c | 188 | void captureKnock(){ |
otis22894 | 0:0d31da041b5c | 189 | float val; |
otis22894 | 0:0d31da041b5c | 190 | userKnock.clear(); |
otis22894 | 0:0d31da041b5c | 191 | timer.reset(); |
otis22894 | 0:0d31da041b5c | 192 | int time; |
otis22894 | 0:0d31da041b5c | 193 | while(timer.read() < 2){ |
otis22894 | 0:0d31da041b5c | 194 | val = ain.read(); |
otis22894 | 0:0d31da041b5c | 195 | if(val > 0.508 && val < 0.538){ |
otis22894 | 0:0d31da041b5c | 196 | time = timer.read_ms(); |
otis22894 | 0:0d31da041b5c | 197 | userKnock.push_back(time); |
otis22894 | 0:0d31da041b5c | 198 | pc.printf("%d\n",time); |
otis22894 | 0:0d31da041b5c | 199 | Thread::wait(50); |
otis22894 | 0:0d31da041b5c | 200 | timer.reset(); |
otis22894 | 0:0d31da041b5c | 201 | } |
otis22894 | 0:0d31da041b5c | 202 | Thread::wait(1); |
otis22894 | 0:0d31da041b5c | 203 | } |
otis22894 | 0:0d31da041b5c | 204 | pc.printf("User size: %d\n",userKnock.size()); |
otis22894 | 0:0d31da041b5c | 205 | } |
otis22894 | 0:0d31da041b5c | 206 | |
otis22894 | 0:0d31da041b5c | 207 | void changeSecretKnock(){ |
otis22894 | 0:0d31da041b5c | 208 | pc.printf("Start the secret knock\n"); |
otis22894 | 0:0d31da041b5c | 209 | float val; |
otis22894 | 0:0d31da041b5c | 210 | Timer t; |
otis22894 | 0:0d31da041b5c | 211 | while(true){ |
otis22894 | 0:0d31da041b5c | 212 | val = ain.read(); |
otis22894 | 0:0d31da041b5c | 213 | if(val > 0.508 && val < 0.538){ |
otis22894 | 0:0d31da041b5c | 214 | break; |
otis22894 | 0:0d31da041b5c | 215 | } |
otis22894 | 0:0d31da041b5c | 216 | Thread::wait(1); |
otis22894 | 0:0d31da041b5c | 217 | } |
otis22894 | 0:0d31da041b5c | 218 | pc.printf("exit val: %f\n",val); |
otis22894 | 0:0d31da041b5c | 219 | t.start(); |
otis22894 | 0:0d31da041b5c | 220 | int time; |
otis22894 | 0:0d31da041b5c | 221 | while(t.read() < 2){ |
otis22894 | 0:0d31da041b5c | 222 | val = ain.read(); |
otis22894 | 0:0d31da041b5c | 223 | if(val > 0.508 && val < 0.538){ |
otis22894 | 0:0d31da041b5c | 224 | time = t.read_ms(); |
otis22894 | 0:0d31da041b5c | 225 | knock.push_back(time); |
otis22894 | 0:0d31da041b5c | 226 | pc.printf("%d\n",time); |
otis22894 | 0:0d31da041b5c | 227 | Thread::wait(50); |
otis22894 | 0:0d31da041b5c | 228 | t.reset(); |
otis22894 | 0:0d31da041b5c | 229 | } |
otis22894 | 0:0d31da041b5c | 230 | Thread::wait(1); |
otis22894 | 0:0d31da041b5c | 231 | } |
otis22894 | 0:0d31da041b5c | 232 | pc.printf("Size: %d\n",knock.size()); |
otis22894 | 0:0d31da041b5c | 233 | } |
otis22894 | 0:0d31da041b5c | 234 | |
otis22894 | 0:0d31da041b5c | 235 | bool checkCode(std::vector<int> master,std::vector<int> v1){ |
otis22894 | 0:0d31da041b5c | 236 | if(v1.size() != master.size()){ |
otis22894 | 0:0d31da041b5c | 237 | return false; |
otis22894 | 0:0d31da041b5c | 238 | }else{ |
otis22894 | 0:0d31da041b5c | 239 | for(int i = 0;i<master.size();i++){ |
otis22894 | 0:0d31da041b5c | 240 | if(master[i] != v1[i]){ |
otis22894 | 0:0d31da041b5c | 241 | return false; |
otis22894 | 0:0d31da041b5c | 242 | } |
otis22894 | 0:0d31da041b5c | 243 | } |
otis22894 | 0:0d31da041b5c | 244 | return true; |
otis22894 | 0:0d31da041b5c | 245 | } |
otis22894 | 0:0d31da041b5c | 246 | } |
otis22894 | 0:0d31da041b5c | 247 | |
otis22894 | 0:0d31da041b5c | 248 | void changeCode(){ |
otis22894 | 0:0d31da041b5c | 249 | pc.printf("Changing Code...\n"); |
otis22894 | 0:0d31da041b5c | 250 | std::vector<int> tempMaster; |
otis22894 | 0:0d31da041b5c | 251 | std::vector<int> key; |
otis22894 | 0:0d31da041b5c | 252 | key.push_back(0); |
otis22894 | 0:0d31da041b5c | 253 | while(key.front() != 12){ |
otis22894 | 0:0d31da041b5c | 254 | key = keypad.getkey(); |
otis22894 | 0:0d31da041b5c | 255 | if(key.size()>0){ |
otis22894 | 0:0d31da041b5c | 256 | tempMaster.push_back(key.front()); |
otis22894 | 0:0d31da041b5c | 257 | pc.printf("Size: %d\n",tempMaster.size()); |
otis22894 | 0:0d31da041b5c | 258 | } |
otis22894 | 0:0d31da041b5c | 259 | Thread::wait(100); |
otis22894 | 0:0d31da041b5c | 260 | } |
otis22894 | 0:0d31da041b5c | 261 | tempMaster.pop_back(); |
otis22894 | 0:0d31da041b5c | 262 | if(tempMaster.size() >= 4){ |
otis22894 | 0:0d31da041b5c | 263 | master.clear(); |
otis22894 | 0:0d31da041b5c | 264 | pc.printf("New Code: "); |
otis22894 | 0:0d31da041b5c | 265 | for(int i = 0;i<tempMaster.size();i++){ |
otis22894 | 0:0d31da041b5c | 266 | pc.printf("%d ",tempMaster[i]); |
otis22894 | 0:0d31da041b5c | 267 | master.push_back(tempMaster[i]); |
otis22894 | 0:0d31da041b5c | 268 | } |
otis22894 | 0:0d31da041b5c | 269 | pc.printf("\n"); |
otis22894 | 0:0d31da041b5c | 270 | }else{ |
otis22894 | 0:0d31da041b5c | 271 | pc.printf("New Password Too Short\n"); |
otis22894 | 0:0d31da041b5c | 272 | } |
otis22894 | 0:0d31da041b5c | 273 | changeCodeBool = false; |
otis22894 | 0:0d31da041b5c | 274 | } |
otis22894 | 0:0d31da041b5c | 275 | |
otis22894 | 0:0d31da041b5c | 276 | void changeCodeInterrupt(){ |
otis22894 | 0:0d31da041b5c | 277 | changeCodeBool = true; |
otis22894 | 0:0d31da041b5c | 278 | } |
otis22894 | 0:0d31da041b5c | 279 | |
otis22894 | 0:0d31da041b5c | 280 | void keypad_thread(void const *args){ |
otis22894 | 0:0d31da041b5c | 281 | pb1.mode(PullUp); |
otis22894 | 0:0d31da041b5c | 282 | Thread::wait(500); |
otis22894 | 0:0d31da041b5c | 283 | pb1.attach_deasserted(&changeCodeInterrupt); |
otis22894 | 0:0d31da041b5c | 284 | pb1.setSampleFrequency(); |
otis22894 | 0:0d31da041b5c | 285 | pc.printf("Begin...\n"); |
otis22894 | 0:0d31da041b5c | 286 | std::vector<int> key; |
otis22894 | 0:0d31da041b5c | 287 | key.push_back(0); |
otis22894 | 0:0d31da041b5c | 288 | while(1) { |
otis22894 | 0:0d31da041b5c | 289 | while(key.front() != 12){ |
otis22894 | 0:0d31da041b5c | 290 | if(changeCodeBool){ |
otis22894 | 0:0d31da041b5c | 291 | changeCode(); |
otis22894 | 0:0d31da041b5c | 292 | } |
otis22894 | 0:0d31da041b5c | 293 | key = keypad.getkey(); |
otis22894 | 0:0d31da041b5c | 294 | if(key.size()>0){ |
otis22894 | 0:0d31da041b5c | 295 | keys.push_back(key.front()); |
otis22894 | 0:0d31da041b5c | 296 | |
otis22894 | 0:0d31da041b5c | 297 | pc.printf("Size: %d\n",keys.size()); |
otis22894 | 0:0d31da041b5c | 298 | } |
otis22894 | 0:0d31da041b5c | 299 | Thread::wait(100); |
otis22894 | 0:0d31da041b5c | 300 | } |
otis22894 | 0:0d31da041b5c | 301 | keys.pop_back(); |
otis22894 | 0:0d31da041b5c | 302 | bool result = checkCode(master,keys); |
otis22894 | 0:0d31da041b5c | 303 | pc.printf("Result %d\n",result); |
otis22894 | 0:0d31da041b5c | 304 | pc.printf("Keys: "); |
otis22894 | 0:0d31da041b5c | 305 | int size = keys.size(); |
otis22894 | 0:0d31da041b5c | 306 | for(int i = 0;i<size;i++){ |
otis22894 | 0:0d31da041b5c | 307 | pc.printf("%d ",keys.front()); |
otis22894 | 0:0d31da041b5c | 308 | keys.erase(keys.begin()); |
otis22894 | 0:0d31da041b5c | 309 | } |
otis22894 | 0:0d31da041b5c | 310 | pc.printf("\n"); |
otis22894 | 0:0d31da041b5c | 311 | keys.clear(); |
otis22894 | 0:0d31da041b5c | 312 | key.clear(); |
otis22894 | 0:0d31da041b5c | 313 | key.push_back(0); |
otis22894 | 0:0d31da041b5c | 314 | Thread::wait(100); |
otis22894 | 0:0d31da041b5c | 315 | } |
otis22894 | 0:0d31da041b5c | 316 | } |