Own fork of MbedSmartRest

Dependents:   MbedSmartRestMain MbedSmartRestMain

Fork of MbedSmartRest by Cumulocity Official

Revision:
13:aba98ad2ac1b
Parent:
11:e1bee9a77652
Child:
18:16192696c106
--- a/SmartRest.cpp	Sat Nov 15 11:37:14 2014 +0100
+++ b/SmartRest.cpp	Sat Nov 15 12:21:41 2014 +0100
@@ -95,7 +95,7 @@
 	ParsedRecord record;
 	int8_t ret;
 
-	ret = beginRequest(NULL);
+	ret = beginRequest(NULL, NULL);
 	if (ret != SMARTREST_SUCCESS)
 		return ret;
 	ret = awaitResponse();
@@ -134,7 +134,7 @@
 {
 	uint8_t res;
 
-	res = beginRequest(overrideIdentifier);
+	res = beginRequest(NULL, overrideIdentifier);
 	if (res != SMARTREST_SUCCESS)
 		return res;
 
@@ -142,6 +142,18 @@
 	return awaitResponse();
 }
 /*-------------------------------------------------------------------------*/
+uint8_t SmartRest::stream(const char *uri, const Record& record, const char *overrideIdentifier)
+{
+	uint8_t res;
+
+	res = beginRequest(uri, overrideIdentifier);
+	if (res != SMARTREST_SUCCESS)
+		return res;
+
+	_client.sendData(record);
+	return awaitResponse();
+}
+/*-------------------------------------------------------------------------*/
 uint8_t SmartRest::receive(ParsedRecord& record)
 {
 	uint8_t res;
@@ -176,11 +188,19 @@
 	return _identifier;
 }
 /*-------------------------------------------------------------------------*/
-uint8_t SmartRest::beginRequest(const char *overrideIdentifier)
+uint8_t SmartRest::beginRequest(const char *uri, const char *overrideIdentifier)
 {
 	int res;
 
-	res = _client.beginRequest();
+    if (uri != NULL)
+    {
+        res = _client.beginStream(uri);
+    }
+    else
+    {
+        res = _client.beginRequest();
+    }
+
 	if (res == CLIENT_CONNECTION_ERROR)
 	{
 		return SMARTREST_CONNECTION_FAILED;