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 30 13:38:20 2014 +0000
Parent:
64:31a640c32399
Child:
66:31c754c36ed7
Commit message:
operation support

Changed in this revision

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
DeviceIO.cpp Show diff for this revision Revisions of this file
DeviceIO.h Show diff for this revision Revisions of this file
GPSTracker.cpp Show diff for this revision Revisions of this file
GPSTracker.h Show diff for this revision Revisions of this file
MbedAgent.cpp 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
io/DeviceFeedback.cpp Show annotated file Show diff for this revision Revisions of this file
io/DeviceFeedback.h Show annotated file Show diff for this revision Revisions of this file
io/DeviceIO.cpp Show annotated file Show diff for this revision Revisions of this file
io/DeviceIO.h Show annotated file Show diff for this revision Revisions of this file
io/GPSTracker.cpp Show annotated file Show diff for this revision Revisions of this file
io/GPSTracker.h Show annotated file Show diff for this revision Revisions of this file
operation/OperationExecutor.cpp Show annotated file Show diff for this revision Revisions of this file
operation/OperationExecutor.h Show annotated file Show diff for this revision Revisions of this file
operation/OperationSupport.cpp Show annotated file Show diff for this revision Revisions of this file
operation/OperationSupport.h Show annotated file Show diff for this revision Revisions of this file
--- a/C027_Support.lib	Thu Oct 30 12:30:04 2014 +0000
+++ b/C027_Support.lib	Thu Oct 30 13:38:20 2014 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/teams/ublox/code/C027_Support/#5f8807ca159a
+http://mbed.org/teams/ublox/code/C027_Support/#89b5b21db71e
--- a/DeviceBootstrap.cpp	Thu Oct 30 12:30:04 2014 +0000
+++ b/DeviceBootstrap.cpp	Thu Oct 30 13:38:20 2014 +0000
@@ -19,9 +19,6 @@
 
 bool DeviceBootstrap::setUpCredentials()
 {
-    strcpy(_username, "vaillant/admin");
-    strcpy(_password, "klanpi");
-
     if (((*_username == '\0') || (*_password == '\0')) &&
         (!obtainFromStorage())) {
         if (!obtainFromPlatform())
--- a/DeviceIO.cpp	Thu Oct 30 12:30:04 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-#include "DeviceIO.h"
-
-#define DEF "\033[39m"
-#define GRE "\033[32m"
-#define CYA "\033[36m"
-
-DeviceIO::DeviceIO(GPSI2C& gps) :
-    _gpsTracker(gps),
-    _resetButton(D4), // fire button on arduino app shield
-    _analog1(A0),
-    _analog2(A1),
-    _temperatureSensor(SDA,SCL),
-    _accelerometer(SDA,SCL),
-    _lcd(D11, D13, D12, D7, D10)
-{
-}
-
-bool DeviceIO::resetButtonPressed()
-{
-    return _resetButton;
-}
-
-GPSTracker& DeviceIO::gpsTracker()
-{
-    return _gpsTracker;
-}
-
-AnalogIn& DeviceIO::analog1()
-{
-    return _analog1;
-}
-
-AnalogIn& DeviceIO::analog2()
-{
-    return _analog2;
-}
-LM75B& DeviceIO::temperatureSensor()
-{
-    return _temperatureSensor;
-}
-
-MMA7660& DeviceIO::accelerometer()
-{
-    return _accelerometer;
-}
-
-void DeviceIO::lcdPrint(const char *line1, const char *line2, const char *line3)
-{
-    printf(GRE "io::lcdPrint" DEF "\r\n");
-    _lcd.cls();
-    _lcd.locate(0, 0);
-
-    _lcd.printf("%s\n", line1);
-    printf(GRE "> " CYA "%s\r\n" DEF, line1);
-
-    if (line2 != NULL) {
-        _lcd.printf("%s\n", line2);
-        printf(GRE "> " CYA "%s\r\n" DEF, line2);
-
-        if (line3 != NULL) {
-            _lcd.printf("%s\n", line3);
-            printf(GRE "> " CYA "%s\r\n" DEF, line3);
-        }
-    }
-}
--- a/DeviceIO.h	Thu Oct 30 12:30:04 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +0,0 @@
-#ifndef DEVICEIO_H
-#define DEVICEIO_H
-
-#include "mbed.h"
-#include "GPSTracker.h"
-#include "GPS.h"
-#include "LM75B.h"
-#include "MMA7660.h"
-#include "C12832.h"
-
-#define A0  P0_23
-#define A1  P0_24
-#define A2  P0_25
-#define A3  P0_26
-#define A4  P0_30
-#define A5  P1_31
-
-#define D0  P4_29
-#define D1  P4_28
-#define D2  P2_13
-#define D3  P2_0
-#define D4  P2_12
-#define D5  P2_1
-#define D6  P2_2
-#define D7  P2_11
-
-#define D8  P2_4
-#define D9  P2_3
-#define D10 P1_21
-#define D11 P1_24
-#define D12 P1_23
-#define D13 P1_20
-    
-#define SDA P0_0
-#define SCL P0_1
-
-class DeviceIO
-{
-public:
-    DeviceIO(GPSI2C&);
-
-    bool resetButtonPressed();
-    GPSTracker& gpsTracker();
-    AnalogIn& analog1();
-    AnalogIn& analog2();
-    LM75B& temperatureSensor();
-    MMA7660& accelerometer();
-    void lcdPrint(const char*, const char* = NULL, const char* = NULL);
-
-private:
-    GPSTracker _gpsTracker;
-    DigitalIn _resetButton;
-    AnalogIn _analog1;
-    AnalogIn _analog2;
-    LM75B _temperatureSensor;
-    MMA7660 _accelerometer;
-    C12832 _lcd;
-};
-
-#endif
\ No newline at end of file
--- a/GPSTracker.cpp	Thu Oct 30 12:30:04 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +0,0 @@
-#include "GPSTracker.h"
-#include <stdlib.h>
-#include <string.h>
-
-GPSTracker::GPSTracker(GPSI2C& gps) :
-    _gps(gps),
-    _thread(GPSTracker::thread_func, this),
-    _positionSet(false)
-{
-}
-
-bool GPSTracker::position(GPSTracker::Position *position)
-{
-    bool result;
-    
-    _mutex.lock();
-    if (_positionSet) {
-        memcpy(position, &_position, sizeof(GPSTracker::Position));
-        _positionSet = false;
-        result = true;
-    } else {
-        result = false;
-    }
-    _mutex.unlock();
-    
-    return result;
-}
-
-void GPSTracker::thread()
-{
-    char buf[256], chr; // needs to be that big otherwise mdm isn't working
-    int ret, len, n;
-    double altitude, latitude, longitude;
-    
-    while (true) {
-        ret = _gps.getMessage(buf, sizeof(buf));
-        if (ret <= 0) {
-            Thread::wait(100);
-            continue;
-        }
-        
-        len = LENGTH(ret);
-        if ((PROTOCOL(ret) != GPSParser::NMEA) || (len <= 6))
-            continue;
-
-        // we're only interested in fixed GPS positions
-        // we are not interested in invalid data
-        if ((strncmp("$GPGGA", buf, 6) != 0) ||
-            (!_gps.getNmeaItem(6, buf, len, n, 10)) || (n == 0))
-            continue;
-        
-        // get altitude, latitude and longitude
-        if ((!_gps.getNmeaAngle(2, buf, len, latitude)) ||
-            (!_gps.getNmeaAngle(4, buf, len, longitude)) ||
-            (!_gps.getNmeaItem(9, buf, len, altitude)) ||
-            (!_gps.getNmeaItem(10, buf, len, chr)) ||
-            (chr != 'M'))
-            continue;
-
-        _mutex.lock();
-        _position.altitude = altitude;
-        _position.latitude = latitude;
-        _position.longitude = longitude;
-        _positionSet = true;
-        _mutex.unlock();
-    }
-}
-
-void GPSTracker::thread_func(void const *arg)
-{
-    GPSTracker *that;
-    that = (GPSTracker*)arg;
-    that->thread();
-}
--- a/GPSTracker.h	Thu Oct 30 12:30:04 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-#ifndef GPSTRACKER_H
-#define GPSTRACKER_H
-
-#include <stddef.h>
-#include "GPS.h"
-#include "rtos.h"
-
-/**
- * A GPS tracker class providing access to the current position.
- */
-class GPSTracker
-{
-public:
-    /**
-     * Initialize a new GPSTracker object.
-     * @param gps a previously initialized instance of the GPSI2C class
-     */
-    GPSTracker(GPSI2C&);
-    
-    typedef struct {
-        double altitude;  // altitude  meters
-        double latitude;  // latitude  degrees
-        double longitude; // longitude degrees
-    } Position;
-    
-    /**
-     * Retrieves and invalidates the current position.
-     * @param position a pointer of type Position where the current position is written to
-     * @return true on success, false otherwise
-     */
-    bool position(Position*);
-    
-protected:
-    void thread();
-    static void thread_func(void const*);
-
-private:
-    GPSI2C _gps;
-    Thread _thread;
-    Mutex _mutex;
-    Position _position;
-    bool _positionSet;
-};
-
-#endif
\ No newline at end of file
--- a/MbedAgent.cpp	Thu Oct 30 12:30:04 2014 +0000
+++ b/MbedAgent.cpp	Thu Oct 30 13:38:20 2014 +0000
@@ -13,7 +13,7 @@
     _accelerationMeasurement(_client, _tpl, _deviceId, _io.accelerometer()),
     _analogMeasurement(_client, _tpl, _deviceId, _io.analog1(), _io.analog2()),
     _locationUpdate(_client, _tpl, _deviceId, _io.gpsTracker()),
-    _operationSupport(_client, _tpl, _deviceId),
+    _operationSupport(_client, _tpl, _deviceId, _io),
     _deviceId(0)
 {
 }
@@ -62,14 +62,14 @@
     while (true) {
         timer.reset();
         
-        /*_signalQualityMeasurement.run();
+        _signalQualityMeasurement.run();
         _temperatureMeasurement.run();
         _accelerationMeasurement.run();
         _analogMeasurement.run();
-        _locationUpdate.run();*/
+        _locationUpdate.run();
         _operationSupport.run();
         
-        while (timer.read() < 10 /*MBED_AGENT_INTERVAL*/) {
+        while (timer.read() < MBED_AGENT_INTERVAL) {
             Thread::yield();
         }
     }
--- a/MbedAgent.h	Thu Oct 30 12:30:04 2014 +0000
+++ b/MbedAgent.h	Thu Oct 30 13:38:20 2014 +0000
@@ -18,7 +18,7 @@
 
 #define MBED_AGENT_HOST "developer.cumulocity.com"
 #define MBED_AGENT_PORT 80
-#define MBED_AGENT_DEVICE_IDENTIFIER "com_cumulocity_MbedAgent_1.1.0_asdbrf"
+#define MBED_AGENT_DEVICE_IDENTIFIER "com_cumulocity_MbedAgent_1.4.1"
 #define MBED_AGENT_INTERVAL 60.0
 
 class MbedAgent
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/io/DeviceFeedback.cpp	Thu Oct 30 13:38:20 2014 +0000
@@ -0,0 +1,81 @@
+#include "DeviceFeedback.h"
+#include <stdlib.h>
+#include <string.h>
+
+#define MSG_CLOSE_RELAY 1
+#define MSG_OPEN_RELAY 2
+
+DeviceFeedback::DeviceFeedback(PwmOut speaker) :
+    _speaker(speaker),
+    _thread(DeviceFeedback::thread_func, this)
+{
+}
+
+void DeviceFeedback::closeRelay()
+{
+    uint8_t *msg;
+    
+    msg = _mail.alloc();
+    *msg = MSG_CLOSE_RELAY;
+    _mail.put(msg);
+}
+
+void DeviceFeedback::openRelay()
+{
+    uint8_t *msg;
+    
+    msg = _mail.alloc();
+    *msg = MSG_OPEN_RELAY;
+    _mail.put(msg);
+}
+
+void DeviceFeedback::thread()
+{
+    osEvent evt; uint8_t *msg;
+    bool relayState = false;
+
+    while (true) {
+        if ((evt = _mail.get(1000)).status == osEventMail) {
+            msg = (uint8_t*)evt.value.p;
+            switch (*msg) {
+            case MSG_CLOSE_RELAY:
+                if (!relayState) {
+                    relayState = true;
+                    for (float i=2000.0; i<10000.0; i+=100) {
+                        _speaker.period(1.0/i);
+                        _speaker = 0.5;
+                        Thread::wait(20);
+                    }
+                    _speaker = 0.0;
+                }
+                break;
+            case MSG_OPEN_RELAY:
+                if (relayState) {
+                    relayState = false;
+                    for (float i=10000.0; i>2000.0; i-=100) {
+                        _speaker.period(1.0/i);
+                        _speaker = 0.5;
+                        Thread::wait(20);
+                    }
+                    _speaker = 0.0;
+                }
+                break;
+            }
+            _mail.free(msg);
+        }
+
+        if (relayState) {
+            _speaker.period(1.0/10000);
+            _speaker = 0.5;
+            Thread::wait(20);
+            _speaker = 0.0;
+        }
+    }
+}
+
+void DeviceFeedback::thread_func(void const *arg)
+{
+    DeviceFeedback *that;
+    that = (DeviceFeedback*)arg;
+    that->thread();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/io/DeviceFeedback.h	Thu Oct 30 13:38:20 2014 +0000
@@ -0,0 +1,26 @@
+#ifndef DEVICEFEEDBACK_H
+#define DEVICEFEEDBACK_H
+
+#include <stddef.h>
+#include "mbed.h"
+#include "rtos.h"
+
+class DeviceFeedback
+{
+public:
+    DeviceFeedback(PwmOut speaker);
+    
+    void closeRelay();
+    void openRelay();
+    
+protected:
+    void thread();
+    static void thread_func(void const*);
+
+private:
+    PwmOut _speaker;
+    Thread _thread;
+    Mail<uint8_t, 16> _mail;
+};
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/io/DeviceIO.cpp	Thu Oct 30 13:38:20 2014 +0000
@@ -0,0 +1,72 @@
+#include "DeviceIO.h"
+
+#define DEF "\033[39m"
+#define GRE "\033[32m"
+#define CYA "\033[36m"
+
+DeviceIO::DeviceIO(GPSI2C& gps) :
+    _resetButton(D4), // fire button on arduino app shield
+    _analog1(A0),
+    _analog2(A1),
+    _speaker(D6),
+    _temperatureSensor(SDA,SCL),
+    _accelerometer(SDA,SCL),
+    _lcd(D11, D13, D12, D7, D10),
+    _gpsTracker(gps),
+    _deviceFeedback(_speaker)
+{
+}
+
+bool DeviceIO::resetButtonPressed()
+{
+    return _resetButton;
+}
+
+GPSTracker& DeviceIO::gpsTracker()
+{
+    return _gpsTracker;
+}
+
+DeviceFeedback& DeviceIO::deviceFeedback()
+{
+    return _deviceFeedback;
+}
+
+AnalogIn& DeviceIO::analog1()
+{
+    return _analog1;
+}
+
+AnalogIn& DeviceIO::analog2()
+{
+    return _analog2;
+}
+LM75B& DeviceIO::temperatureSensor()
+{
+    return _temperatureSensor;
+}
+
+MMA7660& DeviceIO::accelerometer()
+{
+    return _accelerometer;
+}
+
+void DeviceIO::lcdPrint(const char *line1, const char *line2, const char *line3)
+{
+    printf(GRE "io::lcdPrint" DEF "\r\n");
+    _lcd.cls();
+    _lcd.locate(0, 0);
+
+    _lcd.printf("%s\n", line1);
+    printf(GRE "> " CYA "%s\r\n" DEF, line1);
+
+    if (line2 != NULL) {
+        _lcd.printf("%s\n", line2);
+        printf(GRE "> " CYA "%s\r\n" DEF, line2);
+
+        if (line3 != NULL) {
+            _lcd.printf("%s\n", line3);
+            printf(GRE "> " CYA "%s\r\n" DEF, line3);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/io/DeviceIO.h	Thu Oct 30 13:38:20 2014 +0000
@@ -0,0 +1,64 @@
+#ifndef DEVICEIO_H
+#define DEVICEIO_H
+
+#include "mbed.h"
+#include "GPS.h"
+#include "LM75B.h"
+#include "MMA7660.h"
+#include "C12832.h"
+#include "GPSTracker.h"
+#include "DeviceFeedback.h"
+
+#define A0  P0_23
+#define A1  P0_24
+#define A2  P0_25
+#define A3  P0_26
+#define A4  P0_30
+#define A5  P1_31
+
+#define D0  P4_29
+#define D1  P4_28
+#define D2  P2_13
+#define D3  P2_0
+#define D4  P2_12
+#define D5  P2_1
+#define D6  P2_2
+#define D7  P2_11
+
+#define D8  P2_4
+#define D9  P2_3
+#define D10 P1_21
+#define D11 P1_24
+#define D12 P1_23
+#define D13 P1_20
+    
+#define SDA P0_0
+#define SCL P0_1
+
+class DeviceIO
+{
+public:
+    DeviceIO(GPSI2C&);
+
+    bool resetButtonPressed();
+    GPSTracker& gpsTracker();
+    DeviceFeedback& deviceFeedback();
+    AnalogIn& analog1();
+    AnalogIn& analog2();
+    LM75B& temperatureSensor();
+    MMA7660& accelerometer();
+    void lcdPrint(const char*, const char* = NULL, const char* = NULL);
+
+private:
+    DigitalIn _resetButton;
+    AnalogIn _analog1;
+    AnalogIn _analog2;
+    PwmOut _speaker;
+    LM75B _temperatureSensor;
+    MMA7660 _accelerometer;
+    C12832 _lcd;
+    GPSTracker _gpsTracker;
+    DeviceFeedback _deviceFeedback;
+};
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/io/GPSTracker.cpp	Thu Oct 30 13:38:20 2014 +0000
@@ -0,0 +1,74 @@
+#include "GPSTracker.h"
+#include <stdlib.h>
+#include <string.h>
+
+GPSTracker::GPSTracker(GPSI2C& gps) :
+    _gps(gps),
+    _thread(GPSTracker::thread_func, this),
+    _positionSet(false)
+{
+}
+
+bool GPSTracker::position(GPSTracker::Position *position)
+{
+    bool result;
+    
+    _mutex.lock();
+    if (_positionSet) {
+        memcpy(position, &_position, sizeof(GPSTracker::Position));
+        _positionSet = false;
+        result = true;
+    } else {
+        result = false;
+    }
+    _mutex.unlock();
+    
+    return result;
+}
+
+void GPSTracker::thread()
+{
+    char buf[256], chr; // needs to be that big otherwise mdm isn't working
+    int ret, len, n;
+    double altitude, latitude, longitude;
+    
+    while (true) {
+        ret = _gps.getMessage(buf, sizeof(buf));
+        if (ret <= 0) {
+            Thread::wait(100);
+            continue;
+        }
+        
+        len = LENGTH(ret);
+        if ((PROTOCOL(ret) != GPSParser::NMEA) || (len <= 6))
+            continue;
+
+        // we're only interested in fixed GPS positions
+        // we are not interested in invalid data
+        if ((strncmp("$GPGGA", buf, 6) != 0) ||
+            (!_gps.getNmeaItem(6, buf, len, n, 10)) || (n == 0))
+            continue;
+        
+        // get altitude, latitude and longitude
+        if ((!_gps.getNmeaAngle(2, buf, len, latitude)) ||
+            (!_gps.getNmeaAngle(4, buf, len, longitude)) ||
+            (!_gps.getNmeaItem(9, buf, len, altitude)) ||
+            (!_gps.getNmeaItem(10, buf, len, chr)) ||
+            (chr != 'M'))
+            continue;
+
+        _mutex.lock();
+        _position.altitude = altitude;
+        _position.latitude = latitude;
+        _position.longitude = longitude;
+        _positionSet = true;
+        _mutex.unlock();
+    }
+}
+
+void GPSTracker::thread_func(void const *arg)
+{
+    GPSTracker *that;
+    that = (GPSTracker*)arg;
+    that->thread();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/io/GPSTracker.h	Thu Oct 30 13:38:20 2014 +0000
@@ -0,0 +1,45 @@
+#ifndef GPSTRACKER_H
+#define GPSTRACKER_H
+
+#include <stddef.h>
+#include "GPS.h"
+#include "rtos.h"
+
+/**
+ * A GPS tracker class providing access to the current position.
+ */
+class GPSTracker
+{
+public:
+    /**
+     * Initialize a new GPSTracker object.
+     * @param gps a previously initialized instance of the GPSI2C class
+     */
+    GPSTracker(GPSI2C&);
+    
+    typedef struct {
+        double altitude;  // altitude  meters
+        double latitude;  // latitude  degrees
+        double longitude; // longitude degrees
+    } Position;
+    
+    /**
+     * Retrieves and invalidates the current position.
+     * @param position a pointer of type Position where the current position is written to
+     * @return true on success, false otherwise
+     */
+    bool position(Position*);
+    
+protected:
+    void thread();
+    static void thread_func(void const*);
+
+private:
+    GPSI2C _gps;
+    Thread _thread;
+    Mutex _mutex;
+    Position _position;
+    bool _positionSet;
+};
+
+#endif
\ No newline at end of file
--- a/operation/OperationExecutor.cpp	Thu Oct 30 12:30:04 2014 +0000
+++ b/operation/OperationExecutor.cpp	Thu Oct 30 13:38:20 2014 +0000
@@ -5,10 +5,11 @@
 #include <string.h>
 #include <stdio.h>
 
-OperationExecutor::OperationExecutor(AbstractSmartRest& client, SmartRestTemplate& tpl, long& deviceId) :
+OperationExecutor::OperationExecutor(AbstractSmartRest& client, SmartRestTemplate& tpl, long& deviceId, DeviceIO& io) :
     _client(client),
     _tpl(tpl),
-    _deviceId(deviceId)
+    _deviceId(deviceId),
+    _io(io)
 {
     _init = false;
 }
@@ -72,8 +73,8 @@
 bool OperationExecutor::executeRelayStateUpdate(bool relayState)
 {
     if (relayState)
-        puts("Closing relay...");
+        _io.deviceFeedback().closeRelay();
     else
-        puts("Opening relay...");
+        _io.deviceFeedback().openRelay();
     return true;
 }
--- a/operation/OperationExecutor.h	Thu Oct 30 12:30:04 2014 +0000
+++ b/operation/OperationExecutor.h	Thu Oct 30 13:38:20 2014 +0000
@@ -4,11 +4,12 @@
 #include "AbstractSmartRest.h"
 #include "SmartRestTemplate.h"
 #include "OperationStore.h"
+#include "DeviceIO.h"
 
 class OperationExecutor
 {
 public:
-    OperationExecutor(AbstractSmartRest&, SmartRestTemplate&, long&);
+    OperationExecutor(AbstractSmartRest&, SmartRestTemplate&, long&, DeviceIO&);
     
     bool init();
     bool executeOperation(OperationStore::Operation&);
@@ -21,6 +22,7 @@
     long& _deviceId;
     SmartRestTemplate& _tpl;
     AbstractSmartRest& _client;
+    DeviceIO& _io;
 };
 
 #endif
\ No newline at end of file
--- a/operation/OperationSupport.cpp	Thu Oct 30 12:30:04 2014 +0000
+++ b/operation/OperationSupport.cpp	Thu Oct 30 13:38:20 2014 +0000
@@ -4,18 +4,17 @@
 #include "ComposedRecord.h"
 #include "CharValue.h"
 #include "IntegerValue.h"
-#include <stdio.h>
 
 CharValue aOperationStatePending("PENDING");
 CharValue aOperationStateExecuting("EXECUTING");
 CharValue aOperationStateSuccessful("SUCCESSFUL");
 CharValue aOperationStateFailed("FAILED");
 
-OperationSupport::OperationSupport(AbstractSmartRest& client, SmartRestTemplate& tpl, long& deviceId) :
+OperationSupport::OperationSupport(AbstractSmartRest& client, SmartRestTemplate& tpl, long& deviceId, DeviceIO& io) :
     _client(client),
     _tpl(tpl),
     _deviceId(deviceId),
-    _executor(client, tpl, deviceId),
+    _executor(client, tpl, deviceId, io),
     _thread1(OperationSupport::thread1_func, this),
     _thread2(OperationSupport::thread2_func, this)
 {
@@ -83,21 +82,15 @@
     }
     
     while ((ret = _client.receive(received)) == SMARTREST_SUCCESS) {
-        if (!operationFromRecord(received, op)) {
-            puts("Operation conversion failed.");
+        if (!operationFromRecord(received, op))
             continue;
-        }
-        if (!_store.enqueue(op)) {
-            puts("Cannot enqueue operation.");
+        if (!_store.enqueue(op))
             continue;
-        }
-        puts("Enqueued operation.");
     }
     _client.stop();
 
     if ((ret != SMARTREST_END_OF_RESPONSE) &&
         (ret != SMARTREST_CONNECTION_CLOSED)) {
-        puts("Failed receive.");
         return false;
     }
     
@@ -223,9 +216,7 @@
             continue;
         }
         
-        if (_client.send(aggr) != SMARTREST_SUCCESS) {
-            puts("Failed to update.");
-        }
+        if (_client.send(aggr) != SMARTREST_SUCCESS) { }
         _client.stop();
         aggr.clear();        
     }
--- a/operation/OperationSupport.h	Thu Oct 30 12:30:04 2014 +0000
+++ b/operation/OperationSupport.h	Thu Oct 30 13:38:20 2014 +0000
@@ -2,6 +2,7 @@
 #define OPERATIONSUPPORT_H
 
 #include "rtos.h"
+#include "DeviceIO.h"
 #include "OperationExecutor.h"
 #include "AbstractSmartRest.h"
 #include "SmartRestTemplate.h"
@@ -13,7 +14,7 @@
 class OperationSupport
 {
 public:
-    OperationSupport(AbstractSmartRest&, SmartRestTemplate&, long&);
+    OperationSupport(AbstractSmartRest&, SmartRestTemplate&, long&, DeviceIO&);
     
     bool init();
     bool run();