cbData.context = NULL;
cbData.cd = NULL;
- ret = OCDoResource(NULL, method, query.str().c_str(), dest,
- (method == OC_REST_PUT || method == OC_REST_POST) ? putPayload() : NULL,
- ocConnType, qos, &cbData, options, numOptions);
+ OCPayload* payload = (method == OC_REST_PUT || method == OC_REST_POST) ? putPayload() : NULL;
+
+ ret = OCDoRequest(NULL, method, query.str().c_str(), dest,
+ payload, ocConnType, qos, &cbData, options, numOptions);
+
+ OCPayloadDestroy(payload);
if (ret != OC_STACK_OK)
{
{
OIC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
OIC_LOG_PAYLOAD(INFO, clientResponse->payload);
- OIC_LOG(INFO, TAG, ("=============> Put Response"));
+ OIC_LOG(INFO, TAG, "=============> Put Response");
}
return OC_STACK_DELETE_TRANSACTION;
}
{
OIC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
OIC_LOG_PAYLOAD(INFO, clientResponse->payload);
- OIC_LOG(INFO, TAG, ("=============> Post Response"));
+ OIC_LOG(INFO, TAG, "=============> Post Response");
}
return OC_STACK_DELETE_TRANSACTION;
}
OIC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
OIC_LOG_V(INFO, TAG, "SEQUENCE NUMBER: %d", clientResponse->sequenceNumber);
OIC_LOG_PAYLOAD(INFO, clientResponse->payload);
- OIC_LOG(INFO, TAG, ("=============> Get Response"));
+ OIC_LOG(INFO, TAG, "=============> Get Response");
}
return OC_STACK_DELETE_TRANSACTION;
}
case TEST_NON_CON_OP:
InitGetRequest(OC_LOW_QOS);
InitPutRequest(OC_LOW_QOS);
- //InitPostRequest(OC_LOW_QOS);
+ InitPostRequest(OC_LOW_QOS);
break;
case TEST_CON_OP:
InitGetRequest(OC_HIGH_QOS);
InitPutRequest(OC_HIGH_QOS);
- //InitPostRequest(OC_HIGH_QOS);
+ InitPostRequest(OC_HIGH_QOS);
break;
}
}
return (UnicastDiscovery) ? OC_STACK_DELETE_TRANSACTION : OC_STACK_KEEP_TRANSACTION ;
}
-
int InitPutRequest(OCQualityOfService qos)
{
OIC_LOG_V(INFO, TAG, "Executing %s", __func__);
OIC_LOG_V(INFO, TAG, "Executing %s", __func__);
std::ostringstream query;
query << coapServerResource;
+ if(WithTcp)
+ {
+ endpoint.adapter = OC_ADAPTER_TCP;
+ }
endpoint.flags = (OCTransportFlags)(endpoint.flags|OC_SECURE);
// First POST operation (to create an LED instance)
OIC_LOG(INFO, TAG, "Second POST call did not succeed");
}
- // This POST operation will update the original resourced /a/led
- return (InvokeOCDoResource(query, OC_REST_POST, &endpoint,
- ((qos == OC_HIGH_QOS) ? OC_HIGH_QOS: OC_LOW_QOS),
- postReqCB, NULL, 0));
+ // This POST operation will update the original resourced /a/led (as long as
+ // the server is set to max 2 /lcd resources)
+ result = InvokeOCDoResource(query, OC_REST_POST, &endpoint,
+ ((qos == OC_HIGH_QOS) ? OC_HIGH_QOS: OC_LOW_QOS),
+ postReqCB, NULL, 0);
+ if (OC_STACK_OK != result)
+ {
+ OIC_LOG(INFO, TAG, "Third POST call did not succeed");
+ }
+ return result;
}
int InitGetRequest(OCQualityOfService qos)
OIC_LOG_V(INFO, TAG, "Executing %s", __func__);
std::ostringstream query;
query << coapServerResource;
+ if(WithTcp)
+ {
+ endpoint.adapter = OC_ADAPTER_TCP;
+ }
endpoint.flags = (OCTransportFlags)(endpoint.flags|OC_SECURE);
return (InvokeOCDoResource(query, OC_REST_GET, &endpoint,
(UnicastDiscovery) ? "Unicast" : "Multicast",
queryUri);
- ret = OCDoResource(NULL, OC_REST_DISCOVER, queryUri, 0, 0, CT_DEFAULT,
- OC_LOW_QOS, &cbData, NULL, 0);
+ ret = OCDoRequest(NULL, OC_REST_DISCOVER, queryUri, 0, 0, CT_DEFAULT,
+ OC_LOW_QOS, &cbData, NULL, 0);
if (ret != OC_STACK_OK)
{
OIC_LOG(ERROR, TAG, "OCStack resource error");