http
Dependencies: EthernetInterface HTTPClient mbed-rtos mbed
main.cpp
00001 #include "mbed.h" 00002 #include "EthernetInterface.h" 00003 #include "HTTPClient.h" 00004 00005 EthernetInterface eth; 00006 HTTPClient http; 00007 00008 DigitalOut myled(LED2); 00009 00010 char str[512]; 00011 00012 const char *url = "http://developer.mbed.org/media/uploads/planglois/index.html"; 00013 00014 int main() 00015 { 00016 int r = 0; 00017 int flash = 0; 00018 myled = 0; 00019 00020 eth.init(); 00021 eth.connect(); 00022 00023 while (true) { 00024 r = http.get(url, str, 32); 00025 00026 if (r > 0) { 00027 std::printf("Error %d - HTTP return code %d\n", r, http.getHTTPResponseCode()); 00028 goto fail; 00029 } 00030 00031 flash = std::atoi(str); 00032 00033 for (int i = 0; i < flash; i++) { 00034 myled = 1; 00035 wait(0.1); 00036 myled = 0; 00037 wait(0.1); 00038 } 00039 00040 wait(1.0); 00041 } 00042 00043 fail: 00044 eth.disconnect(); 00045 00046 while(1) {} 00047 }
Generated on Wed Jul 13 2022 20:51:17 by 1.7.2