![](/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"}
HTTPClient/data/HTTPFile.h
- Committer:
- stefan1691
- Date:
- 2015-05-27
- Revision:
- 5:cfe277d00d6b
- Parent:
- 1:2e29a33cd918
File content as of revision 5:cfe277d00d6b:
#ifndef HTTPFILE_H #define HTTPFILE_H #if 1 #include <mbed.h> #include "../IHTTPData.h" class HTTPFile : public IHTTPDataIn { public: HTTPFile(char* filename); /** Closes the file, should be called once the http connection is closed. */ void close(); protected: friend class HTTPClient; /** Reset stream to its beginning * Called by the HTTPClient on each new request */ virtual void writeReset(); /** Write a piece of data transmitted by the server * @param[in] buf Pointer to the buffer from which to copy the data * @param[in] len Length of the buffer * @returns number of bytes written. */ virtual int write(const char* buf, size_t len); /** Set MIME type * @param[in] type Internet media type from Content-Type header */ virtual void setDataType(const char* type); /** Determine whether the data is chunked * Recovered from Transfer-Encoding header * @param[in] chunked indicates the transfer is chunked. */ virtual void setIsChunked(bool chunked); /** If the data is not chunked, set its size * From Content-Length header * @param[in] len defines the size of the non-chunked transfer. */ virtual void setDataLen(size_t len); private: FILE *file; size_t m_len; bool m_chunked; }; #endif #endif // HTTPFILE_H