Evrythng API for W5500, WIZ550io
Dependencies: W5500Interface
Dependents: EvrythngApiExampleW5500
Fork of EvrythngApi by
EvrythngApi.h@3:3e6f5e92ffc9, 2014-08-20 (annotated)
- Committer:
- Bongjun
- Date:
- Wed Aug 20 04:53:33 2014 +0000
- Revision:
- 3:3e6f5e92ffc9
- Parent:
- 1:7162d0e030f5
comment added in EvrythngApi.h
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
vladounet | 0:d38d192c2f5f | 1 | /* |
vladounet | 0:d38d192c2f5f | 2 | * (c) Copyright 2012 EVRYTHNG Ltd London / Zurich |
vladounet | 0:d38d192c2f5f | 3 | * www.evrythng.com |
vladounet | 0:d38d192c2f5f | 4 | * |
vladounet | 0:d38d192c2f5f | 5 | * --- DISCLAIMER --- |
vladounet | 0:d38d192c2f5f | 6 | * |
vladounet | 0:d38d192c2f5f | 7 | * EVRYTHNG provides this source code "as is" and without warranty of any kind, |
vladounet | 0:d38d192c2f5f | 8 | * and hereby disclaims all express or implied warranties, including without |
vladounet | 0:d38d192c2f5f | 9 | * limitation warranties of merchantability, fitness for a particular purpose, |
vladounet | 0:d38d192c2f5f | 10 | * performance, accuracy, reliability, and non-infringement. |
vladounet | 0:d38d192c2f5f | 11 | * |
vladounet | 0:d38d192c2f5f | 12 | * Author: Michel Yerly |
vladounet | 0:d38d192c2f5f | 13 | * |
vladounet | 0:d38d192c2f5f | 14 | */ |
vladounet | 0:d38d192c2f5f | 15 | #ifndef EVRYTHNGAPI_H |
vladounet | 0:d38d192c2f5f | 16 | #define EVRYTHNGAPI_H |
vladounet | 0:d38d192c2f5f | 17 | |
Bongjun | 3:3e6f5e92ffc9 | 18 | // not changed code, but import different library, W5500Interface. |
vladounet | 0:d38d192c2f5f | 19 | #include "EthernetInterface.h" |
vladounet | 0:d38d192c2f5f | 20 | #include <string> |
vladounet | 0:d38d192c2f5f | 21 | |
vladounet | 0:d38d192c2f5f | 22 | #include <stdint.h> |
vladounet | 0:d38d192c2f5f | 23 | |
vladounet | 0:d38d192c2f5f | 24 | enum HttpMethod { |
vladounet | 0:d38d192c2f5f | 25 | GET, PUT, POST, DELETE |
vladounet | 0:d38d192c2f5f | 26 | }; |
vladounet | 0:d38d192c2f5f | 27 | |
vladounet | 0:d38d192c2f5f | 28 | |
vladounet | 0:d38d192c2f5f | 29 | /* |
vladounet | 0:d38d192c2f5f | 30 | * Class to communicate with EVRYTHNG engine. |
vladounet | 0:d38d192c2f5f | 31 | */ |
vladounet | 0:d38d192c2f5f | 32 | class EvrythngApi |
vladounet | 0:d38d192c2f5f | 33 | { |
vladounet | 0:d38d192c2f5f | 34 | public: |
vladounet | 0:d38d192c2f5f | 35 | |
vladounet | 0:d38d192c2f5f | 36 | /* |
vladounet | 0:d38d192c2f5f | 37 | * Constructor |
vladounet | 0:d38d192c2f5f | 38 | */ |
vladounet | 1:7162d0e030f5 | 39 | EvrythngApi(const std::string& token, const std::string& host = "api.evrythng.com", int port = 80); |
vladounet | 0:d38d192c2f5f | 40 | |
vladounet | 0:d38d192c2f5f | 41 | /* |
vladounet | 0:d38d192c2f5f | 42 | * Destructor |
vladounet | 0:d38d192c2f5f | 43 | */ |
vladounet | 0:d38d192c2f5f | 44 | virtual ~EvrythngApi(); |
vladounet | 0:d38d192c2f5f | 45 | |
vladounet | 0:d38d192c2f5f | 46 | /* |
vladounet | 0:d38d192c2f5f | 47 | * Reads the current value of a thng's property. The value read is put |
vladounet | 0:d38d192c2f5f | 48 | * in the value parameter. |
vladounet | 0:d38d192c2f5f | 49 | * Returns 0 on success, or an error code on error. Error codes are |
vladounet | 0:d38d192c2f5f | 50 | * described in evry_error.h. |
vladounet | 0:d38d192c2f5f | 51 | */ |
vladounet | 0:d38d192c2f5f | 52 | int getThngPropertyValue(const std::string& thngId, const std::string& key, std::string& value); |
vladounet | 0:d38d192c2f5f | 53 | |
vladounet | 0:d38d192c2f5f | 54 | /* |
vladounet | 0:d38d192c2f5f | 55 | * Sets the value of a thng's property. |
vladounet | 0:d38d192c2f5f | 56 | * Returns 0 on success, or an error code on error. Error codes are |
vladounet | 0:d38d192c2f5f | 57 | * described in evry_error.h. |
vladounet | 0:d38d192c2f5f | 58 | */ |
vladounet | 0:d38d192c2f5f | 59 | int setThngPropertyValue(const std::string& thngId, const std::string& key, const std::string& value, int64_t timestamp); |
vladounet | 0:d38d192c2f5f | 60 | |
vladounet | 0:d38d192c2f5f | 61 | private: |
vladounet | 0:d38d192c2f5f | 62 | std::string token; |
vladounet | 0:d38d192c2f5f | 63 | std::string host; |
vladounet | 0:d38d192c2f5f | 64 | int port; |
vladounet | 0:d38d192c2f5f | 65 | |
vladounet | 0:d38d192c2f5f | 66 | int httpRequest(HttpMethod method, const std::string& path, const std::string& content, std::string& out, int& codeOut); |
vladounet | 0:d38d192c2f5f | 67 | |
vladounet | 0:d38d192c2f5f | 68 | int httpPut(const std::string& path, const std::string& json, std::string& out, int& codeOut); |
vladounet | 0:d38d192c2f5f | 69 | int httpGet(const std::string& path, std::string& out, int& codeOut); |
vladounet | 0:d38d192c2f5f | 70 | int httpPost(const std::string& path, const std::string& json, std::string& out, int& codeOut); |
vladounet | 0:d38d192c2f5f | 71 | int httpDelete(const std::string& path, std::string& out, int& codeOut); |
vladounet | 0:d38d192c2f5f | 72 | }; |
vladounet | 0:d38d192c2f5f | 73 | |
vladounet | 0:d38d192c2f5f | 74 | #endif |