IoT for mbed1
Dependencies: 4DGL-uLCD-SE IoTsecuritySys PinDetect mbed-rtos mbed
Fork of IoT by
Diff: main.cpp
- Revision:
- 6:33185f926189
- Parent:
- 5:ebc70efa2e86
- Child:
- 7:758d4e6fc145
diff -r ebc70efa2e86 -r 33185f926189 main.cpp --- a/main.cpp Mon Dec 07 19:43:53 2015 +0000 +++ b/main.cpp Mon Dec 07 20:08:40 2015 +0000 @@ -67,6 +67,7 @@ string ID = "1"; volatile int NumTry = 0; Timer t1; +Timer t2; // code counter is the next position in inputCode array volatile int codeCounter; // inputCode array is the sequence of numbers the user will enter @@ -566,10 +567,13 @@ eth.connect(); //pc.printf("IP Address is: %s\n\r", eth.getIPAddress()); while (1) { - Thread::wait(10000); - TCPSocketConnection sock; - sock.connect("dreamphysix.com", 80); - char http_cmd[100] = "GET http://www.dreamphysix.com/alarm/readstatus.php?mbedID=0 HTTP/1.0\n\n"; + Thread::wait(1000); + int timeout; + + //t2.start(); + TCPSocketConnection sock; + sock.connect("dreamphysix.com", 80); + char http_cmd[100] = "GET http://www.dreamphysix.com/alarm/readstatus.php?mbedID=0 HTTP/1.0\n\n"; ////////////PC_Access.lock(); //pc.printf("%s",http_cmd); ////PC_Access.unlock(); @@ -582,24 +586,26 @@ buffer[ret] = '\0'; Consul_Access.wait(); ////////////////////////PC_Access.lock(); - //pc.printf("Received %d chars from server:\n%s\n", ret, buffer); + pc.printf("Received %d chars from server:\n%s\n", ret, buffer); ////PC_Access.unlock(); Consul_Access.release(); } sock.close(); - - //string str(buffer); - //found = str.find("Status="); + //t2.stop(); + string str(buffer); + found = str.find("Status="); //pc.printf("location: %d string: %s" , found, str); //pc.printf("\n\rhttp_cmd: %c\n\r",buffer[found+7]); //pc.printf("\n\state: %i\n\r",state); - //int dummy = (buffer[found+7])-48; + int dummy = (buffer[found+7])-48; //int dummy = ((int)buffer[found+7]); //dummy = atoi(dummy); - //state = (Statetype)dummy; + state = (Statetype)dummy; //state = (Statetype)buffer[found+7]; - //pc.printf("\n\state: %i\n\r",dummy); + pc.printf("\n\state: %i\n\r",dummy); //Thread::wait(3000); + + } }