Official reference client implementation for Cumulocity SmartREST on u-blox C027.

Dependencies:   C027_Support C12832 LM75B MMA7660 MbedSmartRest mbed-rtos mbed

Fork of MbedSmartRestMain by Vincent Wochnik

Files at this revision

API Documentation at this revision

Comitter:
vwochnik
Date:
Thu Oct 23 12:50:07 2014 +0000
Parent:
54:7dcc8898d87d
Child:
56:4d6e34f1589d
Commit message:
thread safe smartrest

Changed in this revision

AccelerationMeasurement.cpp Show annotated file Show diff for this revision Revisions of this file
AccelerationMeasurement.h Show annotated file Show diff for this revision Revisions of this file
AnalogMeasurement.cpp Show annotated file Show diff for this revision Revisions of this file
AnalogMeasurement.h Show annotated file Show diff for this revision Revisions of this file
C027_Support.lib Show annotated file Show diff for this revision Revisions of this file
DeviceBootstrap.cpp Show annotated file Show diff for this revision Revisions of this file
DeviceBootstrap.h Show annotated file Show diff for this revision Revisions of this file
DeviceIntegration.cpp Show annotated file Show diff for this revision Revisions of this file
DeviceIntegration.h Show annotated file Show diff for this revision Revisions of this file
LocationUpdate.cpp Show annotated file Show diff for this revision Revisions of this file
LocationUpdate.h Show annotated file Show diff for this revision Revisions of this file
MbedAgent.h Show annotated file Show diff for this revision Revisions of this file
MbedSmartRest.lib Show annotated file Show diff for this revision Revisions of this file
SignalQualityMeasurement.cpp Show annotated file Show diff for this revision Revisions of this file
SignalQualityMeasurement.h Show annotated file Show diff for this revision Revisions of this file
TemperatureMeasurement.cpp Show annotated file Show diff for this revision Revisions of this file
TemperatureMeasurement.h Show annotated file Show diff for this revision Revisions of this file
apndb.cpp Show diff for this revision Revisions of this file
apndb.h Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
util/RtosSmartRest.cpp Show annotated file Show diff for this revision Revisions of this file
util/RtosSmartRest.h Show annotated file Show diff for this revision Revisions of this file
util/SmartRestTemplate.cpp Show annotated file Show diff for this revision Revisions of this file
util/SmartRestTemplate.h Show annotated file Show diff for this revision Revisions of this file
utils/SmartRestTemplate.cpp Show diff for this revision Revisions of this file
utils/SmartRestTemplate.h Show diff for this revision Revisions of this file
--- a/AccelerationMeasurement.cpp	Wed Sep 03 14:36:55 2014 +0000
+++ b/AccelerationMeasurement.cpp	Thu Oct 23 12:50:07 2014 +0000
@@ -4,7 +4,7 @@
 #include "IntegerValue.h"
 #include "FloatValue.h"
 
-AccelerationMeasurement::AccelerationMeasurement(SmartRest& client, SmartRestTemplate& tpl, long& deviceId, MMA7660& sensor) :
+AccelerationMeasurement::AccelerationMeasurement(AbstractSmartRest& client, SmartRestTemplate& tpl, long& deviceId, MMA7660& sensor) :
     _client(client),
     _tpl(tpl),
     _deviceId(deviceId),
--- a/AccelerationMeasurement.h	Wed Sep 03 14:36:55 2014 +0000
+++ b/AccelerationMeasurement.h	Thu Oct 23 12:50:07 2014 +0000
@@ -1,14 +1,14 @@
 #ifndef ACCELERATIONMEASUREMENT_H
 #define ACCELERATIONMEASUREMENT_H
 
-#include "SmartRest.h"
+#include "AbstractSmartRest.h"
 #include "SmartRestTemplate.h"
 #include "MMA7660.h"
 
 class AccelerationMeasurement
 {
 public:
-    AccelerationMeasurement(SmartRest&, SmartRestTemplate&, long&, MMA7660&);
+    AccelerationMeasurement(AbstractSmartRest&, SmartRestTemplate&, long&, MMA7660&);
     
     bool init();
     bool run();
@@ -17,7 +17,7 @@
     bool _init, _test;
     long& _deviceId;
     SmartRestTemplate& _tpl;
-    SmartRest& _client;
+    AbstractSmartRest& _client;
     MMA7660& _sensor;
 };
 
--- a/AnalogMeasurement.cpp	Wed Sep 03 14:36:55 2014 +0000
+++ b/AnalogMeasurement.cpp	Thu Oct 23 12:50:07 2014 +0000
@@ -4,7 +4,7 @@
 #include "IntegerValue.h"
 #include "FloatValue.h"
 
-AnalogMeasurement::AnalogMeasurement(SmartRest& client, SmartRestTemplate& tpl, long& deviceId, AnalogIn& analog1, AnalogIn& analog2) :
+AnalogMeasurement::AnalogMeasurement(AbstractSmartRest& client, SmartRestTemplate& tpl, long& deviceId, AnalogIn& analog1, AnalogIn& analog2) :
     _client(client),
     _tpl(tpl),
     _deviceId(deviceId),
--- a/AnalogMeasurement.h	Wed Sep 03 14:36:55 2014 +0000
+++ b/AnalogMeasurement.h	Thu Oct 23 12:50:07 2014 +0000
@@ -8,7 +8,7 @@
 class AnalogMeasurement
 {
 public:
-    AnalogMeasurement(SmartRest&, SmartRestTemplate&, long&, AnalogIn&, AnalogIn&);
+    AnalogMeasurement(AbstractSmartRest&, SmartRestTemplate&, long&, AnalogIn&, AnalogIn&);
     
     bool init();
     bool run();
@@ -17,7 +17,7 @@
     bool _init;
     long& _deviceId;
     SmartRestTemplate& _tpl;
-    SmartRest& _client;
+    AbstractSmartRest& _client;
     AnalogIn& _analog1;
     AnalogIn& _analog2;
 };
--- a/C027_Support.lib	Wed Sep 03 14:36:55 2014 +0000
+++ b/C027_Support.lib	Thu Oct 23 12:50:07 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/teams/ublox/code/C027_Support/#f6bb2a20de70
+http://mbed.org/teams/ublox/code/C027_Support/#5f8807ca159a
--- a/DeviceBootstrap.cpp	Wed Sep 03 14:36:55 2014 +0000
+++ b/DeviceBootstrap.cpp	Thu Oct 23 12:50:07 2014 +0000
@@ -8,7 +8,7 @@
 #include "IntegerValue.h"
 #include "ParsedRecord.h"
 
-DeviceBootstrap::DeviceBootstrap(SmartRest& client, MDMSerial& mdm, DeviceIO& io, DeviceInfo& deviceInfo) :
+DeviceBootstrap::DeviceBootstrap(AbstractSmartRest& client, MDMSerial& mdm, DeviceIO& io, DeviceInfo& deviceInfo) :
     _client(client),
     _mdm(mdm),
     _io(io),
--- a/DeviceBootstrap.h	Wed Sep 03 14:36:55 2014 +0000
+++ b/DeviceBootstrap.h	Thu Oct 23 12:50:07 2014 +0000
@@ -4,7 +4,7 @@
 #include <stddef.h>
 #include "MDM.h"
 #include "DeviceIO.h"
-#include "SmartRest.h"
+#include "AbstractSmartRest.h"
 #include "DeviceInfo.h"
 
 /** The username used for device bootstrapping. */
@@ -20,7 +20,7 @@
 class DeviceBootstrap
 {
 public:
-    DeviceBootstrap(SmartRest&, MDMSerial&, DeviceIO&, DeviceInfo&);
+    DeviceBootstrap(AbstractSmartRest&, MDMSerial&, DeviceIO&, DeviceInfo&);
     
     bool setUpCredentials();
     const char * username();
@@ -35,7 +35,7 @@
     void setCredentials(const char *, const char*, const char*);
 
 private:
-    SmartRest& _client;
+    AbstractSmartRest& _client;
     MDMSerial& _mdm;
     DeviceInfo& _deviceInfo;
     DeviceIO& _io;
--- a/DeviceIntegration.cpp	Wed Sep 03 14:36:55 2014 +0000
+++ b/DeviceIntegration.cpp	Thu Oct 23 12:50:07 2014 +0000
@@ -4,7 +4,7 @@
 #include "CharValue.h"
 #include "IntegerValue.h"
 
-DeviceIntegration::DeviceIntegration(SmartRest& client, SmartRestTemplate& tpl, long& deviceId, DeviceInfo& deviceInfo) :
+DeviceIntegration::DeviceIntegration(AbstractSmartRest& client, SmartRestTemplate& tpl, long& deviceId, DeviceInfo& deviceInfo) :
     _client(client),
     _tpl(tpl),
     _deviceId(deviceId),
--- a/DeviceIntegration.h	Wed Sep 03 14:36:55 2014 +0000
+++ b/DeviceIntegration.h	Thu Oct 23 12:50:07 2014 +0000
@@ -1,14 +1,14 @@
 #ifndef DEVICEINTEGRATION_H
 #define DEVICEINTEGRATION_H
 
-#include "SmartRest.h"
+#include "AbstractSmartRest.h"
 #include "SmartRestTemplate.h"
 #include "DeviceInfo.h"
 
 class DeviceIntegration
 {
 public:
-    DeviceIntegration(SmartRest&, SmartRestTemplate&, long&, DeviceInfo&);
+    DeviceIntegration(AbstractSmartRest&, SmartRestTemplate&, long&, DeviceInfo&);
     
     bool init();
     bool integrate();
@@ -23,7 +23,7 @@
     bool _init;
     long& _deviceId;
     SmartRestTemplate& _tpl;
-    SmartRest& _client;
+    AbstractSmartRest& _client;
     DeviceInfo& _deviceInfo;
 };
 
--- a/LocationUpdate.cpp	Wed Sep 03 14:36:55 2014 +0000
+++ b/LocationUpdate.cpp	Thu Oct 23 12:50:07 2014 +0000
@@ -5,7 +5,7 @@
 #include "IntegerValue.h"
 #include "FloatValue.h"
 
-LocationUpdate::LocationUpdate(SmartRest& client, SmartRestTemplate& tpl, long& deviceId, GPSTracker& gpsTracker) :
+LocationUpdate::LocationUpdate(AbstractSmartRest& client, SmartRestTemplate& tpl, long& deviceId, GPSTracker& gpsTracker) :
     _client(client),
     _tpl(tpl),
     _deviceId(deviceId),
--- a/LocationUpdate.h	Wed Sep 03 14:36:55 2014 +0000
+++ b/LocationUpdate.h	Thu Oct 23 12:50:07 2014 +0000
@@ -1,14 +1,14 @@
 #ifndef LOCATIONUPDATE_H
 #define LOCATIONUPDATE_H
 
-#include "SmartRest.h"
+#include "AbstractSmartRest.h"
 #include "SmartRestTemplate.h"
 #include "GPSTracker.h"
 
 class LocationUpdate
 {
 public:
-    LocationUpdate(SmartRest&, SmartRestTemplate&, long&, GPSTracker&);
+    LocationUpdate(AbstractSmartRest&, SmartRestTemplate&, long&, GPSTracker&);
     
     bool init();
     bool run();
@@ -17,7 +17,7 @@
     bool _init;
     long& _deviceId;
     SmartRestTemplate& _tpl;
-    SmartRest& _client;
+    AbstractSmartRest& _client;
     GPSTracker& _gpsTracker;
 };
 
--- a/MbedAgent.h	Wed Sep 03 14:36:55 2014 +0000
+++ b/MbedAgent.h	Thu Oct 23 12:50:07 2014 +0000
@@ -4,7 +4,7 @@
 #include <stddef.h>
 #include "MDM.h"
 #include "DeviceIO.h"
-#include "MbedSmartRest.h"
+#include "RtosSmartRest.h"
 #include "SmartRestTemplate.h"
 #include "DeviceInfo.h"
 #include "DeviceBootstrap.h"
@@ -35,7 +35,7 @@
     DeviceIO& _io;
     MDMSerial& _mdm;
     DeviceInfo& _deviceInfo;
-    MbedSmartRest _client;
+    RtosSmartRest _client;
     SmartRestTemplate _tpl;
     DeviceBootstrap _bootstrap;
     DeviceIntegration _integration;
--- a/MbedSmartRest.lib	Wed Sep 03 14:36:55 2014 +0000
+++ b/MbedSmartRest.lib	Thu Oct 23 12:50:07 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/Cumulocity/code/MbedSmartRest/#cd7ba1ddb664
+http://mbed.org/users/Cumulocity/code/MbedSmartRest/#97077cfa13fc
--- a/SignalQualityMeasurement.cpp	Wed Sep 03 14:36:55 2014 +0000
+++ b/SignalQualityMeasurement.cpp	Thu Oct 23 12:50:07 2014 +0000
@@ -4,7 +4,7 @@
 #include "IntegerValue.h"
 #include "FloatValue.h"
 
-SignalQualityMeasurement::SignalQualityMeasurement(SmartRest& client, SmartRestTemplate& tpl, long& deviceId, DeviceInfo& deviceInfo) :
+SignalQualityMeasurement::SignalQualityMeasurement(AbstractSmartRest& client, SmartRestTemplate& tpl, long& deviceId, DeviceInfo& deviceInfo) :
     _client(client),
     _tpl(tpl),
     _deviceId(deviceId),
--- a/SignalQualityMeasurement.h	Wed Sep 03 14:36:55 2014 +0000
+++ b/SignalQualityMeasurement.h	Thu Oct 23 12:50:07 2014 +0000
@@ -1,14 +1,14 @@
 #ifndef SIGNALQUALITYMEASUREMENT_H
 #define SIGNALQUALITYMEASUREMENT_H
 
-#include "SmartRest.h"
+#include "AbstractSmartRest.h"
 #include "SmartRestTemplate.h"
 #include "DeviceInfo.h"
 
 class SignalQualityMeasurement
 {
 public:
-    SignalQualityMeasurement(SmartRest&, SmartRestTemplate&, long&, DeviceInfo&);
+    SignalQualityMeasurement(AbstractSmartRest&, SmartRestTemplate&, long&, DeviceInfo&);
     
     bool init();
     bool run();
@@ -17,7 +17,7 @@
     bool _init;
     long& _deviceId;
     SmartRestTemplate& _tpl;
-    SmartRest& _client;
+    AbstractSmartRest& _client;
     DeviceInfo& _deviceInfo;
 };
 
--- a/TemperatureMeasurement.cpp	Wed Sep 03 14:36:55 2014 +0000
+++ b/TemperatureMeasurement.cpp	Thu Oct 23 12:50:07 2014 +0000
@@ -4,7 +4,7 @@
 #include "IntegerValue.h"
 #include "FloatValue.h"
 
-TemperatureMeasurement::TemperatureMeasurement(SmartRest& client, SmartRestTemplate& tpl, long& deviceId, LM75B& sensor) :
+TemperatureMeasurement::TemperatureMeasurement(AbstractSmartRest& client, SmartRestTemplate& tpl, long& deviceId, LM75B& sensor) :
     _client(client),
     _tpl(tpl),
     _deviceId(deviceId),
--- a/TemperatureMeasurement.h	Wed Sep 03 14:36:55 2014 +0000
+++ b/TemperatureMeasurement.h	Thu Oct 23 12:50:07 2014 +0000
@@ -1,14 +1,14 @@
 #ifndef TEMPERATUREMEASUREMENT_H
 #define TEMPERATUREMEASUREMENT_H
 
-#include "SmartRest.h"
+#include "AbstractSmartRest.h"
 #include "SmartRestTemplate.h"
 #include "LM75B.h"
 
 class TemperatureMeasurement
 {
 public:
-    TemperatureMeasurement(SmartRest&, SmartRestTemplate&, long&, LM75B&);
+    TemperatureMeasurement(AbstractSmartRest&, SmartRestTemplate&, long&, LM75B&);
     
     bool init();
     bool run();
@@ -17,7 +17,7 @@
     bool _init, _open;
     long& _deviceId;
     SmartRestTemplate& _tpl;
-    SmartRest& _client;
+    AbstractSmartRest& _client;
     LM75B& _sensor;
 };
 
--- a/apndb.cpp	Wed Sep 03 14:36:55 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-#include "apndb.h"
-#include "stdlib.h"
-#include "stdio.h"
-#include "string.h"
-
-// Contains all tuples
-apndb_t apndb[] = {
-    { .mcc = "262", .mnc = "01", .carrier = "Telekom Deutschland", .apn = "internet.m2mportal.de" },
-    { .mcc = "262", .mnc = "02", .carrier = "Telekom", .apn = "m2m.business" },
-    { .mcc = "232", .mnc = "03", .carrier = "Telekom", .apn = "m2m.business" },
-    { .mcc = "262", .mnc = "06", .carrier = "Telekom", .apn = "m2m.business" },
-    { .mcc = "204", .mnc = "04", .carrier = "Vodafone NL", .apn = "public4.m2minternet.com" },
-    { .mcc = NULL, .mnc = NULL, .carrier = NULL, .apn = NULL } // ending terminator
-};
-
-apndb_t * apndb_get(const char * imsi)
-{
-    char chr1[8], chr2[8];
-    size_t len;
-    size_t i;
-    
-    i = 0;
-    while (apndb[i].mcc != NULL) {
-        strcpy(chr1, apndb[i].mcc);
-        strcat(chr1, apndb[i].mnc);
-        len = strlen(chr1);
-        strncpy(chr2, imsi, len);
-        chr2[len] = '\0';
-        
-        if (strcmp(chr1, chr2) == 0)
-            return &apndb[i];
-        i++;
-    }
-    
-    return NULL;
-}
--- a/apndb.h	Wed Sep 03 14:36:55 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,15 +0,0 @@
-#ifndef APNDB_H
-#define APNDb_H
-
-// Defiles the base type for storing mcc/mnc-apn/user/pass tuples
-typedef struct
-{
-    const char *mcc; // mobile country code
-    const char *mnc; // mobile network code
-    const char *carrier;
-    const char *apn;
-} apndb_t;
-
-apndb_t * apndb_get(const char * imsi);
-
-#endif
\ No newline at end of file
--- a/main.cpp	Wed Sep 03 14:36:55 2014 +0000
+++ b/main.cpp	Thu Oct 23 12:50:07 2014 +0000
@@ -4,7 +4,6 @@
 #include "GPS.h"
 #include "DeviceInfo.h"
 #include "MbedAgent.h"
-#include "apndb.h"
 #include "GPSTracker.h"
 
 /**
@@ -24,9 +23,8 @@
     MDMParser::DevStatus devStatus;
     int res;
     uint8_t status = 0;
-    apndb_t *apn;
 
-    MDMSerial mdm;
+    MDMRtos<MDMSerial> mdm;
     GPSI2C gps;
 
     if (!mdm.init(SIM_PIN, &devStatus))
@@ -38,7 +36,7 @@
 
     switch (status) {
     case 1:
-        io.lcdPrint("MODEM INIT FAILURE", "REMOVE SIM PIN");
+        io.lcdPrint("MODEM INIT FAILURE", "CHECK SIM");
         break;
     case 2:
         io.lcdPrint("GPS INIT FAILURE");
@@ -63,33 +61,22 @@
         return 0;
     }*/
 
-    io.lcdPrint("IMEI", devStatus.imei);
+    io.lcdPrint("REGISTER NETWORK", "IMEI", devStatus.imei);
 
-#ifndef SIM_APN
-    apn = apndb_get(devStatus.imsi);
-    if (apn == NULL) {
-        io.lcdPrint("NO CARRIER FOUND", "CHECK IMSI", devStatus.imsi);
-        goto error;
-    }
-#endif
-    
     if (!mdm.registerNet()) {
         io.lcdPrint("NETWORK REG ERROR");
         goto error;
     }
 
+    io.lcdPrint("JOIN NETWORK");
 #ifdef SIM_APN
     if (mdm.join(SIM_APN, SIM_USER, SIM_PASS) == NOIP) {
+#else
+    if (mdm.join() == NOIP) {
+#endif
         io.lcdPrint("NETWORK JOIN FAILURE");
         goto error;
     }
-#else
-    io.lcdPrint("JOINING CARRIER", apn->carrier);
-    if (mdm.join(apn->apn) == NOIP) {
-        io.lcdPrint("NETWORK JOIN FAILURE");
-        goto error;
-    }
-#endif
     
     {
         uint8_t tries;
@@ -119,7 +106,6 @@
     return 0;
 
 error:
-    io.lcdPrint("DISCONNECTING");
     mdm.disconnect();
     return 1;
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/util/RtosSmartRest.cpp	Thu Oct 23 12:50:07 2014 +0000
@@ -0,0 +1,112 @@
+#include "RtosSmartRest.h"
+
+RtosSmartRest::RtosSmartRest(const char *host, uint16_t port, const char *identifier, uint8_t tries) :
+    _host(host),
+    _port(port),
+    _identifier(identifier),
+    _tries(tries),
+    _username(NULL),
+    _password(NULL),
+    _count(0)
+{
+}
+
+RtosSmartRest::~RtosSmartRest()
+{
+    size_t i;
+    
+    for (i = 0; i < _count; i++)
+        delete _slots[i].inst;
+}
+
+uint8_t RtosSmartRest::setAuthorization(const char *username, const char *password)
+{
+    uint8_t ret;
+    MbedSmartRest *inst;
+    
+    if ((inst = instance()) == NULL)
+        return SMARTREST_INTERNAL_ERROR;
+    
+    if ((ret = inst->setAuthorization(username, password)) == SMARTREST_SUCCESS) {
+        _username = username;
+        _password = password;
+    }
+    
+    return ret;
+}
+
+uint8_t RtosSmartRest::bootstrap(const DataGenerator& generator)
+{
+    uint8_t ret;
+    MbedSmartRest *inst;
+    
+    if ((inst = instance()) == NULL)
+        return SMARTREST_INTERNAL_ERROR;
+    
+    if ((ret = inst->bootstrap(generator)) == SMARTREST_SUCCESS)
+        _identifier = inst->getIdentifier();
+    
+    return ret;
+}
+    
+uint8_t RtosSmartRest::send(const DataGenerator& generator, const char *overrideIdentifier)
+{
+    MbedSmartRest *inst;
+    
+    if ((inst = instance()) == NULL)
+        return SMARTREST_INTERNAL_ERROR;
+
+    return inst->send(generator, overrideIdentifier);
+}
+
+uint8_t RtosSmartRest::receive(ParsedRecord& record)
+{
+    MbedSmartRest *inst;
+    
+    if ((inst = instance()) == NULL)
+        return SMARTREST_INTERNAL_ERROR;
+
+    return inst->receive(record);
+}
+
+void RtosSmartRest::stop()
+{
+    MbedSmartRest *inst;
+    
+    if ((inst = instance()) == NULL)
+        return;
+
+    inst->stop();
+}
+
+const char * RtosSmartRest::getIdentifier()
+{
+    return _identifier;
+}
+
+MbedSmartRest * RtosSmartRest::instance()
+{
+    size_t i;
+    osThreadId tid;
+    MbedSmartRest *inst;
+    RtosSmartRest::Slot slot;
+    
+    tid = Thread::gettid();
+    
+    for (i = 0; i < _count; i++) {
+        if (tid == _slots[i].tid)
+            return _slots[i].inst;
+    }
+    
+    if (_count == RTOS_SMARTREST_SLOTS)
+        return NULL;
+    
+    inst = new MbedSmartRest(_host, _port, _identifier, _tries);
+    inst->setAuthorization(_username, _password);
+
+    slot.tid = tid;
+    slot.inst = inst;
+    
+    _slots[_count++] = slot;
+    return inst;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/util/RtosSmartRest.h	Thu Oct 23 12:50:07 2014 +0000
@@ -0,0 +1,40 @@
+#ifndef RTOSSMARTREST_H
+#define RTOSSMARTREST_H
+
+#include "AbstractSmartRest.h"
+#include "MbedSmartRest.h"
+#include "rtos.h"
+
+#define RTOS_SMARTREST_SLOTS 8
+
+class RtosSmartRest : public AbstractSmartRest
+{
+public:
+    RtosSmartRest(const char*, uint16_t, const char*, uint8_t = MBEDSMARTREST_TRIES);
+    ~RtosSmartRest();
+    
+    struct Slot {
+        osThreadId tid;
+        MbedSmartRest *inst;
+    };
+
+    uint8_t setAuthorization(const char*, const char*);
+    uint8_t bootstrap(const DataGenerator&);
+    uint8_t send(const DataGenerator&, const char* = NULL);
+    uint8_t receive(ParsedRecord&);
+    void stop();
+    const char * getIdentifier();
+    
+protected:
+    MbedSmartRest * instance();
+
+private:
+    const char *_host, *_identifier;
+    uint8_t _port, _tries;
+    const char *_username, *_password;
+    
+    Slot _slots[RTOS_SMARTREST_SLOTS];
+    size_t _count;
+};
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/util/SmartRestTemplate.cpp	Thu Oct 23 12:50:07 2014 +0000
@@ -0,0 +1,39 @@
+#include "SmartRestTemplate.h"
+#include <string.h>
+
+SmartRestTemplate::SmartRestTemplate()
+{
+    _len = NULL;
+}
+
+bool SmartRestTemplate::add(const char *line)
+{
+    if (_len == SMARTREST_TEMPLATE_FIXED_SIZE)
+        return false;
+    _buffer[_len++] = line;
+}
+
+size_t SmartRestTemplate::writeTo(AbstractDataSink& sink) const
+{
+    size_t len = 0;
+    
+    for (size_t n = 0; n < _len; n++)
+        len += sink.write((char*)_buffer[n], strlen(_buffer[n]));
+    
+    return len;
+}
+
+size_t SmartRestTemplate::writtenLength() const
+{
+    size_t len = 0;
+    
+    for (size_t n = 0; n < _len; n++)
+        len += strlen(_buffer[n]);
+    
+    return len;
+}
+
+DataGenerator * SmartRestTemplate::copy() const
+{
+    return NULL;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/util/SmartRestTemplate.h	Thu Oct 23 12:50:07 2014 +0000
@@ -0,0 +1,27 @@
+#ifndef SMARTRESTTEMPLATE_H
+#define SMARTRESTTEMPLATE_H
+
+#include "DataGenerator.h"
+
+#define SMARTREST_TEMPLATE_FIXED_SIZE 64
+
+/**
+ * A data generator implementation holding an array of template lines
+ * to send via .bootstrap().
+ */
+class SmartRestTemplate : public DataGenerator
+{
+public:
+    SmartRestTemplate();
+    bool add(const char*);
+    
+    size_t writeTo(AbstractDataSink&) const;
+    size_t writtenLength() const;
+    DataGenerator* copy() const;
+
+private:
+    const char *_buffer[SMARTREST_TEMPLATE_FIXED_SIZE];
+    size_t _len;
+};
+
+#endif
\ No newline at end of file
--- a/utils/SmartRestTemplate.cpp	Wed Sep 03 14:36:55 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-#include "SmartRestTemplate.h"
-#include <string.h>
-
-SmartRestTemplate::SmartRestTemplate()
-{
-    _len = NULL;
-}
-
-bool SmartRestTemplate::add(const char *line)
-{
-    if (_len == SMARTREST_TEMPLATE_FIXED_SIZE)
-        return false;
-    _buffer[_len++] = line;
-}
-
-size_t SmartRestTemplate::writeTo(AbstractDataSink& sink) const
-{
-    size_t len = 0;
-    
-    for (size_t n = 0; n < _len; n++)
-        len += sink.write((char*)_buffer[n], strlen(_buffer[n]));
-    
-    return len;
-}
-
-size_t SmartRestTemplate::writtenLength() const
-{
-    size_t len = 0;
-    
-    for (size_t n = 0; n < _len; n++)
-        len += strlen(_buffer[n]);
-    
-    return len;
-}
-
-DataGenerator * SmartRestTemplate::copy() const
-{
-    return NULL;
-}
--- a/utils/SmartRestTemplate.h	Wed Sep 03 14:36:55 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-#ifndef SMARTRESTTEMPLATE_H
-#define SMARTRESTTEMPLATE_H
-
-#include "DataGenerator.h"
-
-#define SMARTREST_TEMPLATE_FIXED_SIZE 64
-
-/**
- * A data generator implementation holding an array of template lines
- * to send via .bootstrap().
- */
-class SmartRestTemplate : public DataGenerator
-{
-public:
-    SmartRestTemplate();
-    bool add(const char*);
-    
-    size_t writeTo(AbstractDataSink&) const;
-    size_t writtenLength() const;
-    DataGenerator* copy() const;
-
-private:
-    const char *_buffer[SMARTREST_TEMPLATE_FIXED_SIZE];
-    size_t _len;
-};
-
-#endif
\ No newline at end of file