if (result == OC_STACK_OK)
{
- OC_LOG(DEBUG, TAG, "Resource Directory send successful...");
+ OIC_LOG(DEBUG, TAG, "Resource Directory send successful...");
}
else
{
- OC_LOG(ERROR, TAG, "Resource Directory send failed...");
+ OIC_LOG(ERROR, TAG, "Resource Directory send failed...");
}
return result;
__attribute__((unused)) OCClientResponse *clientResponse)
{
OCStackApplicationResult ret = OC_STACK_DELETE_TRANSACTION;
- OC_LOG(DEBUG, TAG, "Successfully published resources.");
+ OIC_LOG(DEBUG, TAG, "Successfully published resources.");
if (OC_STACK_OK == OCStopMulticastServer())
{
- OC_LOG_V(DEBUG, TAG, "Stopped receiving the multicast traffic.");
+ OIC_LOG_V(DEBUG, TAG, "Stopped receiving the multicast traffic.");
}
else
{
- OC_LOG_V(DEBUG, TAG, "Failed stopping the multicast traffic.");
+ OIC_LOG_V(DEBUG, TAG, "Failed stopping the multicast traffic.");
}
return ret;
static void retreiveRDDetails(OCClientResponse *clientResponse, OCRDBiasFactorCB clientCB)
{
- OC_LOG_V(DEBUG, TAG, "\tAddress of the RD: %s:%d", clientResponse->devAddr.addr,
+ OIC_LOG_V(DEBUG, TAG, "\tAddress of the RD: %s:%d", clientResponse->devAddr.addr,
clientResponse->devAddr.port);
- OCRDPayload *payload = (OCRDPayload *) clientResponse->payload;
- OC_LOG_PAYLOAD(DEBUG, (OCPayload *) payload);
+ OIC_LOG_PAYLOAD(DEBUG, clientResponse->payload);
// TODO: Multiple Resource Directory will have different biasFactor,
// needs to cache here detail
static OCStackApplicationResult handleDiscoverCB(void *ctx,
__attribute__((unused)) OCDoHandle handle, OCClientResponse *clientResponse)
{
- OC_LOG(DEBUG, TAG, "Found Resource Directory");
+ OIC_LOG(DEBUG, TAG, "Found Resource Directory");
OCStackApplicationResult ret = OC_STACK_DELETE_TRANSACTION;
OCRDClientContextCB *cb = (OCRDClientContextCB *)ctx;
if (!cb)
{
- OC_LOG(ERROR, TAG, "RD Context Invalid Parameters.");
+ OIC_LOG(ERROR, TAG, "RD Context Invalid Parameters.");
return ret;
}
if (cb->context != (void *) DEFAULT_CONTEXT_VALUE)
{
- OC_LOG(ERROR, TAG, "RD Context Invalid Context Value Parameters.");
+ OIC_LOG(ERROR, TAG, "RD Context Invalid Context Value Parameters.");
return ret;
}
- OC_LOG_V(DEBUG, TAG, "Callback Context for DISCOVER query received successfully :%d.", clientResponse->result);
-
- if (clientResponse && clientResponse->result == OC_STACK_OK)
+ if (clientResponse)
{
- retreiveRDDetails(clientResponse, cb->cbFunc);
+ OIC_LOG_V(DEBUG, TAG, "Callback Context for DISCOVER query received successfully :%d.", clientResponse->result);
+ if (clientResponse->result == OC_STACK_OK)
+ {
+ retreiveRDDetails(clientResponse, cb->cbFunc);
+ }
+ else
+ {
+ OIC_LOG(ERROR, TAG, "Discovery of RD Failed");
+ }
}
else
{
- OC_LOG(ERROR, TAG, "Discovery of RD Failed");
+ OIC_LOG(ERROR, TAG, "No client response.");
}
OICFree(cb);
{
if (!cbBiasFactor)
{
- OC_LOG(DEBUG, TAG, "No callback function specified.");
+ OIC_LOG(DEBUG, TAG, "No callback function specified.");
return OC_STACK_INVALID_CALLBACK;
}
char queryUri[MAX_URI_LENGTH] = { '\0' };
snprintf(queryUri, MAX_URI_LENGTH, "coap://%s%s", OC_MULTICAST_PREFIX, OC_RSRVD_RD_URI);
- OC_LOG_V(DEBUG, TAG, "Querying RD: %s\n", queryUri);
+ OIC_LOG_V(DEBUG, TAG, "Querying RD: %s\n", queryUri);
OCRDClientContextCB *cbContext = (OCRDClientContextCB *)OICCalloc(1, sizeof(OCRDClientContextCB));
if (!cbContext)
{
- OC_LOG(ERROR, TAG, "Failed allocating memory.");
+ OIC_LOG(ERROR, TAG, "Failed allocating memory.");
return OC_STACK_NO_MEMORY;
}
*stringLL = (OCStringLL *)OICCalloc(1, sizeof(OCStringLL));
if (!*stringLL)
{
- OC_LOG(ERROR, TAG, "Failed allocating memory.");
+ OIC_LOG(ERROR, TAG, "Failed allocating memory.");
return OC_STACK_NO_MEMORY;
}
(*stringLL)->value = OICStrdup(value);
if (!(*stringLL)->value)
{
- OC_LOG(ERROR, TAG, "Failed copying to OCStringLL.");
+ OIC_LOG(ERROR, TAG, "Failed copying to OCStringLL.");
return OC_STACK_NO_MEMORY;
}
}
cur->next = (OCStringLL *)OICCalloc(1, sizeof(OCStringLL));
if (!cur->next)
{
- OC_LOG(ERROR, TAG, "Failed allocating memory.");
+ OIC_LOG(ERROR, TAG, "Failed allocating memory.");
return OC_STACK_NO_MEMORY;
}
cur->next->value = OICStrdup(value);
if (!cur->next->value)
{
- OC_LOG(ERROR, TAG, "Failed copying to OCStringLL.");
+ OIC_LOG(ERROR, TAG, "Failed copying to OCStringLL.");
return OC_STACK_NO_MEMORY;
}
}
{
if (!addr)
{
- OC_LOG(ERROR, TAG, "RD address not specified.");
+ OIC_LOG(ERROR, TAG, "RD address not specified.");
return OC_STACK_INVALID_PARAM;
}
char targetUri[MAX_URI_LENGTH];
snprintf(targetUri, MAX_URI_LENGTH, "coap://%s:%d%s?rt=%s", addr, port,
OC_RSRVD_RD_URI, OC_RSRVD_RESOURCE_TYPE_RDPUBLISH);
- OC_LOG_V(DEBUG, TAG, "Target URI : %s", targetUri);
+ OIC_LOG_V(DEBUG, TAG, "Target URI : %s", targetUri);
// Gather all resources locally and do publish
OCCallbackData cbData = { 0 };
OCStackResult res = createStringLL(numElement, handle, OCGetResourceTypeName, &rt);
if (res != OC_STACK_OK || !rt)
{
- va_end(arguments);
goto no_memory;
}
}
OCStackResult res = createStringLL(numElement, handle, OCGetResourceInterfaceName, &itf);
if (res != OC_STACK_OK || !itf)
{
- va_end(arguments);
goto no_memory;
}
}
mt = (OCStringLL *)OICCalloc(1, sizeof(OCStringLL));
if (!mt)
{
- va_end(arguments);
goto no_memory;
}
mt->value = OICStrdup("application/json");
if (!mt->value)
{
- va_end(arguments);
goto no_memory;
}
OICStrcpy(rdAddr.addr, MAX_ADDR_STR_SIZE, addr);
rdAddr.port = port;
- OC_LOG_PAYLOAD(DEBUG, (OCPayload *) rdPayload);
+ OIC_LOG_PAYLOAD(DEBUG, (OCPayload *) rdPayload);
return sendRequest(OC_REST_POST, targetUri, &rdAddr, (OCPayload *)rdPayload, cbData);
no_memory:
- OC_LOG(ERROR, TAG, "Failed allocating memory.");
- OCFreeOCStringLL(rt);
- OCFreeOCStringLL(itf);
- OCFreeOCStringLL(mt);
- OCFreeTagsResource(tagsPayload);
- OCFreeLinksResource(linksPayload);
+ OIC_LOG(ERROR, TAG, "Failed allocating memory.");
+ va_end(arguments);
+ if (rt)
+ {
+ OCFreeOCStringLL(rt);
+ }
+ if (itf)
+ {
+ OCFreeOCStringLL(itf);
+ }
+ if (mt)
+ {
+ OCFreeOCStringLL(mt);
+ }
+ if (tagsPayload)
+ {
+ OCFreeTagsResource(tagsPayload);
+ }
+ if (linksPayload)
+ {
+ OCFreeLinksResource(linksPayload);
+ }
OCRDPayloadDestroy(rdPayload);
return OC_STACK_NO_MEMORY;
}