Own fork of MbedSmartRest

Dependents:   MbedSmartRestMain MbedSmartRestMain

Fork of MbedSmartRest by Cumulocity Official

Revision:
6:cd7ba1ddb664
Parent:
5:2b74510900da
Child:
7:8159a2d12e4e
--- a/SmartRest.h	Thu Jul 10 16:20:31 2014 +0200
+++ b/SmartRest.h	Mon Jul 28 12:11:02 2014 +0200
@@ -38,61 +38,16 @@
 #include "config.h"
 #include <stddef.h>
 #include <stdint.h>
+#include "AbstractSmartRest.h"
 #include "AbstractClient.h"
-#include "ParsedRecord.h"
 #include "Parser.h"
-#include "Aggregator.h"
-
-/** Return value indicating that no error occurred. */
-#define SMARTREST_SUCCESS 0
-/** Return value indicating that the connection has been closed during
- * data transmission. */
-#define SMARTREST_CONNECTION_FAILED 1
-/** Return value indicating an internal state error. */
-#define SMARTREST_INTERNAL_ERROR 2
-/** Return value indicating a transmission timeout. */
-#define SMARTREST_TIMEOUT_ERROR 3
-/** Return value indicating an end of response indicated by the
- * Content-Length header. */
-#define SMARTREST_END_OF_RESPONSE 4
-/** Return value indicating that the connection has been closed. */
-#define SMARTREST_CONNECTION_CLOSED 5
 
 /**
- * SmartRest client implementation.
- * This class provides methods to send a request and receive a response
- * from the server.
- * 
- * Example:
- * @code
- * // given a concrete SmartRest implementation and a template
- * SmartRest client;
- * StaticData template;
- * 
- * // bootstrap
- * if (client.bootstrap(template) != SMARTREST_SUCCESS) {
- *     // error handling
- *     return;
- * }
- * 
- * if (client.send(StaticData("100,Hello")) != SMARTREST_SUCCESS) {
- *     // error handling
- * }
- * 
- * uint8_t ret;
- * while ((ret = client.receive(record)) == SMARTREST_SUCCESS) {
- *     // work with data
- * }
- * 
- * // error handling
- * 
- * // call after every request.
- * client.stop();
- * @encode
+ * The main SmartRest client implementation.
  */
-class SmartRest
+class SmartRest : public AbstractSmartRest
 {
-protected:
+public:
     /**
      * Creates a new generic SmartRest object.
      * @param client the abstract client to use
@@ -100,51 +55,15 @@
      */
     SmartRest(AbstractClient&, const char*);
 
-public:
-    virtual ~SmartRest() { };
-
     uint8_t setAuthorization(const char*, const char*);
-
 #ifdef SMARTREST_TRANSACTIONAL
     uint8_t request(const DataGenerator&, const char* = NULL);
     uint8_t request(const DataGenerator&, Aggregator&, const char* = NULL);
 #endif
-
-    /*
-     * Initiates the SmartRest bootstrap process.
-     * When successful, the template identifier will be replaced by the
-     * global managed object ID in future requests.
-     * @param generator the generator which will generate the data to be
-     *                  sent as a template.
-     * @return a non-zero value if and only if an error occured
-     */
     uint8_t bootstrap(const DataGenerator&);
-
 #ifndef SMARTREST_TRANSACTIONAL
-    /**
-     * Sends a smart request.
-     * @param generator the generator which will generate the data to be
-     *                  sent.
-     * @param overrideIdentifier a device identifier which gets sent instead
-     *                           of the identifier specified in the
-     *                           constructor. If an empty string is
-     *                           specified, no identifier is sent at all.
-     * @return a non-zero value if and only if an error occured
-     */
     uint8_t send(const DataGenerator&, const char* = NULL);
-
-    /**
-     * Tries to receive a parsed response row.
-     * When the function succeeds, but the row pointer is NULL, there are
-     * no more rows to be read.
-     * @param record an instance to where the parsed row is written
-     * @return a non-zero value if and only if an error occured
-     */
     uint8_t receive(ParsedRecord&);
-
-    /*
-     * Closes the connection.
-     */
     void stop();
 #endif