
Team 6
Dependencies: HTTPClient PowerControl SNICInterface_mod mbed-rtos mbed
Fork of HTTPClient_WiFi_HelloWorld by
Revision 9:95ab3243d929, committed 2015-02-15
- Comitter:
- daisukekmr
- Date:
- Sun Feb 15 01:34:25 2015 +0000
- Parent:
- 8:846dfefd3110
- Child:
- 10:4f206e833249
- Commit message:
- Add light sensor part with comment out.; Fixed some bugs.
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sun Feb 15 01:08:28 2015 +0000 +++ b/main.cpp Sun Feb 15 01:34:25 2015 +0000 @@ -18,7 +18,7 @@ #endif DigitalIn PIR(p8); -I2C temphum(p28, p27); + HTTPClient http; char str[512]; @@ -50,7 +50,7 @@ printf("IP Address is %s\n", wifi.getIPAddress()); //define var - double value; + int value; char* sensortype; while(1) @@ -58,11 +58,11 @@ //for PIR sensor //GET value from PIR sensor sensortype = "PIR"; - rightvalue = PIR; + value = PIR; //GET data printf("\nTrying to fetch page...\n"); char buf[128]; - sprintf(buf, "http://192.168.179.7/put?type=%s&value=%lf",sensortype, value); + sprintf(buf, "http://192.168.179.7/put?type=%s&value=%d",sensortype, value); int ret = http.get(buf, str, 128); if (!ret) { @@ -75,14 +75,35 @@ } wait(WAIT); /* - //for tempsensor - //GET value from PIR sensor - sensortype = "Temp"; - value = Temp; + //for THERMO + //GET value from THERMO sensor + sensortype = "THERMO"; + value = Thermo; //GET data printf("\nTrying to fetch page...\n"); char buf[128]; - sprintf(buf, "http://192.168.179.7/put?type=%s&value=%lf",sensortype, value); + sprintf(buf, "http://192.168.179.7/put?type=%s&value=%d",sensortype, value); + int ret = http.get(buf, str, 128); + if (!ret) + { + printf("Page fetched successfully - read %d characters\n", strlen(str)); + printf("Result: %s\n", str); + } + else + { + printf("Error - ret = %d - HTTP return code = %d\n", ret, http.getHTTPResponseCode()); + } + wait(WAIT); + */ + /* + //for LIGHT + //GET value from LIGHT sensor + sensortype = "LIGHT"; + value = Light; + //GET data + printf("\nTrying to fetch page...\n"); + char buf[128]; + sprintf(buf, "http://192.168.179.7/put?type=%s&value=%d",sensortype, value); int ret = http.get(buf, str, 128); if (!ret) {