mbed.org implementation of the abstract SmartREST library for the Cumulocity Platform SmartREST protocol.
Dependents: MbedSmartRestMain MbedSmartRestMain
Diff: SmartRest.cpp
- Revision:
- 1:9a11a331e340
- Parent:
- 0:099f76422485
- Child:
- 2:45a6e44a4fb4
--- a/SmartRest.cpp Thu Jul 03 20:38:04 2014 +0200 +++ b/SmartRest.cpp Mon Jul 07 16:14:51 2014 +0200 @@ -36,11 +36,11 @@ _mogid[0] = 0; } -int8_t SmartRest::send(DataGenerator& generator) +int8_t SmartRest::send(const DataGenerator& generator, const char *overrideIdentifier) { uint8_t res; - res = beginRequest(); + res = beginRequest(overrideIdentifier); if (res != SMARTREST_SUCCESS) return res; @@ -73,7 +73,7 @@ ParsedRecord record; int8_t ret; - ret = beginRequest(); + ret = beginRequest(NULL); if (ret != SMARTREST_SUCCESS) return ret; ret = awaitResponse(); @@ -113,7 +113,7 @@ _client.stop(); } -uint8_t SmartRest::beginRequest() +uint8_t SmartRest::beginRequest(const char *overrideIdentifier) { int res; @@ -123,7 +123,10 @@ } else if (res != CLIENT_OK) { return SMARTREST_INTERNAL_ERROR; } - if (strlen(_mogid)) { + if (overrideIdentifier != NULL) { + if (_client.sendIdentifier(overrideIdentifier) != CLIENT_OK) + return SMARTREST_INTERNAL_ERROR; + } else if (strlen(_mogid)) { if (_client.sendIdentifier(_mogid) != CLIENT_OK) return SMARTREST_INTERNAL_ERROR; } else {