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.
main.cpp
00001 #include "mbed.h" 00002 #include "EthernetNetIf.h" 00003 #include "HTTPClient.h" 00004 00005 EthernetNetIf eth; //(IpAddr(160,48,199,80),IpAddr(255,255,255,128),IpAddr(0,0,0,0),IpAddr(0,0,0,0)); 00006 00007 HTTPClient http; 00008 HTTPText txt; 00009 00010 void HTTPGetCallbackEvent(HTTPResult result) { 00011 00012 int iRetValue = http.getHTTPResponseCode(); 00013 00014 printf("HTTPGetCallbackEvent->Result: %d \r\n", iRetValue); 00015 00016 if (result==HTTP_OK) { 00017 // printf("Result :\"%s\"\r\n", txt.gets()); 00018 printf("Result ok : %s\n", txt.gets()); 00019 //printf("Result :ok\r\n"); 00020 } else { 00021 printf("Error %d\r\n", result); 00022 } 00023 } 00024 00025 00026 00027 int main() { 00028 00029 printf("Setting up...\r\n"); 00030 EthernetErr ethErr = eth.setup(); 00031 if (ethErr) { 00032 printf("Error %d in setup.\r\n", ethErr); 00033 return -1; 00034 } 00035 printf("Setup OK\r\n"); 00036 00037 00038 00039 00040 // http.setRequestHeader("Connection", "Keep-Alive"); 00041 00042 printf("Send message\r\n"); 00043 00044 00045 HTTPResult r = http.get("http://mbed.org/media/uploads/donatien/hello.txt", &txt, HTTPGetCallbackEvent); 00046 // HTTPResult r = http.get("http://160.48.199.50/r?b=1&r=0&s=1", &txt, HTTPGetCallbackEvent); 00047 00048 while (1) { 00049 //printf("alive\r\n"); 00050 Net::poll(); 00051 } 00052 00053 return 0; 00054 00055 } 00056
Generated on Tue Jul 12 2022 16:14:25 by
1.7.2