A wrapper class for talking to Axeda from MBED devices. Uses HTTPClient and MbedJSONValue classes.

Dependents:   axeda_wrapper_dev MTS_Axeda_Example

AxedaWrapper simplifies pushing data to Axeda's cloud.

Uses HTTPClient and MbedJSONValue libs:

http://mbed.org/users/donatien/code/HTTPClient/

http://mbed.org/users/samux/code/MbedJSONValue/

Committer:
mfiore
Date:
Sat Jan 04 05:07:10 2014 +0000
Revision:
5:dd1e00e3eba5
added modified HTTPClient library; added MbedJSONValue library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mfiore 5:dd1e00e3eba5 1 /* IHTTPData.h */
mfiore 5:dd1e00e3eba5 2 /* Copyright (C) 2012 mbed.org, MIT License
mfiore 5:dd1e00e3eba5 3 *
mfiore 5:dd1e00e3eba5 4 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
mfiore 5:dd1e00e3eba5 5 * and associated documentation files (the "Software"), to deal in the Software without restriction,
mfiore 5:dd1e00e3eba5 6 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
mfiore 5:dd1e00e3eba5 7 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
mfiore 5:dd1e00e3eba5 8 * furnished to do so, subject to the following conditions:
mfiore 5:dd1e00e3eba5 9 *
mfiore 5:dd1e00e3eba5 10 * The above copyright notice and this permission notice shall be included in all copies or
mfiore 5:dd1e00e3eba5 11 * substantial portions of the Software.
mfiore 5:dd1e00e3eba5 12 *
mfiore 5:dd1e00e3eba5 13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
mfiore 5:dd1e00e3eba5 14 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
mfiore 5:dd1e00e3eba5 15 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
mfiore 5:dd1e00e3eba5 16 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
mfiore 5:dd1e00e3eba5 17 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
mfiore 5:dd1e00e3eba5 18 */
mfiore 5:dd1e00e3eba5 19
mfiore 5:dd1e00e3eba5 20 #ifndef IHTTPDATA_H
mfiore 5:dd1e00e3eba5 21 #define IHTTPDATA_H
mfiore 5:dd1e00e3eba5 22
mfiore 5:dd1e00e3eba5 23 #include <cstring>
mfiore 5:dd1e00e3eba5 24
mfiore 5:dd1e00e3eba5 25 using std::size_t;
mfiore 5:dd1e00e3eba5 26
mfiore 5:dd1e00e3eba5 27 ///This is a simple interface for HTTP data storage (impl examples are Key/Value Pairs, File, etc...)
mfiore 5:dd1e00e3eba5 28 class IHTTPDataOut
mfiore 5:dd1e00e3eba5 29 {
mfiore 5:dd1e00e3eba5 30 protected:
mfiore 5:dd1e00e3eba5 31 friend class HTTPClient;
mfiore 5:dd1e00e3eba5 32
mfiore 5:dd1e00e3eba5 33 /** Reset stream to its beginning
mfiore 5:dd1e00e3eba5 34 * Called by the HTTPClient on each new request
mfiore 5:dd1e00e3eba5 35 */
mfiore 5:dd1e00e3eba5 36 virtual void readReset() = 0;
mfiore 5:dd1e00e3eba5 37
mfiore 5:dd1e00e3eba5 38 /** Read a piece of data to be transmitted
mfiore 5:dd1e00e3eba5 39 * @param buf Pointer to the buffer on which to copy the data
mfiore 5:dd1e00e3eba5 40 * @param len Length of the buffer
mfiore 5:dd1e00e3eba5 41 * @param pReadLen Pointer to the variable on which the actual copied data length will be stored
mfiore 5:dd1e00e3eba5 42 */
mfiore 5:dd1e00e3eba5 43 virtual int read(char* buf, size_t len, size_t* pReadLen) = 0;
mfiore 5:dd1e00e3eba5 44
mfiore 5:dd1e00e3eba5 45 /** Get MIME type
mfiore 5:dd1e00e3eba5 46 * @param type Internet media type from Content-Type header
mfiore 5:dd1e00e3eba5 47 */
mfiore 5:dd1e00e3eba5 48 virtual int getDataType(char* type, size_t maxTypeLen) = 0; //Internet media type for Content-Type header
mfiore 5:dd1e00e3eba5 49
mfiore 5:dd1e00e3eba5 50 /** Determine whether the HTTP client should chunk the data
mfiore 5:dd1e00e3eba5 51 * Used for Transfer-Encoding header
mfiore 5:dd1e00e3eba5 52 */
mfiore 5:dd1e00e3eba5 53 virtual bool getIsChunked() = 0;
mfiore 5:dd1e00e3eba5 54
mfiore 5:dd1e00e3eba5 55 /** If the data is not chunked, get its size
mfiore 5:dd1e00e3eba5 56 * Used for Content-Length header
mfiore 5:dd1e00e3eba5 57 */
mfiore 5:dd1e00e3eba5 58 virtual size_t getDataLen() = 0;
mfiore 5:dd1e00e3eba5 59
mfiore 5:dd1e00e3eba5 60 };
mfiore 5:dd1e00e3eba5 61
mfiore 5:dd1e00e3eba5 62 ///This is a simple interface for HTTP data storage (impl examples are Key/Value Pairs, File, etc...)
mfiore 5:dd1e00e3eba5 63 class IHTTPDataIn
mfiore 5:dd1e00e3eba5 64 {
mfiore 5:dd1e00e3eba5 65 protected:
mfiore 5:dd1e00e3eba5 66 friend class HTTPClient;
mfiore 5:dd1e00e3eba5 67
mfiore 5:dd1e00e3eba5 68 /** Reset stream to its beginning
mfiore 5:dd1e00e3eba5 69 * Called by the HTTPClient on each new request
mfiore 5:dd1e00e3eba5 70 */
mfiore 5:dd1e00e3eba5 71 virtual void writeReset() = 0;
mfiore 5:dd1e00e3eba5 72
mfiore 5:dd1e00e3eba5 73 /** Write a piece of data transmitted by the server
mfiore 5:dd1e00e3eba5 74 * @param buf Pointer to the buffer from which to copy the data
mfiore 5:dd1e00e3eba5 75 * @param len Length of the buffer
mfiore 5:dd1e00e3eba5 76 */
mfiore 5:dd1e00e3eba5 77 virtual int write(const char* buf, size_t len) = 0;
mfiore 5:dd1e00e3eba5 78
mfiore 5:dd1e00e3eba5 79 /** Set MIME type
mfiore 5:dd1e00e3eba5 80 * @param type Internet media type from Content-Type header
mfiore 5:dd1e00e3eba5 81 */
mfiore 5:dd1e00e3eba5 82 virtual void setDataType(const char* type) = 0;
mfiore 5:dd1e00e3eba5 83
mfiore 5:dd1e00e3eba5 84 /** Determine whether the data is chunked
mfiore 5:dd1e00e3eba5 85 * Recovered from Transfer-Encoding header
mfiore 5:dd1e00e3eba5 86 */
mfiore 5:dd1e00e3eba5 87 virtual void setIsChunked(bool chunked) = 0;
mfiore 5:dd1e00e3eba5 88
mfiore 5:dd1e00e3eba5 89 /** If the data is not chunked, set its size
mfiore 5:dd1e00e3eba5 90 * From Content-Length header
mfiore 5:dd1e00e3eba5 91 */
mfiore 5:dd1e00e3eba5 92 virtual void setDataLen(size_t len) = 0;
mfiore 5:dd1e00e3eba5 93
mfiore 5:dd1e00e3eba5 94 };
mfiore 5:dd1e00e3eba5 95
mfiore 5:dd1e00e3eba5 96 #endif