Own fork of MbedSmartRestMain

Dependencies:   C027_Support C12832 LM75B MMA7660 MbedSmartRest mbed-rtos mbed

Fork of MbedSmartRestMain by Cumulocity Official

Committer:
vwochnik
Date:
Fri Oct 24 08:55:17 2014 +0000
Revision:
58:4cc0ae5a7058
Parent:
57:4af5f1bec3a6
Child:
59:f96be79feccd
operation support templates

Who changed what in which revision?

UserRevisionLine numberNew contents of line
vwochnik 57:4af5f1bec3a6 1 #include "OperationSupport.h"
vwochnik 57:4af5f1bec3a6 2 #include "ComposedRecord.h"
vwochnik 57:4af5f1bec3a6 3 #include "CharValue.h"
vwochnik 57:4af5f1bec3a6 4 #include "IntegerValue.h"
vwochnik 57:4af5f1bec3a6 5
vwochnik 57:4af5f1bec3a6 6 OperationSupport::OperationSupport(AbstractSmartRest& client, SmartRestTemplate& tpl, long& deviceId) :
vwochnik 57:4af5f1bec3a6 7 _client(client),
vwochnik 57:4af5f1bec3a6 8 _tpl(tpl),
vwochnik 57:4af5f1bec3a6 9 _deviceId(deviceId)
vwochnik 57:4af5f1bec3a6 10 {
vwochnik 57:4af5f1bec3a6 11 _init = false;
vwochnik 57:4af5f1bec3a6 12 }
vwochnik 57:4af5f1bec3a6 13
vwochnik 57:4af5f1bec3a6 14 bool OperationSupport::init()
vwochnik 57:4af5f1bec3a6 15 {
vwochnik 57:4af5f1bec3a6 16 if (_init)
vwochnik 57:4af5f1bec3a6 17 return false;
vwochnik 57:4af5f1bec3a6 18
vwochnik 57:4af5f1bec3a6 19 // Get pending operations
vwochnik 57:4af5f1bec3a6 20 // USAGE: 110,<DEVICE/ID>
vwochnik 57:4af5f1bec3a6 21 if (!_tpl.add("10,110,GET,/devicecontrol/operations?status=PENDING&deviceId=%%&pageSize=100,,application/vnd.com.nsn.cumulocity.operationCollection+json,%%,UNSIGNED,\r\n"))
vwochnik 57:4af5f1bec3a6 22 return false;
vwochnik 57:4af5f1bec3a6 23
vwochnik 57:4af5f1bec3a6 24 // Set operation state
vwochnik 57:4af5f1bec3a6 25 // USAGE: 110,<OPERATION/ID>,<STATE>
vwochnik 58:4cc0ae5a7058 26 if (!_tpl.add("10,111,PUT,/devicecontrol/operations/%%,application/vnd.com.nsn.cumulocity.operation+json,application/vnd.com.nsn.cumulocity.operation+json,%%,UNSIGNED STRING,\"{\"\"status\"\":\"\"%%\"\"}\"\r\n"))
vwochnik 57:4af5f1bec3a6 27 return false;
vwochnik 57:4af5f1bec3a6 28
vwochnik 57:4af5f1bec3a6 29 // Get operations
vwochnik 57:4af5f1bec3a6 30 // Response: 210,<OPERATION/ID>,<STATUS>
vwochnik 57:4af5f1bec3a6 31 if (!_tpl.add("11,210,\"$.operations\",,\"$.id\",\"$.status\"\r\n"))
vwochnik 57:4af5f1bec3a6 32 return false;
vwochnik 57:4af5f1bec3a6 33
vwochnik 57:4af5f1bec3a6 34 // Get operation
vwochnik 57:4af5f1bec3a6 35 // Response: 211,<OPERATION/ID>,<STATUS>
vwochnik 57:4af5f1bec3a6 36 if (!_tpl.add("11,211,,\"$.deviceId\",\"$.id\",\"$.status\"\r\n"))
vwochnik 57:4af5f1bec3a6 37 return false;
vwochnik 57:4af5f1bec3a6 38
vwochnik 57:4af5f1bec3a6 39 _init = true;
vwochnik 57:4af5f1bec3a6 40 return true;
vwochnik 57:4af5f1bec3a6 41 }
vwochnik 57:4af5f1bec3a6 42
vwochnik 57:4af5f1bec3a6 43 bool OperationSupport::run()
vwochnik 57:4af5f1bec3a6 44 {
vwochnik 57:4af5f1bec3a6 45 }