h
Dependencies: mbed EthernetNetIf
main.cpp@0:f2bf5f966801, 2011-07-27 (annotated)
- Committer:
- okini3939
- Date:
- Wed Jul 27 16:08:54 2011 +0000
- Revision:
- 0:f2bf5f966801
- Child:
- 2:764ecec3dc59
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
okini3939 | 0:f2bf5f966801 | 1 | #include "mbed.h" |
okini3939 | 0:f2bf5f966801 | 2 | #include "EthernetNetIf.h" |
okini3939 | 0:f2bf5f966801 | 3 | #include "TCPSocket.h" |
okini3939 | 0:f2bf5f966801 | 4 | #include "TinyHTTP.h" |
okini3939 | 0:f2bf5f966801 | 5 | |
okini3939 | 0:f2bf5f966801 | 6 | DigitalOut myled(LED1); |
okini3939 | 0:f2bf5f966801 | 7 | Serial pc(USBTX, USBRX); |
okini3939 | 0:f2bf5f966801 | 8 | EthernetNetIf eth; |
okini3939 | 0:f2bf5f966801 | 9 | |
okini3939 | 0:f2bf5f966801 | 10 | int main () { |
okini3939 | 0:f2bf5f966801 | 11 | EthernetErr ethErr; |
okini3939 | 0:f2bf5f966801 | 12 | Host host; |
okini3939 | 0:f2bf5f966801 | 13 | int r; |
okini3939 | 0:f2bf5f966801 | 14 | |
okini3939 | 0:f2bf5f966801 | 15 | myled = 1; |
okini3939 | 0:f2bf5f966801 | 16 | |
okini3939 | 0:f2bf5f966801 | 17 | ethErr = eth.setup(); |
okini3939 | 0:f2bf5f966801 | 18 | if(ethErr) { |
okini3939 | 0:f2bf5f966801 | 19 | return -1; |
okini3939 | 0:f2bf5f966801 | 20 | } |
okini3939 | 0:f2bf5f966801 | 21 | |
okini3939 | 0:f2bf5f966801 | 22 | host.setName("mbed.org"); |
okini3939 | 0:f2bf5f966801 | 23 | r = httpRequest(METHOD_GET, &host, "/", NULL, NULL); |
okini3939 | 0:f2bf5f966801 | 24 | /* |
okini3939 | 0:f2bf5f966801 | 25 | host.setName("www.domain.name"); |
okini3939 | 0:f2bf5f966801 | 26 | r = httpRequest(METHOD_POST, &host, "/xxx.cgi", "Content-Type: application/x-www-form-urlencoded\r\n", "key=value&key2=value2"); |
okini3939 | 0:f2bf5f966801 | 27 | */ |
okini3939 | 0:f2bf5f966801 | 28 | printf("status %d\r\n", r); |
okini3939 | 0:f2bf5f966801 | 29 | |
okini3939 | 0:f2bf5f966801 | 30 | myled = 0; |
okini3939 | 0:f2bf5f966801 | 31 | return 0; |
okini3939 | 0:f2bf5f966801 | 32 | } |