![](/media/cache/group/ep_srxDLMd.webp.50x50_q85.jpg)
Beispiel Abfrage Cloud Dienst Sunrise / Sunset
Dependencies: EthernetInterface MbedJSONValue mbed-rtos mbed
Fork of HTTP_GET by
Sunrise Sunset stellt ein API zur Verfügung, mittels dem die Sonnen Auf- und Untergangszeiten für einen bestimmten Ort abgefragt werden können.
Links
Beispiel: Abfrage für Zürich
http://api.sunrise-sunset.org/json?lat=47.3686498&lng=8.5391825
{"results": { "sunrise":"5:38:12 AM", "sunset":"5:31:12 PM", "solar_noon":"11:34:42 AM", "day_length":"11:53:00", "civil_twilight_begin":"5:07:47 AM", "civil_twilight_end":"6:01:38 PM", "nautical_twilight_begin":"4:32:04 AM", "nautical_twilight_end":"6:37:21 PM", "astronomical_twilight_begin":"3:55:32 AM", "astronomical_twilight_end":"7:13:52 PM" }, "status":"OK"}
Diff: main.cpp
- Revision:
- 0:fb5060c39dd1
- Child:
- 1:2e29a33cd918
diff -r 000000000000 -r fb5060c39dd1 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sun Feb 02 18:16:51 2014 +0000 @@ -0,0 +1,30 @@ +#include "mbed.h" +#include "HTTPClient.h" +#include "EthernetInterface.h" + +Serial pc(USBTX, USBRX); + +EthernetInterface eth; +HTTPClient http; +char message[2000]; + +DigitalOut myled(LED1); + +int main() { + pc.baud(460800); + printf("HTTP Client - Build " __DATE__ " - " __TIME__ "\r\n"); + eth.init(); + eth.connect(); + + while(1) { + myled = 1; + int ret = http.get("http://mbed.org/media/uploads/mbed_official/hello.txt", message, sizeof(message)); + if (!ret) { + printf("Success - read %d characters.\r\n", strlen(message)); + printf("%s\r\n", message); + } + myled = 0; + wait(10); + } + // eth.disconnect(); +}