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.
Dependencies: BMP280 Task671-mbedos-FZ429-TCP-dynamic
Fork of Task671-mbedos-FZ429-TCP-dynamic by
Revision 1:76bd6f78cabc, committed 2017-11-21
- Comitter:
- noutram
- Date:
- Tue Nov 21 14:21:48 2017 +0000
- Parent:
- 0:65ff7ad381e8
- Child:
- 2:f7c18fc24082
- Commit message:
- Added annotation
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Mon Nov 20 17:31:23 2017 +0000
+++ b/main.cpp Tue Nov 21 14:21:48 2017 +0000
@@ -16,7 +16,7 @@
" <body style=\"display:flex;text-align:center\">" "\r\n" \
" <div style=\"margin:auto\">" "\r\n" \
" <h1>Hello World</h1>" "\r\n" \
-" <p>The POT value is "
+" <p>The LDR value is "
#define HTTP_MESSAGE_BODY2 "" \
"</p>" "\r\n" \
@@ -33,7 +33,7 @@
#define NETMASK "255.0.0.0"
#define GATEWAY "10.0.0.1"
-AnalogIn pot(PA_0);
+AnalogIn ldr(PA_0);
int main()
@@ -66,17 +66,24 @@
srv.accept(&clt_sock, &clt_addr);
printf("accept %s:%d\n", clt_addr.get_ip_address(), clt_addr.get_port());
+ //Uses a C++ string to make it easier to concatinate
string response;
- char pot_str[64];
- float u = pot;
- sprintf(pot_str, "%5.3f", u );
- printf("POT: %5.3f\n\r", u);
+ //This is a C string
+ char ldr_str[64];
+
+ //Read the LDR value
+ float u = ldr;
+ //Convert to a C String
+ sprintf(ldr_str, "%5.3f", u );
+ printf("LDR: %5.3f\n\r", u);
+
+ //Build the C++ string response
response = HTTP_MESSAGE_BODY1;
- response += pot_str;
+ response += ldr_str;
response += HTTP_MESSAGE_BODY2;
- //Send static HTML response
+ //Send static HTML response (as a C string)
clt_sock.send(response.c_str(), response.size()+6);
}
}
