Stream messages which you type into an internet app straight to the dispBoB!
Dependencies: EthernetNetIf dispBoB mbed
InternetDispBoB.cpp@3:f4115ac66e09, 2011-07-07 (annotated)
- Committer:
- d_worrall
- Date:
- Thu Jul 07 15:54:47 2011 +0000
- Revision:
- 3:f4115ac66e09
- Parent:
- 2:2707a70078ac
version5
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
d_worrall | 1:ec03de8ed408 | 1 | #include "mbed.h" |
d_worrall | 1:ec03de8ed408 | 2 | #include "EthernetNetIf.h" |
d_worrall | 1:ec03de8ed408 | 3 | #include "HTTPClient.h" |
d_worrall | 1:ec03de8ed408 | 4 | #include "dispBoB.h" |
d_worrall | 3:f4115ac66e09 | 5 | #include "stdio.h" |
d_worrall | 1:ec03de8ed408 | 6 | |
d_worrall | 1:ec03de8ed408 | 7 | EthernetNetIf eth; |
d_worrall | 1:ec03de8ed408 | 8 | HTTPClient http; |
d_worrall | 1:ec03de8ed408 | 9 | dispBoB db(p28, p27, p26); |
d_worrall | 1:ec03de8ed408 | 10 | |
d_worrall | 1:ec03de8ed408 | 11 | int main() { |
d_worrall | 1:ec03de8ed408 | 12 | |
d_worrall | 3:f4115ac66e09 | 13 | EthernetErr ethErr = eth.setup(); //Setup ethernet connection |
d_worrall | 3:f4115ac66e09 | 14 | if(ethErr) return -1; |
d_worrall | 3:f4115ac66e09 | 15 | |
d_worrall | 3:f4115ac66e09 | 16 | db.init(); //initialise screen |
d_worrall | 1:ec03de8ed408 | 17 | db.cls(); |
d_worrall | 1:ec03de8ed408 | 18 | |
d_worrall | 3:f4115ac66e09 | 19 | HTTPText txt; //instantiate HTTPStream object |
d_worrall | 1:ec03de8ed408 | 20 | while(1){ |
d_worrall | 2:2707a70078ac | 21 | HTTPResult r = http.get("http://mbed.net16.net/v1/messageEcho.php", &txt); //load page into buffer |
d_worrall | 1:ec03de8ed408 | 22 | if(r==HTTP_OK){ |
d_worrall | 3:f4115ac66e09 | 23 | string str = txt.gets(); //load web page intop string |
d_worrall | 3:f4115ac66e09 | 24 | |
d_worrall | 3:f4115ac66e09 | 25 | char buf[100]; //instantiate buffer for message |
d_worrall | 3:f4115ac66e09 | 26 | int i = 0; //instantiate integer for iterator |
d_worrall | 3:f4115ac66e09 | 27 | do{ |
d_worrall | 3:f4115ac66e09 | 28 | buf[i] = str[i]; //copy characters into buffer until end of buffer |
d_worrall | 3:f4115ac66e09 | 29 | i++; //or newline tag |
d_worrall | 3:f4115ac66e09 | 30 | } while ((i<100)&&(str[i]!='\n')); |
d_worrall | 3:f4115ac66e09 | 31 | |
d_worrall | 3:f4115ac66e09 | 32 | db.scroll(buf, 0.2); //scroll message |
d_worrall | 1:ec03de8ed408 | 33 | } |
d_worrall | 3:f4115ac66e09 | 34 | wait(2); //wait 2 seconds before looping, so we don't pester the servers too much |
d_worrall | 1:ec03de8ed408 | 35 | } |
d_worrall | 1:ec03de8ed408 | 36 | } |
d_worrall | 1:ec03de8ed408 | 37 | |
d_worrall | 1:ec03de8ed408 | 38 | |
d_worrall | 1:ec03de8ed408 | 39 | |
d_worrall | 1:ec03de8ed408 | 40 | |
d_worrall | 1:ec03de8ed408 | 41 | |
d_worrall | 1:ec03de8ed408 | 42 | |
d_worrall | 1:ec03de8ed408 | 43 | |
d_worrall | 1:ec03de8ed408 | 44 |