Download NHK English news podcast automatically. This application requires mpod mother board. See also http://mbed.org/users/geodenx/notebook/mpod/
Dependencies: BlinkLed HTTPClient EthernetInterface FatFileSystemCpp MSCFileSystem mbed-rtos mbed
Download NHK English news podcast automatically. This application requires mpod mother board. See also http://mbed.org/users/geodenx/notebook/mpod/
Diff: main.cpp
- Revision:
- 4:ab3092d15121
- Parent:
- 3:07562878d3c3
--- a/main.cpp Sun Aug 19 15:57:55 2012 +0000 +++ b/main.cpp Sat Sep 01 04:12:37 2012 +0000 @@ -13,12 +13,11 @@ EthernetInterface eth; HTTPClient http; MSCFileSystem usb("usb"); -BlinkLed led1(LED1, 0.02); -BlinkLed led2(LED2, 0.2); +BlinkLed led3(LED3, 0.02); +BlinkLed led4(LED4, 0.2); BlinkLed ethGreen(p26, 0.02); BlinkLed ethYellow(p25, 0.2); DigitalOut fsusb30s(p9); -Timer timer; const char* rssUrl = "http://www3.nhk.or.jp/rj/podcast/rss/english.xml"; const char* rssPath = "/usb/english.xml"; @@ -30,6 +29,10 @@ printf("mpod NHK English news Downloader\n"); printf("================================\n\n"); + // Indicate downloading + led4.startBlink(); + ethYellow.startBlink(); + // FSUSB30 switches to HSD1 (mbed) printf("USB host was switched to HSD1(mbed).\n\n"); fsusb30s = 0; // HSD1 @@ -137,8 +140,10 @@ printf("\nUSB host was switched to HSD2(External Device).\n"); fsusb30s = 1; // HSD2 - // blink LED - led1.startBlink(); + // Indicate finish downloading + led4.finishBlink(); + ethYellow.finishBlink(); + led3.startBlink(); ethGreen.startBlink(); while(true){} @@ -146,13 +151,7 @@ int GetFile(const char *path, const char *url) { - led2.startBlink(); - ethYellow.startBlink(); - printf("\nGetting %s\n", url); - - timer.stop(); - timer.reset(); - timer.start(); + printf("Getting %s -> %s\n", url, path); HTTPFile file(path); HTTPResult retGet = http.get(url, &file); @@ -163,10 +162,5 @@ } file.clear(); - timer.stop(); - printf("timer.read_ms(): %d\n", timer.read_ms()); - - led2.finishBlink(); - ethYellow.finishBlink(); return (0); }