Temperature dashboard assignment
Dependencies: EthernetInterface LM75B mbed-rtos mbed
Fork of temperature-dashboard-start by
main.cpp@7:65188f4a8c25, 2012-07-25 (annotated)
- Committer:
- emilmont
- Date:
- Wed Jul 25 15:00:43 2012 +0000
- Revision:
- 7:65188f4a8c25
- Parent:
- 5:01f6c3e112af
- Child:
- 9:4757a976148d
Update EthernetInterface
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
donatien | 0:bb128f0e952f | 1 | #include "mbed.h" |
donatien | 0:bb128f0e952f | 2 | #include "EthernetInterface.h" |
donatien | 0:bb128f0e952f | 3 | |
emilmont | 7:65188f4a8c25 | 4 | int main() { |
donatien | 0:bb128f0e952f | 5 | EthernetInterface eth; |
donatien | 0:bb128f0e952f | 6 | eth.init(); //Use DHCP |
donatien | 0:bb128f0e952f | 7 | eth.connect(); |
emilmont | 2:e087e9b789e9 | 8 | printf("IP Address is %s\n", eth.getIPAddress()); |
donatien | 0:bb128f0e952f | 9 | |
emilmont | 7:65188f4a8c25 | 10 | TCPSocketConnection sock; |
donatien | 0:bb128f0e952f | 11 | sock.connect("mbed.org", 80); |
donatien | 0:bb128f0e952f | 12 | |
donatien | 1:e2652bd064c6 | 13 | char http_cmd[] = "GET /media/uploads/donatien/hello.txt HTTP/1.1\r\nHost: %s\r\n\r\n"; |
emilmont | 7:65188f4a8c25 | 14 | sock.send_all(http_cmd, sizeof(http_cmd) - 1, 3000); |
emilmont | 7:65188f4a8c25 | 15 | |
emilmont | 7:65188f4a8c25 | 16 | char in_buf[256]; |
donatien | 0:bb128f0e952f | 17 | int ret; |
emilmont | 7:65188f4a8c25 | 18 | while (true) { |
emilmont | 7:65188f4a8c25 | 19 | ret = sock.receive(in_buf, 255, 100); |
emilmont | 7:65188f4a8c25 | 20 | if (ret <= 0) |
emilmont | 7:65188f4a8c25 | 21 | break; |
emilmont | 7:65188f4a8c25 | 22 | |
donatien | 0:bb128f0e952f | 23 | in_buf[ret] = '\0'; |
donatien | 0:bb128f0e952f | 24 | printf("Received %d chars from server: %s\n", ret, in_buf); |
emilmont | 7:65188f4a8c25 | 25 | } |
donatien | 0:bb128f0e952f | 26 | |
emilmont | 7:65188f4a8c25 | 27 | sock.close(); |
donatien | 0:bb128f0e952f | 28 | |
emilmont | 7:65188f4a8c25 | 29 | eth.disconnect(); |
donatien | 5:01f6c3e112af | 30 | |
donatien | 0:bb128f0e952f | 31 | while(1) { |
donatien | 0:bb128f0e952f | 32 | } |
donatien | 0:bb128f0e952f | 33 | } |