IoT for mbed1

Dependencies:   4DGL-uLCD-SE IoTsecuritySys PinDetect mbed-rtos mbed

Fork of IoT by Tal Landes

Committer:
jsmith352
Date:
Tue Dec 08 23:28:24 2015 +0000
Revision:
9:413c094dd1e2
Parent:
8:429fa05b4952
IoT for mbed1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jsmith352 0:04dcbfb4388c 1 #include <mbed.h>
landes 2:922d5b43bee3 2 #include <string>
landes 5:ebc70efa2e86 3 #include <iostream>
landes 1:7f873efe5b11 4 #include "rtos.h"
jsmith352 0:04dcbfb4388c 5 #include <mpr121.h>
jsmith352 0:04dcbfb4388c 6 #include <stdlib.h>
jsmith352 0:04dcbfb4388c 7 #include "PinDetect.h"
landes 1:7f873efe5b11 8 #include "uLCD_4DGL.h"
landes 1:7f873efe5b11 9 #include "SongPlayer.h"
landes 1:7f873efe5b11 10 #include "Speaker.h"
landes 1:7f873efe5b11 11 #include "EthernetInterface.h"
jsmith352 0:04dcbfb4388c 12 /* CODE_LENGTH needs to be double the amount of numbers you
jsmith352 0:04dcbfb4388c 13 want in your authenticator/passcode because of the way interrupt.fall(&fallInterrupt)
jsmith352 0:04dcbfb4388c 14 works. It is called twice every time an interrupt is detected.
jsmith352 0:04dcbfb4388c 15 The extra numbers in the array will just be filled with zeros and ignored in checking
jsmith352 0:04dcbfb4388c 16 code sequences, so they will not matter either way */
jsmith352 0:04dcbfb4388c 17 /* i.e, you want a code with 7 numbers, CODE_LENGTH needs to be 14 */
landes 1:7f873efe5b11 18 #define CODE_LENGTH 8
jsmith352 0:04dcbfb4388c 19
jsmith352 0:04dcbfb4388c 20 DigitalOut led1(LED1);
jsmith352 0:04dcbfb4388c 21 DigitalOut led2(LED2);
jsmith352 0:04dcbfb4388c 22 DigitalOut led3(LED3);
jsmith352 0:04dcbfb4388c 23 DigitalOut led4(LED4);
jsmith352 0:04dcbfb4388c 24
landes 1:7f873efe5b11 25 DigitalOut doorlock(p21);
landes 1:7f873efe5b11 26
landes 1:7f873efe5b11 27
landes 1:7f873efe5b11 28 //uLCD_4DGL uLCD(p9,p10,p11); // serial tx, serial rx, reset pin;
landes 1:7f873efe5b11 29 uLCD_4DGL uLCD(p28, p27, p29);
jsmith352 0:04dcbfb4388c 30
jsmith352 0:04dcbfb4388c 31 // Create the interrupt receiver object on pin 26
jsmith352 0:04dcbfb4388c 32 InterruptIn interrupt(p30);
jsmith352 0:04dcbfb4388c 33
jsmith352 0:04dcbfb4388c 34 // Setup the i2c bus on pins 9 and 10
jsmith352 0:04dcbfb4388c 35 I2C i2c(p9, p10);
jsmith352 0:04dcbfb4388c 36
jsmith352 0:04dcbfb4388c 37 // Setup the Mpr121:
jsmith352 0:04dcbfb4388c 38 // constructor(i2c object, i2c address of the mpr121)
jsmith352 0:04dcbfb4388c 39 Mpr121 mpr121(&i2c, Mpr121::ADD_VSS);
jsmith352 0:04dcbfb4388c 40
jsmith352 0:04dcbfb4388c 41 // pc serial communication for testing
jsmith352 0:04dcbfb4388c 42 Serial pc(USBTX, USBRX);
jsmith352 0:04dcbfb4388c 43
landes 1:7f873efe5b11 44 //Set up IR sensor
landes 1:7f873efe5b11 45 AnalogIn IrSensor(p20);
landes 1:7f873efe5b11 46
landes 1:7f873efe5b11 47 //Shiftbright
landes 1:7f873efe5b11 48 DigitalOut latch(p15);
landes 1:7f873efe5b11 49 DigitalOut enable(p16);
landes 1:7f873efe5b11 50 //AnalogOut DACout(p18);
landes 1:7f873efe5b11 51 //Cycles through different colors on RGB LED
landes 1:7f873efe5b11 52 SPI spi(p11, p12, p13);
landes 1:7f873efe5b11 53
landes 1:7f873efe5b11 54
landes 1:7f873efe5b11 55 SongPlayer mySpeaker(p26);
landes 1:7f873efe5b11 56 Speaker NotePlayer(p26);
landes 1:7f873efe5b11 57
landes 1:7f873efe5b11 58 // ethernet setup
landes 1:7f873efe5b11 59 EthernetInterface eth;
landes 1:7f873efe5b11 60
landes 1:7f873efe5b11 61 //Lock timeout
landes 4:d8de964b3d2c 62 Timeout flipper;
landes 1:7f873efe5b11 63
jsmith352 0:04dcbfb4388c 64 // ***** GLOBALS ***** //
jsmith352 0:04dcbfb4388c 65 // Timer is to seed rand
landes 4:d8de964b3d2c 66 string ID = "1";
landes 5:ebc70efa2e86 67 volatile int NumTry = 0;
jsmith352 0:04dcbfb4388c 68 Timer t1;
landes 6:33185f926189 69 Timer t2;
jsmith352 0:04dcbfb4388c 70 // code counter is the next position in inputCode array
landes 1:7f873efe5b11 71 volatile int codeCounter;
jsmith352 0:04dcbfb4388c 72 // inputCode array is the sequence of numbers the user will enter
landes 1:7f873efe5b11 73 volatile int inputCode[CODE_LENGTH];
landes 8:429fa05b4952 74 //volatile bool code_enabled;
landes 1:7f873efe5b11 75 volatile float IrVoltage = 0.0;
landes 5:ebc70efa2e86 76 int FindStrLocation(string sntsc, string word, string ptr);
jsmith352 9:413c094dd1e2 77 enum Statetype { Armed = 0, IR_sensed = 1, Second_Step = 2, Cleared = 3, Alarm_ON = 4};
landes 1:7f873efe5b11 78 Statetype state = Armed;
landes 2:922d5b43bee3 79 char charCode[5];
landes 1:7f873efe5b11 80
landes 1:7f873efe5b11 81 float note[18]= {1568.0,1396.9};
landes 1:7f873efe5b11 82 float duration[18]= {0.48,0.24};
landes 1:7f873efe5b11 83
landes 1:7f873efe5b11 84 Mutex LCD_Access;
landes 5:ebc70efa2e86 85 Mutex PC_Access;
landes 8:429fa05b4952 86 Mutex Eth_Lock;
landes 1:7f873efe5b11 87 Semaphore Consul_Access(5);
landes 1:7f873efe5b11 88
landes 1:7f873efe5b11 89 void Shiftbright_thread(void const *args);
landes 1:7f873efe5b11 90 void LCD_Code_Enter_Thread(void const *args);
landes 1:7f873efe5b11 91 void uLCD_thread(void const *args);
landes 1:7f873efe5b11 92 void RGB_LED(int red, int green, int blue);
landes 1:7f873efe5b11 93 void Ethernet_thread(void const *args);
landes 2:922d5b43bee3 94 bool Ethernet_massage_Send(string args);
landes 1:7f873efe5b11 95 void Activate_Lock();
landes 1:7f873efe5b11 96 void init_LCD();
jsmith352 0:04dcbfb4388c 97 // Key hit/release interrupt routine
jsmith352 0:04dcbfb4388c 98 void fallInterrupt() {
jsmith352 0:04dcbfb4388c 99 int key_code=0;
jsmith352 0:04dcbfb4388c 100 int i=0;
jsmith352 0:04dcbfb4388c 101 int value=mpr121.read(0x00);
jsmith352 0:04dcbfb4388c 102 value +=mpr121.read(0x01)<<8;
jsmith352 0:04dcbfb4388c 103 // LED demo mod
jsmith352 0:04dcbfb4388c 104 i=0;
jsmith352 0:04dcbfb4388c 105 // puts key number out to LEDs for demo
jsmith352 0:04dcbfb4388c 106 for (i=0; i<12; i++) {
jsmith352 0:04dcbfb4388c 107 if (((value>>i)&0x01)==1) key_code=i+1;
jsmith352 0:04dcbfb4388c 108 }
jsmith352 0:04dcbfb4388c 109 led4=key_code & 0x01;
jsmith352 0:04dcbfb4388c 110 led3=(key_code>>1) & 0x01;
jsmith352 0:04dcbfb4388c 111 led2=(key_code>>2) & 0x01;
jsmith352 0:04dcbfb4388c 112 led1=(key_code>>3) & 0x01;
jsmith352 0:04dcbfb4388c 113
jsmith352 0:04dcbfb4388c 114 // save the keypress to inputCode array
landes 2:922d5b43bee3 115 switch (state) {
landes 2:922d5b43bee3 116 case Armed:
landes 2:922d5b43bee3 117 break;
landes 2:922d5b43bee3 118 case IR_sensed:
landes 2:922d5b43bee3 119 case Second_Step:
landes 2:922d5b43bee3 120 if(codeCounter < CODE_LENGTH){
landes 2:922d5b43bee3 121 // ignore odd numbers
landes 2:922d5b43bee3 122 if(codeCounter % 2 != 0){
landes 2:922d5b43bee3 123 inputCode[codeCounter] = 0;
landes 2:922d5b43bee3 124 }
landes 2:922d5b43bee3 125 // only save the even numbers (see lines 6-10)
landes 2:922d5b43bee3 126 else{
landes 2:922d5b43bee3 127 inputCode[codeCounter] = key_code - 1;
landes 2:922d5b43bee3 128 //pc.printf("codeCounter: %d -- code: %d\n\r", codeCounter, key_code - 1);
landes 2:922d5b43bee3 129 }
landes 2:922d5b43bee3 130 codeCounter++;
jsmith352 0:04dcbfb4388c 131 }
landes 2:922d5b43bee3 132 break;
landes 2:922d5b43bee3 133 case Alarm_ON:
landes 8:429fa05b4952 134 if(key_code == 12 ){
landes 8:429fa05b4952 135 state = Armed;
jsmith352 9:413c094dd1e2 136 //Ethernet_massage_Send("UpdateStatus");
landes 8:429fa05b4952 137 }
landes 2:922d5b43bee3 138 break;
landes 2:922d5b43bee3 139 case Cleared:
landes 5:ebc70efa2e86 140 if(key_code == 12 ){
landes 2:922d5b43bee3 141 state = Armed;
jsmith352 9:413c094dd1e2 142 //Ethernet_massage_Send("UpdateStatus");
landes 5:ebc70efa2e86 143 }
landes 5:ebc70efa2e86 144 else if (key_code == 11 ){
landes 5:ebc70efa2e86 145 doorlock = 1;
jsmith352 9:413c094dd1e2 146 flipper.attach(&Activate_Lock, 3.0);
landes 5:ebc70efa2e86 147 }
landes 2:922d5b43bee3 148 break;
landes 2:922d5b43bee3 149 }
landes 2:922d5b43bee3 150
jsmith352 0:04dcbfb4388c 151 }
jsmith352 0:04dcbfb4388c 152
jsmith352 0:04dcbfb4388c 153 // generate randomized code
jsmith352 0:04dcbfb4388c 154 void generate_random_code(int (&codeArray)[CODE_LENGTH]){
landes 1:7f873efe5b11 155 //int i = 0;
jsmith352 0:04dcbfb4388c 156 // only care about the even numbers (see lines 6-10)
landes 8:429fa05b4952 157 //PC_Access.lock();
landes 5:ebc70efa2e86 158 //pc.printf("NEW CODE: ");
landes 5:ebc70efa2e86 159 //PC_Access.unlock();
landes 1:7f873efe5b11 160 for(int i = 0; i < CODE_LENGTH; i+=2){
jsmith352 0:04dcbfb4388c 161 srand(t1.read_us());
landes 1:7f873efe5b11 162 codeArray[i] = (rand() % 9)+1; //nake code only 1-9
landes 8:429fa05b4952 163 PC_Access.lock();
jsmith352 0:04dcbfb4388c 164 pc.printf("%d, ", codeArray[i]);
landes 8:429fa05b4952 165 PC_Access.unlock();
jsmith352 0:04dcbfb4388c 166 }
landes 5:ebc70efa2e86 167
landes 2:922d5b43bee3 168 snprintf(charCode, sizeof(charCode), "%i%i%i%i ", codeArray[0], codeArray[2], codeArray[4], codeArray[6]);
landes 8:429fa05b4952 169 //PC_Access.lock();
landes 5:ebc70efa2e86 170 //pc.printf("\n\r");
landes 5:ebc70efa2e86 171 //pc.printf("%s\n\r",charCode,codeArray[6]);
landes 5:ebc70efa2e86 172 //PC_Access.unlock();
landes 5:ebc70efa2e86 173 //Ethernet_massage_Send("TextCode");
jsmith352 0:04dcbfb4388c 174 }
jsmith352 0:04dcbfb4388c 175
jsmith352 0:04dcbfb4388c 176 // check if the code entered is the correct code
jsmith352 0:04dcbfb4388c 177 bool check_code_sequence(int (&codeArray)[CODE_LENGTH]){
landes 5:ebc70efa2e86 178 //int i = 0;
jsmith352 0:04dcbfb4388c 179 int j = 0;
jsmith352 0:04dcbfb4388c 180 // only care about the even numbers (see lines 6-10)
landes 4:d8de964b3d2c 181
landes 5:ebc70efa2e86 182 if (NumTry < 3) {
landes 5:ebc70efa2e86 183 NumTry++;
landes 5:ebc70efa2e86 184 for(int i = 0; i < CODE_LENGTH; i+=2){
landes 5:ebc70efa2e86 185
landes 5:ebc70efa2e86 186 if(inputCode[i] == codeArray[i]){
jsmith352 0:04dcbfb4388c 187 j++; // count the number of right numbers
landes 5:ebc70efa2e86 188 }
landes 5:ebc70efa2e86 189
jsmith352 0:04dcbfb4388c 190 }
landes 5:ebc70efa2e86 191 if(j == CODE_LENGTH/2){
landes 8:429fa05b4952 192 /*for(int i = 0; i < CODE_LENGTH; i+=2){
landes 8:429fa05b4952 193 //inputCode[i] =0;
landes 8:429fa05b4952 194 }*/
jsmith352 0:04dcbfb4388c 195 return(true);
landes 5:ebc70efa2e86 196 }
landes 2:922d5b43bee3 197 else if (Ethernet_massage_Send("GetTempCode")){
landes 8:429fa05b4952 198 /*for(int i = 0; i < CODE_LENGTH; i+=2){
landes 8:429fa05b4952 199 //inputCode[i] =0;
landes 8:429fa05b4952 200 }*/
landes 5:ebc70efa2e86 201 //pc.printf("return true");
landes 2:922d5b43bee3 202 return(true);
landes 2:922d5b43bee3 203 }
landes 2:922d5b43bee3 204 else {
landes 8:429fa05b4952 205 /*for(int i = 0; i < CODE_LENGTH; i+=2){
landes 8:429fa05b4952 206 //inputCode[i] =0;
landes 8:429fa05b4952 207 }*/
landes 2:922d5b43bee3 208 return(false);
landes 2:922d5b43bee3 209 }
landes 5:ebc70efa2e86 210 }
landes 5:ebc70efa2e86 211 else {
landes 8:429fa05b4952 212 //PC_Access.lock();
landes 8:429fa05b4952 213 //pc.printf("3 times ");
landes 8:429fa05b4952 214 //PC_Access.unlock();
landes 5:ebc70efa2e86 215 state = Alarm_ON;
jsmith352 9:413c094dd1e2 216 //Ethernet_massage_Send("UpdateStatus");
landes 5:ebc70efa2e86 217 return(false);
landes 5:ebc70efa2e86 218 }
jsmith352 0:04dcbfb4388c 219 }
jsmith352 0:04dcbfb4388c 220
jsmith352 0:04dcbfb4388c 221 int main() {
jsmith352 0:04dcbfb4388c 222 interrupt.fall(&fallInterrupt);
jsmith352 0:04dcbfb4388c 223 interrupt.mode(PullUp);
landes 1:7f873efe5b11 224 pc.baud(921600);
landes 1:7f873efe5b11 225
jsmith352 0:04dcbfb4388c 226
jsmith352 0:04dcbfb4388c 227 // authenticator is the randomly generated sequence of numbers by the machine
jsmith352 0:04dcbfb4388c 228 // the user has to match this sequence to gain access, used for phase 2
jsmith352 0:04dcbfb4388c 229 int authenticator[CODE_LENGTH];
jsmith352 0:04dcbfb4388c 230 // passcode is the user's personal passcode, used for phase 1
landes 1:7f873efe5b11 231 int passcode[CODE_LENGTH] = {1,0,2,0,3,0,4,0};//,4,0,5,0,6,0};
jsmith352 0:04dcbfb4388c 232 codeCounter = 0;
jsmith352 0:04dcbfb4388c 233 bool pass = false;
jsmith352 0:04dcbfb4388c 234
jsmith352 0:04dcbfb4388c 235 // these 2 variables tell the machine when to generate a new random authentication code
jsmith352 0:04dcbfb4388c 236 int new_code_timer = 0;
jsmith352 0:04dcbfb4388c 237 int new_code_counter = 0;
jsmith352 0:04dcbfb4388c 238 // this tells the state machine with phase of authentication we are in
landes 8:429fa05b4952 239 //code_enabled = false;
jsmith352 0:04dcbfb4388c 240
jsmith352 0:04dcbfb4388c 241 for(int i = 0; i < CODE_LENGTH; i++){
jsmith352 0:04dcbfb4388c 242 authenticator[i] = 0;
jsmith352 0:04dcbfb4388c 243 inputCode[i] = 0;
jsmith352 0:04dcbfb4388c 244 }
jsmith352 0:04dcbfb4388c 245
jsmith352 0:04dcbfb4388c 246 // go ahead and start the timer so that when a random code is generated,
jsmith352 0:04dcbfb4388c 247 // the seed will always be random, unlike the predecessor version
jsmith352 0:04dcbfb4388c 248 t1.start();
landes 1:7f873efe5b11 249 init_LCD();
landes 8:429fa05b4952 250
landes 8:429fa05b4952 251 Timer t;
landes 8:429fa05b4952 252 t.start();
landes 1:7f873efe5b11 253 //start threads:
landes 8:429fa05b4952 254 PC_Access.lock();
landes 1:7f873efe5b11 255 pc.printf("\n\n\nSetting up Ethernet\n\r");
landes 8:429fa05b4952 256 PC_Access.unlock();
landes 2:922d5b43bee3 257 Thread Ethernetthread(Ethernet_thread);
landes 2:922d5b43bee3 258 wait(5); //Give the Ethernet connection some time to set up
landes 1:7f873efe5b11 259 Thread Shiftbright(Shiftbright_thread);
landes 1:7f873efe5b11 260 Thread LCDthread(uLCD_thread);
jsmith352 9:413c094dd1e2 261 //Thread LCD_CodeEnterThread(LCD_Code_Enter_Thread);
landes 5:ebc70efa2e86 262
jsmith352 0:04dcbfb4388c 263 // while loop constantly checks if the entered code sequence is right or wrong,
jsmith352 0:04dcbfb4388c 264 // given that the correct amount of numbers were entered
landes 8:429fa05b4952 265 PC_Access.lock();
landes 5:ebc70efa2e86 266 pc.printf("Ready\n\r");
landes 8:429fa05b4952 267 PC_Access.unlock();
landes 1:7f873efe5b11 268 doorlock = 0; // make sure locked
jsmith352 0:04dcbfb4388c 269 while (1){
landes 1:7f873efe5b11 270 switch(state){
landes 8:429fa05b4952 271 case Armed:
jsmith352 9:413c094dd1e2 272 IrVoltage=IrSensor.read();
jsmith352 9:413c094dd1e2 273 if (IrVoltage <= 0.1) { //if value just nois reset timer
jsmith352 9:413c094dd1e2 274 t.reset();
jsmith352 9:413c094dd1e2 275 state = Armed;
landes 8:429fa05b4952 276 }
jsmith352 9:413c094dd1e2 277 if (t.read() >= 3) { //wait 5 seconds to make sure that sense someone
jsmith352 9:413c094dd1e2 278 state = IR_sensed;
jsmith352 9:413c094dd1e2 279 //Ethernet_massage_Send("UpdateStatus");
jsmith352 9:413c094dd1e2 280 }
landes 8:429fa05b4952 281 break;
landes 1:7f873efe5b11 282 case Cleared:
landes 1:7f873efe5b11 283 break;
landes 1:7f873efe5b11 284 case IR_sensed:
jsmith352 0:04dcbfb4388c 285 if(codeCounter >= CODE_LENGTH){
jsmith352 0:04dcbfb4388c 286 pass = check_code_sequence(passcode);
jsmith352 0:04dcbfb4388c 287 if(pass == true){
landes 8:429fa05b4952 288 //PC_Access.lock();
landes 5:ebc70efa2e86 289 //pc.printf("SENDING AUTHENTICATION CODE...\n\r");
landes 8:429fa05b4952 290 //PC_Access.unlock();
jsmith352 0:04dcbfb4388c 291 generate_random_code(authenticator);
jsmith352 0:04dcbfb4388c 292 t1.stop(); // reset the time
jsmith352 0:04dcbfb4388c 293 t1.reset(); // so that it is an even
jsmith352 0:04dcbfb4388c 294 t1.start(); // 30 seconds before 1st new code is generated
jsmith352 0:04dcbfb4388c 295 codeCounter = 0;
landes 1:7f873efe5b11 296 //code_enabled = true;
landes 1:7f873efe5b11 297 state = Second_Step;
jsmith352 9:413c094dd1e2 298 //Ethernet_massage_Send("UpdateStatus");
landes 8:429fa05b4952 299 Ethernet_massage_Send("TextCode");
jsmith352 0:04dcbfb4388c 300 }
jsmith352 0:04dcbfb4388c 301 else{
landes 8:429fa05b4952 302 //PC_Access.lock();
landes 5:ebc70efa2e86 303 //pc.printf("WRONG passcode\n\r");
landes 8:429fa05b4952 304 //PC_Access.unlock();
jsmith352 0:04dcbfb4388c 305 codeCounter = 0;
jsmith352 0:04dcbfb4388c 306 }
jsmith352 0:04dcbfb4388c 307 }
jsmith352 0:04dcbfb4388c 308 break;
landes 1:7f873efe5b11 309 case Second_Step:
jsmith352 0:04dcbfb4388c 310 if(codeCounter >= CODE_LENGTH){
landes 5:ebc70efa2e86 311 NumTry = 0;
jsmith352 0:04dcbfb4388c 312 pass = check_code_sequence(authenticator);
jsmith352 0:04dcbfb4388c 313 if(pass == true){
landes 8:429fa05b4952 314 //PC_Access.lock();
landes 5:ebc70efa2e86 315 //pc.printf("ACCESS GRANTED\n\r");
landes 8:429fa05b4952 316 //PC_Access.unlock();
landes 8:429fa05b4952 317
landes 1:7f873efe5b11 318 //wait(5);
jsmith352 9:413c094dd1e2 319
landes 5:ebc70efa2e86 320 //pc.printf("Resetting....\n\r");
landes 5:ebc70efa2e86 321 //pc.printf("\n\n\rPlease Enter Your Personal Security Code\n\r");
jsmith352 0:04dcbfb4388c 322 codeCounter = 0;
landes 8:429fa05b4952 323 //code_enabled = false;
landes 1:7f873efe5b11 324 state = Cleared;
jsmith352 9:413c094dd1e2 325 //Ethernet_massage_Send("TextCode");
jsmith352 9:413c094dd1e2 326 //Ethernet_massage_Send("UpdateStatus");
landes 8:429fa05b4952 327 doorlock = 1;
jsmith352 9:413c094dd1e2 328 flipper.attach(&Activate_Lock, 3.0);
jsmith352 0:04dcbfb4388c 329 }
jsmith352 0:04dcbfb4388c 330 else{
landes 8:429fa05b4952 331 //PC_Access.lock();
landes 5:ebc70efa2e86 332 //pc.printf("ACCESS DENIED\n\r");
landes 8:429fa05b4952 333 //PC_Access.unlock();
jsmith352 0:04dcbfb4388c 334 codeCounter = 0;
jsmith352 0:04dcbfb4388c 335 }
jsmith352 0:04dcbfb4388c 336 }
jsmith352 0:04dcbfb4388c 337 // this code generates a new authentication code every 30 seconds (30000 ms)
landes 2:922d5b43bee3 338 new_code_timer = (int)(t1.read_ms()/300000000);
jsmith352 0:04dcbfb4388c 339 if(new_code_timer > new_code_counter){
jsmith352 0:04dcbfb4388c 340 new_code_counter++;
jsmith352 0:04dcbfb4388c 341 generate_random_code(authenticator);
jsmith352 0:04dcbfb4388c 342 codeCounter = 0;
jsmith352 0:04dcbfb4388c 343 }
jsmith352 0:04dcbfb4388c 344 break;
jsmith352 0:04dcbfb4388c 345 }
jsmith352 0:04dcbfb4388c 346 // reset the timer when the number gets too high, should last about 35 minutes
jsmith352 0:04dcbfb4388c 347 // We do this because int can only hold a number up to 2^32 - 1, preventing errors
jsmith352 0:04dcbfb4388c 348 if(t1.read_us() > 2147400000){
jsmith352 0:04dcbfb4388c 349 t1.stop();
jsmith352 0:04dcbfb4388c 350 t1.reset();
jsmith352 0:04dcbfb4388c 351 new_code_timer = 0;
jsmith352 0:04dcbfb4388c 352 new_code_counter = 0;
jsmith352 0:04dcbfb4388c 353 t1.start();
jsmith352 0:04dcbfb4388c 354 }
jsmith352 0:04dcbfb4388c 355 }
landes 1:7f873efe5b11 356 }
landes 1:7f873efe5b11 357
landes 1:7f873efe5b11 358
landes 1:7f873efe5b11 359 void Shiftbright_thread(void const *args){
landes 1:7f873efe5b11 360 spi.format(16,0);
landes 1:7f873efe5b11 361 spi.frequency(500000);
landes 1:7f873efe5b11 362 enable=0;
landes 1:7f873efe5b11 363 latch=0;
landes 1:7f873efe5b11 364
landes 1:7f873efe5b11 365 while(1) {
landes 1:7f873efe5b11 366 switch (state) {
landes 1:7f873efe5b11 367 case Armed:
landes 8:429fa05b4952 368
landes 1:7f873efe5b11 369 for (int i = 0; i <= 50; i++) {
landes 1:7f873efe5b11 370 RGB_LED( i, 0, 0);
landes 1:7f873efe5b11 371 Thread::wait(10);
landes 1:7f873efe5b11 372 }
landes 1:7f873efe5b11 373 for (int i = 50; i >= 0; i--) {
landes 1:7f873efe5b11 374 RGB_LED( i, 0, 0);
landes 1:7f873efe5b11 375 Thread::wait(10);
landes 1:7f873efe5b11 376 }
landes 1:7f873efe5b11 377 break;
landes 1:7f873efe5b11 378 case IR_sensed:
landes 1:7f873efe5b11 379 RGB_LED( 100, 0, 0);
landes 1:7f873efe5b11 380 Thread::wait(500);
landes 1:7f873efe5b11 381 RGB_LED( 0, 0, 0);
landes 1:7f873efe5b11 382 break;
landes 1:7f873efe5b11 383 case Alarm_ON:
landes 8:429fa05b4952 384 mySpeaker.PlaySong(note,duration);
landes 8:429fa05b4952 385 //Thread::wait(2000);
landes 1:7f873efe5b11 386 for (int i = 0; i <= 100; i++) {
landes 1:7f873efe5b11 387 RGB_LED( i, i/2, 0);
landes 1:7f873efe5b11 388 Thread::wait(10);
landes 1:7f873efe5b11 389 }
landes 1:7f873efe5b11 390 for (int i = 100; i >= 0; i--) {
landes 1:7f873efe5b11 391 RGB_LED( i, i/3, 0);
landes 1:7f873efe5b11 392 Thread::wait(10);
landes 1:7f873efe5b11 393 }
landes 1:7f873efe5b11 394 break;
landes 1:7f873efe5b11 395 case Cleared:
landes 1:7f873efe5b11 396 RGB_LED( 0, 100, 0);
landes 1:7f873efe5b11 397 break;
landes 1:7f873efe5b11 398 }
landes 1:7f873efe5b11 399 Thread::wait(1000);
landes 1:7f873efe5b11 400 }
landes 1:7f873efe5b11 401 }
landes 1:7f873efe5b11 402
landes 1:7f873efe5b11 403 void RGB_LED(int red, int green, int blue) {
landes 1:7f873efe5b11 404
landes 1:7f873efe5b11 405 unsigned int low_color=0;
landes 1:7f873efe5b11 406 unsigned int high_color=0;
landes 1:7f873efe5b11 407 high_color=(blue<<4)|((red&0x3C0)>>6);
landes 1:7f873efe5b11 408 low_color=(((red&0x3F)<<10)|(green));
landes 1:7f873efe5b11 409 spi.write(high_color);
landes 1:7f873efe5b11 410 spi.write(low_color);
landes 1:7f873efe5b11 411 latch=1;
landes 1:7f873efe5b11 412 latch=0;
landes 1:7f873efe5b11 413 }
landes 1:7f873efe5b11 414
landes 1:7f873efe5b11 415 void init_LCD() {
landes 1:7f873efe5b11 416 uLCD.baudrate(3000000);
landes 1:7f873efe5b11 417 uLCD.background_color(BLACK);
landes 1:7f873efe5b11 418
landes 1:7f873efe5b11 419 }
landes 1:7f873efe5b11 420
landes 1:7f873efe5b11 421
landes 1:7f873efe5b11 422 void uLCD_thread(void const *args) {
landes 1:7f873efe5b11 423 int Change = 99;
landes 2:922d5b43bee3 424 string temp;
landes 2:922d5b43bee3 425 temp = "abc";
landes 1:7f873efe5b11 426 while(1) {
landes 1:7f873efe5b11 427
landes 1:7f873efe5b11 428 if (Change != state) {
landes 1:7f873efe5b11 429 Change = state;
landes 1:7f873efe5b11 430 switch (state) {
landes 1:7f873efe5b11 431 case Armed:
landes 1:7f873efe5b11 432 LCD_Access.lock();
landes 1:7f873efe5b11 433 uLCD.cls();
landes 1:7f873efe5b11 434 uLCD.color(WHITE);
landes 1:7f873efe5b11 435 uLCD.text_width(2);
landes 1:7f873efe5b11 436 uLCD.text_height(2);
landes 1:7f873efe5b11 437 uLCD.printf(" ARMED\r\n");
landes 1:7f873efe5b11 438 uLCD.text_width(1);
landes 1:7f873efe5b11 439 uLCD.text_height(1);
landes 1:7f873efe5b11 440
landes 1:7f873efe5b11 441 if (eth.getIPAddress() == "\0") {
landes 1:7f873efe5b11 442 uLCD.printf("\n\n No Internet connection");
landes 1:7f873efe5b11 443 }
landes 1:7f873efe5b11 444 else {
landes 1:7f873efe5b11 445 uLCD.printf("\n\nConnected to the Internet\n");
landes 1:7f873efe5b11 446 uLCD.printf("IP Address: \n%s ", eth.getIPAddress());
landes 1:7f873efe5b11 447 }
landes 1:7f873efe5b11 448 LCD_Access.unlock();
landes 1:7f873efe5b11 449 break;
landes 1:7f873efe5b11 450 case IR_sensed:
landes 1:7f873efe5b11 451 LCD_Access.lock();
landes 1:7f873efe5b11 452 uLCD.cls();
landes 1:7f873efe5b11 453 uLCD.printf("\nSensor triggred \n");
landes 1:7f873efe5b11 454 uLCD.printf("\n Enter the code ...");
landes 1:7f873efe5b11 455 LCD_Access.unlock();
landes 1:7f873efe5b11 456 for (int i=30; i>=0; --i) {
landes 1:7f873efe5b11 457 if (state == IR_sensed) {
landes 1:7f873efe5b11 458 LCD_Access.lock();
landes 1:7f873efe5b11 459 uLCD.text_width(4);
landes 1:7f873efe5b11 460 uLCD.text_height(4);
jsmith352 9:413c094dd1e2 461 //LCD_Access.unlock();
jsmith352 9:413c094dd1e2 462 //LCD_Access.lock();
landes 1:7f873efe5b11 463 uLCD.color(RED);
landes 1:7f873efe5b11 464 uLCD.locate(1,2);
landes 1:7f873efe5b11 465 uLCD.printf("%2D",i);
landes 1:7f873efe5b11 466 LCD_Access.unlock();
landes 1:7f873efe5b11 467 Thread::wait(1000);
landes 1:7f873efe5b11 468 }
landes 1:7f873efe5b11 469 }
landes 1:7f873efe5b11 470 if (state == IR_sensed) {
landes 8:429fa05b4952 471 LCD_Access.lock();
landes 8:429fa05b4952 472 uLCD.cls();
landes 8:429fa05b4952 473 LCD_Access.unlock();
landes 1:7f873efe5b11 474 state = Alarm_ON;
jsmith352 9:413c094dd1e2 475 //Ethernet_massage_Send("UpdateStatus");
landes 2:922d5b43bee3 476 Ethernet_massage_Send("TextAlarm");
landes 1:7f873efe5b11 477 }
landes 1:7f873efe5b11 478
landes 1:7f873efe5b11 479 break;
landes 1:7f873efe5b11 480 case Second_Step:
landes 1:7f873efe5b11 481 LCD_Access.lock();
landes 1:7f873efe5b11 482 uLCD.cls();
landes 1:7f873efe5b11 483 uLCD.color(BLUE);
landes 1:7f873efe5b11 484 uLCD.printf("\nPleas enter code from text massage \n");
landes 1:7f873efe5b11 485 LCD_Access.unlock();
landes 1:7f873efe5b11 486 break;
landes 1:7f873efe5b11 487 case Alarm_ON:
landes 1:7f873efe5b11 488 LCD_Access.lock();
landes 1:7f873efe5b11 489 uLCD.cls();
landes 1:7f873efe5b11 490 uLCD.color(RED);
landes 1:7f873efe5b11 491 uLCD.text_width(1.5); //4X size text
landes 1:7f873efe5b11 492 uLCD.text_height(1.5);
landes 1:7f873efe5b11 493 uLCD.printf("\nALARM IS ON \nText message sent \n");
landes 1:7f873efe5b11 494 LCD_Access.unlock();
landes 1:7f873efe5b11 495 break;
landes 1:7f873efe5b11 496 case Cleared:
landes 1:7f873efe5b11 497 LCD_Access.lock();
landes 1:7f873efe5b11 498 uLCD.cls();
landes 1:7f873efe5b11 499 uLCD.color(GREEN);
landes 1:7f873efe5b11 500 uLCD.printf("\n\nAccess Granted. \n\n");
landes 1:7f873efe5b11 501 LCD_Access.unlock();
landes 1:7f873efe5b11 502 break;
landes 1:7f873efe5b11 503 }
landes 1:7f873efe5b11 504 }
jsmith352 9:413c094dd1e2 505 Thread::wait(100);
landes 1:7f873efe5b11 506 }
landes 1:7f873efe5b11 507 }
landes 1:7f873efe5b11 508
landes 1:7f873efe5b11 509 void LCD_Code_Enter_Thread(void const *args) {
landes 1:7f873efe5b11 510 int LineHight = 120;
landes 1:7f873efe5b11 511 int LineWidth = 10;
landes 1:7f873efe5b11 512 int SpaceWidth = 5;
landes 1:7f873efe5b11 513 int MidPoint = 127/2;
landes 1:7f873efe5b11 514 while(1) {
landes 1:7f873efe5b11 515 switch (state) {
landes 1:7f873efe5b11 516 case Armed:
landes 1:7f873efe5b11 517 break;
landes 1:7f873efe5b11 518 case IR_sensed:
landes 1:7f873efe5b11 519 case Cleared:
landes 1:7f873efe5b11 520 case Second_Step:
landes 1:7f873efe5b11 521
landes 1:7f873efe5b11 522 Thread::wait(500);
landes 1:7f873efe5b11 523 while((state == IR_sensed)||(state == Cleared)||(state == Second_Step)) {
landes 1:7f873efe5b11 524 LCD_Access.lock();
landes 1:7f873efe5b11 525 //dusplay four lines
landes 1:7f873efe5b11 526 uLCD.line(MidPoint-2*(LineWidth+SpaceWidth), LineHight, MidPoint- 2*SpaceWidth-LineWidth, LineHight, WHITE); //line( int x1, int y1, int x2, int y2, int color)
landes 1:7f873efe5b11 527 uLCD.line(MidPoint-LineWidth-SpaceWidth, LineHight, MidPoint-SpaceWidth, LineHight, WHITE); //line( int x1, int y1, int x2, int y2, int color)
landes 1:7f873efe5b11 528 uLCD.line(MidPoint+SpaceWidth, LineHight, MidPoint+SpaceWidth+LineWidth, LineHight, WHITE); //line( int x1, int y1, int x2, int y2, int color)
landes 1:7f873efe5b11 529 uLCD.line(MidPoint+2*SpaceWidth+LineWidth, LineHight, MidPoint+2*(SpaceWidth+LineWidth), LineHight, WHITE); //line( int x1, int y1, int x2, int y2, int color)
landes 1:7f873efe5b11 530 uLCD.locate(5,14);
landes 1:7f873efe5b11 531 uLCD.text_width(1); //4X size text
landes 1:7f873efe5b11 532 uLCD.text_height(1);
landes 5:ebc70efa2e86 533
landes 1:7f873efe5b11 534 // add black numbers
landes 5:ebc70efa2e86 535 /*if (inputCode[0] == inputCode[2] ==inputCode[4] ==inputCode[6] == 0) {
landes 5:ebc70efa2e86 536 uLCD.color(BLACK);
landes 5:ebc70efa2e86 537 }
landes 5:ebc70efa2e86 538 else {*/
landes 5:ebc70efa2e86 539 //uLCD.color(WHITE);
landes 1:7f873efe5b11 540 uLCD.printf("%d %d %d %d",inputCode[0],inputCode[2],inputCode[4],inputCode[6]);
landes 5:ebc70efa2e86 541 //}
landes 1:7f873efe5b11 542 LCD_Access.unlock();
landes 1:7f873efe5b11 543 }
landes 1:7f873efe5b11 544
landes 1:7f873efe5b11 545 case Alarm_ON:
landes 1:7f873efe5b11 546 break;
landes 1:7f873efe5b11 547 }
landes 1:7f873efe5b11 548 }
landes 1:7f873efe5b11 549 }
landes 1:7f873efe5b11 550
landes 1:7f873efe5b11 551 void Ethernet_thread(void const *args) {
landes 4:d8de964b3d2c 552
landes 2:922d5b43bee3 553 char buffer[300];
jsmith352 9:413c094dd1e2 554 int tempstatus = state;
landes 5:ebc70efa2e86 555 int ret,found;
landes 1:7f873efe5b11 556 eth.init(); //Use DHCP
landes 1:7f873efe5b11 557 eth.connect();
landes 5:ebc70efa2e86 558 //pc.printf("IP Address is: %s\n\r", eth.getIPAddress());
landes 5:ebc70efa2e86 559 while (1) {
jsmith352 9:413c094dd1e2 560 Thread::wait(1000);
jsmith352 9:413c094dd1e2 561 if (tempstatus !=state) {
jsmith352 9:413c094dd1e2 562 Ethernet_massage_Send("UpdateStatus");
jsmith352 9:413c094dd1e2 563 Thread::wait(1500);
jsmith352 9:413c094dd1e2 564 tempstatus = state;
jsmith352 9:413c094dd1e2 565 }
landes 6:33185f926189 566 //t2.start();
landes 6:33185f926189 567 TCPSocketConnection sock;
landes 6:33185f926189 568 sock.connect("dreamphysix.com", 80);
landes 6:33185f926189 569 char http_cmd[100] = "GET http://www.dreamphysix.com/alarm/readstatus.php?mbedID=0 HTTP/1.0\n\n";
landes 8:429fa05b4952 570 //PC_Access.lock();
landes 5:ebc70efa2e86 571 //pc.printf("%s",http_cmd);
landes 8:429fa05b4952 572 //PC_Access.unlock();
landes 8:429fa05b4952 573 Eth_Lock.lock();
landes 4:d8de964b3d2c 574 sock.send_all(http_cmd, sizeof(http_cmd)-1);
landes 8:429fa05b4952 575 Eth_Lock.unlock();
landes 4:d8de964b3d2c 576 while (true) {
landes 8:429fa05b4952 577 Eth_Lock.lock();
landes 1:7f873efe5b11 578 ret = sock.receive(buffer, sizeof(buffer)-1);
landes 8:429fa05b4952 579 Eth_Lock.unlock();
landes 1:7f873efe5b11 580 if (ret <= 0)
landes 1:7f873efe5b11 581 break;
landes 1:7f873efe5b11 582 buffer[ret] = '\0';
landes 1:7f873efe5b11 583 Consul_Access.wait();
landes 8:429fa05b4952 584 //PC_Access.lock();
landes 7:758d4e6fc145 585 //pc.printf("Received %d chars from server:\n%s\n", ret, buffer);
landes 8:429fa05b4952 586 //PC_Access.unlock();
landes 1:7f873efe5b11 587 Consul_Access.release();
landes 1:7f873efe5b11 588 }
landes 1:7f873efe5b11 589 sock.close();
landes 6:33185f926189 590 //t2.stop();
landes 6:33185f926189 591 string str(buffer);
landes 6:33185f926189 592 found = str.find("Status=");
landes 5:ebc70efa2e86 593 //pc.printf("location: %d string: %s" , found, str);
landes 5:ebc70efa2e86 594 //pc.printf("\n\rhttp_cmd: %c\n\r",buffer[found+7]);
landes 5:ebc70efa2e86 595 //pc.printf("\n\state: %i\n\r",state);
landes 6:33185f926189 596 int dummy = (buffer[found+7])-48;
landes 6:33185f926189 597 state = (Statetype)dummy;
landes 5:ebc70efa2e86 598 //state = (Statetype)buffer[found+7];
landes 8:429fa05b4952 599 PC_Access.lock();
jsmith352 9:413c094dd1e2 600 pc.printf("\nstate: %i\n\r",dummy);
landes 8:429fa05b4952 601 PC_Access.unlock();
landes 5:ebc70efa2e86 602 //Thread::wait(3000);
landes 5:ebc70efa2e86 603 }
landes 2:922d5b43bee3 604 }
landes 2:922d5b43bee3 605
landes 2:922d5b43bee3 606 bool Ethernet_massage_Send(string buff) {
landes 4:d8de964b3d2c 607
landes 2:922d5b43bee3 608 char buffer[300];
landes 2:922d5b43bee3 609 int ret;
landes 5:ebc70efa2e86 610 //pc.printf("IP Address is: %s\n\r", eth.getIPAddress());
landes 2:922d5b43bee3 611
landes 2:922d5b43bee3 612 TCPSocketConnection sock;
landes 2:922d5b43bee3 613 sock.connect("dreamphysix.com", 80);
landes 2:922d5b43bee3 614
landes 2:922d5b43bee3 615 if (buff == "TextCode") {
landes 2:922d5b43bee3 616 char http_cmd[100] = "GET http://www.dreamphysix.com/alarm/sendcode.php?authcode=0e9cae34a0&randomcode=";
landes 2:922d5b43bee3 617 strcat(http_cmd, charCode);
landes 2:922d5b43bee3 618 strcat(http_cmd, " HTTP/1.0\n\n");
landes 8:429fa05b4952 619 PC_Access.lock();
landes 8:429fa05b4952 620 pc.printf("%s",http_cmd);
landes 8:429fa05b4952 621 PC_Access.unlock();
landes 8:429fa05b4952 622 Eth_Lock.lock();
landes 2:922d5b43bee3 623 sock.send_all(http_cmd, sizeof(http_cmd)-1);
landes 8:429fa05b4952 624 Eth_Lock.unlock();
landes 2:922d5b43bee3 625 }
landes 2:922d5b43bee3 626 else if (buff == "TextAlarm") {
landes 2:922d5b43bee3 627 char http_cmd[] = "GET http://dreamphysix.com/alarm/sendalert.php?authcode=0e9cae34a0 HTTP/1.0\n\n";
landes 8:429fa05b4952 628 Eth_Lock.lock();
landes 2:922d5b43bee3 629 sock.send_all(http_cmd, sizeof(http_cmd)-1);
landes 8:429fa05b4952 630 Eth_Lock.unlock();
landes 8:429fa05b4952 631 PC_Access.lock();
landes 8:429fa05b4952 632 pc.printf("%s",http_cmd);
landes 8:429fa05b4952 633 PC_Access.unlock();
landes 2:922d5b43bee3 634 }
landes 2:922d5b43bee3 635 else if (buff == "GetTempCode") {
landes 4:d8de964b3d2c 636 snprintf(charCode, sizeof(charCode), "%i%i%i%i ", inputCode[0], inputCode[2], inputCode[4], inputCode[6]);
landes 2:922d5b43bee3 637 char http_cmd[100] = "GET http://www.dreamphysix.com/alarm/validatecode.php?code=";
landes 2:922d5b43bee3 638 strcat(http_cmd, charCode);
landes 2:922d5b43bee3 639 strcat(http_cmd, " HTTP/1.0\n\n");
landes 8:429fa05b4952 640 PC_Access.lock();
landes 8:429fa05b4952 641 pc.printf("%s",http_cmd);
landes 8:429fa05b4952 642 PC_Access.unlock();
landes 8:429fa05b4952 643 Eth_Lock.lock();
landes 2:922d5b43bee3 644 sock.send_all(http_cmd, sizeof(http_cmd)-1);
landes 8:429fa05b4952 645 Eth_Lock.unlock();
landes 2:922d5b43bee3 646 }
landes 2:922d5b43bee3 647 else if (buff == "UpdateStatus") {
landes 4:d8de964b3d2c 648 char tempStatus[2];
landes 4:d8de964b3d2c 649 snprintf(tempStatus, sizeof(tempStatus), "%i", state);
landes 4:d8de964b3d2c 650 char http_cmd[100] = "GET http://www.dreamphysix.com/alarm/updatestatus.php?mbedID=1";
landes 4:d8de964b3d2c 651 //strcat(http_cmd, ID);
landes 4:d8de964b3d2c 652 strcat(http_cmd, "&status=");
landes 4:d8de964b3d2c 653 strcat(http_cmd, tempStatus);
landes 4:d8de964b3d2c 654 strcat(http_cmd, " HTTP/1.0\n\n");
landes 8:429fa05b4952 655 PC_Access.lock();
landes 8:429fa05b4952 656 pc.printf("%s",http_cmd);
landes 8:429fa05b4952 657 PC_Access.unlock();
landes 8:429fa05b4952 658 Eth_Lock.lock();
landes 4:d8de964b3d2c 659 sock.send_all(http_cmd, sizeof(http_cmd)-1);
landes 8:429fa05b4952 660 Eth_Lock.unlock();
landes 2:922d5b43bee3 661 }
landes 2:922d5b43bee3 662 else {
landes 2:922d5b43bee3 663
landes 2:922d5b43bee3 664 }
landes 2:922d5b43bee3 665
landes 2:922d5b43bee3 666
landes 2:922d5b43bee3 667 while (true) {
landes 8:429fa05b4952 668 Eth_Lock.lock();
landes 2:922d5b43bee3 669 ret = sock.receive(buffer, sizeof(buffer)-1);
landes 8:429fa05b4952 670 Eth_Lock.unlock();
landes 2:922d5b43bee3 671 if (ret <= 0)
landes 2:922d5b43bee3 672 break;
landes 2:922d5b43bee3 673 buffer[ret] = '\0';
landes 2:922d5b43bee3 674 Consul_Access.wait();
landes 8:429fa05b4952 675 //PC_Access.lock();
landes 7:758d4e6fc145 676 //pc.printf("Received %d chars from server:\n%s\n", ret, buffer);
landes 8:429fa05b4952 677 //PC_Access.unlock();
landes 2:922d5b43bee3 678 Consul_Access.release();
landes 2:922d5b43bee3 679 }
landes 2:922d5b43bee3 680 sock.close();
landes 4:d8de964b3d2c 681
landes 5:ebc70efa2e86 682 snprintf(buffer, ret, "%c",buffer);
landes 5:ebc70efa2e86 683 //pc.printf("buffer: %s", buffer);
landes 4:d8de964b3d2c 684 if (strstr(buffer,"True") != NULL) {
jsmith352 9:413c094dd1e2 685 pc.printf("true fron eth check");
landes 5:ebc70efa2e86 686 return true;
landes 5:ebc70efa2e86 687 }
landes 5:ebc70efa2e86 688 else if (strstr(buffer,"False") != NULL) {
jsmith352 9:413c094dd1e2 689 pc.printf("false fron eth check");
landes 4:d8de964b3d2c 690 return false;
landes 2:922d5b43bee3 691 }
landes 5:ebc70efa2e86 692 else {
jsmith352 9:413c094dd1e2 693 pc.printf("default ");
landes 8:429fa05b4952 694 return true;
landes 4:d8de964b3d2c 695 }
landes 1:7f873efe5b11 696 }
landes 1:7f873efe5b11 697
landes 1:7f873efe5b11 698 void Activate_Lock(){
landes 1:7f873efe5b11 699 doorlock =! doorlock;
landes 1:7f873efe5b11 700 }
jsmith352 9:413c094dd1e2 701
jsmith352 9:413c094dd1e2 702