Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Task671-mbedos-FZ429-TCP-dynamic by
Revision 2:edfdb8e455b9, committed 2017-12-26
- Comitter:
- bMcDonnell
- Date:
- Tue Dec 26 11:26:35 2017 +0000
- Parent:
- 1:76bd6f78cabc
- Commit message:
- Working HTML except for 10's instead of values read from sensors and date/time. May need to update as Date/time is days/months and hours/mins
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue Nov 21 14:21:48 2017 +0000
+++ b/main.cpp Tue Dec 26 11:26:35 2017 +0000
@@ -15,10 +15,25 @@
"<html>" "\r\n" \
" <body style=\"display:flex;text-align:center\">" "\r\n" \
" <div style=\"margin:auto\">" "\r\n" \
-" <h1>Hello World</h1>" "\r\n" \
-" <p>The LDR value is "
+" <h1>Team-Q Elec351</h1>" "\r\n" \
+" <p>Time : " \
#define HTTP_MESSAGE_BODY2 "" \
+ "  Date : " \
+
+#define HTTP_MESSAGE_BODY3 "" \
+ "</p>" "\r\n" \
+" <p>Light levels are : " "\r\n" \
+
+#define HTTP_MESSAGE_BODY4 "" \
+ "</p>" "\r\n" \
+" <p>Current Temperature : " "\r\n" \
+
+#define HTTP_MESSAGE_BODY5 "" \
+ "</p>" "\r\n" \
+" <p>Current Pressure : " "\r\n" \
+
+#define HTTP_MESSAGE_BODY6 "" \
"</p>" "\r\n" \
" </div>" "\r\n" \
" </body>" "\r\n" \
@@ -67,22 +82,44 @@
printf("accept %s:%d\n", clt_addr.get_ip_address(), clt_addr.get_port());
//Uses a C++ string to make it easier to concatinate
+ //"response" is the string that makes up the whole web page
string response;
//This is a C string
+ //make space to save variables as strings
+ char time_str[64];
+ char date_str[64];
char ldr_str[64];
+ char temp_str[64];
+ char pres_str[64];
- //Read the LDR value
- float u = ldr;
+ //Read the time/date/sensor values
+ //use sensor readings instead of 10's
+ float a = 10;
+ float e = 10;
+ float i = ldr;
+ float o = 10;
+ float u = 10;
//Convert to a C String
- sprintf(ldr_str, "%5.3f", u );
- printf("LDR: %5.3f\n\r", u);
+ sprintf(time_str, "%5.3f", a );
+ sprintf(date_str, "%5.3f", e );
+ sprintf(ldr_str, "%5.3f", i );
+ sprintf(temp_str, "%5.3f", o );
+ sprintf(pres_str, "%5.3f", u );
//Build the C++ string response
response = HTTP_MESSAGE_BODY1;
- response += ldr_str;
+ response += time_str;
response += HTTP_MESSAGE_BODY2;
-
+ response += date_str;
+ response += HTTP_MESSAGE_BODY3;
+ response += ldr_str;
+ response += HTTP_MESSAGE_BODY4;
+ response += temp_str;
+ response += HTTP_MESSAGE_BODY5;
+ response += pres_str;
+ response += HTTP_MESSAGE_BODY6;
+
//Send static HTML response (as a C string)
clt_sock.send(response.c_str(), response.size()+6);
}
