void RMGenerateGatewayID(uint8_t *id, size_t idLen)
{
- OC_LOG(DEBUG, TAG, "RMGenerateGatewayID IN");
+ OIC_LOG(DEBUG, TAG, "RMGenerateGatewayID IN");
OCFillRandomMem(id, idLen);
- OC_LOG(DEBUG, TAG, "RMGenerateGatewayID OUT");
+ OIC_LOG(DEBUG, TAG, "RMGenerateGatewayID OUT");
}
OCStackResult RMInitialize()
{
- OC_LOG(DEBUG, TAG, "RMInitialize IN");
+ OIC_LOG(DEBUG, TAG, "RMInitialize IN");
if (g_isRMInitialized)
{
- OC_LOG(DEBUG, TAG, "RM already initialized");
+ OIC_LOG(DEBUG, TAG, "RM already initialized");
return OC_STACK_OK;
}
OCStackResult result = RMInitGatewayResource();
if (OC_STACK_OK != result)
{
- OC_LOG_V(ERROR, TAG, "RMInitGatewayResource failed[%d]", result);
+ OIC_LOG_V(ERROR, TAG, "RMInitGatewayResource failed[%d]", result);
return result;
}
// Generates a 4 byte Gateway ID.
RMGenerateGatewayID((uint8_t *)&g_GatewayID, sizeof(g_GatewayID));
- OC_LOG_V(INFO, RM_TAG, "Gateway ID: %u", g_GatewayID);
+ OIC_LOG_V(INFO, RM_TAG, "Gateway ID: %u", g_GatewayID);
// Initialize the Routing table manager.
result = RTMInitialize(&g_routingGatewayTable, &g_routingEndpointTable);
if (OC_STACK_OK != result)
{
- OC_LOG_V(ERROR, TAG, "RTMInitialize failed[%d]", result);
+ OIC_LOG_V(ERROR, TAG, "RTMInitialize failed[%d]", result);
return result;
}
result = RMDiscoverGatewayResource();
if (OC_STACK_OK != result)
{
- OC_LOG_V(ERROR, TAG, "RMDiscoverGatewayResource failed[%d]", result);
+ OIC_LOG_V(ERROR, TAG, "RMDiscoverGatewayResource failed[%d]", result);
RTMTerminate(&g_routingGatewayTable, &g_routingEndpointTable);
return result;
}
g_aliveTime = RTMGetCurrentTime();
g_refreshTableTime = g_aliveTime;
- OC_LOG(DEBUG, TAG, "RMInitialize OUT");
+ OIC_LOG(DEBUG, TAG, "RMInitialize OUT");
return result;
}
OCStackResult RMTerminate()
{
- OC_LOG(DEBUG, TAG, "RMTerminate IN");
+ OIC_LOG(DEBUG, TAG, "RMTerminate IN");
if (!g_isRMInitialized)
{
- OC_LOG(ERROR, TAG, "RM not initialized");
+ OIC_LOG(ERROR, TAG, "RM not initialized");
return OC_STACK_ERROR;
}
// Send DELETE request to neighbour nodes
OCStackResult result = RTMTerminate(&g_routingGatewayTable, &g_routingEndpointTable);
if (OC_STACK_OK != result)
{
- OC_LOG_V(ERROR, TAG, "CARegisterRoutingMessageHandler failed[%d]", result);
+ OIC_LOG_V(ERROR, TAG, "CARegisterRoutingMessageHandler failed[%d]", result);
return result;
}
g_isRMInitialized = false;
- OC_LOG(DEBUG, TAG, "RMTerminate OUT");
+ OIC_LOG(DEBUG, TAG, "RMTerminate OUT");
return result;
}
OCStackResult RMHandleGatewayRequest(OCServerRequest *request, const OCResource *resource)
{
- OC_LOG(DEBUG, TAG, "RMHandleGatewayRequest IN");
+ OIC_LOG(DEBUG, TAG, "RMHandleGatewayRequest IN");
if (!g_isRMInitialized)
{
- OC_LOG(ERROR, TAG, "RM not initialized");
+ OIC_LOG(ERROR, TAG, "RM not initialized");
return OC_STACK_ERROR;
}
RM_NULL_CHECK_WITH_RET(request, TAG, "request");
RM_NULL_CHECK_WITH_RET(resource, TAG, "resource");
- OC_LOG_V(DEBUG, TAG, "Received request of method: %d", request->method);
+ OIC_LOG_V(DEBUG, TAG, "Received request of method: %d", request->method);
if (OC_REST_GET == request->method)
{
switch((OCObserveAction)request->observationOption)
{
case OC_OBSERVE_REGISTER:
- OC_LOG(DEBUG, TAG, "Received OBSERVE request");
+ OIC_LOG(DEBUG, TAG, "Received OBSERVE request");
RMHandleOBSERVERequest(request, resource);
break;
case OC_OBSERVE_DEREGISTER:
//TODO: Handle this case
- OC_LOG(DEBUG, TAG, "Received OBSERVE deregister");
+ OIC_LOG(DEBUG, TAG, "Received OBSERVE deregister");
break;
case OC_OBSERVE_NO_OPTION:
- OC_LOG(DEBUG, TAG, "Received GET request");
+ OIC_LOG(DEBUG, TAG, "Received GET request");
RMHandleGETRequest(request, resource);
break;
default:
- OC_LOG(DEBUG, TAG, "Not Supported by Routing Manager");
+ OIC_LOG(DEBUG, TAG, "Not Supported by Routing Manager");
}
}
else if (OC_REST_DELETE == request->method)
{
- OC_LOG(DEBUG, TAG, "Received a Delete request");
+ OIC_LOG(DEBUG, TAG, "Received a Delete request");
RMHandleDELETERequest(request, resource);
}
- OC_LOG(DEBUG, TAG, "RMHandleGatewayRequest OUT");
+ OIC_LOG(DEBUG, TAG, "RMHandleGatewayRequest OUT");
return OC_STACK_OK;
}
OCStackResult RMHandleRequestPayload(OCDevAddr devAddr, const uint8_t *reqPayload,
size_t payloadSize)
{
- OC_LOG(DEBUG, TAG, "RMHandleRequestPayload IN");
+ OIC_LOG(DEBUG, TAG, "RMHandleRequestPayload IN");
RM_NULL_CHECK_WITH_RET(reqPayload, TAG, "reqPayload");
uint32_t gatewayId = 0;
OCStackResult result = RMPParseRequestPayload(reqPayload, payloadSize, &gatewayId);
RM_VERIFY_SUCCESS(result, OC_STACK_OK);
- OC_LOG(INFO, TAG, "RMPParseRequestPayload is success");
+ OIC_LOG(INFO, TAG, "RMPParseRequestPayload is success");
// Check if the entry is its own.
if (gatewayId == g_GatewayID)
{
- OC_LOG(INFO, TAG, "Own Request Received!!");
+ OIC_LOG(INFO, TAG, "Own Request Received!!");
return OC_STACK_CONTINUE;
}
CAEndpoint_t endpoint = {.adapter = CA_DEFAULT_ADAPTER};
CopyDevAddrToEndpoint(&devAddr, &endpoint);
- OC_LOG_V(INFO, TAG, "Add the gateway ID: %u", gatewayId);
+ OIC_LOG_V(INFO, TAG, "Add the gateway ID: %u", gatewayId);
RTMDestIntfInfo_t destInterfaces = {.observerId = 0};
destInterfaces.destIntfAddr = endpoint;
result = RTMAddGatewayEntry(gatewayId, 0, 1, &destInterfaces, &g_routingGatewayTable);
if (OC_STACK_OK != result)
{
- OC_LOG(DEBUG, TAG, "Gateway was not added to the routing table");
+ OIC_LOG(DEBUG, TAG, "Gateway was not added to the routing table");
return result;
}
- OC_LOG(INFO, TAG, "Gateway was added");
+ OIC_LOG(INFO, TAG, "Gateway was added");
// Create a list to add the updated entries and notify the observers
u_linklist_t *updatedTableList = u_linklist_create();
if(!updatedTableList)
{
- OC_LOG(DEBUG, TAG, "Failure to notify");
+ OIC_LOG(DEBUG, TAG, "Failure to notify");
return OC_STACK_NO_MEMORY;
}
&updatedPayload);
if (OC_STACK_OK != result)
{
- OC_LOG_V(ERROR, TAG, "RMPConstructObserveResPayload failed[%d]", result);
+ OIC_LOG_V(ERROR, TAG, "RMPConstructObserveResPayload failed[%d]", result);
RMPFreePayload(updatedPayload);
goto exit;
}
exit:
u_linklist_free(&updatedTableList);
- OC_LOG(DEBUG, TAG, "RMHandleRequestPayload OUT");
+ OIC_LOG(DEBUG, TAG, "RMHandleRequestPayload OUT");
return result;
}
OCStackResult RMHandleResponsePayload(const OCDevAddr *devAddr, const OCRepPayload *respPayload)
{
- OC_LOG(DEBUG, TAG, "RMHandleResponsePayload IN");
+ OIC_LOG(DEBUG, TAG, "RMHandleResponsePayload IN");
RM_NULL_CHECK_WITH_RET(respPayload, TAG, "respPayload");
// Parse the Payload to get the Gateway ID of neighbouring node.
// Check if the entry is its own.
if (gatewayId == g_GatewayID)
{
- OC_LOG(INFO, TAG, "-------------->Own entry, continue!!");
+ OIC_LOG(INFO, TAG, "-------------->Own entry, continue!!");
RTMFreeGatewayRouteTable(&gatewayTableList);
return OC_STACK_ERROR;
}
destInterfaces.destIntfAddr = endpoint;
if (0 < seqNum)
{
- OC_LOG_V(DEBUG, TAG, "Sequence Number of Resp payload is %d, Forceupdate: %d",
+ OIC_LOG_V(DEBUG, TAG, "Sequence Number of Resp payload is %d, Forceupdate: %d",
seqNum, isUpdateSeqNum);
result = RTMUpdateEntryParameters(gatewayId, seqNum, &destInterfaces,
&g_routingGatewayTable, isUpdateSeqNum);
if (OC_STACK_COMM_ERROR == result)
{
- OC_LOG(ERROR, TAG, "Few packet drops are found, sequence number is not matching");
+ OIC_LOG(ERROR, TAG, "Few packet drops are found, sequence number is not matching");
// Send a observe request to the gateway.
RMSendObserveRequest(devAddr, NULL);
RTMFreeGatewayRouteTable(&gatewayTableList);
}
else if (OC_STACK_DUPLICATE_REQUEST == result)
{
- OC_LOG(ERROR, TAG, "Same sequence number is received");
+ OIC_LOG(ERROR, TAG, "Same sequence number is received");
RTMFreeGatewayRouteTable(&gatewayTableList);
return result;
}
RTMGatewayEntry_t *headPtr = u_linklist_get_data(gatewayTableList->list);
if (headPtr && 0 == headPtr->routeCost)
{
- OC_LOG(INFO, TAG, "Remove entry is called");
+ OIC_LOG(INFO, TAG, "Remove entry is called");
doRemoveEntry = true;
}
}
u_linklist_t *updatedTableList = u_linklist_create();
if(!updatedTableList)
{
- OC_LOG(DEBUG, TAG, "Failed to allocate memory");
+ OIC_LOG(DEBUG, TAG, "Failed to allocate memory");
return OC_STACK_NO_MEMORY;
}
u_linklist_t *alternativeRouteList = u_linklist_create();
if(!alternativeRouteList)
{
- OC_LOG(DEBUG, TAG, "Failed to allocate memory");
+ OIC_LOG(DEBUG, TAG, "Failed to allocate memory");
return OC_STACK_NO_MEMORY;
}
OCRepPayload *updatedPayload = NULL;
if (false == doRemoveEntry)
{
- OC_LOG_V(INFO, TAG, "Add the gateway ID: %u", gatewayId);
+ OIC_LOG_V(INFO, TAG, "Add the gateway ID: %u", gatewayId);
result = RTMAddGatewayEntry(gatewayId, 0, 1, &destInterfaces, &g_routingGatewayTable);
if (OC_STACK_OK == result)
{
- OC_LOG(INFO, TAG, "Node was added");
+ OIC_LOG(INFO, TAG, "Node was added");
RTMGatewayId_t gwId = {.gatewayId = gatewayId};
RTMGatewayEntry_t newNode;
newNode.destination = &gwId;
if (NULL == gatewayTableList)
{
- OC_LOG(INFO, TAG, "Received a Discover Payload");
+ OIC_LOG(INFO, TAG, "Received a Discover Payload");
g_sequenceNumber++;
result = RMPConstructObserveResPayload(g_GatewayID, g_sequenceNumber,
updatedTableList, false,
// Check if the entry is its own.
if (!entry || entry->destination->gatewayId == g_GatewayID)
{
- OC_LOG(INFO, TAG, "Ignore entry, continue!!");
+ OIC_LOG(INFO, TAG, "Ignore entry, continue!!");
u_linklist_get_next(&iterTable);
continue;
}
- OC_LOG_V(INFO, TAG, "Gateway ID: %u", entry->destination->gatewayId);
+ OIC_LOG_V(INFO, TAG, "Gateway ID: %u", entry->destination->gatewayId);
if (true == doRemoveEntry)
{
// Remove the entry from RTM.
if (OC_STACK_OK == result)
{
- OC_LOG(INFO, TAG, "Gateway was added/removed");
+ OIC_LOG(INFO, TAG, "Gateway was added/removed");
u_linklist_add(updatedTableList, (void *)entry);
RTMPrintTable(g_routingGatewayTable, g_routingEndpointTable);
}
if ( 0 < u_linklist_length(alternativeRouteList))
{
- OC_LOG(DEBUG, TAG, "Alternative routing found");
+ OIC_LOG(DEBUG, TAG, "Alternative routing found");
// Send the notification.
OCRepPayload *removeTablePayload = NULL;
g_sequenceNumber++;
&removeTablePayload);
if (OC_STACK_OK != result)
{
- OC_LOG_V(ERROR, TAG, "RMPConstructObserveResPayload failed[%d]", result);
+ OIC_LOG_V(ERROR, TAG, "RMPConstructObserveResPayload failed[%d]", result);
RMPFreePayload(removeTablePayload);
goto exit;
}
if ( 0 >= u_linklist_length(updatedTableList))
{
- OC_LOG_V(DEBUG, TAG, "No updation is needed, Length is %d",
+ OIC_LOG_V(DEBUG, TAG, "No updation is needed, Length is %d",
u_linklist_length(updatedTableList));
goto exit;
}
RTMFreeGatewayRouteTable(&gatewayTableList);
u_linklist_free(&updatedTableList);
u_linklist_free(&alternativeRouteList);
- OC_LOG(DEBUG, TAG, "RMHandleResponsePayload OUT");
+ OIC_LOG(DEBUG, TAG, "RMHandleResponsePayload OUT");
return OC_STACK_OK;
}
OCStackResult RMHandleGETRequest(const OCServerRequest *request, const OCResource *resource)
{
- OC_LOG(DEBUG, TAG, "RMHandleGETRequest IN");
+ OIC_LOG(DEBUG, TAG, "RMHandleGETRequest IN");
RM_NULL_CHECK_WITH_RET(request, TAG, "request");
RM_NULL_CHECK_WITH_RET(resource, TAG, "resource");
OCStackResult result = RMPConstructGatewayPayload(g_GatewayID, &payload);
if (OC_STACK_OK != result)
{
- OC_LOG_V(DEBUG, TAG, "RMPConstructDiscoverPayload failed[%d]", result);
+ OIC_LOG_V(DEBUG, TAG, "RMPConstructDiscoverPayload failed[%d]", result);
return result;
}
result = RMSendResponse(request, resource, payload);
if (OC_STACK_OK != result)
{
- OC_LOG_V(DEBUG, TAG, "Send response failed[%d]", result);
+ OIC_LOG_V(DEBUG, TAG, "Send response failed[%d]", result);
RMPFreePayload(payload);
return result;
}
result = RMSendObserveRequest(&(request->devAddr), NULL);
if (OC_STACK_OK != result)
{
- OC_LOG_V(DEBUG, TAG, "Send response failed[%d]", result);
+ OIC_LOG_V(DEBUG, TAG, "Send response failed[%d]", result);
}
- OC_LOG(DEBUG, TAG, "RMHandleGETRequest OUT");
+ OIC_LOG(DEBUG, TAG, "RMHandleGETRequest OUT");
return result;
}
OCStackResult RMHandleOBSERVERequest(OCServerRequest *request, const OCResource *resource)
{
- OC_LOG(DEBUG, TAG, "RMHandleOBSERVERequest IN");
+ OIC_LOG(DEBUG, TAG, "RMHandleOBSERVERequest IN");
RM_NULL_CHECK_WITH_RET(request, TAG, "request");
RM_NULL_CHECK_WITH_RET(resource, TAG, "resource");
OCObservationId obsID = 0;
OCStackResult result = RMAddObserver(request, &obsID);
RM_VERIFY_SUCCESS(result, OC_STACK_OK);
- OC_LOG_V(DEBUG, TAG, "Observer ID is %d", obsID);
+ OIC_LOG_V(DEBUG, TAG, "Observer ID is %d", obsID);
// Get the Routing table from RTM
OCRepPayload *payload = NULL;
RTMPrintTable(g_routingGatewayTable, g_routingEndpointTable);
- OC_LOG(DEBUG, TAG, "Construct Routing table payload");
+ OIC_LOG(DEBUG, TAG, "Construct Routing table payload");
result = RMPConstructObserveResPayload(g_GatewayID, g_sequenceNumber,
g_routingGatewayTable, true,
&payload);
if (OC_STACK_OK != result)
{
- OC_LOG_V(ERROR, TAG, "RMPConstructObserveResPayload failed[%d]", result);
+ OIC_LOG_V(ERROR, TAG, "RMPConstructObserveResPayload failed[%d]", result);
RMPFreePayload(payload);
goto exit;
}
RMPFreePayload(payload);
RM_VERIFY_SUCCESS(result, OC_STACK_OK);
exit:
- OC_LOG(DEBUG, TAG, "RMHandleOBSERVERequest OUT");
+ OIC_LOG(DEBUG, TAG, "RMHandleOBSERVERequest OUT");
return result;
}
OCStackResult RMHandleDELETERequest(const OCServerRequest *request, const OCResource *resource)
{
- OC_LOG(DEBUG, TAG, "RMHandleDELETERequest IN");
+ OIC_LOG(DEBUG, TAG, "RMHandleDELETERequest IN");
RM_NULL_CHECK_WITH_RET(request, TAG, "request");
RM_NULL_CHECK_WITH_RET(resource, TAG, "resource");
OCStackResult result = RMPParseRequestPayload(request->payload, request->payloadSize,
&gatewayId);
RM_VERIFY_SUCCESS(result, OC_STACK_OK);
- OC_LOG(INFO, TAG, "RMPParseRequestPayload is success");
+ OIC_LOG(INFO, TAG, "RMPParseRequestPayload is success");
- OC_LOG_V(INFO, TAG, "Remove the gateway ID: %u", gatewayId);
+ OIC_LOG_V(INFO, TAG, "Remove the gateway ID: %u", gatewayId);
u_linklist_t *removedGatewayNodes = NULL;
result = RTMRemoveGatewayEntry(gatewayId, &removedGatewayNodes, &g_routingGatewayTable);
false, &resPayloads);
if (OC_STACK_OK != result)
{
- OC_LOG_V(ERROR, TAG, "RMPConstructRemovalPayload failed[%d]", result);
+ OIC_LOG_V(ERROR, TAG, "RMPConstructRemovalPayload failed[%d]", result);
RMPFreePayload(resPayloads);
goto exit;
}
exit:
RTMFreeGatewayRouteTable(&removedGatewayNodes);
- OC_LOG(DEBUG, TAG, "RMHandleDELETERequest OUT");
+ OIC_LOG(DEBUG, TAG, "RMHandleDELETERequest OUT");
return result;
}
OCStackResult RMAddObserver(OCServerRequest *request, OCObservationId *obsID)
{
- OC_LOG(DEBUG, TAG, "RMAddObserverForGateway OUT");
+ OIC_LOG(DEBUG, TAG, "RMAddObserverForGateway OUT");
RM_NULL_CHECK_WITH_RET(request, TAG, "request");
RM_NULL_CHECK_WITH_RET(obsID, TAG, "obsID");
// Check if observer is already added.
if (true == RTMIsObserverPresent(endpoint, obsID, g_routingGatewayTable))
{
- OC_LOG(DEBUG, TAG, "Observer is present");
+ OIC_LOG(DEBUG, TAG, "Observer is present");
request->observeResult = OC_STACK_OK;
return OC_STACK_OK;
}
request->observeResult = result;
if (OC_STACK_OK == result)
{
- OC_LOG(DEBUG, TAG, "Added observer successfully");
+ OIC_LOG(DEBUG, TAG, "Added observer successfully");
// Add the observer to the list.
result = RTMAddObserver(*obsID, endpoint, &g_routingGatewayTable);
if (OC_STACK_OK != result)
{
- OC_LOG_V(DEBUG, TAG, "RMAddObserver failed[%d]", result);
+ OIC_LOG_V(DEBUG, TAG, "RMAddObserver failed[%d]", result);
}
}
- OC_LOG(DEBUG, TAG, "RMAddObserverForGateway OUT");
+ OIC_LOG(DEBUG, TAG, "RMAddObserverForGateway OUT");
return result;
}
OCStackResult RMSendNotificationToAll(const OCRepPayload *payload)
{
- OC_LOG(DEBUG, TAG, "RMSendNotificationToAll IN");
+ OIC_LOG(DEBUG, TAG, "RMSendNotificationToAll IN");
RM_NULL_CHECK_WITH_RET(payload, TAG, "payload");
OCObservationId *obsList = NULL;
// Get the complete observer list.
RTMGetObserverList(&obsList, &obsLen, g_routingGatewayTable);
OCStackResult result = OC_STACK_OK;
- OC_LOG_V(DEBUG, TAG, "Number of observers is %d", obsLen);
+ OIC_LOG_V(DEBUG, TAG, "Number of observers is %d", obsLen);
if (0 < obsLen)
{
// Send notification to the list of observers.
- OC_LOG_V(DEBUG, TAG, "Sending notification with Sequence Number: %d", g_sequenceNumber);
+ OIC_LOG_V(DEBUG, TAG, "Sending notification with Sequence Number: %d", g_sequenceNumber);
result = RMSendNotificationForListofObservers(obsList, obsLen, payload);
RM_VERIFY_SUCCESS(result, OC_STACK_OK);
g_aliveTime = RTMGetCurrentTime();
exit:
OICFree(obsList);
- OC_LOG(DEBUG, TAG, "RMSendNotificationToAll OUT");
+ OIC_LOG(DEBUG, TAG, "RMSendNotificationToAll OUT");
return result;
}
false, &payload);
if (OC_STACK_OK != result)
{
- OC_LOG_V(ERROR, TAG, "RMPConstructObserveResPayload failed[%d]", result);
+ OIC_LOG_V(ERROR, TAG, "RMPConstructObserveResPayload failed[%d]", result);
RMPFreePayload(payload);
goto exit;
}
- OC_LOG(DEBUG, TAG, "Sending the alive notification to all");
+ OIC_LOG(DEBUG, TAG, "Sending the alive notification to all");
// Send notification for every 15s to all the neighbours.
result = RMSendNotificationToAll(payload);
RMPFreePayload(payload);
if (ROUTINGTABLE_VALIDATION_TIMEOUT <= currentTime - g_refreshTableTime)
{
- OC_LOG(DEBUG, TAG, "Validating the routing table");
+ OIC_LOG(DEBUG, TAG, "Validating the routing table");
u_linklist_t *removedEntries = NULL;
// Remove the invalid gateway entries.
RTMRemoveInvalidGateways(&removedEntries, &g_routingGatewayTable);
RTMFreeGatewayRouteTable(&removedEntries);
if (OC_STACK_OK != result)
{
- OC_LOG_V(ERROR, TAG, "RMPConstructRemovalPayload failed[%d]", result);
+ OIC_LOG_V(ERROR, TAG, "RMPConstructRemovalPayload failed[%d]", result);
RMPFreePayload(resPayloads);
goto exit;
}
if (!g_isValidated && ROUTINGTABLE_REFRESH_TIMEOUT <= (currentTime - g_refreshTableTime))
{
- OC_LOG_V(DEBUG, TAG, "Refreshing the routing table: %llu", currentTime);
+ OIC_LOG_V(DEBUG, TAG, "Refreshing the routing table: %llu", currentTime);
u_linklist_t* invalidInterfaces = NULL;
RTMUpdateDestAddrValidity(&invalidInterfaces, &g_routingGatewayTable);
if (0 < u_linklist_length(invalidInterfaces))
OCStackResult RMGetGatewayPayload(OCRepPayload **payload)
{
- OC_LOG(DEBUG, TAG, "RMGetGatewayPayload IN");
+ OIC_LOG(DEBUG, TAG, "RMGetGatewayPayload IN");
OCStackResult result = RMPConstructGatewayPayload(g_GatewayID, payload);
- OC_LOG_V(DEBUG, TAG, "RMPConstructDiscoverPayload result is %d", result);
- OC_LOG(DEBUG, TAG, "RMGetGatewayPayload OUT");
+ OIC_LOG_V(DEBUG, TAG, "RMPConstructDiscoverPayload result is %d", result);
+ OIC_LOG(DEBUG, TAG, "RMGetGatewayPayload OUT");
return result;
}
void RMSendDeleteToNeighbourNodes()
{
- OC_LOG(DEBUG, TAG, "RMSendDeleteToNeighbourNodes IN");
+ OIC_LOG(DEBUG, TAG, "RMSendDeleteToNeighbourNodes IN");
u_linklist_t *neighbourNodes = NULL;
RTMGetNeighbours(&neighbourNodes, g_routingGatewayTable);
if (0 >= u_linklist_length(neighbourNodes))
{
- OC_LOG(DEBUG, TAG, "No neighbour nodes present");
+ OIC_LOG(DEBUG, TAG, "No neighbour nodes present");
return;
}
OCStackResult result = RMPConstructGatewayPayload(g_GatewayID, &payload);
if (OC_STACK_OK != result)
{
- OC_LOG_V(DEBUG, TAG, "RMPConstructGatewayPayload failed[%d]", result);
+ OIC_LOG_V(DEBUG, TAG, "RMPConstructGatewayPayload failed[%d]", result);
RMPFreePayload(payload);
u_linklist_free(&neighbourNodes);
return;
RTMDestIntfInfo_t *dest = u_arraylist_get(entry->destination->destIntfAddr, i);
if (!dest)
{
- OC_LOG(ERROR, RM_TAG, "Failed to get dest address");
+ OIC_LOG(ERROR, RM_TAG, "Failed to get dest address");
continue;
}
OCDevAddr devAddr = {.adapter = OC_DEFAULT_ADAPTER};
CopyEndpointToDevAddr(&(dest->destIntfAddr), &devAddr);
- OC_LOG_V(DEBUG, TAG, "\nDestination interface addresses: %s[%d], OCDevAddr: %s[%d]",
+ OIC_LOG_V(DEBUG, TAG, "\nDestination interface addresses: %s[%d], OCDevAddr: %s[%d]",
dest->destIntfAddr.addr, dest->destIntfAddr.port, devAddr.addr, devAddr.port);
RMSendDeleteRequest(&devAddr, payload);
}
}
u_linklist_free(&neighbourNodes);
- OC_LOG(DEBUG, TAG, "RMSendDeleteToNeighbourNodes OUT");
+ OIC_LOG(DEBUG, TAG, "RMSendDeleteToNeighbourNodes OUT");
}
uint32_t RMGetGatewayId()
{
if (!g_isRMInitialized)
{
- OC_LOG(ERROR, TAG, "RM not initialized");
+ OIC_LOG(ERROR, TAG, "RM not initialized");
return 0;
}
return g_GatewayID;
{
if (!g_isRMInitialized)
{
- OC_LOG(DEBUG, TAG, "RM not initialized");
+ OIC_LOG(DEBUG, TAG, "RM not initialized");
return 0;
}
return ++g_mcastsequenceNumber;
RMGetRouteOptionIndex(info->options, info->numOptions, &routeIndex);
if (-1 >= routeIndex)
{
- OC_LOG(ERROR, RM_TAG, "No route option present. Let RI Handle");
+ OIC_LOG(ERROR, RM_TAG, "No route option present. Let RI Handle");
// Let RI handle this packet.
*selfDestination = true;
return OC_STACK_OK;
OCStackResult res = RMParseRouteOption(&info->options[routeIndex], &routeOption);
if (OC_STACK_OK != res)
{
- OC_LOG_V(ERROR, RM_TAG, "RMParseRouteOption failed");
+ OIC_LOG_V(ERROR, RM_TAG, "RMParseRouteOption failed");
return OC_STACK_ERROR;
}
*/
if (g_GatewayID == routeOption.srcGw)
{
- OC_LOG_V(ERROR, RM_TAG, "Packet is of its own");
+ OIC_LOG_V(ERROR, RM_TAG, "Packet is of its own");
if (0 == routeOption.destGw && g_mcastsequenceNumber < routeOption.mSeqNum)
{
g_mcastsequenceNumber = routeOption.mSeqNum;
}
else if (0 == routeOption.srcGw)
{
- OC_LOG(INFO, RM_TAG, "Source missing in option");
+ OIC_LOG(INFO, RM_TAG, "Source missing in option");
// Packet from end device as Gateway will add source in option.
uint16_t endpointId = g_EndpointCount + 1;
OCStackResult res = RTMAddEndpointEntry(&endpointId, sender, &g_routingEndpointTable);
if (OC_STACK_OK == res)
{
g_EndpointCount = endpointId;
- OC_LOG_V(INFO, RM_TAG, "New endpoint added [%d]:[%s]", g_EndpointCount, sender->addr);
+ OIC_LOG_V(INFO, RM_TAG, "New endpoint added [%d]:[%s]", g_EndpointCount, sender->addr);
}
else if (OC_STACK_DUPLICATE_REQUEST == res)
{
- OC_LOG_V(INFO, RM_TAG, "Endpoint exist [%d]", endpointId);
+ OIC_LOG_V(INFO, RM_TAG, "Endpoint exist [%d]", endpointId);
}
else
{
- OC_LOG(ERROR, RM_TAG, "Add Endpoint failed");
+ OIC_LOG(ERROR, RM_TAG, "Add Endpoint failed");
return OC_STACK_ERROR;
}
// add source option.
routeOption.srcGw = g_GatewayID;
routeOption.srcEp = endpointId;
- OC_LOG_V(INFO, RM_TAG, "Added source: [%u:%u]", g_GatewayID, endpointId);
+ OIC_LOG_V(INFO, RM_TAG, "Added source: [%u:%u]", g_GatewayID, endpointId);
}
/*
*/
if (0 == routeOption.destGw)
{
- OC_LOG(INFO, RM_TAG, "Destination missing in option");
+ OIC_LOG(INFO, RM_TAG, "Destination missing in option");
// This is a multicast packet.
if (g_GatewayID == routeOption.srcGw)
{
if (OC_STACK_OK != update)
{
// this shouldnt have been forwarded. ignore.
- OC_LOG_V(ERROR, RM_TAG, "Multicast Sequence number not proper: %d",
+ OIC_LOG_V(ERROR, RM_TAG, "Multicast Sequence number not proper: %d",
routeOption.mSeqNum);
return OC_STACK_ERROR;
}
}
else if (g_GatewayID == routeOption.destGw)
{
- OC_LOG(INFO, RM_TAG, "GatewayId found in destination");
+ OIC_LOG(INFO, RM_TAG, "GatewayId found in destination");
/*
* This unicast packet either belongs to us or any of our connected end devices
* check if packet belongs to end device.
if (0 != routeOption.destEp)
{
// forward packet to the client.
- OC_LOG_V(INFO, RM_TAG, "Forwarding packet to client id [%u]", routeOption.destEp);
+ OIC_LOG_V(INFO, RM_TAG, "Forwarding packet to client id [%u]", routeOption.destEp);
CAEndpoint_t *clientInfo = RTMGetEndpointEntry(routeOption.destEp,
g_routingEndpointTable);
if(!clientInfo)
{
- OC_LOG(ERROR, RM_TAG, "Failed to get Client info");
+ OIC_LOG(ERROR, RM_TAG, "Failed to get Client info");
return OC_STACK_ERROR;
}
else
{
// packet is for us.
- OC_LOG(INFO, RM_TAG, "Received packet for self");
+ OIC_LOG(INFO, RM_TAG, "Received packet for self");
forward = false;
*selfDestination = true;
goto rewriteandexit;
* This unicast packet belongs to other gateway.
* we only want to print first 4 bytes of packet as readable GatewayId.
*/
- OC_LOG_V(INFO, RM_TAG, "Forwarding packet to Gateway: %u", routeOption.destGw);
+ OIC_LOG_V(INFO, RM_TAG, "Forwarding packet to Gateway: %u", routeOption.destGw);
RTMGatewayId_t *nextHopGw = RTMGetNextHop(routeOption.destGw, g_routingGatewayTable);
if(!nextHopGw)
{
- OC_LOG(ERROR, RM_TAG, "Failed to get next hop");
+ OIC_LOG(ERROR, RM_TAG, "Failed to get next hop");
return OC_STACK_ERROR;
}
RTMDestIntfInfo_t *address = u_arraylist_get(nextHopGw->destIntfAddr, 0);
if (!address)
{
- OC_LOG(ERROR, RM_TAG, "Failed to get address for next hop");
+ OIC_LOG(ERROR, RM_TAG, "Failed to get address for next hop");
return OC_STACK_ERROR;
}
// Don't forward any packet meant for gateway resource.
if (info->resourceUri && (0 == strcmp(info->resourceUri, OC_RSRVD_GATEWAY_URI)))
{
- OC_LOG(ERROR, RM_TAG, "Not forwarding gateway resource packet");
+ OIC_LOG(ERROR, RM_TAG, "Not forwarding gateway resource packet");
}
else if (sender->flags & CA_SECURE)
{
- OC_LOG(ERROR, RM_TAG, "This is secured request. Not supported by routing manager");
+ OIC_LOG(ERROR, RM_TAG, "This is secured request. Not supported by routing manager");
return OC_STACK_ERROR;
}
else
res = RMCreateRouteOption(&routeOption, &info->options[routeIndex]);
if (OC_STACK_OK != res)
{
- OC_LOG_V(ERROR, RM_TAG, "Rewriting RM option failed");
+ OIC_LOG_V(ERROR, RM_TAG, "Rewriting RM option failed");
return res;
}
/*
CAResult_t caRes = CASendRequest(&nextHop, msg);
if (CA_STATUS_OK != caRes)
{
- OC_LOG_V(ERROR, RM_TAG, "Failed to forward request to next hop [%d][%s]", caRes,
+ OIC_LOG_V(ERROR, RM_TAG, "Failed to forward request to next hop [%d][%s]", caRes,
nextHop.addr);
if(0 == routeOption.destGw)
{
CAResult_t caRes = CASendResponse(&nextHop, msg);
if (CA_STATUS_OK != caRes)
{
- OC_LOG_V(ERROR, RM_TAG, "Failed to forward response to next hop [%d][%s]",
+ OIC_LOG_V(ERROR, RM_TAG, "Failed to forward response to next hop [%d][%s]",
caRes, nextHop.addr);
// Since a response is always unicast, return error here.
return OC_STACK_ERROR;
}
}
- OC_LOG_V(INFO, RM_TAG, "Sender: [%u] Destination: [%u]", routeOption.srcGw, routeOption.destGw);
+ OIC_LOG_V(INFO, RM_TAG, "Sender: [%u] Destination: [%u]", routeOption.srcGw, routeOption.destGw);
return OC_STACK_OK;
}
{
if (!g_isRMInitialized)
{
- OC_LOG(ERROR, TAG, "RM not initialized");
+ OIC_LOG(ERROR, TAG, "RM not initialized");
*selfDestination = true;
return OC_STACK_OK;
}
{
if (!g_isRMInitialized)
{
- OC_LOG(ERROR, TAG, "RM not initialized");
+ OIC_LOG(ERROR, TAG, "RM not initialized");
*selfDestination = true;
return OC_STACK_OK;
}
case OC_DEFAULT_ADAPTER:
break;
default:
- OC_LOG(DEBUG, TAG, "Default option will be selected");
+ OIC_LOG(DEBUG, TAG, "Default option will be selected");
}
return CT_DEFAULT;
}
OCStackResult RMInitGatewayResource()
{
- OC_LOG(DEBUG, TAG, "RMInitGatewayResource IN");
+ OIC_LOG(DEBUG, TAG, "RMInitGatewayResource IN");
// Create a Gateway resource
OCStackResult result = OCCreateResource(&g_gateWayHandle,
if (OC_STACK_OK != result)
{
- OC_LOG_V(ERROR, TAG, "Create resource for gateway failed[%d]", result);
+ OIC_LOG_V(ERROR, TAG, "Create resource for gateway failed[%d]", result);
}
- OC_LOG(DEBUG, TAG, "RMInitGatewayResource OUT");
+ OIC_LOG(DEBUG, TAG, "RMInitGatewayResource OUT");
return result;
}
OCStackResult RMDiscoverGatewayResource()
{
- OC_LOG(DEBUG, TAG, "RMDiscoverGatewayResource IN");
+ OIC_LOG(DEBUG, TAG, "RMDiscoverGatewayResource IN");
OCCallbackData discoverData = {.cb = RMDiscoverGatewayCallback};
OCStackResult result = OC_STACK_OK;
CT_ADAPTER_IP, OC_LOW_QOS, &discoverData, NULL, 0);
usleep(100000);
}
- OC_LOG(DEBUG, TAG, "RMDiscoverGatewayResource OUT");
+ OIC_LOG(DEBUG, TAG, "RMDiscoverGatewayResource OUT");
return result;
}
OCStackApplicationResult RMDiscoverGatewayCallback(void* ctx, OCDoHandle handle,
OCClientResponse * clientResponse)
{
- OC_LOG(DEBUG, TAG, "RMDiscoverGatewayCallback IN");
+ OIC_LOG(DEBUG, TAG, "RMDiscoverGatewayCallback IN");
(void)ctx;
(void)handle;
if (NULL == clientResponse)
{
- OC_LOG(DEBUG, TAG, "clientResponse is NULL");
+ OIC_LOG(DEBUG, TAG, "clientResponse is NULL");
return OC_STACK_KEEP_TRANSACTION;
}
(OCRepPayload *)clientResponse->payload);
if (OC_STACK_OK != result)
{
- OC_LOG_V(ERROR, TAG, "RMHandleResponsePayload Failed[%d]", result);
+ OIC_LOG_V(ERROR, TAG, "RMHandleResponsePayload Failed[%d]", result);
}
OCRepPayload *payload = NULL;
result= RMGetGatewayPayload(&payload);
if (OC_STACK_OK != result)
{
- OC_LOG_V(ERROR, TAG, "RMGetGatewayPayload Failed[%d]", result);
+ OIC_LOG_V(ERROR, TAG, "RMGetGatewayPayload Failed[%d]", result);
}
RMSendObserveRequest(&(clientResponse->devAddr), payload);
- OC_LOG(DEBUG, TAG, "RMDiscoverGatewayCallback OUT");
+ OIC_LOG(DEBUG, TAG, "RMDiscoverGatewayCallback OUT");
return OC_STACK_KEEP_TRANSACTION;
}
OCStackResult RMSendObserveRequest(const OCDevAddr *devAddr, OCRepPayload *payload)
{
- OC_LOG(DEBUG, TAG, "RMSendObserveRequest IN");
- OC_LOG_V(DEBUG, TAG, "Destination address is %s:%d", devAddr->addr, devAddr->port);
+ OIC_LOG(DEBUG, TAG, "RMSendObserveRequest IN");
+ OIC_LOG_V(DEBUG, TAG, "Destination address is %s:%d", devAddr->addr, devAddr->port);
OCCallbackData observeData = {.cb = RMObserveRequestCallback};
- OC_LOG(DEBUG, TAG, "RMSendObserveRequest OUT");
+ OIC_LOG(DEBUG, TAG, "RMSendObserveRequest OUT");
return OCDoResource(NULL, OC_REST_OBSERVE, GW_RESOURCE_URI, devAddr, (OCPayload *)payload,
RMGetConnectivityType(devAddr->adapter), OC_HIGH_QOS,
OCStackResult RMSendDeleteRequest(const OCDevAddr *devAddr, OCRepPayload *payload)
{
- OC_LOG(DEBUG, TAG, "RMSendDeleteRequest IN");
+ OIC_LOG(DEBUG, TAG, "RMSendDeleteRequest IN");
RM_NULL_CHECK_WITH_RET(payload, TAG, "payload");
- OC_LOG_V(DEBUG, TAG, "Destination address is %s:%d", devAddr->addr, devAddr->port);
+ OIC_LOG_V(DEBUG, TAG, "Destination address is %s:%d", devAddr->addr, devAddr->port);
OCCallbackData deleteCb = {.cb = RMDiscoverGatewayCallback};
- OC_LOG(DEBUG, TAG, "RMSendDeleteRequest OUT");
+ OIC_LOG(DEBUG, TAG, "RMSendDeleteRequest OUT");
return OCDoResource(NULL, OC_REST_DELETE, GW_RESOURCE_URI, devAddr, (OCPayload *)payload,
RMGetConnectivityType(devAddr->adapter), OC_LOW_QOS,
&deleteCb, NULL, 0);
OCStackResult RMSendResponse(const OCServerRequest *request, const OCResource *resource,
const OCRepPayload *payload)
{
- OC_LOG(DEBUG, TAG, "RMSendResponse IN");
+ OIC_LOG(DEBUG, TAG, "RMSendResponse IN");
OCEntityHandlerResponse response = {.ehResult = OC_EH_OK,
.payload = (OCPayload *)payload,
.persistentBufferFlag = 0,
.requestHandle = (OCRequestHandle) request,
.resourceHandle = (OCResourceHandle) resource
};
- OC_LOG(DEBUG, TAG, "RMSendResponse OUT");
+ OIC_LOG(DEBUG, TAG, "RMSendResponse OUT");
return OCDoResponse(&response);
}
OCStackResult RMSendNotificationForListofObservers(OCObservationId *obsId, uint8_t obsLen,
const OCRepPayload *payload)
{
- OC_LOG(DEBUG, TAG, "RMSendNotificationForListofObservers IN");
+ OIC_LOG(DEBUG, TAG, "RMSendNotificationForListofObservers IN");
RM_NULL_CHECK_WITH_RET(obsId, TAG, "obsId");
RM_NULL_CHECK_WITH_RET(payload, TAG, "payload");
OCStackResult result = OCNotifyListOfObservers(g_gateWayHandle, obsId, obsLen,
payload, OC_LOW_QOS);
- OC_LOG_V(DEBUG, TAG, "Result is %d", result);
- OC_LOG(DEBUG, TAG, "RMSendNotificationForListofObservers OUT");
+ OIC_LOG_V(DEBUG, TAG, "Result is %d", result);
+ OIC_LOG(DEBUG, TAG, "RMSendNotificationForListofObservers OUT");
return result;
}
OCStackApplicationResult RMObserveRequestCallback(void* ctx, OCDoHandle handle,
OCClientResponse *clientResponse)
{
- OC_LOG(DEBUG, TAG, "RMObserveRequestCallback IN");
+ OIC_LOG(DEBUG, TAG, "RMObserveRequestCallback IN");
(void)ctx;
(void)handle;
if (NULL == clientResponse)
{
- OC_LOG(DEBUG, TAG, "clientResponse is NULL");
+ OIC_LOG(DEBUG, TAG, "clientResponse is NULL");
return OC_STACK_KEEP_TRANSACTION;
}
if (OC_STACK_COMM_ERROR == clientResponse->result)
{
- OC_LOG(DEBUG, TAG, "Received TIMEOUT ERROR");
+ OIC_LOG(DEBUG, TAG, "Received TIMEOUT ERROR");
return OC_STACK_KEEP_TRANSACTION;
}
(OCRepPayload *)clientResponse->payload);
if (OC_STACK_OK != result)
{
- OC_LOG_V(ERROR, TAG, "RMHandleResponsePayload Failed[%d]", result);
+ OIC_LOG_V(ERROR, TAG, "RMHandleResponsePayload Failed[%d]", result);
}
- OC_LOG(DEBUG, TAG, "RMObserveRequestCallback OUT");
+ OIC_LOG(DEBUG, TAG, "RMObserveRequestCallback OUT");
return OC_STACK_KEEP_TRANSACTION;
}
OCStackResult RMAddObserverToStack(const OCServerRequest *request, OCObservationId *obsID)
{
- OC_LOG(DEBUG, TAG, "RMAddObserverToStack IN");
+ OIC_LOG(DEBUG, TAG, "RMAddObserverToStack IN");
RM_NULL_CHECK_WITH_RET(request, TAG, "request");
RM_NULL_CHECK_WITH_RET(obsID, TAG, "obsID");
}
if (OC_STACK_OK != result)
{
- OC_LOG_V(DEBUG, TAG, "GenerateObserverId failed[%d]", result);
+ OIC_LOG_V(DEBUG, TAG, "GenerateObserverId failed[%d]", result);
return result;
}
- OC_LOG_V(DEBUG, TAG, "Observer ID is %d", *obsID);
+ OIC_LOG_V(DEBUG, TAG, "Observer ID is %d", *obsID);
// Add the observer
result = AddObserver((const char*)(request->resourceUrl),
(const char *)(request->query),
*obsID, request->requestToken, request->tokenLength,
(OCResource *)g_gateWayHandle, request->qos, OC_FORMAT_CBOR,
&request->devAddr);
- OC_LOG(DEBUG, TAG, "RMAddObserverToStack OUT");
+ OIC_LOG(DEBUG, TAG, "RMAddObserverToStack OUT");
return result;
}
OCStackResult RMPConstructGatewayPayload(uint32_t gatewayId, OCRepPayload **payload)
{
- OC_LOG(DEBUG, TAG, "RMPConstructGatewayPayload IN");
+ OIC_LOG(DEBUG, TAG, "RMPConstructGatewayPayload IN");
RM_NULL_CHECK_WITH_RET(payload, TAG, "payload");
*payload = OCRepPayloadCreate();
if(!*payload)
{
- OC_LOG(ERROR, TAG, "Failed to allocate Payload");
+ OIC_LOG(ERROR, TAG, "Failed to allocate Payload");
return OC_STACK_ERROR;
}
OCRepPayloadSetPropInt(*payload, GATEWAY, gatewayId);
OCRepPayloadSetPropInt(*payload, LENGTH_PROP, 0);
- OC_LOG(DEBUG, TAG, "RMPConstructGatewayPayload OUT");
+ OIC_LOG(DEBUG, TAG, "RMPConstructGatewayPayload OUT");
return OC_STACK_OK;
}
const u_linklist_t *routingtable, bool isUpdateSeqNeeded,
OCRepPayload **payload)
{
- OC_LOG(DEBUG, TAG, "RMPConstructObserveResPayload IN");
+ OIC_LOG(DEBUG, TAG, "RMPConstructObserveResPayload IN");
RM_NULL_CHECK_WITH_RET(payload, TAG, "payload");
*payload = (OCRepPayload *)OCRepPayloadCreate();
if(!*payload)
{
- OC_LOG(ERROR, TAG, "Failed to allocate Payload");
+ OIC_LOG(ERROR, TAG, "Failed to allocate Payload");
return OC_STACK_ERROR;
}
if (NULL == routingtable)
{
OCRepPayloadSetPropInt(*payload, LENGTH_PROP, 0);
- OC_LOG(DEBUG, TAG, "Routing Table NULL for ObserveRes Payload");
+ OIC_LOG(DEBUG, TAG, "Routing Table NULL for ObserveRes Payload");
return OC_STACK_OK;
}
OCRepPayload *add = OCRepPayloadCreate();
if(!add)
{
- OC_LOG(ERROR, TAG, "Failed to allocate Payload");
+ OIC_LOG(ERROR, TAG, "Failed to allocate Payload");
return OC_STACK_ERROR;
}
bool res = OCRepPayloadSetPropObjectArray(*payload, TABLE, arrayPayload, dimensions);
if (!res)
{
- OC_LOG(ERROR, TAG, "Failed to Construct Observer response Payload");
+ OIC_LOG(ERROR, TAG, "Failed to Construct Observer response Payload");
return OC_STACK_ERROR;
}
}
- OC_LOG(DEBUG, TAG, "RMPConstructObserveResPayload OUT");
+ OIC_LOG(DEBUG, TAG, "RMPConstructObserveResPayload OUT");
return OC_STACK_OK;
}
const u_linklist_t *removedGateways, bool isUpdateSeqNeeded,
OCRepPayload **removedPayload)
{
- OC_LOG(DEBUG, TAG, "RMPConstructRemovalPayload IN");
+ OIC_LOG(DEBUG, TAG, "RMPConstructRemovalPayload IN");
RM_NULL_CHECK_WITH_RET(removedGateways, TAG, "removedGateways");
RM_NULL_CHECK_WITH_RET(removedPayload, TAG, "removedPayload");
*removedPayload = OCRepPayloadCreate();
if(!*removedPayload)
{
- OC_LOG(ERROR, TAG, "Failed to allocate Payload");
+ OIC_LOG(ERROR, TAG, "Failed to allocate Payload");
return OC_STACK_ERROR;
}
OCRepPayload *add = OCRepPayloadCreate();
if(!add)
{
- OC_LOG(ERROR, TAG, "Failed to allocate Payload");
+ OIC_LOG(ERROR, TAG, "Failed to allocate Payload");
return OC_STACK_ERROR;
}
add->base.type = PAYLOAD_TYPE_REPRESENTATION;
- OC_LOG_V(DEBUG, TAG, "Removing the gateway entry: %u", entry->destination->gatewayId);
+ OIC_LOG_V(DEBUG, TAG, "Removing the gateway entry: %u", entry->destination->gatewayId);
OCRepPayloadSetPropInt(add, GATEWAY, entry->destination->gatewayId);
OCRepPayloadSetPropInt(add, ROUTE_COST, 0);
arrayPayload[i] = add;
bool res = OCRepPayloadSetPropObjectArray(*removedPayload, TABLE, arrayPayload, dimensions);
if (!res)
{
- OC_LOG(ERROR, TAG, "Failed to Construct Removal Payload");
+ OIC_LOG(ERROR, TAG, "Failed to Construct Removal Payload");
return OC_STACK_ERROR;
}
- OC_LOG(DEBUG, TAG, "RMPConstructRemovalPayload OUT");
+ OIC_LOG(DEBUG, TAG, "RMPConstructRemovalPayload OUT");
return OC_STACK_OK;
}
OCStackResult res = RMPParseResponsePayload(repPayload, gatewayId, NULL, NULL, NULL);
if (OC_STACK_OK != res)
{
- OC_LOG(DEBUG, TAG, "ParseResponsePayload failed");
+ OIC_LOG(DEBUG, TAG, "ParseResponsePayload failed");
}
return res;
uint32_t *seqNum, u_linklist_t **gatewayTable,
bool *isUpdateSeqNeeded)
{
- OC_LOG(DEBUG, TAG, "RMPParsePayload IN");
+ OIC_LOG(DEBUG, TAG, "RMPParsePayload IN");
RM_NULL_CHECK_WITH_RET(payload, TAG, "payload");
RM_NULL_CHECK_WITH_RET(gatewayId, TAG, "gatewayId");
int len = length;
if (0 == len)
{
- OC_LOG(DEBUG, TAG, "Parsed Gateway Payload");
+ OIC_LOG(DEBUG, TAG, "Parsed Gateway Payload");
return OC_STACK_OK;
}
if (NULL == gatewayTable)
{
- OC_LOG(DEBUG, TAG, "gatewayTable is NULL");
+ OIC_LOG(DEBUG, TAG, "gatewayTable is NULL");
return OC_STACK_OK;
}
if (NULL == *responsePayload)
{
- OC_LOG(DEBUG, TAG, "RMPParsePayload OUT");
+ OIC_LOG(DEBUG, TAG, "RMPParsePayload OUT");
return OC_STACK_OK;
}
*gatewayTable = u_linklist_create();
if (NULL == *gatewayTable)
{
- OC_LOG(DEBUG, TAG, "Gateway table create failed");
+ OIC_LOG(DEBUG, TAG, "Gateway table create failed");
return OC_STACK_ERROR;
}
if (NULL == entry)
{
- OC_LOG(DEBUG, TAG, "RTMGatewayEntry_t Calloc failed");
+ OIC_LOG(DEBUG, TAG, "RTMGatewayEntry_t Calloc failed");
return OC_STACK_ERROR;
}
// Filling new Entry
entry->destination = (RTMGatewayId_t*)OICCalloc(1, sizeof(RTMGatewayId_t));
if (NULL == entry->destination)
{
- OC_LOG(DEBUG, TAG, "Destination Calloc failed");
+ OIC_LOG(DEBUG, TAG, "Destination Calloc failed");
OICFree(entry);
return OC_STACK_ERROR;
}
entry->nextHop = (RTMGatewayId_t*)OICCalloc(1, sizeof(RTMGatewayId_t));
if (NULL == entry->nextHop)
{
- OC_LOG(DEBUG, TAG, "nextHop Calloc failed");
+ OIC_LOG(DEBUG, TAG, "nextHop Calloc failed");
OICFree(entry->destination);
OICFree(entry);
return OC_STACK_ERROR;
entry->routeCost = routeCost;
u_linklist_add(*gatewayTable, (void *)entry);
}
- OC_LOG(DEBUG, TAG, "RMPParsePayload OUT");
+ OIC_LOG(DEBUG, TAG, "RMPParsePayload OUT");
return OC_STACK_OK;
}
void RMPFreePayload(OCRepPayload *payload)
{
- OC_LOG(DEBUG, TAG, "RMPFreePayload IN");
+ OIC_LOG(DEBUG, TAG, "RMPFreePayload IN");
RM_NULL_CHECK_VOID(payload, TAG, "payload");
OCRepPayloadDestroy(payload);
- OC_LOG(DEBUG, TAG, "RMPFreePayload OUT");
+ OIC_LOG(DEBUG, TAG, "RMPFreePayload OUT");
}
OCStackResult RTMInitialize(u_linklist_t **gatewayTable, u_linklist_t **endpointTable)
{
- OC_LOG(DEBUG, TAG, "RTMInitialize IN");
+ OIC_LOG(DEBUG, TAG, "RTMInitialize IN");
RM_NULL_CHECK_WITH_RET(gatewayTable, TAG, "gatewayTable");
RM_NULL_CHECK_WITH_RET(endpointTable, TAG, "endpointTable");
if (NULL == *gatewayTable)
*gatewayTable = u_linklist_create();
if (NULL == *gatewayTable)
{
- OC_LOG(ERROR, TAG, "Creating Routing Table failed");
+ OIC_LOG(ERROR, TAG, "Creating Routing Table failed");
RTMTerminate(gatewayTable, endpointTable);
return OC_STACK_ERROR;
}
*endpointTable = u_linklist_create();
if (NULL == *endpointTable)
{
- OC_LOG(ERROR, TAG, "Creating Routing Table failed");
+ OIC_LOG(ERROR, TAG, "Creating Routing Table failed");
RTMTerminate(gatewayTable, endpointTable);
return OC_STACK_ERROR;
}
}
- OC_LOG(DEBUG, TAG, "RTMInitialize OUT");
+ OIC_LOG(DEBUG, TAG, "RTMInitialize OUT");
return OC_STACK_OK;
}
*/
OCStackResult RTMFreeGatewayRouteTable(u_linklist_t **gatewayTable)
{
- OC_LOG(DEBUG, TAG, "RTMFreeGatewayRouteTable IN");
+ OIC_LOG(DEBUG, TAG, "RTMFreeGatewayRouteTable IN");
if (NULL == gatewayTable || NULL == *gatewayTable)
{
return OC_STACK_OK;
OCStackResult ret = u_linklist_remove(*gatewayTable, &iterTable);
if (OC_STACK_OK != ret)
{
- OC_LOG(ERROR, TAG, "Deleting Entry from Routing Table failed");
+ OIC_LOG(ERROR, TAG, "Deleting Entry from Routing Table failed");
return OC_STACK_ERROR;
}
}
u_linklist_free(gatewayTable);
- OC_LOG(DEBUG, TAG, "RTMFreeGatewayRouteTable OUT");
+ OIC_LOG(DEBUG, TAG, "RTMFreeGatewayRouteTable OUT");
return OC_STACK_OK;
}
*/
OCStackResult RTMFreeEndpointRouteTable(u_linklist_t **endpointTable)
{
- OC_LOG(DEBUG, TAG, "IN");
+ OIC_LOG(DEBUG, TAG, "IN");
if (NULL == endpointTable || NULL == *endpointTable)
{
return OC_STACK_OK;
OCStackResult ret = u_linklist_remove(*endpointTable, &iterTable);
if (OC_STACK_OK != ret)
{
- OC_LOG(ERROR, TAG, "Deleting Entry from Routing Table failed");
+ OIC_LOG(ERROR, TAG, "Deleting Entry from Routing Table failed");
return OC_STACK_ERROR;
}
}
u_linklist_free(endpointTable);
- OC_LOG(DEBUG, TAG, "OUT");
+ OIC_LOG(DEBUG, TAG, "OUT");
return OC_STACK_OK;
}
OCStackResult RTMFreeGatewayIdList(u_linklist_t **gatewayIdTable)
{
- OC_LOG(DEBUG, TAG, "IN");
+ OIC_LOG(DEBUG, TAG, "IN");
if (NULL == gatewayIdTable || NULL == *gatewayIdTable)
{
return OC_STACK_OK;
OCStackResult ret = u_linklist_remove(*gatewayIdTable, &iterTable);
if (OC_STACK_OK != ret)
{
- OC_LOG(ERROR, TAG, "Deleting Entry from Routing Table failed");
+ OIC_LOG(ERROR, TAG, "Deleting Entry from Routing Table failed");
return OC_STACK_ERROR;
}
}
OCStackResult res = u_linklist_remove(*gatewayIdTable, &iterTable);
if (OC_STACK_OK != res)
{
- OC_LOG(ERROR, TAG, "Deleting Entry from Routing Table failed");
+ OIC_LOG(ERROR, TAG, "Deleting Entry from Routing Table failed");
return OC_STACK_ERROR;
}
}
}
- OC_LOG(DEBUG, TAG, "OUT");
+ OIC_LOG(DEBUG, TAG, "OUT");
return OC_STACK_OK;
}
*/
OCStackResult RTMTerminate(u_linklist_t **gatewayTable, u_linklist_t **endpointTable)
{
- OC_LOG(DEBUG, TAG, "IN");
+ OIC_LOG(DEBUG, TAG, "IN");
OCStackResult ret = RTMFreeGatewayRouteTable(gatewayTable);
if (OC_STACK_OK != ret)
{
- OC_LOG(ERROR, TAG, "Deleting Gateway Routing Table failed");
+ OIC_LOG(ERROR, TAG, "Deleting Gateway Routing Table failed");
}
if (NULL != *gatewayTable)
{
ret = RTMFreeEndpointRouteTable(endpointTable);
if (OC_STACK_OK != ret)
{
- OC_LOG(ERROR, TAG, "Deleting Endpoint Routing Table failed");
+ OIC_LOG(ERROR, TAG, "Deleting Endpoint Routing Table failed");
}
if (NULL != *endpointTable)
{
*endpointTable = NULL;
}
- OC_LOG(DEBUG, TAG, "OUT");
+ OIC_LOG(DEBUG, TAG, "OUT");
return OC_STACK_OK;
}
OCStackResult RTMAddGatewayEntry(uint32_t gatewayId, uint32_t nextHop, uint32_t routeCost,
const RTMDestIntfInfo_t *destInterfaces, u_linklist_t **gatewayTable)
{
- OC_LOG(DEBUG, TAG, "IN");
+ OIC_LOG(DEBUG, TAG, "IN");
RM_NULL_CHECK_WITH_RET(gatewayTable, TAG, "gatewayTable");
if (NULL == *gatewayTable)
{
*gatewayTable = u_linklist_create();
if (NULL == *gatewayTable)
{
- OC_LOG(ERROR, TAG, "u_linklist_create failed");
+ OIC_LOG(ERROR, TAG, "u_linklist_create failed");
return OC_STACK_NO_MEMORY;
}
}
if (1 == routeCost && 0 != nextHop)
{
- OC_LOG(ERROR, TAG, "Adding Gateway Failed as Next Hop should be 0 for route cost 1");
+ OIC_LOG(ERROR, TAG, "Adding Gateway Failed as Next Hop should be 0 for route cost 1");
return OC_STACK_ERROR;
}
if (0 == routeCost)
{
- OC_LOG(ERROR, TAG, "Adding Gateway Failed as Route cost shouldnot be less than 1");
+ OIC_LOG(ERROR, TAG, "Adding Gateway Failed as Route cost shouldnot be less than 1");
return OC_STACK_ERROR;
}
if (1 < routeCost && NULL == gatewayNodeMap)
{
- OC_LOG(ERROR, TAG, "Adding Gateway Failed as Next Hop is invalid");
+ OIC_LOG(ERROR, TAG, "Adding Gateway Failed as Next Hop is invalid");
return OC_STACK_ERROR;
}
{
if (NULL == destInterfaces)
{
- OC_LOG(ERROR, TAG, "Not Adding Gateway destInterfaces is NULL");
+ OIC_LOG(ERROR, TAG, "Not Adding Gateway destInterfaces is NULL");
return OC_STACK_ERROR;
}
OCStackResult update = RTMUpdateDestinationIntfAdr(gatewayId, *destInterfaces, true,
gatewayTable);
if (OC_STACK_OK != update)
{
- OC_LOG(ERROR, TAG, "RTMUpdateDestinationIntfAdr failed");
+ OIC_LOG(ERROR, TAG, "RTMUpdateDestinationIntfAdr failed");
}
return update;
}
if (entry->routeCost == routeCost && NULL != entry->nextHop &&
(nextHop == entry->nextHop->gatewayId))
{
- OC_LOG(ERROR, TAG, "Not Adding Gateway As it is Duplicate request");
+ OIC_LOG(ERROR, TAG, "Not Adding Gateway As it is Duplicate request");
return OC_STACK_DUPLICATE_REQUEST;
}
{
entry->routeCost = 1;
// Entry can't be updated if Next hop is not same as existing Destinations of Table.
- OC_LOG(DEBUG, TAG, "Updating the gateway");
+ OIC_LOG(DEBUG, TAG, "Updating the gateway");
entry->nextHop = NULL;
entry->destination->destIntfAddr = u_arraylist_create();
if (NULL == entry->destination->destIntfAddr)
{
- OC_LOG(ERROR, TAG, "Failed to create array list");
+ OIC_LOG(ERROR, TAG, "Failed to create array list");
return OC_STACK_ERROR;
}
(RTMDestIntfInfo_t *) OICCalloc(1, sizeof(RTMDestIntfInfo_t));
if (NULL == destAdr)
{
- OC_LOG(ERROR, TAG, "Failed to Calloc destAdr");
+ OIC_LOG(ERROR, TAG, "Failed to Calloc destAdr");
return OC_STACK_ERROR;
}
u_arraylist_add(entry->destination->destIntfAddr, (void *)destAdr);
if (!result)
{
- OC_LOG(ERROR, TAG, "Adding node to head failed");
+ OIC_LOG(ERROR, TAG, "Adding node to head failed");
OICFree(destAdr);
return OC_STACK_ERROR;
}
}
else
{
- OC_LOG(ERROR, TAG, "Adding Gateway Failed as Next hop is invalid");
+ OIC_LOG(ERROR, TAG, "Adding Gateway Failed as Next hop is invalid");
return OC_STACK_ERROR;
}
}
else if (NULL != entry && entry->routeCost < routeCost)
{
- OC_LOG(ERROR, TAG, "Adding Gateway Failed as Route cost is more than old");
+ OIC_LOG(ERROR, TAG, "Adding Gateway Failed as Route cost is more than old");
return OC_STACK_ERROR;
}
OCStackResult res = u_linklist_remove(*gatewayTable, &destNode);
if (OC_STACK_OK != res)
{
- OC_LOG(ERROR, TAG, "Removing node failed");
+ OIC_LOG(ERROR, TAG, "Removing node failed");
}
else
{
res = u_linklist_add_head(*gatewayTable, (void *)entry);
if (OC_STACK_OK != res)
{
- OC_LOG(ERROR, TAG, "Adding node to head failed");
+ OIC_LOG(ERROR, TAG, "Adding node to head failed");
}
}
}
RTMGatewayEntry_t *hopEntry = (RTMGatewayEntry_t *)OICCalloc(1, sizeof(RTMGatewayEntry_t));
if (NULL == hopEntry)
{
- OC_LOG(ERROR, TAG, "Calloc failed for hop entry");
+ OIC_LOG(ERROR, TAG, "Calloc failed for hop entry");
return OC_STACK_ERROR;
}
hopEntry->destination = (RTMGatewayId_t*)OICCalloc(1, sizeof(RTMGatewayId_t));
if (NULL == hopEntry->destination)
{
- OC_LOG(ERROR, TAG, "Calloc failed for hop entry destination");
+ OIC_LOG(ERROR, TAG, "Calloc failed for hop entry destination");
OICFree(hopEntry);
return OC_STACK_ERROR;
}
(RTMDestIntfInfo_t *) OICCalloc(1, sizeof(RTMDestIntfInfo_t));
if (NULL == destAdr)
{
- OC_LOG(ERROR, TAG, "Calloc failed for destAdr");
+ OIC_LOG(ERROR, TAG, "Calloc failed for destAdr");
u_arraylist_free(&(hopEntry->destination->destIntfAddr));
OICFree(hopEntry->destination);
OICFree(hopEntry);
}
else
{
- OC_LOG(ERROR, TAG, "Adding Gateway Failed as Next Hop is invalid");
+ OIC_LOG(ERROR, TAG, "Adding Gateway Failed as Next Hop is invalid");
while (u_arraylist_length(hopEntry->destination->destIntfAddr) > 0)
{
RTMDestIntfInfo_t *data =
if (OC_STACK_OK != ret)
{
- OC_LOG(ERROR, TAG, "Adding Gateway Entry to Routing Table failed");
+ OIC_LOG(ERROR, TAG, "Adding Gateway Entry to Routing Table failed");
while (u_arraylist_length(hopEntry->destination->destIntfAddr) > 0)
{
RTMDestIntfInfo_t *data = u_arraylist_remove(hopEntry->destination->destIntfAddr, 0);
return OC_STACK_ERROR;
}
}
- OC_LOG(DEBUG, TAG, "OUT");
+ OIC_LOG(DEBUG, TAG, "OUT");
return OC_STACK_OK;
}
OCStackResult RTMAddEndpointEntry(uint16_t *endpointId, const CAEndpoint_t *destAddr,
u_linklist_t **endpointTable)
{
- OC_LOG(DEBUG, TAG, "IN");
+ OIC_LOG(DEBUG, TAG, "IN");
RM_NULL_CHECK_WITH_RET(endpointId, TAG, "endpointId");
RM_NULL_CHECK_WITH_RET(destAddr, TAG, "destAddr");
RM_NULL_CHECK_WITH_RET(endpointTable, TAG, "endpointTable");
*endpointTable = u_linklist_create();
if (NULL == *endpointTable)
{
- OC_LOG(ERROR, TAG, "u_linklist_create failed");
+ OIC_LOG(ERROR, TAG, "u_linklist_create failed");
return OC_STACK_NO_MEMORY;
}
}
&& destAddr->port == entry->destIntfAddr.port)
{
*endpointId = entry->endpointId;
- OC_LOG(ERROR, TAG, "Adding failed as Enpoint Entry Already present in Table");
+ OIC_LOG(ERROR, TAG, "Adding failed as Enpoint Entry Already present in Table");
return OC_STACK_DUPLICATE_REQUEST;
}
u_linklist_get_next(&iterTable);
if (NULL == hopEntry)
{
- OC_LOG(ERROR, TAG, "Malloc failed for hop entry");
+ OIC_LOG(ERROR, TAG, "Malloc failed for hop entry");
return OC_STACK_ERROR;
}
OCStackResult ret = u_linklist_add(*endpointTable, (void *)hopEntry);
if (OC_STACK_OK != ret)
{
- OC_LOG(ERROR, TAG, "Adding Enpoint Entry to Routing Table failed");
+ OIC_LOG(ERROR, TAG, "Adding Enpoint Entry to Routing Table failed");
OICFree(hopEntry);
return OC_STACK_ERROR;
}
- OC_LOG(DEBUG, TAG, "OUT");
+ OIC_LOG(DEBUG, TAG, "OUT");
return OC_STACK_OK;
}
OCStackResult RTMAddObserver(uint32_t obsID, CAEndpoint_t devAddr, u_linklist_t **gatewayTable)
{
- OC_LOG(DEBUG, TAG, "IN");
+ OIC_LOG(DEBUG, TAG, "IN");
RM_NULL_CHECK_WITH_RET(gatewayTable, TAG, "gatewayTable");
RM_NULL_CHECK_WITH_RET(*gatewayTable, TAG, "*gatewayTable");
&& devAddr.port == destCheck->destIntfAddr.port)
{
destCheck->observerId = obsID;
- OC_LOG(DEBUG, TAG, "OUT");
+ OIC_LOG(DEBUG, TAG, "OUT");
return OC_STACK_OK;
}
}
u_linklist_get_next(&iterTable);
}
- OC_LOG(DEBUG, TAG, "OUT");
+ OIC_LOG(DEBUG, TAG, "OUT");
return OC_STACK_ERROR;
}
bool RTMIsObserverPresent(CAEndpoint_t devAddr, OCObservationId *obsID,
const u_linklist_t *gatewayTable)
{
- OC_LOG(DEBUG, TAG, "IN");
+ OIC_LOG(DEBUG, TAG, "IN");
if (NULL == obsID)
{
- OC_LOG(ERROR, TAG, "obsID is null");
+ OIC_LOG(ERROR, TAG, "obsID is null");
return false;
}
if (NULL == gatewayTable)
{
- OC_LOG(ERROR, TAG, "gatewayTable is null");
+ OIC_LOG(ERROR, TAG, "gatewayTable is null");
return false;
}
RTMGatewayEntry_t *entry = u_linklist_get_data(iterTable);
if (NULL == entry || NULL == entry->destination)
{
- OC_LOG(ERROR, TAG, "entry is NULL");
+ OIC_LOG(ERROR, TAG, "entry is NULL");
return false;
}
for (uint32_t i = 0; i < u_arraylist_length(entry->destination->destIntfAddr); i++)
&& devAddr.port == destCheck->destIntfAddr.port && 0 != destCheck->observerId)
{
*obsID = destCheck->observerId;
- OC_LOG(DEBUG, TAG, "OUT");
+ OIC_LOG(DEBUG, TAG, "OUT");
return true;
}
}
u_linklist_get_next(&iterTable);
}
- OC_LOG(DEBUG, TAG, "OUT");
+ OIC_LOG(DEBUG, TAG, "OUT");
return false;
}
OCStackResult RTMRemoveGatewayEntry(uint32_t gatewayId, u_linklist_t **removedGatewayNodes,
u_linklist_t **gatewayTable)
{
- OC_LOG(DEBUG, TAG, "IN");
+ OIC_LOG(DEBUG, TAG, "IN");
RM_NULL_CHECK_WITH_RET(gatewayTable, TAG, "gatewayTable");
RM_NULL_CHECK_WITH_RET(*gatewayTable, TAG, "*gatewayTable");
*removedGatewayNodes = u_linklist_create();
if (NULL == *removedGatewayNodes)
{
- OC_LOG(ERROR, TAG, "u_linklist_create failed");
+ OIC_LOG(ERROR, TAG, "u_linklist_create failed");
return OC_STACK_NO_MEMORY;
}
}
if (gatewayId == entry->destination->gatewayId || (NULL != entry->nextHop &&
(gatewayId == entry->nextHop->gatewayId)))
{
- OC_LOG_V(DEBUG, TAG, "Removing the gateway entry: %u", entry->destination->gatewayId);
+ OIC_LOG_V(DEBUG, TAG, "Removing the gateway entry: %u", entry->destination->gatewayId);
ret = u_linklist_remove(*gatewayTable, &iterTable);
if (OC_STACK_OK != ret)
{
- OC_LOG(ERROR, TAG, "Deleting Entry from Routing Table failed");
+ OIC_LOG(ERROR, TAG, "Deleting Entry from Routing Table failed");
return OC_STACK_ERROR;
}
else
u_linklist_get_next(&iterTable);
}
}
- OC_LOG(DEBUG, TAG, "RTMRemoveGatewayEntry OUT");
+ OIC_LOG(DEBUG, TAG, "RTMRemoveGatewayEntry OUT");
return OC_STACK_OK;
}
const RTMDestIntfInfo_t *destInfAdr,
RTMGatewayEntry_t **existEntry, u_linklist_t **gatewayTable)
{
- OC_LOG(DEBUG, TAG, "IN");
+ OIC_LOG(DEBUG, TAG, "IN");
RM_NULL_CHECK_WITH_RET(gatewayTable, TAG, "gatewayTable");
RM_NULL_CHECK_WITH_RET(*gatewayTable, TAG, "*gatewayTable");
RM_NULL_CHECK_WITH_RET(destInfAdr, TAG, "destInfAdr");
// Remove node with given gatewayid and nextHop if not found update exist entry.
if (NULL != entry->destination && (gatewayId == entry->destination->gatewayId))
{
- OC_LOG_V(INFO, TAG, "Remove the gateway ID: %u", entry->destination->gatewayId);
+ OIC_LOG_V(INFO, TAG, "Remove the gateway ID: %u", entry->destination->gatewayId);
if (NULL != entry->nextHop && nextHop == entry->nextHop->gatewayId)
{
ret = u_linklist_remove(*gatewayTable, &iterTable);
if (OC_STACK_OK != ret)
{
- OC_LOG(ERROR, TAG, "Deleting Entry from Routing Table failed");
+ OIC_LOG(ERROR, TAG, "Deleting Entry from Routing Table failed");
return OC_STACK_ERROR;
}
OICFree(entry);
}
*existEntry = entry;
- OC_LOG(DEBUG, TAG, "OUT");
+ OIC_LOG(DEBUG, TAG, "OUT");
return OC_STACK_ERROR;
}
u_linklist_get_next(&iterTable);
}
- OC_LOG(DEBUG, TAG, "OUT");
+ OIC_LOG(DEBUG, TAG, "OUT");
return OC_STACK_ERROR;
}
OCStackResult RTMRemoveEndpointEntry(uint16_t endpointId, u_linklist_t **endpointTable)
{
- OC_LOG(DEBUG, TAG, "IN");
+ OIC_LOG(DEBUG, TAG, "IN");
RM_NULL_CHECK_WITH_RET(endpointTable, TAG, "endpointTable");
RM_NULL_CHECK_WITH_RET(*endpointTable, TAG, "*endpointTable");
OCStackResult ret = u_linklist_remove(*endpointTable, &iterTable);
if (OC_STACK_OK != ret)
{
- OC_LOG(ERROR, TAG, "Deleting Entry from Routing Table failed");
+ OIC_LOG(ERROR, TAG, "Deleting Entry from Routing Table failed");
return OC_STACK_ERROR;
}
OICFree(entry);
u_linklist_get_next(&iterTable);
}
}
- OC_LOG(DEBUG, TAG, "OUT");
+ OIC_LOG(DEBUG, TAG, "OUT");
return OC_STACK_OK;
}
OCStackResult RTMRemoveGateways(u_linklist_t **gatewayTable)
{
- OC_LOG(DEBUG, TAG, "IN");
+ OIC_LOG(DEBUG, TAG, "IN");
if (NULL == gatewayTable || NULL == *gatewayTable)
{
- OC_LOG(DEBUG, TAG, "OUT");
+ OIC_LOG(DEBUG, TAG, "OUT");
return OC_STACK_OK;
}
OCStackResult ret = RTMFreeGatewayRouteTable(gatewayTable);
if (OC_STACK_OK != ret)
{
- OC_LOG(ERROR, TAG, "Removing Gateways failed");
+ OIC_LOG(ERROR, TAG, "Removing Gateways failed");
return ret;
}
- OC_LOG(DEBUG, TAG, "OUT");
+ OIC_LOG(DEBUG, TAG, "OUT");
return OC_STACK_OK;
}
OCStackResult RTMRemoveEndpoints(u_linklist_t **endpointTable)
{
- OC_LOG(DEBUG, TAG, "IN");
+ OIC_LOG(DEBUG, TAG, "IN");
if (NULL == endpointTable || NULL == *endpointTable)
{
- OC_LOG(DEBUG, TAG, "OUT");
+ OIC_LOG(DEBUG, TAG, "OUT");
return OC_STACK_OK;
}
OCStackResult ret = RTMFreeEndpointRouteTable(endpointTable);
if (OC_STACK_OK != ret)
{
- OC_LOG(ERROR, TAG, "Freeing Endpoints failed");
+ OIC_LOG(ERROR, TAG, "Freeing Endpoints failed");
return OC_STACK_ERROR;
}
- OC_LOG(DEBUG, TAG, "OUT");
+ OIC_LOG(DEBUG, TAG, "OUT");
return OC_STACK_OK;
}
void RTMFreeGateway(RTMGatewayId_t *gateway, u_linklist_t **gatewayTable)
{
- OC_LOG(DEBUG, TAG, "IN");
+ OIC_LOG(DEBUG, TAG, "IN");
RM_NULL_CHECK_VOID(gateway, TAG, "gateway");
RM_NULL_CHECK_VOID(gatewayTable, TAG, "gatewayTable");
RM_NULL_CHECK_VOID(*gatewayTable, TAG, "*gatewayTable");
}
u_arraylist_free(&(gateway->destIntfAddr));
OICFree(gateway);
- OC_LOG(DEBUG, TAG, "OUT");
+ OIC_LOG(DEBUG, TAG, "OUT");
}
void RTMGetNeighbours(u_linklist_t **neighbourNodes, const u_linklist_t *gatewayTable)
{
- OC_LOG(DEBUG, TAG, "IN");
+ OIC_LOG(DEBUG, TAG, "IN");
RM_NULL_CHECK_VOID(neighbourNodes, TAG, "neighbourNodes");
RM_NULL_CHECK_VOID(gatewayTable, TAG, "gatewayTable");
*neighbourNodes = u_linklist_create();
if (NULL == *neighbourNodes)
{
- OC_LOG(ERROR, TAG, "u_linklist_create failed");
+ OIC_LOG(ERROR, TAG, "u_linklist_create failed");
return;
}
u_linklist_iterator_t *iterTable = NULL;
}
else if (NULL != entry && 1 < entry->routeCost)
{
- OC_LOG(DEBUG, TAG, "OUT");
+ OIC_LOG(DEBUG, TAG, "OUT");
return;
}
u_linklist_get_next(&iterTable);
}
- OC_LOG(DEBUG, TAG, "OUT");
+ OIC_LOG(DEBUG, TAG, "OUT");
}
RTMGatewayId_t *RTMGetNextHop(uint32_t gatewayId, const u_linklist_t *gatewayTable)
{
- OC_LOG(DEBUG, TAG, "IN");
+ OIC_LOG(DEBUG, TAG, "IN");
if (0 == gatewayId)
{
- OC_LOG(ERROR, TAG, "gatewayId is invalid");
+ OIC_LOG(ERROR, TAG, "gatewayId is invalid");
return NULL;
}
if (NULL == gatewayTable)
{
- OC_LOG(ERROR, TAG, "gatewayTable is null");
+ OIC_LOG(ERROR, TAG, "gatewayTable is null");
return NULL;
}
{
if (1 == entry->routeCost)
{
- OC_LOG(DEBUG, TAG, "OUT");
+ OIC_LOG(DEBUG, TAG, "OUT");
return entry->destination;
}
- OC_LOG(DEBUG, TAG, "OUT");
+ OIC_LOG(DEBUG, TAG, "OUT");
return entry->nextHop;
}
u_linklist_get_next(&iterTable);
}
- OC_LOG(DEBUG, TAG, "OUT");
+ OIC_LOG(DEBUG, TAG, "OUT");
return NULL;
}
CAEndpoint_t *RTMGetEndpointEntry(uint16_t endpointId, const u_linklist_t *endpointTable)
{
- OC_LOG(DEBUG, TAG, "IN");
+ OIC_LOG(DEBUG, TAG, "IN");
if (NULL == endpointTable)
{
- OC_LOG(ERROR, TAG, "endpointTable is null");
+ OIC_LOG(ERROR, TAG, "endpointTable is null");
return NULL;
}
RTMEndpointEntry_t *entry = u_linklist_get_data(iterTable);
if (NULL != entry && (endpointId == entry->endpointId))
{
- OC_LOG(DEBUG, TAG, "OUT");
+ OIC_LOG(DEBUG, TAG, "OUT");
return &(entry->destIntfAddr);
}
u_linklist_get_next(&iterTable);
}
- OC_LOG(DEBUG, TAG, "OUT");
+ OIC_LOG(DEBUG, TAG, "OUT");
return NULL;
}
void RTMGetObserverList(OCObservationId **obsList, uint8_t *obsListLen,
const u_linklist_t *gatewayTable)
{
- OC_LOG(DEBUG, TAG, "IN");
+ OIC_LOG(DEBUG, TAG, "IN");
RM_NULL_CHECK_VOID(gatewayTable, TAG, "gatewayTable");
RM_NULL_CHECK_VOID(obsList, TAG, "obsList");
*obsList = (OCObservationId *) OICCalloc(MAX_OBSERVER_LIST_LENGTH, sizeof(OCObservationId));
if (!(*obsList))
{
- OC_LOG(ERROR, TAG, "out of memory");
+ OIC_LOG(ERROR, TAG, "out of memory");
return;
}
RTMDestIntfInfo_t *destCheck = u_arraylist_get(entry->destination->destIntfAddr, 0);
if (NULL == destCheck)
{
- OC_LOG(ERROR, TAG, "destCheck is null");
+ OIC_LOG(ERROR, TAG, "destCheck is null");
return;
}
if (0 != destCheck->observerId)
{
- OC_LOG_V(DEBUG, TAG, "Observer ID is %d", destCheck->observerId);
+ OIC_LOG_V(DEBUG, TAG, "Observer ID is %d", destCheck->observerId);
*(*obsList + len) = destCheck->observerId;
len++;
}
}
*obsListLen = len;
- OC_LOG(DEBUG, TAG, "OUT");
+ OIC_LOG(DEBUG, TAG, "OUT");
}
OCStackResult RTMUpdateDestinationIntfAdr(uint32_t gatewayId, RTMDestIntfInfo_t destInterfaces,
bool addAdr, u_linklist_t **gatewayTable)
{
- OC_LOG(DEBUG, TAG, "IN");
+ OIC_LOG(DEBUG, TAG, "IN");
RM_NULL_CHECK_WITH_RET(gatewayTable, TAG, "gatewayTable");
RM_NULL_CHECK_WITH_RET(*gatewayTable, TAG, "*gatewayTable");
u_arraylist_get(entry->destination->destIntfAddr, i);
if (NULL == destCheck)
{
- OC_LOG(ERROR, TAG, "Destination adr get failed");
+ OIC_LOG(ERROR, TAG, "Destination adr get failed");
continue;
}
{
destCheck->timeElapsed = RTMGetCurrentTime();
destCheck->isValid = true;
- OC_LOG(ERROR, TAG, "destInterfaces already present");
+ OIC_LOG(ERROR, TAG, "destInterfaces already present");
return OC_STACK_ERROR;
}
}
(RTMDestIntfInfo_t *) OICCalloc(1, sizeof(RTMDestIntfInfo_t));
if (NULL == destAdr)
{
- OC_LOG(ERROR, TAG, "Calloc destAdr failed");
+ OIC_LOG(ERROR, TAG, "Calloc destAdr failed");
return OC_STACK_ERROR;
}
*destAdr = destInterfaces;
u_arraylist_add(entry->destination->destIntfAddr, (void *)destAdr);
if (!result)
{
- OC_LOG(ERROR, TAG, "Updating Destinterface address failed");
+ OIC_LOG(ERROR, TAG, "Updating Destinterface address failed");
OICFree(destAdr);
return OC_STACK_ERROR;
}
- OC_LOG(DEBUG, TAG, "OUT");
+ OIC_LOG(DEBUG, TAG, "OUT");
return OC_STACK_DUPLICATE_REQUEST;
}
}
u_linklist_get_next(&iterTable);
}
- OC_LOG(DEBUG, TAG, "OUT");
+ OIC_LOG(DEBUG, TAG, "OUT");
return OC_STACK_OK;
}
OCStackResult RTMUpdateMcastSeqNumber(uint32_t gatewayId, uint16_t seqNum,
u_linklist_t **gatewayTable)
{
- OC_LOG(DEBUG, TAG, "IN");
+ OIC_LOG(DEBUG, TAG, "IN");
RM_NULL_CHECK_WITH_RET(gatewayTable, TAG, "gatewayTable");
RM_NULL_CHECK_WITH_RET(*gatewayTable, TAG, "*gatewayTable");
}
u_linklist_get_next(&iterTable);
}
- OC_LOG(DEBUG, TAG, "OUT");
+ OIC_LOG(DEBUG, TAG, "OUT");
return OC_STACK_OK;
}
OCStackResult RTMUpdateDestAddrValidity(u_linklist_t **invalidTable, u_linklist_t **gatewayTable)
{
- OC_LOG(DEBUG, TAG, "IN");
+ OIC_LOG(DEBUG, TAG, "IN");
RM_NULL_CHECK_WITH_RET(invalidTable, TAG, "invalidTable");
RM_NULL_CHECK_WITH_RET(gatewayTable, TAG, "gatewayTable");
RM_NULL_CHECK_WITH_RET(*gatewayTable, TAG, "*gatewayTable");
*invalidTable = u_linklist_create();
if (NULL == *invalidTable)
{
- OC_LOG(ERROR, TAG, "u_linklist_create failed");
+ OIC_LOG(ERROR, TAG, "u_linklist_create failed");
return OC_STACK_NO_MEMORY;
}
}
u_linklist_get_next(&iterTable);
}
- OC_LOG(DEBUG, TAG, "OUT");
+ OIC_LOG(DEBUG, TAG, "OUT");
return OC_STACK_OK;
}
OCStackResult RTMRemoveInvalidGateways(u_linklist_t **invalidTable, u_linklist_t **gatewayTable)
{
- OC_LOG(DEBUG, TAG, "IN");
+ OIC_LOG(DEBUG, TAG, "IN");
RM_NULL_CHECK_WITH_RET(invalidTable, TAG, "invalidTable");
RM_NULL_CHECK_WITH_RET(gatewayTable, TAG, "gatewayTable");
RM_NULL_CHECK_WITH_RET(*gatewayTable, TAG, "*gatewayTable");
*invalidTable = u_linklist_create();
if (NULL == *invalidTable)
{
- OC_LOG(ERROR, TAG, "u_linklist_create failed");
+ OIC_LOG(ERROR, TAG, "u_linklist_create failed");
return OC_STACK_NO_MEMORY;
}
RTMRemoveGatewayEntry(entry->destination->gatewayId, invalidTable, gatewayTable);
if (OC_STACK_OK != res)
{
- OC_LOG(ERROR, TAG, "Removing Entries failed");
+ OIC_LOG(ERROR, TAG, "Removing Entries failed");
return OC_STACK_ERROR;
}
u_linklist_get_next(&iterTable);
u_linklist_get_next(&iterTable);
}
}
- OC_LOG(DEBUG, TAG, "OUT");
+ OIC_LOG(DEBUG, TAG, "OUT");
return OC_STACK_OK;
}
const RTMDestIntfInfo_t *destAdr, u_linklist_t **gatewayTable,
bool forceUpdate)
{
- OC_LOG(DEBUG, TAG, "IN");
+ OIC_LOG(DEBUG, TAG, "IN");
RM_NULL_CHECK_WITH_RET(gatewayTable, TAG, "gatewayTable");
RM_NULL_CHECK_WITH_RET(*gatewayTable, TAG, "*gatewayTable");
RM_NULL_CHECK_WITH_RET(destAdr, TAG, "destAdr");
else
{
entry->seqNum = seqNum;
- OC_LOG(DEBUG, TAG, "OUT");
+ OIC_LOG(DEBUG, TAG, "OUT");
return OC_STACK_OK;
}
}
u_linklist_get_next(&iterTable);
}
- OC_LOG(DEBUG, TAG, "OUT");
+ OIC_LOG(DEBUG, TAG, "OUT");
return OC_STACK_OK;
}
void RTMPrintTable(const u_linklist_t *gatewayTable, const u_linklist_t *endpointTable)
{
RM_NULL_CHECK_VOID(gatewayTable, TAG, "gatewayTable");
- OC_LOG(DEBUG, RM_TAG, "=================Gateway List table============================\n");
+ OIC_LOG(DEBUG, RM_TAG, "=================Gateway List table============================\n");
u_linklist_iterator_t *iterTable = NULL;
u_linklist_init_iterator(gatewayTable, &iterTable);
while (NULL != iterTable)
(RTMGatewayEntry_t *) u_linklist_get_data(iterTable);
if (NULL == hop)
{
- OC_LOG(ERROR, RM_TAG, "Printing Table Failed");
+ OIC_LOG(ERROR, RM_TAG, "Printing Table Failed");
return;
}
if (NULL == hop->nextHop || 0 == hop->nextHop->gatewayId)
{
- OC_LOG_V(DEBUG, RM_TAG, "\nDestination : %u\nNextHop : (null)\nHopCount : %d",
+ OIC_LOG_V(DEBUG, RM_TAG, "\nDestination : %u\nNextHop : (null)\nHopCount : %d",
hop->destination->gatewayId, hop->routeCost);
- OC_LOG_V(DEBUG, RM_TAG, "\nSequence Number :%u", hop->seqNum);
+ OIC_LOG_V(DEBUG, RM_TAG, "\nSequence Number :%u", hop->seqNum);
}
else
{
- OC_LOG_V(DEBUG, RM_TAG, "\nDestination : %u\nNextHop : %u\nHopCount : %d",
+ OIC_LOG_V(DEBUG, RM_TAG, "\nDestination : %u\nNextHop : %u\nHopCount : %d",
hop->destination->gatewayId, hop->nextHop->gatewayId, hop->routeCost);
- OC_LOG_V(DEBUG, RM_TAG, "\nSequence Number :%u", hop->seqNum);
+ OIC_LOG_V(DEBUG, RM_TAG, "\nSequence Number :%u", hop->seqNum);
}
if (1 == hop->routeCost && NULL != hop->destination &&
hop->destination->destIntfAddr != NULL)
RTMDestIntfInfo_t *dest = u_arraylist_get(hop->destination->destIntfAddr, i);
if (NULL != dest)
{
- OC_LOG_V(DEBUG, RM_TAG, "\nDestination interface addresses: %s Port : %d Obs ID: %d",
+ OIC_LOG_V(DEBUG, RM_TAG, "\nDestination interface addresses: %s Port : %d Obs ID: %d",
dest->destIntfAddr.addr, dest->destIntfAddr.port, dest->observerId);
- OC_LOG_V(DEBUG, RM_TAG, "Validity: %d", dest->isValid);
+ OIC_LOG_V(DEBUG, RM_TAG, "Validity: %d", dest->isValid);
}
}
}
- OC_LOG(DEBUG, RM_TAG, "********************************************\n");
+ OIC_LOG(DEBUG, RM_TAG, "********************************************\n");
u_linklist_get_next(&iterTable);
}
- OC_LOG(DEBUG, RM_TAG, "=================Endpoint List table============================\n");
+ OIC_LOG(DEBUG, RM_TAG, "=================Endpoint List table============================\n");
u_linklist_iterator_t *iterEndpointTable = NULL;
u_linklist_init_iterator(endpointTable, &iterEndpointTable);
(RTMEndpointEntry_t *) u_linklist_get_data(iterEndpointTable);
if (NULL == hop)
{
- OC_LOG(ERROR, RM_TAG, "Printing Table Failed");
+ OIC_LOG(ERROR, RM_TAG, "Printing Table Failed");
return;
}
- OC_LOG_V(DEBUG, RM_TAG, "EndpointId : %u\naddr : %s Port : %d",
+ OIC_LOG_V(DEBUG, RM_TAG, "EndpointId : %u\naddr : %s Port : %d",
hop->endpointId, hop->destIntfAddr.addr, hop->destIntfAddr.port);
- OC_LOG(DEBUG, RM_TAG, "********************************************\n");
+ OIC_LOG(DEBUG, RM_TAG, "********************************************\n");
u_linklist_get_next(&iterEndpointTable);
}
}
OCStackResult RMAddInfo(const char *destination, CAHeaderOption_t **options,
uint8_t *numOptions)
{
- OC_LOG(DEBUG, TAG, "IN");
+ OIC_LOG(DEBUG, TAG, "IN");
RM_NULL_CHECK_WITH_RET(options, TAG, "options");
RM_NULL_CHECK_WITH_RET(numOptions, TAG, "numOptions");
if (-1 < index)
{
- OC_LOG(INFO, TAG, "Route option is present");
+ OIC_LOG(INFO, TAG, "Route option is present");
optionPtr = *options;
}
else
{
- OC_LOG(INFO, TAG, "Route option is not present");
+ OIC_LOG(INFO, TAG, "Route option is not present");
index = *numOptions;
optionPtr = OICCalloc((*numOptions + 1), sizeof(CAHeaderOption_t));
if (!optionPtr)
{
- OC_LOG(ERROR, TAG, "OICCalloc failed");
+ OIC_LOG(ERROR, TAG, "OICCalloc failed");
return OC_STACK_NO_MEMORY;
}
RMRouteOption_t routeOption = {.destGw = 0};
if (*numOptions != index)
{
- OC_LOG(INFO, TAG, "Route option is already present");
+ OIC_LOG(INFO, TAG, "Route option is already present");
res = RMParseRouteOption(&optionPtr[index], &routeOption);
if (OC_STACK_OK != res)
{
- OC_LOG(ERROR, TAG, "RMParseRouteOption failed");
+ OIC_LOG(ERROR, TAG, "RMParseRouteOption failed");
return OC_STACK_ERROR;
}
}
res = RMCreateRouteOption(&routeOption, optionPtr + index);
if (OC_STACK_OK != res)
{
- OC_LOG(ERROR, TAG, "Creation of routing option failed");
+ OIC_LOG(ERROR, TAG, "Creation of routing option failed");
OICFree(optionPtr);
return res;
}
*options = optionPtr;
}
- OC_LOG(DEBUG, TAG, "OUT");
+ OIC_LOG(DEBUG, TAG, "OUT");
return OC_STACK_OK;
}
OCStackResult RMUpdateInfo(CAHeaderOption_t **options, uint8_t *numOptions,
CAEndpoint_t *endpoint)
{
- OC_LOG(DEBUG, TAG, "IN");
+ OIC_LOG(DEBUG, TAG, "IN");
RM_NULL_CHECK_WITH_RET(options, TAG, "options");
RM_NULL_CHECK_WITH_RET(*options, TAG, "invalid option");
RM_NULL_CHECK_WITH_RET(numOptions, TAG, "numOptions");
if (0 >= *numOptions)
{
- OC_LOG(ERROR, TAG, "Invalid arguement: numOptions");
+ OIC_LOG(ERROR, TAG, "Invalid arguement: numOptions");
return OC_STACK_ERROR;
}
if (-1 >= routeIndex)
{
- OC_LOG(DEBUG, TAG, "Nothing to remove.");
+ OIC_LOG(DEBUG, TAG, "Nothing to remove.");
return OC_STACK_OK;
}
{
memcpy(endpoint->routeData, (*options + routeIndex)->optionData + count,
GATEWAY_ID_LENGTH);
- OC_LOG_V(DEBUG, TAG, "adding srcgid: %u in endpoint [%d]",
+ OIC_LOG_V(DEBUG, TAG, "adding srcgid: %u in endpoint [%d]",
*((uint32_t *)endpoint->routeData), sLen);
count += GATEWAY_ID_LENGTH;
{
memcpy(endpoint->routeData + GATEWAY_ID_LENGTH,
(*options + routeIndex)->optionData + count, ENDPOINT_ID_LENGTH);
- OC_LOG_V(DEBUG, TAG, "adding srceid: %u in endpoint",
+ OIC_LOG_V(DEBUG, TAG, "adding srceid: %u in endpoint",
*((uint16_t *)(endpoint->routeData + GATEWAY_ID_LENGTH)));
}
}
OICFree(*options);
*options = NULL;
}
- OC_LOG(DEBUG, TAG, "OUT");
+ OIC_LOG(DEBUG, TAG, "OUT");
return OC_STACK_OK;
}
void RMGetRouteOptionIndex(const CAHeaderOption_t *options, uint8_t numOptions, int8_t *index)
{
- OC_LOG(DEBUG, TAG, "IN");
+ OIC_LOG(DEBUG, TAG, "IN");
RM_NULL_CHECK_VOID(options, TAG, "options");
RM_NULL_CHECK_VOID(index, TAG, "index");
for (uint32_t i = 0; i < numOptions; i++)
{
- OC_LOG_V(DEBUG, TAG, "Request- optionID: %u", options[i].optionID);
+ OIC_LOG_V(DEBUG, TAG, "Request- optionID: %u", options[i].optionID);
if (RM_OPTION_MESSAGE_SWITCHING == options[i].optionID)
{
- OC_LOG_V(INFO, TAG, "Found Option at %d", i);
+ OIC_LOG_V(INFO, TAG, "Found Option at %d", i);
*index = i;
break;
}
}
- OC_LOG(DEBUG, TAG, "OUT");
+ OIC_LOG(DEBUG, TAG, "OUT");
}
OCStackResult RMCreateRouteOption(const RMRouteOption_t *optValue, CAHeaderOption_t *options)
{
- OC_LOG(DEBUG, RM_TAG, "IN");
+ OIC_LOG(DEBUG, RM_TAG, "IN");
RM_NULL_CHECK_WITH_RET(optValue, RM_TAG, "optValue");
RM_NULL_CHECK_WITH_RET(options, RM_TAG, "options");
uint8_t sLen = (optValue->srcGw ? GATEWAY_ID_LENGTH:0) +
(optValue->srcEp ? ENDPOINT_ID_LENGTH:0);
- OC_LOG_V(DEBUG, RM_TAG, "createoption dlen %u slen [%u]", dLen, sLen);
+ OIC_LOG_V(DEBUG, RM_TAG, "createoption dlen %u slen [%u]", dLen, sLen);
unsigned int totalLength = MIN_ROUTE_OPTION_LEN + dLen + sLen;
void *tempData = OICCalloc(totalLength, sizeof(char));
if (NULL == tempData)
{
- OC_LOG(ERROR, RM_TAG, "Calloc failed");
+ OIC_LOG(ERROR, RM_TAG, "Calloc failed");
return OC_STACK_NO_MEMORY;
}
memcpy(tempData, &dLen, sizeof(dLen));
options->optionID = RM_OPTION_MESSAGE_SWITCHING;
options->optionLength = totalLength;
- OC_LOG_V(INFO, RM_TAG, "Option Length is %d", options->optionLength);
+ OIC_LOG_V(INFO, RM_TAG, "Option Length is %d", options->optionLength);
OICFree(tempData);
- OC_LOG(DEBUG, RM_TAG, "OUT");
+ OIC_LOG(DEBUG, RM_TAG, "OUT");
return OC_STACK_OK;
}
OCStackResult RMParseRouteOption(const CAHeaderOption_t *options, RMRouteOption_t *optValue)
{
- OC_LOG(DEBUG, RM_TAG, "IN");
+ OIC_LOG(DEBUG, RM_TAG, "IN");
RM_NULL_CHECK_WITH_RET(options, RM_TAG, "options");
RM_NULL_CHECK_WITH_RET(optValue, RM_TAG, "optValue");
if (0 == options->optionLength)
{
- OC_LOG(ERROR, RM_TAG, "Option data is not present");
+ OIC_LOG(ERROR, RM_TAG, "Option data is not present");
return OC_STACK_ERROR;
}
}
memcpy(&optValue->mSeqNum, options->optionData + count, sizeof(optValue->mSeqNum));
- OC_LOG_V(INFO, RM_TAG, "Option hopcount is %d", optValue->mSeqNum);
- OC_LOG_V(INFO, RM_TAG, "Option Sender Addr is [%u][%u]", optValue->srcGw, optValue->srcEp);
- OC_LOG_V(INFO, RM_TAG, "Option Dest Addr is [%u][%u]", optValue->destGw, optValue->destEp);
- OC_LOG(DEBUG, RM_TAG, "OUT");
+ OIC_LOG_V(INFO, RM_TAG, "Option hopcount is %d", optValue->mSeqNum);
+ OIC_LOG_V(INFO, RM_TAG, "Option Sender Addr is [%u][%u]", optValue->srcGw, optValue->srcEp);
+ OIC_LOG_V(INFO, RM_TAG, "Option Dest Addr is [%u][%u]", optValue->destGw, optValue->destEp);
+ OIC_LOG(DEBUG, RM_TAG, "OUT");
return OC_STACK_OK;
}
#ifdef TB_LOG
#define OC_LOG_PAYLOAD(level, payload) OCPayloadLog((level),(payload))
+ #define OIC_LOG_PAYLOAD(level, payload) OCPayloadLog((level),(payload))
#define UUID_SIZE (16)
const char *convertTriggerEnumToString(OCPresenceTrigger trigger);
OCPresenceTrigger convertTriggerStringToEnum(const char * triggerStr);
static inline void OCPayloadLogRep(LogLevel level, OCRepPayload* payload)
{
- OC_LOG(level, (PL_TAG), "Payload Type: Representation");
+ OIC_LOG(level, (PL_TAG), "Payload Type: Representation");
OCRepPayload* rep = payload;
int i = 1;
while(rep)
{
- OC_LOG_V(level, PL_TAG, "\tResource #%d", i);
- OC_LOG_V(level, PL_TAG, "\tURI:%s", rep->uri);
- OC_LOG(level, PL_TAG, "\tResource Types:");
+ OIC_LOG_V(level, PL_TAG, "\tResource #%d", i);
+ OIC_LOG_V(level, PL_TAG, "\tURI:%s", rep->uri);
+ OIC_LOG(level, PL_TAG, "\tResource Types:");
OCStringLL* strll = rep->types;
while(strll)
{
- OC_LOG_V(level, PL_TAG, "\t\t%s", strll->value);
+ OIC_LOG_V(level, PL_TAG, "\t\t%s", strll->value);
strll = strll->next;
}
- OC_LOG(level, PL_TAG, "\tInterfaces:");
+ OIC_LOG(level, PL_TAG, "\tInterfaces:");
strll = rep->interfaces;
while(strll)
{
- OC_LOG_V(level, PL_TAG, "\t\t%s", strll->value);
+ OIC_LOG_V(level, PL_TAG, "\t\t%s", strll->value);
strll = strll->next;
}
// TODO Finish Logging: Values
OCRepPayloadValue* val = rep->values;
- OC_LOG(level, PL_TAG, "\tValues:");
+ OIC_LOG(level, PL_TAG, "\tValues:");
while(val)
{
switch(val->type)
{
case OCREP_PROP_NULL:
- OC_LOG_V(level, PL_TAG, "\t\t%s: NULL", val->name);
+ OIC_LOG_V(level, PL_TAG, "\t\t%s: NULL", val->name);
break;
case OCREP_PROP_INT:
- OC_LOG_V(level, PL_TAG, "\t\t%s(int):%zd", val->name, val->i);
+ OIC_LOG_V(level, PL_TAG, "\t\t%s(int):%zd", val->name, val->i);
break;
case OCREP_PROP_DOUBLE:
- OC_LOG_V(level, PL_TAG, "\t\t%s(double):%f", val->name, val->d);
+ OIC_LOG_V(level, PL_TAG, "\t\t%s(double):%f", val->name, val->d);
break;
case OCREP_PROP_BOOL:
- OC_LOG_V(level, PL_TAG, "\t\t%s(bool):%s", val->name, val->b ? "true" : "false");
+ OIC_LOG_V(level, PL_TAG, "\t\t%s(bool):%s", val->name, val->b ? "true" : "false");
break;
case OCREP_PROP_STRING:
- OC_LOG_V(level, PL_TAG, "\t\t%s(string):%s", val->name, val->str);
+ OIC_LOG_V(level, PL_TAG, "\t\t%s(string):%s", val->name, val->str);
break;
case OCREP_PROP_BYTE_STRING:
- OC_LOG_V(level, PL_TAG, "\t\t%s(binary):", val->name);
- OC_LOG_BUFFER(level, PL_TAG, val->ocByteStr.bytes, val->ocByteStr.len);
+ OIC_LOG_V(level, PL_TAG, "\t\t%s(binary):", val->name);
+ OIC_LOG_BUFFER(level, PL_TAG, val->ocByteStr.bytes, val->ocByteStr.len);
break;
case OCREP_PROP_OBJECT:
// Note: Only prints the URI (if available), to print further, you'll
// need to dig into the object better!
- OC_LOG_V(level, PL_TAG, "\t\t%s(OCRep):%s", val->name, val->obj->uri);
+ OIC_LOG_V(level, PL_TAG, "\t\t%s(OCRep):%s", val->name, val->obj->uri);
break;
case OCREP_PROP_ARRAY:
switch(val->arr.type)
{
case OCREP_PROP_INT:
- OC_LOG_V(level, PL_TAG, "\t\t%s(int array):%zu x %zu x %zu",
+ OIC_LOG_V(level, PL_TAG, "\t\t%s(int array):%zu x %zu x %zu",
val->name,
val->arr.dimensions[0], val->arr.dimensions[1],
val->arr.dimensions[2]);
break;
case OCREP_PROP_DOUBLE:
- OC_LOG_V(level, PL_TAG, "\t\t%s(double array):%zu x %zu x %zu",
+ OIC_LOG_V(level, PL_TAG, "\t\t%s(double array):%zu x %zu x %zu",
val->name,
val->arr.dimensions[0], val->arr.dimensions[1],
val->arr.dimensions[2]);
break;
case OCREP_PROP_BOOL:
- OC_LOG_V(level, PL_TAG, "\t\t%s(bool array):%zu x %zu x %zu",
+ OIC_LOG_V(level, PL_TAG, "\t\t%s(bool array):%zu x %zu x %zu",
val->name,
val->arr.dimensions[0], val->arr.dimensions[1],
val->arr.dimensions[2]);
break;
case OCREP_PROP_STRING:
- OC_LOG_V(level, PL_TAG, "\t\t%s(string array):%zu x %zu x %zu",
+ OIC_LOG_V(level, PL_TAG, "\t\t%s(string array):%zu x %zu x %zu",
val->name,
val->arr.dimensions[0], val->arr.dimensions[1],
val->arr.dimensions[2]);
break;
case OCREP_PROP_BYTE_STRING:
- OC_LOG_V(level, PL_TAG, "\t\t%s(byte array):%zu x %zu x %zu",
+ OIC_LOG_V(level, PL_TAG, "\t\t%s(byte array):%zu x %zu x %zu",
val->name,
val->arr.dimensions[0], val->arr.dimensions[1],
val->arr.dimensions[2]);
break;
case OCREP_PROP_OBJECT:
- OC_LOG_V(level, PL_TAG, "\t\t%s(OCRep array):%zu x %zu x %zu",
+ OIC_LOG_V(level, PL_TAG, "\t\t%s(OCRep array):%zu x %zu x %zu",
val->name,
val->arr.dimensions[0], val->arr.dimensions[1],
val->arr.dimensions[2]);
break;
default:
- OC_LOG_V(ERROR, PL_TAG, "\t\t%s <-- Unknown/unsupported array type!",
+ OIC_LOG_V(ERROR, PL_TAG, "\t\t%s <-- Unknown/unsupported array type!",
val->name);
break;
}
break;
default:
- OC_LOG_V(ERROR, PL_TAG, "\t\t%s <-- Unknown type!", val->name);
+ OIC_LOG_V(ERROR, PL_TAG, "\t\t%s <-- Unknown type!", val->name);
break;
}
val = val -> next;
static inline void OCPayloadLogDiscovery(LogLevel level, OCDiscoveryPayload* payload)
{
- OC_LOG(level, PL_TAG, "Payload Type: Discovery");
+ OIC_LOG(level, PL_TAG, "Payload Type: Discovery");
int i = 1;
if(!payload->resources)
{
- OC_LOG(level, PL_TAG, "\tNO Resources");
+ OIC_LOG(level, PL_TAG, "\tNO Resources");
return;
}
- OC_LOG(level, PL_TAG, "\tSID:");
- OC_LOG_BUFFER(level, PL_TAG, payload->sid, UUID_SIZE);
+ OIC_LOG(level, PL_TAG, "\tSID:");
+ OIC_LOG_BUFFER(level, PL_TAG, payload->sid, UUID_SIZE);
OCResourcePayload* res = payload->resources;
while(res)
{
- OC_LOG_V(level, PL_TAG, "\tResource #%d", i);
- OC_LOG_V(level, PL_TAG, "\tURI:%s", res->uri);
- OC_LOG(level, PL_TAG, "\tResource Types:");
+ OIC_LOG_V(level, PL_TAG, "\tResource #%d", i);
+ OIC_LOG_V(level, PL_TAG, "\tURI:%s", res->uri);
+ OIC_LOG(level, PL_TAG, "\tResource Types:");
OCStringLL* strll = res->types;
while(strll)
{
- OC_LOG_V(level, PL_TAG, "\t\t%s", strll->value);
+ OIC_LOG_V(level, PL_TAG, "\t\t%s", strll->value);
strll = strll->next;
}
- OC_LOG(level, PL_TAG, "\tInterfaces:");
+ OIC_LOG(level, PL_TAG, "\tInterfaces:");
strll = res->interfaces;
while(strll)
{
- OC_LOG_V(level, PL_TAG, "\t\t%s", strll->value);
+ OIC_LOG_V(level, PL_TAG, "\t\t%s", strll->value);
strll = strll->next;
}
- OC_LOG_V(level, PL_TAG, "\tBitmap: %u", res->bitmap);
- OC_LOG_V(level, PL_TAG, "\tSecure?: %s", res->secure ? "true" : "false");
- OC_LOG_V(level, PL_TAG, "\tPort: %u", res->port);
- OC_LOG(level, PL_TAG, "");
+ OIC_LOG_V(level, PL_TAG, "\tBitmap: %u", res->bitmap);
+ OIC_LOG_V(level, PL_TAG, "\tSecure?: %s", res->secure ? "true" : "false");
+ OIC_LOG_V(level, PL_TAG, "\tPort: %u", res->port);
+ OIC_LOG(level, PL_TAG, "");
res = res->next;
++i;
}
static inline void OCPayloadLogDevice(LogLevel level, OCDevicePayload* payload)
{
- OC_LOG(level, PL_TAG, "Payload Type: Device");
- OC_LOG(level, PL_TAG, "\tSID:");
- OC_LOG_BUFFER(level, PL_TAG, payload->sid, UUID_SIZE);
- OC_LOG_V(level, PL_TAG, "\tDevice Name:%s", payload->deviceName);
- OC_LOG_V(level, PL_TAG, "\tSpec Version%s", payload->specVersion);
- OC_LOG_V(level, PL_TAG, "\tData Model Version:%s", payload->dataModelVersion);
+ OIC_LOG(level, PL_TAG, "Payload Type: Device");
+ OIC_LOG(level, PL_TAG, "\tSID:");
+ OIC_LOG_BUFFER(level, PL_TAG, payload->sid, UUID_SIZE);
+ OIC_LOG_V(level, PL_TAG, "\tDevice Name:%s", payload->deviceName);
+ OIC_LOG_V(level, PL_TAG, "\tSpec Version%s", payload->specVersion);
+ OIC_LOG_V(level, PL_TAG, "\tData Model Version:%s", payload->dataModelVersion);
}
static inline void OCPayloadLogPlatform(LogLevel level, OCPlatformPayload* payload)
{
- OC_LOG(level, PL_TAG, "Payload Type: Platform");
- OC_LOG_V(level, PL_TAG, "\tURI:%s", payload->uri);
- OC_LOG_V(level, PL_TAG, "\tPlatform ID:%s", payload->info.platformID);
- OC_LOG_V(level, PL_TAG, "\tMfg Name:%s", payload->info.manufacturerName);
- OC_LOG_V(level, PL_TAG, "\tMfg URL:%s", payload->info.manufacturerUrl);
- OC_LOG_V(level, PL_TAG, "\tModel Number:%s", payload->info.modelNumber);
- OC_LOG_V(level, PL_TAG, "\tDate of Mfg:%s", payload->info.dateOfManufacture);
- OC_LOG_V(level, PL_TAG, "\tPlatform Version:%s", payload->info.platformVersion);
- OC_LOG_V(level, PL_TAG, "\tOS Version:%s", payload->info.operatingSystemVersion);
- OC_LOG_V(level, PL_TAG, "\tHardware Version:%s", payload->info.hardwareVersion);
- OC_LOG_V(level, PL_TAG, "\tFirmware Version:%s", payload->info.firmwareVersion);
- OC_LOG_V(level, PL_TAG, "\tSupport URL:%s", payload->info.supportUrl);
- OC_LOG_V(level, PL_TAG, "\tSystem Time:%s", payload->info.systemTime);
+ OIC_LOG(level, PL_TAG, "Payload Type: Platform");
+ OIC_LOG_V(level, PL_TAG, "\tURI:%s", payload->uri);
+ OIC_LOG_V(level, PL_TAG, "\tPlatform ID:%s", payload->info.platformID);
+ OIC_LOG_V(level, PL_TAG, "\tMfg Name:%s", payload->info.manufacturerName);
+ OIC_LOG_V(level, PL_TAG, "\tMfg URL:%s", payload->info.manufacturerUrl);
+ OIC_LOG_V(level, PL_TAG, "\tModel Number:%s", payload->info.modelNumber);
+ OIC_LOG_V(level, PL_TAG, "\tDate of Mfg:%s", payload->info.dateOfManufacture);
+ OIC_LOG_V(level, PL_TAG, "\tPlatform Version:%s", payload->info.platformVersion);
+ OIC_LOG_V(level, PL_TAG, "\tOS Version:%s", payload->info.operatingSystemVersion);
+ OIC_LOG_V(level, PL_TAG, "\tHardware Version:%s", payload->info.hardwareVersion);
+ OIC_LOG_V(level, PL_TAG, "\tFirmware Version:%s", payload->info.firmwareVersion);
+ OIC_LOG_V(level, PL_TAG, "\tSupport URL:%s", payload->info.supportUrl);
+ OIC_LOG_V(level, PL_TAG, "\tSystem Time:%s", payload->info.systemTime);
}
static inline void OCPayloadLogPresence(LogLevel level, OCPresencePayload* payload)
{
- OC_LOG(level, PL_TAG, "Payload Type: Presence");
- OC_LOG_V(level, PL_TAG, "\tSequence Number:%u", payload->sequenceNumber);
- OC_LOG_V(level, PL_TAG, "\tMax Age:%d", payload->maxAge);
- OC_LOG_V(level, PL_TAG, "\tTrigger:%s", convertTriggerEnumToString(payload->trigger));
- OC_LOG_V(level, PL_TAG, "\tResource Type:%s", payload->resourceType);
+ OIC_LOG(level, PL_TAG, "Payload Type: Presence");
+ OIC_LOG_V(level, PL_TAG, "\tSequence Number:%u", payload->sequenceNumber);
+ OIC_LOG_V(level, PL_TAG, "\tMax Age:%d", payload->maxAge);
+ OIC_LOG_V(level, PL_TAG, "\tTrigger:%s", convertTriggerEnumToString(payload->trigger));
+ OIC_LOG_V(level, PL_TAG, "\tResource Type:%s", payload->resourceType);
}
static inline void OCPayloadLogSecurity(LogLevel level, OCSecurityPayload* payload)
{
- OC_LOG(level, PL_TAG, "Payload Type: Security");
- OC_LOG_V(level, PL_TAG, "\tSecurity Data: %s", payload->securityData);
+ OIC_LOG(level, PL_TAG, "Payload Type: Security");
+ OIC_LOG_V(level, PL_TAG, "\tSecurity Data: %s", payload->securityData);
}
static inline void OCRDPayloadLog(const LogLevel level, const OCRDPayload *payload)
if (payload->rdDiscovery)
{
- OC_LOG(level, PL_TAG, "RD Discovery");
- OC_LOG_V(level, PL_TAG, " Device Name : %s", payload->rdDiscovery->n.deviceName);
- OC_LOG_V(level, PL_TAG, " Device Identity : %s", payload->rdDiscovery->di.id);
- OC_LOG_V(level, PL_TAG, " Bias: %d", payload->rdDiscovery->sel);
+ OIC_LOG(level, PL_TAG, "RD Discovery");
+ OIC_LOG_V(level, PL_TAG, " Device Name : %s", payload->rdDiscovery->n.deviceName);
+ OIC_LOG_V(level, PL_TAG, " Device Identity : %s", payload->rdDiscovery->di.id);
+ OIC_LOG_V(level, PL_TAG, " Bias: %d", payload->rdDiscovery->sel);
}
if (payload->rdPublish)
{
- OC_LOG(level, PL_TAG, "RD Publish");
+ OIC_LOG(level, PL_TAG, "RD Publish");
OCResourceCollectionPayload *rdPublish = payload->rdPublish;
OCTagsLog(level, rdPublish->tags);
OCLinksLog(level, rdPublish->setLinks);
{
if(!payload)
{
- OC_LOG(level, PL_TAG, "NULL Payload");
+ OIC_LOG(level, PL_TAG, "NULL Payload");
return;
}
switch(payload->type)
OCRDPayloadLog(level, (OCRDPayload*)payload);
break;
default:
- OC_LOG_V(level, PL_TAG, "Unknown Payload Type: %d", payload->type);
+ OIC_LOG_V(level, PL_TAG, "Unknown Payload Type: %d", payload->type);
break;
}
}
#else
+ #define OIC_LOG_PAYLOAD(level, payload)
#define OC_LOG_PAYLOAD(level, payload)
#endif
// check for the presence of the shield:
if (WiFi.status() == WL_NO_SHIELD)
{
- OC_LOG(ERROR, TAG, ("WiFi shield not present"));
+ OIC_LOG(ERROR, TAG, ("WiFi shield not present"));
return -1;
}
// Verify that WiFi Shield is running the firmware with all UDP fixes
fwVersion = WiFi.firmwareVersion();
- OC_LOG_V(INFO, TAG, "WiFi Shield Firmware version %s", fwVersion);
+ OIC_LOG_V(INFO, TAG, "WiFi Shield Firmware version %s", fwVersion);
if ( strncmp(fwVersion, ARDUINO_WIFI_SHIELD_UDP_FW_VER, sizeof(ARDUINO_WIFI_SHIELD_UDP_FW_VER)) !=0 )
{
- OC_LOG(DEBUG, TAG, ("!!!!! Upgrade WiFi Shield Firmware version !!!!!!"));
+ OIC_LOG(DEBUG, TAG, ("!!!!! Upgrade WiFi Shield Firmware version !!!!!!"));
return -1;
}
// attempt to connect to Wifi network:
while (status != WL_CONNECTED)
{
- OC_LOG_V(INFO, TAG, "Attempting to connect to SSID: %s", ssid);
+ OIC_LOG_V(INFO, TAG, "Attempting to connect to SSID: %s", ssid);
status = WiFi.begin(ssid,pass);
// wait 10 seconds for connection:
delay(10000);
}
- OC_LOG(DEBUG, TAG, ("Connected to wifi"));
+ OIC_LOG(DEBUG, TAG, ("Connected to wifi"));
IPAddress ip = WiFi.localIP();
- OC_LOG_V(INFO, TAG, "IP Address: %d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
+ OIC_LOG_V(INFO, TAG, "IP Address: %d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
return 0;
}
#elif defined ARDUINOETH
uint8_t error = Ethernet.begin(ETHERNET_MAC);
if (error == 0)
{
- OC_LOG_V(ERROR, TAG, "error is: %d", error);
+ OIC_LOG_V(ERROR, TAG, "error is: %d", error);
return -1;
}
IPAddress ip = Ethernet.localIP();
- OC_LOG_V(INFO, TAG, "IP Address: %d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
+ OIC_LOG_V(INFO, TAG, "IP Address: %d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
return 0;
}
#endif //ARDUINOWIFI
extern char *__brkval;
//address of tmp gives us the current stack boundry
int tmp;
- OC_LOG_V(INFO, TAG, "Stack: %u Heap: %u", (unsigned int)&tmp, (unsigned int)__brkval);
- OC_LOG_V(INFO, TAG, "Unallocated Memory between heap and stack: %u",
+ OIC_LOG_V(INFO, TAG, "Stack: %u Heap: %u", (unsigned int)&tmp, (unsigned int)__brkval);
+ OIC_LOG_V(INFO, TAG, "Unallocated Memory between heap and stack: %u",
((unsigned int)&tmp - (unsigned int)__brkval));
#endif
}
OCRepPayload* payload = OCRepPayloadCreate();
if(!payload)
{
- OC_LOG(ERROR, TAG, ("Failed to allocate Payload"));
+ OIC_LOG(ERROR, TAG, ("Failed to allocate Payload"));
return OC_EH_ERROR;
}
if(entityHandlerRequest && (flag & OC_REQUEST_FLAG))
{
- OC_LOG (INFO, TAG, ("Flag includes OC_REQUEST_FLAG"));
+ OIC_LOG (INFO, TAG, ("Flag includes OC_REQUEST_FLAG"));
if(OC_REST_GET == entityHandlerRequest->method)
{
// Send the response
if (OCDoResponse(&response) != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "Error sending response");
+ OIC_LOG(ERROR, TAG, "Error sending response");
ehRet = OC_EH_ERROR;
}
}
{
if (OC_OBSERVE_REGISTER == entityHandlerRequest->obsInfo.action)
{
- OC_LOG (INFO, TAG, ("Received OC_OBSERVE_REGISTER from client"));
+ OIC_LOG (INFO, TAG, ("Received OC_OBSERVE_REGISTER from client"));
gLightUnderObservation = 1;
}
else if (OC_OBSERVE_DEREGISTER == entityHandlerRequest->obsInfo.action)
{
- OC_LOG (INFO, TAG, ("Received OC_OBSERVE_DEREGISTER from client"));
+ OIC_LOG (INFO, TAG, ("Received OC_OBSERVE_DEREGISTER from client"));
gLightUnderObservation = 0;
}
}
Light.power += 5;
if (gLightUnderObservation)
{
- OC_LOG_V(INFO, TAG, " =====> Notifying stack of new power level %d\n", Light.power);
+ OIC_LOG_V(INFO, TAG, " =====> Notifying stack of new power level %d\n", Light.power);
result = OCNotifyAllObservers (Light.handle, OC_NA_QOS);
if (OC_STACK_NO_OBSERVERS == result)
{
{
// Add your initialization code here
// Note : This will initialize Serial port on Arduino at 115200 bauds
- OC_LOG_INIT();
- OC_LOG(DEBUG, TAG, ("OCServer is starting..."));
+ OIC_LOG_INIT();
+ OIC_LOG(DEBUG, TAG, ("OCServer is starting..."));
// Connect to Ethernet or WiFi network
#if defined(ARDUINOWIFI) || defined(ARDUINOETH)
if (ConnectToNetwork() != 0)
{
- OC_LOG(ERROR, TAG, ("Unable to connect to network"));
+ OIC_LOG(ERROR, TAG, ("Unable to connect to network"));
return;
}
#endif
// Initialize the OC Stack in Server mode
if (OCInit(NULL, 0, OC_SERVER) != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, ("OCStack init error"));
+ OIC_LOG(ERROR, TAG, ("OCStack init error"));
return;
}
// Give CPU cycles to OCStack to perform send/recv and other OCStack stuff
if (OCProcess() != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, ("OCStack process error"));
+ OIC_LOG(ERROR, TAG, ("OCStack process error"));
return;
}
ChangeLightRepresentation(NULL);
OCEntityHandlerCb,
NULL,
OC_DISCOVERABLE|OC_OBSERVABLE);
- OC_LOG_V(INFO, TAG, "Created Light resource with result: %s", getResult(res));
+ OIC_LOG_V(INFO, TAG, "Created Light resource with result: %s", getResult(res));
}
const char *getResult(OCStackResult result) {
static void PrintUsage()
{
- OC_LOG(INFO, TAG, "Usage : occlient -u <0|1> -t <1..17> -c <0|1>");
- OC_LOG(INFO, TAG, "-u <0|1> : Perform multicast/unicast discovery of resources");
- OC_LOG(INFO, TAG, "-c 0 : Use Default connectivity(IP)");
- OC_LOG(INFO, TAG, "-c 1 : IP Connectivity Type");
- OC_LOG(INFO, TAG, "-t 1 : Discover Resources");
- OC_LOG(INFO, TAG, "-t 2 : Discover Resources and Initiate Nonconfirmable Get Request");
- OC_LOG(INFO, TAG, "-t 3 : Discover Resources and Initiate Nonconfirmable Get Request"
+ OIC_LOG(INFO, TAG, "Usage : occlient -u <0|1> -t <1..17> -c <0|1>");
+ OIC_LOG(INFO, TAG, "-u <0|1> : Perform multicast/unicast discovery of resources");
+ OIC_LOG(INFO, TAG, "-c 0 : Use Default connectivity(IP)");
+ OIC_LOG(INFO, TAG, "-c 1 : IP Connectivity Type");
+ OIC_LOG(INFO, TAG, "-t 1 : Discover Resources");
+ OIC_LOG(INFO, TAG, "-t 2 : Discover Resources and Initiate Nonconfirmable Get Request");
+ OIC_LOG(INFO, TAG, "-t 3 : Discover Resources and Initiate Nonconfirmable Get Request"
" with query filter.");
- OC_LOG(INFO, TAG, "-t 4 : Discover Resources and Initiate Nonconfirmable Put Requests");
- OC_LOG(INFO, TAG, "-t 5 : Discover Resources and Initiate Nonconfirmable Post Requests");
- OC_LOG(INFO, TAG, "-t 6 : Discover Resources and Initiate Nonconfirmable Delete Requests");
- OC_LOG(INFO, TAG, "-t 7 : Discover Resources and Initiate Nonconfirmable Observe Requests");
- OC_LOG(INFO, TAG, "-t 8 : Discover Resources and Initiate Nonconfirmable Get Request "\
+ OIC_LOG(INFO, TAG, "-t 4 : Discover Resources and Initiate Nonconfirmable Put Requests");
+ OIC_LOG(INFO, TAG, "-t 5 : Discover Resources and Initiate Nonconfirmable Post Requests");
+ OIC_LOG(INFO, TAG, "-t 6 : Discover Resources and Initiate Nonconfirmable Delete Requests");
+ OIC_LOG(INFO, TAG, "-t 7 : Discover Resources and Initiate Nonconfirmable Observe Requests");
+ OIC_LOG(INFO, TAG, "-t 8 : Discover Resources and Initiate Nonconfirmable Get Request "\
"for a resource which is unavailable");
- OC_LOG(INFO, TAG, "-t 9 : Discover Resources and Initiate Confirmable Get Request");
- OC_LOG(INFO, TAG, "-t 10 : Discover Resources and Initiate Confirmable Post Request");
- OC_LOG(INFO, TAG, "-t 11 : Discover Resources and Initiate Confirmable Delete Requests");
- OC_LOG(INFO, TAG, "-t 12 : Discover Resources and Initiate Confirmable Observe Requests"\
+ OIC_LOG(INFO, TAG, "-t 9 : Discover Resources and Initiate Confirmable Get Request");
+ OIC_LOG(INFO, TAG, "-t 10 : Discover Resources and Initiate Confirmable Post Request");
+ OIC_LOG(INFO, TAG, "-t 11 : Discover Resources and Initiate Confirmable Delete Requests");
+ OIC_LOG(INFO, TAG, "-t 12 : Discover Resources and Initiate Confirmable Observe Requests"\
" and cancel with Low QoS");
#ifdef WITH_PRESENCE
- OC_LOG(INFO, TAG, "-t 13 : Discover Resources and Initiate Nonconfirmable presence");
- OC_LOG(INFO, TAG, "-t 14 : Discover Resources and Initiate Nonconfirmable presence with "\
+ OIC_LOG(INFO, TAG, "-t 13 : Discover Resources and Initiate Nonconfirmable presence");
+ OIC_LOG(INFO, TAG, "-t 14 : Discover Resources and Initiate Nonconfirmable presence with "\
"filter");
- OC_LOG(INFO, TAG, "-t 15 : Discover Resources and Initiate Nonconfirmable presence with "\
+ OIC_LOG(INFO, TAG, "-t 15 : Discover Resources and Initiate Nonconfirmable presence with "\
"2 filters");
- OC_LOG(INFO, TAG, "-t 16 : Discover Resources and Initiate Nonconfirmable multicast presence.");
+ OIC_LOG(INFO, TAG, "-t 16 : Discover Resources and Initiate Nonconfirmable multicast presence.");
#endif
- OC_LOG(INFO, TAG, "-t 17 : Discover Resources and Initiate Nonconfirmable Observe Requests "\
+ OIC_LOG(INFO, TAG, "-t 17 : Discover Resources and Initiate Nonconfirmable Observe Requests "\
"then cancel immediately with High QOS");
- OC_LOG(INFO, TAG, "-t 18 : Discover Resources and Initiate Nonconfirmable Get Request and "\
+ OIC_LOG(INFO, TAG, "-t 18 : Discover Resources and Initiate Nonconfirmable Get Request and "\
"add vendor specific header options");
- OC_LOG(INFO, TAG, "-t 19 : Discover Platform");
- OC_LOG(INFO, TAG, "-t 20 : Discover Devices");
+ OIC_LOG(INFO, TAG, "-t 19 : Discover Platform");
+ OIC_LOG(INFO, TAG, "-t 20 : Discover Devices");
}
OCStackResult InvokeOCDoResource(std::ostringstream &query,
if (ret != OC_STACK_OK)
{
- OC_LOG_V(ERROR, TAG, "OCDoResource returns error %d with method %d", ret, method);
+ OIC_LOG_V(ERROR, TAG, "OCDoResource returns error %d with method %d", ret, method);
}
#ifdef WITH_PRESENCE
else if (method == OC_REST_PRESENCE)
{
if (ctx == (void*)DEFAULT_CONTEXT_VALUE)
{
- OC_LOG(INFO, TAG, "Callback Context for PUT recvd successfully");
+ OIC_LOG(INFO, TAG, "Callback Context for PUT recvd successfully");
}
if (clientResponse)
{
- OC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
- OC_LOG_PAYLOAD(INFO, clientResponse->payload);
- OC_LOG(INFO, TAG, ("=============> Put Response"));
+ OIC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
+ OIC_LOG_PAYLOAD(INFO, clientResponse->payload);
+ OIC_LOG(INFO, TAG, ("=============> Put Response"));
}
else
{
- OC_LOG_V(INFO, TAG, "putReqCB received Null clientResponse");
+ OIC_LOG_V(INFO, TAG, "putReqCB received Null clientResponse");
}
return OC_STACK_DELETE_TRANSACTION;
}
{
if (ctx == (void*)DEFAULT_CONTEXT_VALUE)
{
- OC_LOG(INFO, TAG, "Callback Context for POST recvd successfully");
+ OIC_LOG(INFO, TAG, "Callback Context for POST recvd successfully");
}
if (clientResponse)
{
- OC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
- OC_LOG_PAYLOAD(INFO, clientResponse->payload);
- OC_LOG(INFO, TAG, ("=============> Post Response"));
+ OIC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
+ OIC_LOG_PAYLOAD(INFO, clientResponse->payload);
+ OIC_LOG(INFO, TAG, ("=============> Post Response"));
}
else
{
- OC_LOG_V(INFO, TAG, "postReqCB received Null clientResponse");
+ OIC_LOG_V(INFO, TAG, "postReqCB received Null clientResponse");
}
return OC_STACK_DELETE_TRANSACTION;
}
{
if (ctx == (void*)DEFAULT_CONTEXT_VALUE)
{
- OC_LOG(INFO, TAG, "Callback Context for DELETE recvd successfully");
+ OIC_LOG(INFO, TAG, "Callback Context for DELETE recvd successfully");
}
if (clientResponse)
{
- OC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
- OC_LOG_PAYLOAD(INFO, clientResponse->payload);
- OC_LOG(INFO, TAG, ("=============> Delete Response"));
+ OIC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
+ OIC_LOG_PAYLOAD(INFO, clientResponse->payload);
+ OIC_LOG(INFO, TAG, ("=============> Delete Response"));
}
else
{
- OC_LOG_V(INFO, TAG, "deleteReqCB received Null clientResponse");
+ OIC_LOG_V(INFO, TAG, "deleteReqCB received Null clientResponse");
}
return OC_STACK_DELETE_TRANSACTION;
}
{
if (clientResponse == NULL)
{
- OC_LOG(INFO, TAG, "getReqCB received NULL clientResponse");
+ OIC_LOG(INFO, TAG, "getReqCB received NULL clientResponse");
return OC_STACK_DELETE_TRANSACTION;
}
if (ctx == (void*)DEFAULT_CONTEXT_VALUE)
{
- OC_LOG(INFO, TAG, "Callback Context for GET query recvd successfully");
+ OIC_LOG(INFO, TAG, "Callback Context for GET query recvd successfully");
}
- OC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
- OC_LOG_V(INFO, TAG, "SEQUENCE NUMBER: %d", clientResponse->sequenceNumber);
- OC_LOG_PAYLOAD(INFO, clientResponse->payload);
- OC_LOG(INFO, TAG, ("=============> Get Response"));
+ 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"));
if (clientResponse->numRcvdVendorSpecificHeaderOptions > 0)
{
- OC_LOG (INFO, TAG, "Received vendor specific options");
+ OIC_LOG (INFO, TAG, "Received vendor specific options");
uint8_t i = 0;
OCHeaderOption * rcvdOptions = clientResponse->rcvdVendorSpecificHeaderOptions;
for( i = 0; i < clientResponse->numRcvdVendorSpecificHeaderOptions; i++)
{
if (((OCHeaderOption)rcvdOptions[i]).protocolID == OC_COAP_ID)
{
- OC_LOG_V(INFO, TAG, "Received option with OC_COAP_ID and ID %u with",
+ OIC_LOG_V(INFO, TAG, "Received option with OC_COAP_ID and ID %u with",
((OCHeaderOption)rcvdOptions[i]).optionID );
- OC_LOG_BUFFER(INFO, TAG, ((OCHeaderOption)rcvdOptions[i]).optionData,
+ OIC_LOG_BUFFER(INFO, TAG, ((OCHeaderOption)rcvdOptions[i]).optionData,
MAX_HEADER_OPTION_DATA_LENGTH);
}
}
{
if (ctx == (void*)DEFAULT_CONTEXT_VALUE)
{
- OC_LOG(INFO, TAG, "Callback Context for OBS query recvd successfully");
+ OIC_LOG(INFO, TAG, "Callback Context for OBS query recvd successfully");
}
if (clientResponse)
{
- OC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
- OC_LOG_V(INFO, TAG, "SEQUENCE NUMBER: %d", clientResponse->sequenceNumber);
- OC_LOG_V(INFO, TAG, "Callback Context for OBSERVE notification recvd successfully %d",
+ OIC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
+ OIC_LOG_V(INFO, TAG, "SEQUENCE NUMBER: %d", clientResponse->sequenceNumber);
+ OIC_LOG_V(INFO, TAG, "Callback Context for OBSERVE notification recvd successfully %d",
gNumObserveNotifies);
- OC_LOG_PAYLOAD(INFO, clientResponse->payload);
- OC_LOG(INFO, TAG, ("=============> Obs Response"));
+ OIC_LOG_PAYLOAD(INFO, clientResponse->payload);
+ OIC_LOG(INFO, TAG, ("=============> Obs Response"));
gNumObserveNotifies++;
if (gNumObserveNotifies > 15) //large number to test observing in DELETE case.
{
if (TestCase == TEST_OBS_REQ_NON || TestCase == TEST_OBS_REQ_CON)
{
- OC_LOG(ERROR, TAG, "Cancelling with LOW QOS");
+ OIC_LOG(ERROR, TAG, "Cancelling with LOW QOS");
if (OCCancel (handle, OC_LOW_QOS, NULL, 0) != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "Observe cancel error");
+ OIC_LOG(ERROR, TAG, "Observe cancel error");
}
return OC_STACK_DELETE_TRANSACTION;
}
else if (TestCase == TEST_OBS_REQ_NON_CANCEL_IMM)
{
- OC_LOG(ERROR, TAG, "Cancelling with HIGH QOS");
+ OIC_LOG(ERROR, TAG, "Cancelling with HIGH QOS");
if (OCCancel (handle, OC_HIGH_QOS, NULL, 0) != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "Observe cancel error");
+ OIC_LOG(ERROR, TAG, "Observe cancel error");
}
}
}
if (clientResponse->sequenceNumber == OC_OBSERVE_REGISTER)
{
- OC_LOG(INFO, TAG, "This also serves as a registration confirmation");
+ OIC_LOG(INFO, TAG, "This also serves as a registration confirmation");
}
else if (clientResponse->sequenceNumber == OC_OBSERVE_DEREGISTER)
{
- OC_LOG(INFO, TAG, "This also serves as a deregistration confirmation");
+ OIC_LOG(INFO, TAG, "This also serves as a deregistration confirmation");
return OC_STACK_DELETE_TRANSACTION;
}
else if (clientResponse->sequenceNumber == OC_OBSERVE_NO_OPTION)
{
- OC_LOG(INFO, TAG, "This also tells you that registration/deregistration failed");
+ OIC_LOG(INFO, TAG, "This also tells you that registration/deregistration failed");
return OC_STACK_DELETE_TRANSACTION;
}
}
else
{
- OC_LOG_V(INFO, TAG, "obsReqCB received Null clientResponse");
+ OIC_LOG_V(INFO, TAG, "obsReqCB received Null clientResponse");
}
return OC_STACK_KEEP_TRANSACTION;
}
{
if (ctx == (void*) DEFAULT_CONTEXT_VALUE)
{
- OC_LOG(INFO, TAG, "Callback Context for Presence recvd successfully");
+ OIC_LOG(INFO, TAG, "Callback Context for Presence recvd successfully");
}
if (clientResponse)
{
- OC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
- OC_LOG_V(INFO, TAG, "Callback Context for Presence notification recvd successfully %d",
+ OIC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
+ OIC_LOG_V(INFO, TAG, "Callback Context for Presence notification recvd successfully %d",
gNumPresenceNotifies);
- OC_LOG_PAYLOAD(INFO, clientResponse->payload);
- OC_LOG(INFO, TAG, ("=============> Presence Response"));
+ OIC_LOG_PAYLOAD(INFO, clientResponse->payload);
+ OIC_LOG(INFO, TAG, ("=============> Presence Response"));
gNumPresenceNotifies++;
if (gNumPresenceNotifies == 20)
{
if (OCCancel(gPresenceHandle, OC_LOW_QOS, NULL, 0) != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "Presence cancel error");
+ OIC_LOG(ERROR, TAG, "Presence cancel error");
}
return OC_STACK_DELETE_TRANSACTION;
}
}
else
{
- OC_LOG_V(INFO, TAG, "presenceCB received Null clientResponse");
+ OIC_LOG_V(INFO, TAG, "presenceCB received Null clientResponse");
}
return OC_STACK_KEEP_TRANSACTION;
}
{
if (ctx == (void*) DEFAULT_CONTEXT_VALUE)
{
- OC_LOG(INFO, TAG, "Callback Context for DISCOVER query recvd successfully");
+ OIC_LOG(INFO, TAG, "Callback Context for DISCOVER query recvd successfully");
}
if (clientResponse)
{
- OC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
+ OIC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
std::string connectionType = getConnectivityType (clientResponse->connType);
- OC_LOG_V(INFO, TAG, "Discovered on %s", connectionType.c_str());
- OC_LOG_V(INFO, TAG,
+ OIC_LOG_V(INFO, TAG, "Discovered on %s", connectionType.c_str());
+ OIC_LOG_V(INFO, TAG,
"Device =============> Discovered @ %s:%d",
clientResponse->devAddr.addr,
clientResponse->devAddr.port);
- OC_LOG_PAYLOAD(INFO, clientResponse->payload);
+ OIC_LOG_PAYLOAD(INFO, clientResponse->payload);
ConnType = clientResponse->connType;
serverAddr = clientResponse->devAddr;
OCResourcePayload *resource = (OCResourcePayload*) payload->resources;
if (!resource)
{
- OC_LOG_V (INFO, TAG, "No resources in payload");
+ OIC_LOG_V (INFO, TAG, "No resources in payload");
return OC_STACK_DELETE_TRANSACTION;
}
coapServerResource = resource->uri;
}
else
{
- OC_LOG_V(INFO, TAG, "discoveryReqCB received Null clientResponse");
+ OIC_LOG_V(INFO, TAG, "discoveryReqCB received Null clientResponse");
}
return OC_STACK_KEEP_TRANSACTION;
}
{
if (ctx == (void*) DEFAULT_CONTEXT_VALUE)
{
- OC_LOG(INFO, TAG, "Callback Context for Platform DISCOVER query recvd successfully");
+ OIC_LOG(INFO, TAG, "Callback Context for Platform DISCOVER query recvd successfully");
}
if (clientResponse)
{
- OC_LOG(INFO, TAG, ("Discovery Response:"));
- OC_LOG_PAYLOAD(INFO, clientResponse->payload);
+ OIC_LOG(INFO, TAG, ("Discovery Response:"));
+ OIC_LOG_PAYLOAD(INFO, clientResponse->payload);
}
else
{
- OC_LOG_V(INFO, TAG, "PlatformDiscoveryReqCB received Null clientResponse");
+ OIC_LOG_V(INFO, TAG, "PlatformDiscoveryReqCB received Null clientResponse");
}
return (UnicastDiscovery) ? OC_STACK_DELETE_TRANSACTION : OC_STACK_KEEP_TRANSACTION;
{
if (ctx == (void*) DEFAULT_CONTEXT_VALUE)
{
- OC_LOG(INFO, TAG, "Callback Context for Device DISCOVER query recvd successfully");
+ OIC_LOG(INFO, TAG, "Callback Context for Device DISCOVER query recvd successfully");
}
if (clientResponse)
{
- OC_LOG(INFO, TAG, ("Discovery Response:"));
- OC_LOG_PAYLOAD(INFO, clientResponse->payload);
+ OIC_LOG(INFO, TAG, ("Discovery Response:"));
+ OIC_LOG_PAYLOAD(INFO, clientResponse->payload);
}
else
{
- OC_LOG_V(INFO, TAG, "PlatformDiscoveryReqCB received Null clientResponse");
+ OIC_LOG_V(INFO, TAG, "PlatformDiscoveryReqCB received Null clientResponse");
}
return (UnicastDiscovery) ? OC_STACK_DELETE_TRANSACTION : OC_STACK_KEEP_TRANSACTION;
int InitPresence()
{
OCStackResult result = OC_STACK_OK;
- OC_LOG_V(INFO, TAG, "\n\nExecuting %s", __func__);
+ OIC_LOG_V(INFO, TAG, "\n\nExecuting %s", __func__);
std::ostringstream query;
std::ostringstream querySuffix;
query << OC_RSRVD_PRESENCE_URI;
{
std::ostringstream query;
query << "/SomeUnknownResource";
- OC_LOG_V(INFO, TAG, "\nExecuting %s with query %s", __func__, query.str().c_str());
+ OIC_LOG_V(INFO, TAG, "\nExecuting %s with query %s", __func__, query.str().c_str());
return (InvokeOCDoResource(query, &serverAddr, OC_REST_GET, (qos == OC_HIGH_QOS)? OC_HIGH_QOS:OC_LOW_QOS,
getReqCB, NULL, 0));
}
{
std::ostringstream query;
query << coapServerResource;
- OC_LOG_V(INFO, TAG, "\nExecuting %s with query %s", __func__, query.str().c_str());
+ OIC_LOG_V(INFO, TAG, "\nExecuting %s with query %s", __func__, query.str().c_str());
return (InvokeOCDoResource(query, &serverAddr, OC_REST_OBSERVE,
(qos == OC_HIGH_QOS)? OC_HIGH_QOS:OC_LOW_QOS, obsReqCB, NULL, 0));
}
{
std::ostringstream query;
query << coapServerResource;
- OC_LOG_V(INFO, TAG, "\nExecuting %s with query %s", __func__, query.str().c_str());
+ OIC_LOG_V(INFO, TAG, "\nExecuting %s with query %s", __func__, query.str().c_str());
return (InvokeOCDoResource(query, &serverAddr, OC_REST_PUT, (qos == OC_HIGH_QOS)? OC_HIGH_QOS:OC_LOW_QOS,
putReqCB, NULL, 0));
}
std::ostringstream query;
query << coapServerResource;
- OC_LOG_V(INFO, TAG, "\nExecuting %s with query %s", __func__, query.str().c_str());
+ OIC_LOG_V(INFO, TAG, "\nExecuting %s with query %s", __func__, query.str().c_str());
// First POST operation (to create an Light instance)
result = InvokeOCDoResource(query, &serverAddr, OC_REST_POST,
((qos == OC_HIGH_QOS) ? OC_HIGH_QOS: OC_LOW_QOS),
if (OC_STACK_OK != result)
{
// Error can happen if for example, network connectivity is down
- OC_LOG(INFO, TAG, "First POST call did not succeed");
+ OIC_LOG(INFO, TAG, "First POST call did not succeed");
}
// Second POST operation (to create an Light instance)
postReqCB, NULL, 0);
if (OC_STACK_OK != result)
{
- OC_LOG(INFO, TAG, "Second POST call did not succeed");
+ OIC_LOG(INFO, TAG, "Second POST call did not succeed");
}
// This POST operation will update the original resourced /a/light
std::ostringstream query;
query << coapServerResource;
- OC_LOG_V(INFO, TAG, "\nExecuting %s with query %s", __func__, query.str().c_str());
+ OIC_LOG_V(INFO, TAG, "\nExecuting %s with query %s", __func__, query.str().c_str());
// Second DELETE operation to delete the resource that might have been removed already.
OCQualityOfService qos;
if (OC_STACK_OK != result)
{
- OC_LOG(INFO, TAG, "Second DELETE call did not succeed");
+ OIC_LOG(INFO, TAG, "Second DELETE call did not succeed");
}
return NULL;
std::ostringstream query;
query << coapServerResource;
- OC_LOG_V(INFO, TAG, "\nExecuting %s with query %s", __func__, query.str().c_str());
+ OIC_LOG_V(INFO, TAG, "\nExecuting %s with query %s", __func__, query.str().c_str());
// First DELETE operation
result = InvokeOCDoResource(query, &serverAddr, OC_REST_DELETE,
if (OC_STACK_OK != result)
{
// Error can happen if for example, network connectivity is down
- OC_LOG(INFO, TAG, "First DELETE call did not succeed");
+ OIC_LOG(INFO, TAG, "First DELETE call did not succeed");
}
else
{
pthread_create (&threadId, NULL, RequestDeleteDeathResourceTask, (void*)qos);
}
- OC_LOG_V(INFO, TAG, "\n\nExit %s", __func__);
+ OIC_LOG_V(INFO, TAG, "\n\nExit %s", __func__);
return result;
}
// ocserver is written to only process "power<X" query.
if (getWithQuery)
{
- OC_LOG(INFO, TAG, "Using query power<50");
+ OIC_LOG(INFO, TAG, "Using query power<50");
query << "?power<50";
}
- OC_LOG_V(INFO, TAG, "\nExecuting %s with query %s", __func__, query.str().c_str());
+ OIC_LOG_V(INFO, TAG, "\nExecuting %s with query %s", __func__, query.str().c_str());
if (withVendorSpecificHeaderOptions)
{
int InitPlatformDiscovery(OCQualityOfService qos)
{
- OC_LOG_V(INFO, TAG, "\n\nExecuting %s", __func__);
+ OIC_LOG_V(INFO, TAG, "\n\nExecuting %s", __func__);
OCStackResult ret;
OCCallbackData cbData;
&cbData, NULL, 0);
if (ret != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack device error");
+ OIC_LOG(ERROR, TAG, "OCStack device error");
}
return ret;
int InitDeviceDiscovery(OCQualityOfService qos)
{
- OC_LOG_V(INFO, TAG, "\n\nExecuting %s", __func__);
+ OIC_LOG_V(INFO, TAG, "\n\nExecuting %s", __func__);
OCStackResult ret;
OCCallbackData cbData;
&cbData, NULL, 0);
if (ret != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack device error");
+ OIC_LOG(ERROR, TAG, "OCStack device error");
}
return ret;
&cbData, NULL, 0);
if (ret != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack resource error");
+ OIC_LOG(ERROR, TAG, "OCStack resource error");
}
return ret;
}
if (OCInit1(OC_CLIENT, OC_DEFAULT_FLAGS, OC_DEFAULT_FLAGS) != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack init error");
+ OIC_LOG(ERROR, TAG, "OCStack init error");
return 0;
}
{
if (OC_STACK_OK != OCProcess())
{
- OC_LOG(ERROR, TAG, "OCStack process error");
+ OIC_LOG(ERROR, TAG, "OCStack process error");
return 0;
}
usleep(SLEEP_DURATION);
}
else
{
- OC_LOG(INFO, TAG, "Default Connectivity type selected...");
+ OIC_LOG(INFO, TAG, "Default Connectivity type selected...");
PrintUsage();
}
if (UnicastDiscovery)
{
- OC_LOG(INFO, TAG, "Enter IP address of server with optional port number");
- OC_LOG(INFO, TAG, "IPv4: 192.168.0.15:45454\n");
- OC_LOG(INFO, TAG, "IPv6: [fe80::20c:29ff:fe1b:9c5]:45454\n");
+ OIC_LOG(INFO, TAG, "Enter IP address of server with optional port number");
+ OIC_LOG(INFO, TAG, "IPv4: 192.168.0.15:45454\n");
+ OIC_LOG(INFO, TAG, "IPv6: [fe80::20c:29ff:fe1b:9c5]:45454\n");
if (fgets(discoveryAddr, sizeof (discoveryAddr), stdin))
{
}
else
{
- OC_LOG(ERROR, TAG, "!! Bad input for IP address. !!");
+ OIC_LOG(ERROR, TAG, "!! Bad input for IP address. !!");
return OC_STACK_INVALID_PARAM;
}
}
}
// Break from loop with Ctrl+C
- OC_LOG(INFO, TAG, "Entering occlient main loop...");
+ OIC_LOG(INFO, TAG, "Entering occlient main loop...");
signal(SIGINT, handleSigInt);
while (!gQuitFlag)
{
if (OCProcess() != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack process error");
+ OIC_LOG(ERROR, TAG, "OCStack process error");
return 0;
}
#ifndef ROUTING_GATEAWAY
sleep(1);
#endif
}
- OC_LOG(INFO, TAG, "Exiting occlient main loop...");
+ OIC_LOG(INFO, TAG, "Exiting occlient main loop...");
if (OCStop() != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack stop error");
+ OIC_LOG(ERROR, TAG, "OCStack stop error");
}
return 0;
static void PrintUsage()
{
- OC_LOG(INFO, TAG, "Usage : occlient -u <0|1> -t <1|2|3> -c <0|1>");
- OC_LOG(INFO, TAG, "-u <0|1> : Perform multicast/unicast discovery of resources");
- OC_LOG(INFO, TAG, "-t 1 : Discover Resources");
- OC_LOG(INFO, TAG, "-t 2 : Discover Resources and"
+ OIC_LOG(INFO, TAG, "Usage : occlient -u <0|1> -t <1|2|3> -c <0|1>");
+ OIC_LOG(INFO, TAG, "-u <0|1> : Perform multicast/unicast discovery of resources");
+ OIC_LOG(INFO, TAG, "-t 1 : Discover Resources");
+ OIC_LOG(INFO, TAG, "-t 2 : Discover Resources and"
" Initiate Nonconfirmable Get/Put/Post Requests");
- OC_LOG(INFO, TAG, "-t 3 : Discover Resources and Initiate "
+ OIC_LOG(INFO, TAG, "-t 3 : Discover Resources and Initiate "
"Confirmable Get/Put/Post Requests");
- OC_LOG(INFO, TAG, "-c 0 : Default auto-selection");
- OC_LOG(INFO, TAG, "-c 1 : IP Connectivity Type");
+ OIC_LOG(INFO, TAG, "-c 0 : Default auto-selection");
+ OIC_LOG(INFO, TAG, "-c 1 : IP Connectivity Type");
}
/*
if (ret != OC_STACK_OK)
{
- OC_LOG_V(ERROR, TAG, "OCDoResource returns error %d with method %d",
+ OIC_LOG_V(ERROR, TAG, "OCDoResource returns error %d with method %d",
ret, method);
}
{
if(ctx == (void*)DEFAULT_CONTEXT_VALUE)
{
- OC_LOG(INFO, TAG, "<====Callback Context for PUT received successfully====>");
+ OIC_LOG(INFO, TAG, "<====Callback Context for PUT received successfully====>");
}
else
{
- OC_LOG(ERROR, TAG, "<====Callback Context for PUT fail====>");
+ OIC_LOG(ERROR, TAG, "<====Callback Context for PUT fail====>");
}
if(clientResponse)
{
- OC_LOG_PAYLOAD(INFO, clientResponse->payload);
- OC_LOG(INFO, TAG, ("=============> Put Response"));
+ OIC_LOG_PAYLOAD(INFO, clientResponse->payload);
+ OIC_LOG(INFO, TAG, ("=============> Put Response"));
}
else
{
- OC_LOG(ERROR, TAG, "<====PUT Callback fail to receive clientResponse====>\n");
+ OIC_LOG(ERROR, TAG, "<====PUT Callback fail to receive clientResponse====>\n");
}
return OC_STACK_DELETE_TRANSACTION;
}
{
if(ctx == (void*)DEFAULT_CONTEXT_VALUE)
{
- OC_LOG(INFO, TAG, "<====Callback Context for POST received successfully====>");
+ OIC_LOG(INFO, TAG, "<====Callback Context for POST received successfully====>");
}
else
{
- OC_LOG(ERROR, TAG, "<====Callback Context for POST fail====>");
+ OIC_LOG(ERROR, TAG, "<====Callback Context for POST fail====>");
}
if(clientResponse)
{
- OC_LOG_PAYLOAD(INFO, clientResponse->payload);
- OC_LOG(INFO, TAG, ("=============> Post Response"));
+ OIC_LOG_PAYLOAD(INFO, clientResponse->payload);
+ OIC_LOG(INFO, TAG, ("=============> Post Response"));
}
else
{
- OC_LOG(ERROR, TAG, "<====POST Callback fail to receive clientResponse====>\n");
+ OIC_LOG(ERROR, TAG, "<====POST Callback fail to receive clientResponse====>\n");
}
return OC_STACK_DELETE_TRANSACTION;
{
if (ctx == (void*) DEFAULT_CONTEXT_VALUE)
{
- OC_LOG(INFO, TAG, "<====Callback Context for GET received successfully====>");
+ OIC_LOG(INFO, TAG, "<====Callback Context for GET received successfully====>");
}
else
{
- OC_LOG(ERROR, TAG, "<====Callback Context for GET fail====>");
+ OIC_LOG(ERROR, TAG, "<====Callback Context for GET fail====>");
}
if (clientResponse)
{
- OC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
- OC_LOG_V(INFO, TAG, "SEQUENCE NUMBER: %d", clientResponse->sequenceNumber);
- OC_LOG_PAYLOAD(INFO, clientResponse->payload);
- OC_LOG(INFO, TAG, ("=============> Get Response"));
+ 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"));
if (clientResponse->numRcvdVendorSpecificHeaderOptions > 0 )
{
- OC_LOG (INFO, TAG, "Received vendor specific options");
+ OIC_LOG (INFO, TAG, "Received vendor specific options");
uint8_t i = 0;
OCHeaderOption * rcvdOptions = clientResponse->rcvdVendorSpecificHeaderOptions;
for (i = 0; i < clientResponse->numRcvdVendorSpecificHeaderOptions; i++)
{
if (((OCHeaderOption) rcvdOptions[i]).protocolID == OC_COAP_ID)
{
- OC_LOG_V(INFO, TAG, "Received option with OC_COAP_ID and ID %u with",
+ OIC_LOG_V(INFO, TAG, "Received option with OC_COAP_ID and ID %u with",
((OCHeaderOption)rcvdOptions[i]).optionID );
- OC_LOG_BUFFER(INFO, TAG, ((OCHeaderOption)rcvdOptions[i]).optionData,
+ OIC_LOG_BUFFER(INFO, TAG, ((OCHeaderOption)rcvdOptions[i]).optionData,
MAX_HEADER_OPTION_DATA_LENGTH);
}
}
}
else
{
- OC_LOG(ERROR, TAG, "<====GET Callback fail to receive clientResponse====>\n");
+ OIC_LOG(ERROR, TAG, "<====GET Callback fail to receive clientResponse====>\n");
}
return OC_STACK_DELETE_TRANSACTION;
}
{
if (ctx == (void*)DEFAULT_CONTEXT_VALUE)
{
- OC_LOG(INFO, TAG, "\n<====Callback Context for DISCOVERY query "
+ OIC_LOG(INFO, TAG, "\n<====Callback Context for DISCOVERY query "
"received successfully====>");
}
else
{
- OC_LOG(ERROR, TAG, "\n<====Callback Context for DISCOVERY fail====>");
+ OIC_LOG(ERROR, TAG, "\n<====Callback Context for DISCOVERY fail====>");
}
if (clientResponse)
{
- OC_LOG_V(INFO, TAG,
+ OIC_LOG_V(INFO, TAG,
"Device =============> Discovered @ %s:%d",
clientResponse->devAddr.addr,
clientResponse->devAddr.port);
- OC_LOG_PAYLOAD(INFO, clientResponse->payload);
+ OIC_LOG_PAYLOAD(INFO, clientResponse->payload);
collectUniqueResource(clientResponse);
}
else
{
- OC_LOG(ERROR, TAG, "<====DISCOVERY Callback fail to receive clientResponse====>\n");
+ OIC_LOG(ERROR, TAG, "<====DISCOVERY Callback fail to receive clientResponse====>\n");
}
return (UnicastDiscovery) ?
OC_STACK_DELETE_TRANSACTION : OC_STACK_KEEP_TRANSACTION ;
if(!resource)
{
- OC_LOG_V(ERROR, TAG, "Resource null, can't do PUT request\n");
+ OIC_LOG_V(ERROR, TAG, "Resource null, can't do PUT request\n");
return -1;
}
query << resource->uri;
- OC_LOG_V(INFO, TAG,"Executing InitPutRequest, Query: %s", query.str().c_str());
+ OIC_LOG_V(INFO, TAG,"Executing InitPutRequest, Query: %s", query.str().c_str());
return (InvokeOCDoResource(query, OC_REST_PUT, &resource->endpoint,
((qos == OC_HIGH_QOS) ? OC_HIGH_QOS: OC_LOW_QOS),
if(!resource)
{
- OC_LOG_V(ERROR, TAG, "Resource null, can't do POST request\n");
+ OIC_LOG_V(ERROR, TAG, "Resource null, can't do POST request\n");
return -1;
}
query << resource->uri;
- OC_LOG_V(INFO, TAG,"Executing InitPostRequest, Query: %s", query.str().c_str());
+ OIC_LOG_V(INFO, TAG,"Executing InitPostRequest, Query: %s", query.str().c_str());
// First POST operation (to create an LED instance)
result = InvokeOCDoResource(query, OC_REST_POST, &resource->endpoint,
if (OC_STACK_OK != result)
{
// Error can happen if for example, network connectivity is down
- OC_LOG(ERROR, TAG, "First POST call did not succeed");
+ OIC_LOG(ERROR, TAG, "First POST call did not succeed");
}
// Second POST operation (to create an LED instance)
postReqCB, NULL, 0);
if (OC_STACK_OK != result)
{
- OC_LOG(ERROR, TAG, "Second POST call did not succeed");
+ OIC_LOG(ERROR, TAG, "Second POST call did not succeed");
}
// This POST operation will update the original resourced /a/led
if(!resource)
{
- OC_LOG_V(ERROR, TAG, "Resource null, can't do GET request\n");
+ OIC_LOG_V(ERROR, TAG, "Resource null, can't do GET request\n");
return -1;
}
query << resource->uri;
- OC_LOG_V(INFO, TAG,"Executing InitGetRequest, Query: %s", query.str().c_str());
+ OIC_LOG_V(INFO, TAG,"Executing InitGetRequest, Query: %s", query.str().c_str());
return (InvokeOCDoResource(query, OC_REST_GET, &resource->endpoint,
(qos == OC_HIGH_QOS)?OC_HIGH_QOS:OC_LOW_QOS, getReqCB, NULL, 0));
if (UnicastDiscovery)
{
- OC_LOG(INFO, TAG, "Enter IP address (with optional port) of the Server hosting resource\n");
- OC_LOG(INFO, TAG, "IPv4: 192.168.0.15:45454\n");
- OC_LOG(INFO, TAG, "IPv6: [fe80::20c:29ff:fe1b:9c5]:45454\n");
+ OIC_LOG(INFO, TAG, "Enter IP address (with optional port) of the Server hosting resource\n");
+ OIC_LOG(INFO, TAG, "IPv4: 192.168.0.15:45454\n");
+ OIC_LOG(INFO, TAG, "IPv6: [fe80::20c:29ff:fe1b:9c5]:45454\n");
if (fgets(ipaddr, sizeof (ipaddr), stdin))
{
}
else
{
- OC_LOG(ERROR, TAG, "!! Bad input for IP address. !!");
+ OIC_LOG(ERROR, TAG, "!! Bad input for IP address. !!");
return OC_STACK_INVALID_PARAM;
}
}
OC_LOW_QOS, &cbData, NULL, 0);
if (ret != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack resource error");
+ OIC_LOG(ERROR, TAG, "OCStack resource error");
}
return ret;
}
{
if(insertResource(sidStr, res->uri, clientResponse) == 1)
{
- OC_LOG_V(INFO,TAG,"%s%s%s%s\n",sidStr, ":", res->uri, " is new");
+ OIC_LOG_V(INFO,TAG,"%s%s%s%s\n",sidStr, ":", res->uri, " is new");
printResourceList();
queryResource();
}
else {
- OC_LOG_V(INFO,TAG,"%s%s%s%s\n",sidStr, ":", res->uri, " is old");
+ OIC_LOG_V(INFO,TAG,"%s%s%s%s\n",sidStr, ":", res->uri, " is old");
}
}
else
{
- OC_LOG(ERROR, TAG, "Could Not Retrieve the Server ID");
+ OIC_LOG(ERROR, TAG, "Could Not Retrieve the Server ID");
}
res = res->next;
}
else
{
- OC_LOG(ERROR, TAG, "Memory not allocated to ResourceNode");
+ OIC_LOG(ERROR, TAG, "Memory not allocated to ResourceNode");
OICFree(sid_cpy);
OICFree(uri_cpy);
return -1;
{
ResourceNode * iter;
iter = resourceList;
- OC_LOG(INFO, TAG, "Resource List: ");
+ OIC_LOG(INFO, TAG, "Resource List: ");
while(iter)
{
- OC_LOG(INFO, TAG, "*****************************************************");
- OC_LOG_V(INFO, TAG, "sid = %s",iter->sid);
- OC_LOG_V(INFO, TAG, "uri = %s", iter->uri);
- OC_LOG_V(INFO, TAG, "ip = %s", iter->endpoint.addr);
- OC_LOG_V(INFO, TAG, "port = %d", iter->endpoint.port);
+ OIC_LOG(INFO, TAG, "*****************************************************");
+ OIC_LOG_V(INFO, TAG, "sid = %s",iter->sid);
+ OIC_LOG_V(INFO, TAG, "uri = %s", iter->uri);
+ OIC_LOG_V(INFO, TAG, "ip = %s", iter->endpoint.addr);
+ OIC_LOG_V(INFO, TAG, "port = %d", iter->endpoint.port);
switch (iter->endpoint.adapter)
{
case OC_ADAPTER_IP:
- OC_LOG(INFO, TAG, "connType = Default (IPv4)");
+ OIC_LOG(INFO, TAG, "connType = Default (IPv4)");
break;
case OC_ADAPTER_GATT_BTLE:
- OC_LOG(INFO, TAG, "connType = BLE");
+ OIC_LOG(INFO, TAG, "connType = BLE");
break;
case OC_ADAPTER_RFCOMM_BTEDR:
- OC_LOG(INFO, TAG, "connType = BT");
+ OIC_LOG(INFO, TAG, "connType = BT");
break;
default:
- OC_LOG(INFO, TAG, "connType = Invalid connType");
+ OIC_LOG(INFO, TAG, "connType = Invalid connType");
break;
}
- OC_LOG(INFO, TAG, "*****************************************************");
+ OIC_LOG(INFO, TAG, "*****************************************************");
iter = iter->next;
}
}
void freeResourceList()
{
- OC_LOG(INFO, TAG, "Freeing ResourceNode List");
+ OIC_LOG(INFO, TAG, "Freeing ResourceNode List");
ResourceNode * temp;
while(resourceList)
{
/* Initialize OCStack*/
if (OCInit1(OC_CLIENT, OC_DEFAULT_FLAGS, OC_DEFAULT_FLAGS) != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack init error");
+ OIC_LOG(ERROR, TAG, "OCStack init error");
return 0;
}
}
else
{
- OC_LOG(INFO, TAG, "Default Connectivity type selected");
+ OIC_LOG(INFO, TAG, "Default Connectivity type selected");
PrintUsage();
}
{
if (OCProcess() != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack process error");
+ OIC_LOG(ERROR, TAG, "OCStack process error");
return 0;
}
sleep(2);
}
freeResourceList();
- OC_LOG(INFO, TAG, "Exiting occlient main loop...");
+ OIC_LOG(INFO, TAG, "Exiting occlient main loop...");
if (OCStop() != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack stop error");
+ OIC_LOG(ERROR, TAG, "OCStack stop error");
}
return 0;
}
void PrintUsage()
{
- OC_LOG(INFO, TAG, "Usage : occlientcoll -t <Test Case> -c <CA connectivity Type>");
- OC_LOG(INFO, TAG, "-c 0 : Default auto-selection");
- OC_LOG(INFO, TAG, "-c 1 : IP Connectivity Type");
- OC_LOG(INFO, TAG, "Test Case 1 : Discover Resources && Initiate GET Request on an "\
+ OIC_LOG(INFO, TAG, "Usage : occlientcoll -t <Test Case> -c <CA connectivity Type>");
+ OIC_LOG(INFO, TAG, "-c 0 : Default auto-selection");
+ OIC_LOG(INFO, TAG, "-c 1 : IP Connectivity Type");
+ OIC_LOG(INFO, TAG, "Test Case 1 : Discover Resources && Initiate GET Request on an "\
"available resource using default interface.");
- OC_LOG(INFO, TAG, "Test Case 2 : Discover Resources && Initiate GET Request on an "\
+ OIC_LOG(INFO, TAG, "Test Case 2 : Discover Resources && Initiate GET Request on an "\
"available resource using batch interface.");
- OC_LOG(INFO, TAG, "Test Case 3 : Discover Resources && Initiate GET Request on an "\
+ OIC_LOG(INFO, TAG, "Test Case 3 : Discover Resources && Initiate GET Request on an "\
"available resource using link list interface.");
- OC_LOG(INFO, TAG, "Test Case 4 : Discover Resources && Initiate GET & PUT Request on an "\
+ OIC_LOG(INFO, TAG, "Test Case 4 : Discover Resources && Initiate GET & PUT Request on an "\
"available resource using default interface.");
- OC_LOG(INFO, TAG, "Test Case 5 : Discover Resources && Initiate GET & PUT Request on an "\
+ OIC_LOG(INFO, TAG, "Test Case 5 : Discover Resources && Initiate GET & PUT Request on an "\
"available resource using batch interface.");
- OC_LOG(INFO, TAG, "Test Case 6 : Discover Resources && Initiate GET & PUT Request on an "\
+ OIC_LOG(INFO, TAG, "Test Case 6 : Discover Resources && Initiate GET & PUT Request on an "\
"available resource using link list interface.");
- OC_LOG(INFO, TAG, "Test Case 7 : Discover Resources && Initiate GET Request on an "\
+ OIC_LOG(INFO, TAG, "Test Case 7 : Discover Resources && Initiate GET Request on an "\
"unavailable resource using default interface.");
- OC_LOG(INFO, TAG, "Test Case 8 : Discover Resources && Initiate GET Request on an "\
+ OIC_LOG(INFO, TAG, "Test Case 8 : Discover Resources && Initiate GET Request on an "\
"unavailable resource using batch interface.");
- OC_LOG(INFO, TAG, "Test Case 9 : Discover Resources && Initiate GET Request on an "\
+ OIC_LOG(INFO, TAG, "Test Case 9 : Discover Resources && Initiate GET Request on an "\
"unavailable resource using link list interface.");
}
{
if(clientResponse == NULL)
{
- OC_LOG(INFO, TAG, "The clientResponse is NULL");
+ OIC_LOG(INFO, TAG, "The clientResponse is NULL");
return OC_STACK_DELETE_TRANSACTION;
}
if(ctx == (void*)DEFAULT_CONTEXT_VALUE)
{
- OC_LOG_V(INFO, TAG, "Callback Context for PUT query recvd successfully");
- OC_LOG_PAYLOAD(INFO, clientResponse->payload);
+ OIC_LOG_V(INFO, TAG, "Callback Context for PUT query recvd successfully");
+ OIC_LOG_PAYLOAD(INFO, clientResponse->payload);
}
return OC_STACK_KEEP_TRANSACTION;
OCStackApplicationResult getReqCB(void* ctx, OCDoHandle /*handle*/,
OCClientResponse * clientResponse)
{
- OC_LOG_V(INFO, TAG, "StackResult: %s",
+ OIC_LOG_V(INFO, TAG, "StackResult: %s",
getResult(clientResponse->result));
if(ctx == (void*)DEFAULT_CONTEXT_VALUE)
{
- OC_LOG_V(INFO, TAG, "SEQUENCE NUMBER: %d", clientResponse->sequenceNumber);
+ OIC_LOG_V(INFO, TAG, "SEQUENCE NUMBER: %d", clientResponse->sequenceNumber);
if(clientResponse->sequenceNumber == 0)
{
- OC_LOG_V(INFO, TAG, "Callback Context for GET query recvd successfully");
- OC_LOG_PAYLOAD(INFO, clientResponse->payload);
+ OIC_LOG_V(INFO, TAG, "Callback Context for GET query recvd successfully");
+ OIC_LOG_PAYLOAD(INFO, clientResponse->payload);
}
else
{
- OC_LOG_V(INFO, TAG, "Callback Context for Get recvd successfully %d",
+ OIC_LOG_V(INFO, TAG, "Callback Context for Get recvd successfully %d",
gNumObserveNotifies);
- OC_LOG_PAYLOAD(INFO, clientResponse->payload);;
+ OIC_LOG_PAYLOAD(INFO, clientResponse->payload);;
gNumObserveNotifies++;
if (gNumObserveNotifies == 3)
{
if (OCCancel (gObserveDoHandle, OC_LOW_QOS, NULL, 0) != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "Observe cancel error");
+ OIC_LOG(ERROR, TAG, "Observe cancel error");
}
}
}
OCStackApplicationResult discoveryReqCB(void* ctx, OCDoHandle /*handle*/,
OCClientResponse * clientResponse)
{
- OC_LOG(INFO, TAG,
+ OIC_LOG(INFO, TAG,
"Entering discoveryReqCB (Application Layer CB)");
- OC_LOG_V(INFO, TAG, "StackResult: %s",
+ OIC_LOG_V(INFO, TAG, "StackResult: %s",
getResult(clientResponse->result));
if (ctx == (void*) DEFAULT_CONTEXT_VALUE)
{
- OC_LOG_V(INFO, TAG, "Callback Context recvd successfully");
+ OIC_LOG_V(INFO, TAG, "Callback Context recvd successfully");
}
- OC_LOG_V(INFO, TAG,
+ OIC_LOG_V(INFO, TAG,
"Device =============> Discovered @ %s:%d",
clientResponse->devAddr.addr,
clientResponse->devAddr.port);
- OC_LOG_PAYLOAD(INFO, clientResponse->payload);
+ OIC_LOG_PAYLOAD(INFO, clientResponse->payload);
ConnType = clientResponse->connType;
&cbData, NULL, 0);
if (ret != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack resource error");
+ OIC_LOG(ERROR, TAG, "OCStack resource error");
}
return ret;
}
cbData.cb = getReqCB;
cbData.context = (void*)DEFAULT_CONTEXT_VALUE;
cbData.cd = NULL;
- OC_LOG_V(INFO, TAG, "OBSERVE payload from client =");
+ OIC_LOG_V(INFO, TAG, "OBSERVE payload from client =");
OCPayload* payload = putPayload();
- OC_LOG_PAYLOAD(INFO, payload);
+ OIC_LOG_PAYLOAD(INFO, payload);
OCPayloadDestroy(payload);
ret = OCDoResource(&handle, OC_REST_OBSERVE, obsReg.str().c_str(),
OC_LOW_QOS, &cbData, NULL, 0);
if (ret != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack resource error");
+ OIC_LOG(ERROR, TAG, "OCStack resource error");
}
else
{
cbData.cb = putReqCB;
cbData.context = (void*)DEFAULT_CONTEXT_VALUE;
cbData.cd = NULL;
- OC_LOG_V(INFO, TAG, "PUT payload from client = ");
+ OIC_LOG_V(INFO, TAG, "PUT payload from client = ");
OCPayload* payload = putPayload();
- OC_LOG_PAYLOAD(INFO, payload);
+ OIC_LOG_PAYLOAD(INFO, payload);
OCPayloadDestroy(payload);
ret = OCDoResource(NULL, OC_REST_PUT, getQuery.str().c_str(),
OC_LOW_QOS, &cbData, NULL, 0);
if (ret != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack resource error");
+ OIC_LOG(ERROR, TAG, "OCStack resource error");
}
return ret;
}
&cbData, NULL, 0);
if (ret != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack resource error");
+ OIC_LOG(ERROR, TAG, "OCStack resource error");
}
return ret;
}
&cbData, NULL, 0);
if (ret != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack resource error");
+ OIC_LOG(ERROR, TAG, "OCStack resource error");
}
return ret;
}
/* Initialize OCStack*/
if (OCInit(NULL, 0, OC_CLIENT) != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack init error");
+ OIC_LOG(ERROR, TAG, "OCStack init error");
return 0;
}
}
else
{
- OC_LOG(INFO, TAG, "Default Connectivity type selected...");
+ OIC_LOG(INFO, TAG, "Default Connectivity type selected...");
ConnType = CT_ADAPTER_IP;
}
InitDiscovery();
// Break from loop with Ctrl+C
- OC_LOG(INFO, TAG, "Entering occlient main loop...");
+ OIC_LOG(INFO, TAG, "Entering occlient main loop...");
signal(SIGINT, handleSigInt);
while (!gQuitFlag)
{
if (OCProcess() != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack process error");
+ OIC_LOG(ERROR, TAG, "OCStack process error");
return 0;
}
sleep(2);
- } OC_LOG(INFO, TAG, "Exiting occlient main loop...");
+ } OIC_LOG(INFO, TAG, "Exiting occlient main loop...");
if (OCStop() != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack stop error");
+ OIC_LOG(ERROR, TAG, "OCStack stop error");
}
return 0;
static void PrintUsage()
{
- OC_LOG(INFO, TAG, "Usage : occlient -c <0|1> -u <0|1> -t <1|2|3>");
- OC_LOG(INFO, TAG, "-c 0 : Default auto-selection");
- OC_LOG(INFO, TAG, "-c 1 : IP Connectivity Type");
- OC_LOG(INFO, TAG, "-u <0|1> : Perform multicast/unicast discovery of resources");
- OC_LOG(INFO, TAG, "-t 1 : Discover Resources");
- OC_LOG(INFO, TAG, "-t 2 : Discover Resources and Initiate Nonconfirmable Get Request");
- OC_LOG(INFO, TAG, "-t 3 : Discover Resources and Initiate Confirmable Get Request");
- OC_LOG(INFO, TAG, "-t 4 : Discover Resources and Initiate NonConfirmable Put Request");
- OC_LOG(INFO, TAG, "-t 5 : Discover Resources and Initiate Confirmable Put Request");
+ OIC_LOG(INFO, TAG, "Usage : occlient -c <0|1> -u <0|1> -t <1|2|3>");
+ OIC_LOG(INFO, TAG, "-c 0 : Default auto-selection");
+ OIC_LOG(INFO, TAG, "-c 1 : IP Connectivity Type");
+ OIC_LOG(INFO, TAG, "-u <0|1> : Perform multicast/unicast discovery of resources");
+ OIC_LOG(INFO, TAG, "-t 1 : Discover Resources");
+ OIC_LOG(INFO, TAG, "-t 2 : Discover Resources and Initiate Nonconfirmable Get Request");
+ OIC_LOG(INFO, TAG, "-t 3 : Discover Resources and Initiate Confirmable Get Request");
+ OIC_LOG(INFO, TAG, "-t 4 : Discover Resources and Initiate NonConfirmable Put Request");
+ OIC_LOG(INFO, TAG, "-t 5 : Discover Resources and Initiate Confirmable Put Request");
}
OCPayload* putPayload()
if (ret != OC_STACK_OK)
{
- OC_LOG_V(ERROR, TAG, "OCDoResource returns error %d with method %d", ret, method);
+ OIC_LOG_V(ERROR, TAG, "OCDoResource returns error %d with method %d", ret, method);
}
return ret;
{
if(clientResponse == NULL)
{
- OC_LOG(INFO, TAG, "The clientResponse is NULL");
+ OIC_LOG(INFO, TAG, "The clientResponse is NULL");
return OC_STACK_DELETE_TRANSACTION;
}
if(ctx == (void*)DEFAULT_CONTEXT_VALUE)
{
- OC_LOG(INFO, TAG, "Callback Context for GET query recvd successfully");
+ OIC_LOG(INFO, TAG, "Callback Context for GET query recvd successfully");
}
- OC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
- OC_LOG_V(INFO, TAG, "SEQUENCE NUMBER: %d", clientResponse->sequenceNumber);
- OC_LOG(INFO, TAG, "Get Response =============> ");
- OC_LOG_PAYLOAD(INFO, clientResponse->payload);
+ OIC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
+ OIC_LOG_V(INFO, TAG, "SEQUENCE NUMBER: %d", clientResponse->sequenceNumber);
+ OIC_LOG(INFO, TAG, "Get Response =============> ");
+ OIC_LOG_PAYLOAD(INFO, clientResponse->payload);
if(clientResponse->rcvdVendorSpecificHeaderOptions &&
clientResponse->numRcvdVendorSpecificHeaderOptions)
{
- OC_LOG (INFO, TAG, "Received vendor specific options");
+ OIC_LOG (INFO, TAG, "Received vendor specific options");
uint8_t i = 0;
OCHeaderOption * rcvdOptions = clientResponse->rcvdVendorSpecificHeaderOptions;
for( i = 0; i < clientResponse->numRcvdVendorSpecificHeaderOptions; i++)
{
if(((OCHeaderOption)rcvdOptions[i]).protocolID == OC_COAP_ID)
{
- OC_LOG_V(INFO, TAG, "Received option with OC_COAP_ID and ID %u with",
+ OIC_LOG_V(INFO, TAG, "Received option with OC_COAP_ID and ID %u with",
((OCHeaderOption)rcvdOptions[i]).optionID );
- OC_LOG_BUFFER(INFO, TAG, ((OCHeaderOption)rcvdOptions[i]).optionData,
+ OIC_LOG_BUFFER(INFO, TAG, ((OCHeaderOption)rcvdOptions[i]).optionData,
MAX_HEADER_OPTION_DATA_LENGTH);
}
}
{
if (ctx == (void*) DEFAULT_CONTEXT_VALUE)
{
- OC_LOG(INFO, TAG, "Callback Context for DISCOVER query recvd successfully");
+ OIC_LOG(INFO, TAG, "Callback Context for DISCOVER query recvd successfully");
}
if (clientResponse)
{
- OC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
+ OIC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
- OC_LOG_V(INFO, TAG, "Discovered @ %s:%u =============> ",
+ OIC_LOG_V(INFO, TAG, "Discovered @ %s:%u =============> ",
clientResponse->devAddr.addr, clientResponse->devAddr.port);
- OC_LOG_PAYLOAD (INFO, clientResponse->payload);
+ OIC_LOG_PAYLOAD (INFO, clientResponse->payload);
endpoint = clientResponse->devAddr;
int InitGetRequest(OCQualityOfService qos)
{
- OC_LOG_V(INFO, TAG, "\n\nExecuting %s", __func__);
+ OIC_LOG_V(INFO, TAG, "\n\nExecuting %s", __func__);
std::ostringstream query;
query << coapServerResource;
- OC_LOG_V (INFO, TAG, "Performing GET with query : %s", query.str().c_str());
+ OIC_LOG_V (INFO, TAG, "Performing GET with query : %s", query.str().c_str());
return (InvokeOCDoResource(query, OC_REST_GET, &endpoint,
(qos == OC_HIGH_QOS)? OC_HIGH_QOS : OC_LOW_QOS,
getReqCB, NULL, 0));
int InitPutRequest(OCQualityOfService qos)
{
- OC_LOG_V(INFO, TAG, "\n\nExecuting %s", __func__);
+ OIC_LOG_V(INFO, TAG, "\n\nExecuting %s", __func__);
std::ostringstream query;
query << coapServerResource;
- OC_LOG_V (INFO, TAG, "Performing PUT with query : %s", query.str().c_str());
+ OIC_LOG_V (INFO, TAG, "Performing PUT with query : %s", query.str().c_str());
return (InvokeOCDoResource(query, OC_REST_PUT, &endpoint,
(qos == OC_HIGH_QOS)? OC_HIGH_QOS:OC_LOW_QOS,
getReqCB, NULL, 0));
if (UnicastDiscovery)
{
- OC_LOG(INFO, TAG, "Enter IP address (with optional port) of the Server hosting resource\n");
- OC_LOG(INFO, TAG, "IPv4: 192.168.0.15:45454\n");
- OC_LOG(INFO, TAG, "IPv6: [fe80::20c:29ff:fe1b:9c5]:45454\n");
+ OIC_LOG(INFO, TAG, "Enter IP address (with optional port) of the Server hosting resource\n");
+ OIC_LOG(INFO, TAG, "IPv4: 192.168.0.15:45454\n");
+ OIC_LOG(INFO, TAG, "IPv6: [fe80::20c:29ff:fe1b:9c5]:45454\n");
if (fgets(ipaddr, sizeof (ipaddr), stdin))
{
}
else
{
- OC_LOG(ERROR, TAG, "!! Bad input for IP address. !!");
+ OIC_LOG(ERROR, TAG, "!! Bad input for IP address. !!");
return OC_STACK_INVALID_PARAM;
}
}
OC_LOW_QOS, &cbData, NULL, 0);
if (ret != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack resource error");
+ OIC_LOG(ERROR, TAG, "OCStack resource error");
}
return ret;
}
/* Initialize OCStack*/
if (OCInit(NULL, 0, OC_CLIENT) != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack init error");
+ OIC_LOG(ERROR, TAG, "OCStack init error");
return 0;
}
}
else
{
- OC_LOG(INFO, TAG, "Default Connectivity type selected...");
+ OIC_LOG(INFO, TAG, "Default Connectivity type selected...");
AdapterType = CT_ADAPTER_IP;
}
InitDiscovery();
// Break from loop with Ctrl+C
- OC_LOG(INFO, TAG, "Entering occlient main loop...");
+ OIC_LOG(INFO, TAG, "Entering occlient main loop...");
signal(SIGINT, handleSigInt);
while (!gQuitFlag)
{
if (OCProcess() != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack process error");
+ OIC_LOG(ERROR, TAG, "OCStack process error");
return 0;
}
sleep(2);
}
- OC_LOG(INFO, TAG, "Exiting occlient main loop...");
+ OIC_LOG(INFO, TAG, "Exiting occlient main loop...");
if (OCStop() != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack stop error");
+ OIC_LOG(ERROR, TAG, "OCStack stop error");
}
return 0;
static void PrintUsage()
{
- OC_LOG(INFO, TAG, "This sample makes all requests via the remote access adapter");
- OC_LOG(INFO, TAG, "Usage : ocremoteaccessclient -t <number>");
- OC_LOG(INFO, TAG, "-t 1 : Discover Resources");
- OC_LOG(INFO, TAG, "-t 2 : Discover & Get");
- OC_LOG(INFO, TAG, "-t 3 : Discover & Put");
- OC_LOG(INFO, TAG, "-t 4 : Discover & Post");
- OC_LOG(INFO, TAG, "-t 5 : Discover & Delete");
- OC_LOG(INFO, TAG, "-t 6 : Discover & Observe");
- OC_LOG(INFO, TAG, "-t 7 : Discover & Observe then cancel immediately with High QOS");
+ OIC_LOG(INFO, TAG, "This sample makes all requests via the remote access adapter");
+ OIC_LOG(INFO, TAG, "Usage : ocremoteaccessclient -t <number>");
+ OIC_LOG(INFO, TAG, "-t 1 : Discover Resources");
+ OIC_LOG(INFO, TAG, "-t 2 : Discover & Get");
+ OIC_LOG(INFO, TAG, "-t 3 : Discover & Put");
+ OIC_LOG(INFO, TAG, "-t 4 : Discover & Post");
+ OIC_LOG(INFO, TAG, "-t 5 : Discover & Delete");
+ OIC_LOG(INFO, TAG, "-t 6 : Discover & Observe");
+ OIC_LOG(INFO, TAG, "-t 7 : Discover & Observe then cancel immediately with High QOS");
}
OCStackResult InvokeOCDoResource(std::ostringstream &query,
if (ret != OC_STACK_OK)
{
- OC_LOG_V(ERROR, TAG, "OCDoResource returns error %d with method %d", ret, method);
+ OIC_LOG_V(ERROR, TAG, "OCDoResource returns error %d with method %d", ret, method);
}
else if (method == OC_REST_OBSERVE || method == OC_REST_OBSERVE_ALL)
{
{
if(clientResponse == NULL)
{
- OC_LOG(INFO, TAG, "Received NULL response");
+ OIC_LOG(INFO, TAG, "Received NULL response");
return OC_STACK_DELETE_TRANSACTION;
}
if(ctx == (void*)DEFAULT_CONTEXT_VALUE)
{
- OC_LOG(INFO, TAG, "Callback Context recvd successfully");
+ OIC_LOG(INFO, TAG, "Callback Context recvd successfully");
}
- OC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
- OC_LOG_V(INFO, TAG, "SEQUENCE NUMBER: %d", clientResponse->sequenceNumber);
- OC_LOG_PAYLOAD(INFO, clientResponse->payload);
+ 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);
if(clientResponse->numRcvdVendorSpecificHeaderOptions > 0)
{
- OC_LOG (INFO, TAG, "Received vendor specific options. Ignoring");
+ OIC_LOG (INFO, TAG, "Received vendor specific options. Ignoring");
}
SET_BUT_NOT_USED(handle);
return OC_STACK_DELETE_TRANSACTION;
{
if(!clientResponse)
{
- OC_LOG_V(INFO, TAG, "obsReqCB received NULL response");
+ OIC_LOG_V(INFO, TAG, "obsReqCB received NULL response");
}
if(ctx == (void*)DEFAULT_CONTEXT_VALUE)
{
- OC_LOG(INFO, TAG, "Callback Context recvd successfully");
+ OIC_LOG(INFO, TAG, "Callback Context recvd successfully");
}
- OC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
- OC_LOG_V(INFO, TAG, "SEQUENCE NUMBER: %d", clientResponse->sequenceNumber);
- OC_LOG_V(INFO, TAG, "OBSERVE notification %d recvd", gNumObserveNotifies);
- OC_LOG_PAYLOAD(INFO, clientResponse->payload);
+ OIC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
+ OIC_LOG_V(INFO, TAG, "SEQUENCE NUMBER: %d", clientResponse->sequenceNumber);
+ OIC_LOG_V(INFO, TAG, "OBSERVE notification %d recvd", gNumObserveNotifies);
+ OIC_LOG_PAYLOAD(INFO, clientResponse->payload);
gNumObserveNotifies++;
if (gNumObserveNotifies == maxNotification)
{
if (OCCancel (gObserveDoHandle, OC_LOW_QOS, NULL, 0) != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "Observe cancel error");
+ OIC_LOG(ERROR, TAG, "Observe cancel error");
}
return OC_STACK_DELETE_TRANSACTION;
}
{
if (OCCancel (gObserveDoHandle, OC_HIGH_QOS, NULL, 0) != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "Observe cancel error");
+ OIC_LOG(ERROR, TAG, "Observe cancel error");
}
}
if(clientResponse->sequenceNumber == OC_OBSERVE_REGISTER)
{
- OC_LOG(INFO, TAG, "Registration confirmed");
+ OIC_LOG(INFO, TAG, "Registration confirmed");
}
else if(clientResponse->sequenceNumber == OC_OBSERVE_DEREGISTER)
{
- OC_LOG(INFO, TAG, "de-registration confirmed");
+ OIC_LOG(INFO, TAG, "de-registration confirmed");
return OC_STACK_DELETE_TRANSACTION;
}
else if(clientResponse->sequenceNumber == OC_OBSERVE_NO_OPTION)
{
- OC_LOG(INFO, TAG, "Registration/deregistration failed");
+ OIC_LOG(INFO, TAG, "Registration/deregistration failed");
return OC_STACK_DELETE_TRANSACTION;
}
{
if(ctx == (void*)DEFAULT_CONTEXT_VALUE)
{
- OC_LOG(INFO, TAG, "Callback Context recvd successfully");
+ OIC_LOG(INFO, TAG, "Callback Context recvd successfully");
}
if (clientResponse)
{
- OC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
- OC_LOG_V(INFO, TAG, "NONCE NUMBER: %u", clientResponse->sequenceNumber);
- OC_LOG_V(INFO, TAG, "PRESENCE notification %d recvd", gNumPresenceNotifies);
- OC_LOG_PAYLOAD(INFO, clientResponse->payload);
+ OIC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
+ OIC_LOG_V(INFO, TAG, "NONCE NUMBER: %u", clientResponse->sequenceNumber);
+ OIC_LOG_V(INFO, TAG, "PRESENCE notification %d recvd", gNumPresenceNotifies);
+ OIC_LOG_PAYLOAD(INFO, clientResponse->payload);
gNumPresenceNotifies++;
if (gNumPresenceNotifies == maxNotification)
{
if (OCCancel(gPresenceHandle, OC_LOW_QOS, NULL, 0) != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "Presence cancel error");
+ OIC_LOG(ERROR, TAG, "Presence cancel error");
}
return OC_STACK_DELETE_TRANSACTION;
}
}
else
{
- OC_LOG_V(INFO, TAG, "presenceCB received Null clientResponse");
+ OIC_LOG_V(INFO, TAG, "presenceCB received Null clientResponse");
}
SET_BUT_NOT_USED(handle);
return OC_STACK_KEEP_TRANSACTION;
{
if (ctx == (void*) DEFAULT_CONTEXT_VALUE)
{
- OC_LOG(INFO, TAG, "DISCOVER callback recvd");
+ OIC_LOG(INFO, TAG, "DISCOVER callback recvd");
}
if (!clientResponse)
{
- OC_LOG_V(INFO, TAG, "discoveryReqCB received Null clientResponse");
+ OIC_LOG_V(INFO, TAG, "discoveryReqCB received Null clientResponse");
}
- OC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
- OC_LOG_PAYLOAD(INFO, clientResponse->payload);
+ OIC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
+ OIC_LOG_PAYLOAD(INFO, clientResponse->payload);
responseAddr = clientResponse->devAddr;
switch(TEST_CASE)
{
- OC_LOG_V(INFO, TAG, "TEST_CASE %u\n", TEST_CASE);
+ OIC_LOG_V(INFO, TAG, "TEST_CASE %u\n", TEST_CASE);
case TEST_GET_REQ_NON:
InitGetRequest(OC_LOW_QOS);
break;
{
if (ctx == (void*) DEFAULT_CONTEXT_VALUE)
{
- OC_LOG(INFO, TAG, "Callback Context for Platform DISCOVER query recvd successfully");
+ OIC_LOG(INFO, TAG, "Callback Context for Platform DISCOVER query recvd successfully");
}
if(clientResponse)
{
- OC_LOG_PAYLOAD(INFO, clientResponse->payload);
+ OIC_LOG_PAYLOAD(INFO, clientResponse->payload);
}
else
{
- OC_LOG_V(INFO, TAG, "PlatformDiscoveryReqCB received Null clientResponse");
+ OIC_LOG_V(INFO, TAG, "PlatformDiscoveryReqCB received Null clientResponse");
}
SET_BUT_NOT_USED(handle);
{
if (ctx == (void*) DEFAULT_CONTEXT_VALUE)
{
- OC_LOG(INFO, TAG, "Callback Context for Device DISCOVER query recvd successfully");
+ OIC_LOG(INFO, TAG, "Callback Context for Device DISCOVER query recvd successfully");
}
if(clientResponse)
{
- OC_LOG_PAYLOAD(INFO, clientResponse->payload);
+ OIC_LOG_PAYLOAD(INFO, clientResponse->payload);
}
else
{
- OC_LOG_V(INFO, TAG, "PlatformDiscoveryReqCB received Null clientResponse");
+ OIC_LOG_V(INFO, TAG, "PlatformDiscoveryReqCB received Null clientResponse");
}
SET_BUT_NOT_USED(handle);
int InitObserveRequest(OCQualityOfService qos)
{
- OC_LOG_V(INFO, TAG, "\n\nExecuting %s", __func__);
+ OIC_LOG_V(INFO, TAG, "\n\nExecuting %s", __func__);
std::ostringstream query;
query << coapServerResource;
return (InvokeOCDoResource(query,
int InitPutRequest(OCQualityOfService qos)
{
- OC_LOG_V(INFO, TAG, "\n\nExecuting %s", __func__);
+ OIC_LOG_V(INFO, TAG, "\n\nExecuting %s", __func__);
std::ostringstream query;
query << coapServerResource;
return (InvokeOCDoResource(query, OC_REST_PUT, (qos == OC_HIGH_QOS)? OC_HIGH_QOS:OC_LOW_QOS,
int InitPostRequest(OCQualityOfService qos)
{
- OC_LOG_V(INFO, TAG, "\n\nExecuting %s", __func__);
+ OIC_LOG_V(INFO, TAG, "\n\nExecuting %s", __func__);
std::ostringstream query;
query << coapServerResource;
// First POST operation (to create an Light instance)
if (OC_STACK_OK != result)
{
// Error can happen if for example, network connectivity is down
- OC_LOG(INFO, TAG, "First POST call did not succeed");
+ OIC_LOG(INFO, TAG, "First POST call did not succeed");
}
// Second POST operation (to create an Light instance)
restRequestCB, NULL, 0);
if (OC_STACK_OK != result)
{
- OC_LOG(INFO, TAG, "Second POST call did not succeed");
+ OIC_LOG(INFO, TAG, "Second POST call did not succeed");
}
// This POST operation will update the original resourced /a/light
{
std::ostringstream query;
query << coapServerResource;
- OC_LOG_V(INFO, TAG, "\n\nExecuting %s", __func__);
+ OIC_LOG_V(INFO, TAG, "\n\nExecuting %s", __func__);
// First DELETE operation
OCStackResult result = InvokeOCDoResource(query, OC_REST_DELETE,
if (OC_STACK_OK != result)
{
// Error can happen if for example, network connectivity is down
- OC_LOG(INFO, TAG, "DELETE call did not succeed");
+ OIC_LOG(INFO, TAG, "DELETE call did not succeed");
}
return result;
}
int InitGetRequest(OCQualityOfService qos)
{
- OC_LOG_V(INFO, TAG, "\n\nExecuting %s", __func__);
+ OIC_LOG_V(INFO, TAG, "\n\nExecuting %s", __func__);
std::ostringstream query;
query << coapServerResource;
return (InvokeOCDoResource(query, OC_REST_GET,
if (ret != OC_STACK_OK)
{
- OC_LOG_V(ERROR, TAG, "Error %u in OCDoResource with discovery", ret);
+ OIC_LOG_V(ERROR, TAG, "Error %u in OCDoResource with discovery", ret);
}
return ret;
}
static void jidbound(char *jid)
{
- OC_LOG_V(INFO, TAG, "\n\n Bound JID: %s\n\n", jid);
+ OIC_LOG_V(INFO, TAG, "\n\n Bound JID: %s\n\n", jid);
}
int main(int argc, char* argv[])
if (OCSetRAInfo(&rainfo) != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "Error initiating remote access adapter");
+ OIC_LOG(ERROR, TAG, "Error initiating remote access adapter");
return 0;
}
if (OCInit(NULL, 0, OC_CLIENT) != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack init error");
+ OIC_LOG(ERROR, TAG, "OCStack init error");
return 0;
}
- OC_LOG(INFO, TAG, "Enter JID of remote server");
+ OIC_LOG(INFO, TAG, "Enter JID of remote server");
if (fgets(remoteServerJabberID, MAX_ADDR_STR_SIZE, stdin))
{
StripNewLineChar(remoteServerJabberID);
}
else
{
- OC_LOG(ERROR, TAG, "Bad input for jabberID");
+ OIC_LOG(ERROR, TAG, "Bad input for jabberID");
return OC_STACK_INVALID_PARAM;
}
InitDiscovery(OC_LOW_QOS);
// Break from loop with Ctrl+C
- OC_LOG(INFO, TAG, "Press CTRL+C to stop the stack");
+ OIC_LOG(INFO, TAG, "Press CTRL+C to stop the stack");
signal(SIGINT, handleSigInt);
while (!gQuitFlag)
{
if (OCProcess() != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack process error");
+ OIC_LOG(ERROR, TAG, "OCStack process error");
return 0;
}
sleep(2);
}
- OC_LOG(INFO, TAG, "Exiting ocremoteaccessclient main loop...");
+ OIC_LOG(INFO, TAG, "Exiting ocremoteaccessclient main loop...");
if (OCStop() != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack stop error");
+ OIC_LOG(ERROR, TAG, "OCStack stop error");
}
return 0;
int main()
{
- OC_LOG(DEBUG, TAG, "OCRouting sample is starting...");
+ OIC_LOG(DEBUG, TAG, "OCRouting sample is starting...");
if (OCInit(NULL, 0, OC_GATEWAY) != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack init error");
+ OIC_LOG(ERROR, TAG, "OCStack init error");
return 0;
}
// Break from loop with Ctrl-C
- OC_LOG(INFO, TAG, "Entering ocrouting main loop...");
+ OIC_LOG(INFO, TAG, "Entering ocrouting main loop...");
signal(SIGINT, handleSigInt);
{
if (OCProcess() != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack process error");
+ OIC_LOG(ERROR, TAG, "OCStack process error");
return 0;
}
}
- OC_LOG(INFO, TAG, "Exiting ocrouting main loop...");
+ OIC_LOG(INFO, TAG, "Exiting ocrouting main loop...");
if (OCStop() != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack process error");
+ OIC_LOG(ERROR, TAG, "OCStack process error");
}
return 0;
OCRepPayload* payload = OCRepPayloadCreate();
if(!payload)
{
- OC_LOG(ERROR, TAG, PCF("Failed to allocate Payload"));
+ OIC_LOG(ERROR, TAG, PCF("Failed to allocate Payload"));
return nullptr;
}
{
if(ehRequest->payload && ehRequest->payload->type != PAYLOAD_TYPE_REPRESENTATION)
{
- OC_LOG(ERROR, TAG, PCF("Incoming payload not a representation"));
+ OIC_LOG(ERROR, TAG, PCF("Incoming payload not a representation"));
return nullptr;
}
int powerRequested = atoi(pointerToOperator + 1);
if (Light.power > powerRequested)
{
- OC_LOG_V(INFO, TAG, "Current power: %d. Requested: <%d", Light.power
+ OIC_LOG_V(INFO, TAG, "Current power: %d. Requested: <%d", Light.power
, powerRequested);
return false;
}
*/
OCEntityHandlerResult ValidateQueryParams (OCEntityHandlerRequest *entityHandlerRequest)
{
- OC_LOG_V(INFO, TAG, PCF("Received query %s"), entityHandlerRequest->query);
- OC_LOG(INFO, TAG, PCF("Not processing query"));
+ OIC_LOG_V(INFO, TAG, PCF("Received query %s"), entityHandlerRequest->query);
+ OIC_LOG(INFO, TAG, PCF("Not processing query"));
return OC_EH_OK;
}
OCRepPayload *getResp = constructResponse(ehRequest);
if(!getResp)
{
- OC_LOG(ERROR, TAG, "constructResponse failed");
+ OIC_LOG(ERROR, TAG, "constructResponse failed");
return OC_EH_ERROR;
}
if(!putResp)
{
- OC_LOG(ERROR, TAG, "Failed to construct Json response");
+ OIC_LOG(ERROR, TAG, "Failed to construct Json response");
return OC_EH_ERROR;
}
if (0 == createLightResource (newLightUri, &gLightInstance[gCurrLightInstance]))
{
- OC_LOG (INFO, TAG, "Created new Light instance\n");
+ OIC_LOG (INFO, TAG, "Created new Light instance\n");
gLightInstance[gCurrLightInstance].state = 0;
gLightInstance[gCurrLightInstance].power = 0;
gCurrLightInstance++;
}
else
{
- OC_LOG(INFO, TAG, "Payload was NULL");
+ OIC_LOG(INFO, TAG, "Payload was NULL");
ehResult = OC_EH_ERROR;
}
{
if(ehRequest == NULL)
{
- OC_LOG(INFO, TAG, "The ehRequest is NULL");
+ OIC_LOG(INFO, TAG, "The ehRequest is NULL");
return OC_EH_ERROR;
}
OCEntityHandlerResult ehResult = OC_EH_OK;
- OC_LOG_V(INFO, TAG, "\n\nExecuting %s for resource %p ", __func__, ehRequest->resource);
+ OIC_LOG_V(INFO, TAG, "\n\nExecuting %s for resource %p ", __func__, ehRequest->resource);
/*
* In the sample below, the application will:
if (result == OC_STACK_OK)
{
- OC_LOG (INFO, TAG, "\n\nDelete Resource operation succeeded.");
+ OIC_LOG (INFO, TAG, "\n\nDelete Resource operation succeeded.");
ehResult = OC_EH_OK;
//Step 2: clear observers who wanted to observe this resource at the app level.
}
else if (result == OC_STACK_NO_RESOURCE)
{
- OC_LOG(INFO, TAG, "\n\nThe resource doesn't exist or it might have been deleted.");
+ OIC_LOG(INFO, TAG, "\n\nThe resource doesn't exist or it might have been deleted.");
ehResult = OC_EH_RESOURCE_DELETED;
}
else
{
- OC_LOG(INFO, TAG, "\n\nEncountered error from OCDeleteResource().");
+ OIC_LOG(INFO, TAG, "\n\nEncountered error from OCDeleteResource().");
ehResult = OC_EH_ERROR;
}
}
{
//Let's this app not supporting DELETE on some resources so
//consider the DELETE request is received for a non-support resource.
- OC_LOG_V(INFO, TAG, "\n\nThe request is received for a non-support resource.");
+ OIC_LOG_V(INFO, TAG, "\n\nThe request is received for a non-support resource.");
ehResult = OC_EH_FORBIDDEN;
}
OCEntityHandlerResult ProcessNonExistingResourceRequest(OCEntityHandlerRequest * /*ehRequest*/)
{
- OC_LOG_V(INFO, TAG, "\n\nExecuting %s ", __func__);
+ OIC_LOG_V(INFO, TAG, "\n\nExecuting %s ", __func__);
return OC_EH_RESOURCE_NOT_FOUND;
}
void ProcessObserveRegister (OCEntityHandlerRequest *ehRequest)
{
- OC_LOG_V (INFO, TAG, "Received observation registration request with observation Id %d",
+ OIC_LOG_V (INFO, TAG, "Received observation registration request with observation Id %d",
ehRequest->obsInfo.obsId);
if (!observeThreadStarted)
{
bool clientStillObserving = false;
- OC_LOG_V (INFO, TAG, "Received observation deregistration request for observation Id %d",
+ OIC_LOG_V (INFO, TAG, "Received observation deregistration request for observation Id %d",
ehRequest->obsInfo.obsId);
for (uint8_t i = 0; i < SAMPLE_MAX_NUM_OBSERVATIONS; i++)
{
char* uri,
void* /*callbackParam*/)
{
- OC_LOG_V (INFO, TAG, "Inside device default entity handler - flags: 0x%x, uri: %s", flag, uri);
+ OIC_LOG_V (INFO, TAG, "Inside device default entity handler - flags: 0x%x, uri: %s", flag, uri);
OCEntityHandlerResult ehResult = OC_EH_OK;
OCEntityHandlerResponse response;
// Validate pointer
if (!entityHandlerRequest)
{
- OC_LOG (ERROR, TAG, "Invalid request pointer");
+ OIC_LOG (ERROR, TAG, "Invalid request pointer");
return OC_EH_ERROR;
}
// Initialize certain response fields
if (flag & OC_REQUEST_FLAG)
{
- OC_LOG (INFO, TAG, "Flag includes OC_REQUEST_FLAG");
+ OIC_LOG (INFO, TAG, "Flag includes OC_REQUEST_FLAG");
if (entityHandlerRequest->resource == NULL)
{
- OC_LOG (INFO, TAG, "Received request from client to a non-existing resource");
+ OIC_LOG (INFO, TAG, "Received request from client to a non-existing resource");
ehResult = ProcessNonExistingResourceRequest(entityHandlerRequest);
}
else if (OC_REST_GET == entityHandlerRequest->method)
{
- OC_LOG (INFO, TAG, "Received OC_REST_GET from client");
+ OIC_LOG (INFO, TAG, "Received OC_REST_GET from client");
ehResult = ProcessGetRequest (entityHandlerRequest, &payload);
}
else if (OC_REST_PUT == entityHandlerRequest->method)
{
- OC_LOG (INFO, TAG, "Received OC_REST_PUT from client");
+ OIC_LOG (INFO, TAG, "Received OC_REST_PUT from client");
ehResult = ProcessPutRequest (entityHandlerRequest, &payload);
}
else if (OC_REST_DELETE == entityHandlerRequest->method)
{
- OC_LOG (INFO, TAG, "Received OC_REST_DELETE from client");
+ OIC_LOG (INFO, TAG, "Received OC_REST_DELETE from client");
ehResult = ProcessDeleteRequest (entityHandlerRequest);
}
else
{
- OC_LOG_V (INFO, TAG, "Received unsupported method %d from client",
+ OIC_LOG_V (INFO, TAG, "Received unsupported method %d from client",
entityHandlerRequest->method);
ehResult = OC_EH_ERROR;
}
// Send the response
if (OCDoResponse(&response) != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "Error sending response");
+ OIC_LOG(ERROR, TAG, "Error sending response");
ehResult = OC_EH_ERROR;
}
}
}
if (flag & OC_OBSERVE_FLAG)
{
- OC_LOG(INFO, TAG, "Flag includes OC_OBSERVE_FLAG");
+ OIC_LOG(INFO, TAG, "Flag includes OC_OBSERVE_FLAG");
if (OC_OBSERVE_REGISTER == entityHandlerRequest->obsInfo.action)
{
- OC_LOG (INFO, TAG, "Received OC_OBSERVE_REGISTER from client");
+ OIC_LOG (INFO, TAG, "Received OC_OBSERVE_REGISTER from client");
}
else if (OC_OBSERVE_DEREGISTER == entityHandlerRequest->obsInfo.action)
{
- OC_LOG (INFO, TAG, "Received OC_OBSERVE_DEREGISTER from client");
+ OIC_LOG (INFO, TAG, "Received OC_OBSERVE_DEREGISTER from client");
}
}
OCEntityHandlerCb (OCEntityHandlerFlag flag,
OCEntityHandlerRequest *entityHandlerRequest, void* /*callback*/)
{
- OC_LOG_V (INFO, TAG, "Inside entity handler - flags: 0x%x", flag);
+ OIC_LOG_V (INFO, TAG, "Inside entity handler - flags: 0x%x", flag);
OCEntityHandlerResult ehResult = OC_EH_OK;
OCEntityHandlerResponse response = { 0, 0, OC_EH_ERROR, 0, 0, { },{ 0 }, false };
// Validate pointer
if (!entityHandlerRequest)
{
- OC_LOG (ERROR, TAG, "Invalid request pointer");
+ OIC_LOG (ERROR, TAG, "Invalid request pointer");
return OC_EH_ERROR;
}
if (flag & OC_REQUEST_FLAG)
{
- OC_LOG (INFO, TAG, "Flag includes OC_REQUEST_FLAG");
+ OIC_LOG (INFO, TAG, "Flag includes OC_REQUEST_FLAG");
if (OC_REST_GET == entityHandlerRequest->method)
{
- OC_LOG (INFO, TAG, "Received OC_REST_GET from client");
+ OIC_LOG (INFO, TAG, "Received OC_REST_GET from client");
ehResult = ProcessGetRequest (entityHandlerRequest, &payload);
}
else if (OC_REST_PUT == entityHandlerRequest->method)
{
- OC_LOG (INFO, TAG, "Received OC_REST_PUT from client");
+ OIC_LOG (INFO, TAG, "Received OC_REST_PUT from client");
ehResult = ProcessPutRequest (entityHandlerRequest, &payload);
}
else if (OC_REST_POST == entityHandlerRequest->method)
{
- OC_LOG (INFO, TAG, "Received OC_REST_POST from client");
+ OIC_LOG (INFO, TAG, "Received OC_REST_POST from client");
ehResult = ProcessPostRequest (entityHandlerRequest, &response, &payload);
}
else if (OC_REST_DELETE == entityHandlerRequest->method)
{
- OC_LOG (INFO, TAG, "Received OC_REST_DELETE from client");
+ OIC_LOG (INFO, TAG, "Received OC_REST_DELETE from client");
ehResult = ProcessDeleteRequest (entityHandlerRequest);
}
else
{
- OC_LOG_V (INFO, TAG, "Received unsupported method %d from client",
+ OIC_LOG_V (INFO, TAG, "Received unsupported method %d from client",
entityHandlerRequest->method);
ehResult = OC_EH_ERROR;
}
if(entityHandlerRequest->rcvdVendorSpecificHeaderOptions &&
entityHandlerRequest->numRcvdVendorSpecificHeaderOptions)
{
- OC_LOG (INFO, TAG, "Received vendor specific options");
+ OIC_LOG (INFO, TAG, "Received vendor specific options");
uint8_t i = 0;
OCHeaderOption * rcvdOptions =
entityHandlerRequest->rcvdVendorSpecificHeaderOptions;
{
if(((OCHeaderOption)rcvdOptions[i]).protocolID == OC_COAP_ID)
{
- OC_LOG_V(INFO, TAG, "Received option with OC_COAP_ID and ID %u with",
+ OIC_LOG_V(INFO, TAG, "Received option with OC_COAP_ID and ID %u with",
((OCHeaderOption)rcvdOptions[i]).optionID );
- OC_LOG_BUFFER(INFO, TAG, ((OCHeaderOption)rcvdOptions[i]).optionData,
+ OIC_LOG_BUFFER(INFO, TAG, ((OCHeaderOption)rcvdOptions[i]).optionData,
MAX_HEADER_OPTION_DATA_LENGTH);
}
}
// Send the response
if (OCDoResponse(&response) != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "Error sending response");
+ OIC_LOG(ERROR, TAG, "Error sending response");
ehResult = OC_EH_ERROR;
}
}
}
if (flag & OC_OBSERVE_FLAG)
{
- OC_LOG(INFO, TAG, "Flag includes OC_OBSERVE_FLAG");
+ OIC_LOG(INFO, TAG, "Flag includes OC_OBSERVE_FLAG");
if (OC_OBSERVE_REGISTER == entityHandlerRequest->obsInfo.action)
{
- OC_LOG (INFO, TAG, "Received OC_OBSERVE_REGISTER from client");
+ OIC_LOG (INFO, TAG, "Received OC_OBSERVE_REGISTER from client");
ProcessObserveRegister (entityHandlerRequest);
}
else if (OC_OBSERVE_DEREGISTER == entityHandlerRequest->obsInfo.action)
{
- OC_LOG (INFO, TAG, "Received OC_OBSERVE_DEREGISTER from client");
+ OIC_LOG (INFO, TAG, "Received OC_OBSERVE_DEREGISTER from client");
ProcessObserveDeregister (entityHandlerRequest);
}
}
Light.power += 5;
if (gLightUnderObservation)
{
- OC_LOG_V(INFO, TAG, " =====> Notifying stack of new power level %d\n", Light.power);
+ OIC_LOG_V(INFO, TAG, " =====> Notifying stack of new power level %d\n", Light.power);
if (gObserveNotifyType == 1)
{
// Notify list of observers. Alternate observers on the list will be notified.
result = OCNotifyAllObservers (Light.handle, OC_NA_QOS);
if (OC_STACK_NO_OBSERVERS == result)
{
- OC_LOG (INFO, TAG,
+ OIC_LOG (INFO, TAG,
"=======> No more observers exist, stop sending observations");
gLightUnderObservation = 0;
}
}
else
{
- OC_LOG (ERROR, TAG, "Incorrect notification type selected");
+ OIC_LOG (ERROR, TAG, "Incorrect notification type selected");
}
}
}
void *presenceNotificationGenerator(void *param)
{
uint8_t secondsBeforePresence = 10;
- OC_LOG_V(INFO, TAG, "Will send out presence in %u seconds", secondsBeforePresence);
+ OIC_LOG_V(INFO, TAG, "Will send out presence in %u seconds", secondsBeforePresence);
sleep(secondsBeforePresence);
(void)param;
OCDoHandle presenceNotificationHandles[numPresenceResources];
}
if(res != OC_STACK_OK)
{
- OC_LOG_V(ERROR, TAG, "\"Presence Notification Generator\" failed to create resource "
+ OIC_LOG_V(ERROR, TAG, "\"Presence Notification Generator\" failed to create resource "
"%s with result %s.", presenceNotificationResources.at(i).c_str(),
getResult(res));
break;
}
- OC_LOG_V(INFO, TAG, PCF("Created %s for presence notification"),
+ OIC_LOG_V(INFO, TAG, PCF("Created %s for presence notification"),
presenceNotificationUris[i].c_str());
}
sleep(5);
}
if(res != OC_STACK_OK)
{
- OC_LOG_V(ERROR, TAG, "\"Presence Notification Generator\" failed to delete "\
+ OIC_LOG_V(ERROR, TAG, "\"Presence Notification Generator\" failed to delete "\
"resource %s.", presenceNotificationResources.at(i).c_str());
break;
}
- OC_LOG_V(INFO, TAG, PCF("Deleted %s for presence notification"),
+ OIC_LOG_V(INFO, TAG, PCF("Deleted %s for presence notification"),
presenceNotificationUris[i].c_str());
}
- OC_LOG(INFO, TAG, "================ stopping presence");
+ OIC_LOG(INFO, TAG, "================ stopping presence");
OCStopPresence();
return NULL;
{
if (!uri)
{
- OC_LOG(ERROR, TAG, "Resource URI cannot be NULL");
+ OIC_LOG(ERROR, TAG, "Resource URI cannot be NULL");
return -1;
}
OCEntityHandlerCb,
NULL,
OC_DISCOVERABLE|OC_OBSERVABLE);
- OC_LOG_V(INFO, TAG, "Created Light resource with result: %s", getResult(res));
+ OIC_LOG_V(INFO, TAG, "Created Light resource with result: %s", getResult(res));
return 0;
}
static void PrintUsage()
{
- OC_LOG(INFO, TAG, "Usage : ocserver -o <0|1>");
- OC_LOG(INFO, TAG, "-o 0 : Notify all observers");
- OC_LOG(INFO, TAG, "-o 1 : Notify list of observers");
+ OIC_LOG(INFO, TAG, "Usage : ocserver -o <0|1>");
+ OIC_LOG(INFO, TAG, "-o 0 : Notify all observers");
+ OIC_LOG(INFO, TAG, "-o 1 : Notify list of observers");
}
#ifdef RA_ADAPTER
static void jidbound(char *jid)
{
- OC_LOG_V(INFO, TAG, "\n\n Bound JID: %s\n\n", jid);
+ OIC_LOG_V(INFO, TAG, "\n\n Bound JID: %s\n\n", jid);
}
#endif
OCSetRAInfo(&rainfo);
#endif
- OC_LOG(DEBUG, TAG, "OCServer is starting...");
+ OIC_LOG(DEBUG, TAG, "OCServer is starting...");
if (OCInit(NULL, 0, OC_SERVER) != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack init error");
+ OIC_LOG(ERROR, TAG, "OCStack init error");
return 0;
}
#ifdef WITH_PRESENCE
if (OCStartPresence(0) != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack presence/discovery error");
+ OIC_LOG(ERROR, TAG, "OCStack presence/discovery error");
return 0;
}
#endif
if (registrationResult != OC_STACK_OK)
{
- OC_LOG(INFO, TAG, "Platform info setting failed locally!");
+ OIC_LOG(INFO, TAG, "Platform info setting failed locally!");
exit (EXIT_FAILURE);
}
if (registrationResult != OC_STACK_OK)
{
- OC_LOG(INFO, TAG, "Platform Registration failed!");
+ OIC_LOG(INFO, TAG, "Platform Registration failed!");
exit (EXIT_FAILURE);
}
if (registrationResult != OC_STACK_OK)
{
- OC_LOG(INFO, TAG, "Device info setting failed locally!");
+ OIC_LOG(INFO, TAG, "Device info setting failed locally!");
exit (EXIT_FAILURE);
}
if (registrationResult != OC_STACK_OK)
{
- OC_LOG(INFO, TAG, "Device Registration failed!");
+ OIC_LOG(INFO, TAG, "Device Registration failed!");
exit (EXIT_FAILURE);
}
#endif
// Break from loop with Ctrl-C
- OC_LOG(INFO, TAG, "Entering ocserver main loop...");
+ OIC_LOG(INFO, TAG, "Entering ocserver main loop...");
DeletePlatformInfo();
DeleteDeviceInfo();
{
if (OCProcess() != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack process error");
+ OIC_LOG(ERROR, TAG, "OCStack process error");
return 0;
}
}
pthread_cancel(threadId_presence);
pthread_join(threadId_presence, NULL);
- OC_LOG(INFO, TAG, "Exiting ocserver main loop...");
+ OIC_LOG(INFO, TAG, "Exiting ocserver main loop...");
if (OCStop() != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack process error");
+ OIC_LOG(ERROR, TAG, "OCStack process error");
}
return 0;
OCRepPayload* payload = OCRepPayloadCreate();
if(!payload)
{
- OC_LOG(ERROR, TAG, PCF("Failed to allocate Payload"));
+ OIC_LOG(ERROR, TAG, PCF("Failed to allocate Payload"));
return nullptr;
}
{
if(ehRequest->payload && ehRequest->payload->type != PAYLOAD_TYPE_REPRESENTATION)
{
- OC_LOG(ERROR, TAG, PCF("Incoming payload not a representation"));
+ OIC_LOG(ERROR, TAG, PCF("Incoming payload not a representation"));
return nullptr;
}
if (0 == createLEDResource (newLedUri, &gLedInstance[gCurrLedInstance], false, 0))
{
- OC_LOG (INFO, TAG, "Created new LED instance");
+ OIC_LOG (INFO, TAG, "Created new LED instance");
gLedInstance[gCurrLedInstance].state = 0;
gLedInstance[gCurrLedInstance].power = 0;
gCurrLedInstance++;
}
else
{
- OC_LOG_V (INFO, TAG, "Payload was NULL");
+ OIC_LOG_V (INFO, TAG, "Payload was NULL");
ehResult = OC_EH_ERROR;
}
OCEntityHandlerRequest *entityHandlerRequest,
void* /*callbackParam*/)
{
- OC_LOG_V (INFO, TAG, "Inside entity handler - flags: 0x%x", flag);
+ OIC_LOG_V (INFO, TAG, "Inside entity handler - flags: 0x%x", flag);
OCEntityHandlerResult ehResult = OC_EH_ERROR;
OCEntityHandlerResponse response = { 0, 0, OC_EH_ERROR, 0, 0, { },{ 0 }, false };
// Validate pointer
if (!entityHandlerRequest)
{
- OC_LOG (ERROR, TAG, "Invalid request pointer");
+ OIC_LOG (ERROR, TAG, "Invalid request pointer");
return OC_EH_ERROR;
}
if (flag & OC_REQUEST_FLAG)
{
- OC_LOG (INFO, TAG, "Flag includes OC_REQUEST_FLAG");
+ OIC_LOG (INFO, TAG, "Flag includes OC_REQUEST_FLAG");
if (entityHandlerRequest)
{
if (OC_REST_GET == entityHandlerRequest->method)
{
- OC_LOG (INFO, TAG, "Received OC_REST_GET from client");
+ OIC_LOG (INFO, TAG, "Received OC_REST_GET from client");
ehResult = ProcessGetRequest (entityHandlerRequest, &payload);
}
else if (OC_REST_PUT == entityHandlerRequest->method)
{
- OC_LOG (INFO, TAG, "Received OC_REST_PUT from client");
+ OIC_LOG (INFO, TAG, "Received OC_REST_PUT from client");
ehResult = ProcessPutRequest (entityHandlerRequest, &payload);
}
else if (OC_REST_POST == entityHandlerRequest->method)
{
- OC_LOG (INFO, TAG, "Received OC_REST_POST from client");
+ OIC_LOG (INFO, TAG, "Received OC_REST_POST from client");
ehResult = ProcessPostRequest (entityHandlerRequest, &response, &payload);
}
else
{
- OC_LOG_V (INFO, TAG, "Received unsupported method %d from client",
+ OIC_LOG_V (INFO, TAG, "Received unsupported method %d from client",
entityHandlerRequest->method);
}
// Send the response
if (OCDoResponse(&response) != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "Error sending response");
+ OIC_LOG(ERROR, TAG, "Error sending response");
ehResult = OC_EH_ERROR;
}
}
int main(int /*argc*/, char* /*argv*/[])
{
- OC_LOG(DEBUG, TAG, "OCServer is starting...");
+ OIC_LOG(DEBUG, TAG, "OCServer is starting...");
if (OCInit(NULL, 0, OC_SERVER) != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack init error");
+ OIC_LOG(ERROR, TAG, "OCStack init error");
return 0;
}
createLEDResource(gResourceUri, &LED, false, 0);
// Break from loop with Ctrl-C
- OC_LOG(INFO, TAG, "Entering ocserver main loop...");
+ OIC_LOG(INFO, TAG, "Entering ocserver main loop...");
signal(SIGINT, handleSigInt);
while (!gQuitFlag)
{
if (OCProcess() != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack process error");
+ OIC_LOG(ERROR, TAG, "OCStack process error");
return 0;
}
sleep(2);
}
- OC_LOG(INFO, TAG, "Exiting ocserver main loop...");
+ OIC_LOG(INFO, TAG, "Exiting ocserver main loop...");
if (OCStop() != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack process error");
+ OIC_LOG(ERROR, TAG, "OCStack process error");
}
return 0;
{
if (!uri)
{
- OC_LOG(ERROR, TAG, "Resource URI cannot be NULL");
+ OIC_LOG(ERROR, TAG, "Resource URI cannot be NULL");
return -1;
}
OCEntityHandlerCb,
NULL,
OC_DISCOVERABLE|OC_OBSERVABLE);
- OC_LOG_V(INFO, TAG, "Created LED resource with result: %s", getResult(res));
+ OIC_LOG_V(INFO, TAG, "Created LED resource with result: %s", getResult(res));
return 0;
}
void PrintUsage()
{
- OC_LOG(INFO, TAG, "Usage : ocservercoll -t <Test Case>");
- OC_LOG(INFO, TAG,
+ OIC_LOG(INFO, TAG, "Usage : ocservercoll -t <Test Case>");
+ OIC_LOG(INFO, TAG,
"Test Case 1 : Create room resource with default collection entity handler.");
- OC_LOG(INFO, TAG,
+ OIC_LOG(INFO, TAG,
"Test Case 2 : Create room resource with application collection entity handler.");
}
typeOfMethod = "OC_REST_PUT";
}
- OC_LOG_V(INFO, TAG, "Receiving message type: %s, method %s", typeOfMessage,
+ OIC_LOG_V(INFO, TAG, "Receiving message type: %s, method %s", typeOfMessage,
typeOfMethod);
}
OCDeviceEntityHandlerCb (OCEntityHandlerFlag flag,
OCEntityHandlerRequest *entityHandlerRequest, char* uri, void* /*callbackParam*/)
{
- OC_LOG_V(INFO, TAG, "Inside device default entity handler - flags: 0x%x, uri: %s", flag, uri);
+ OIC_LOG_V(INFO, TAG, "Inside device default entity handler - flags: 0x%x, uri: %s", flag, uri);
OCEntityHandlerResult ehResult = OC_EH_OK;
OCEntityHandlerResponse response;
if (!entityHandlerRequest)
{
- OC_LOG(ERROR, TAG, "Invalid request pointer");
+ OIC_LOG(ERROR, TAG, "Invalid request pointer");
return OC_EH_ERROR;
}
if (entityHandlerRequest->resource == NULL)
{
- OC_LOG(INFO, TAG, "Received request from client to a non-existing resource");
+ OIC_LOG(INFO, TAG, "Received request from client to a non-existing resource");
ehResult = OC_EH_RESOURCE_NOT_FOUND;
}
else
{
- OC_LOG_V(INFO, TAG, "Device Handler: Received unsupported request from client %d",
+ OIC_LOG_V(INFO, TAG, "Device Handler: Received unsupported request from client %d",
entityHandlerRequest->method);
ehResult = OC_EH_ERROR;
}
// Send the response
if (OCDoResponse(&response) != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "Error sending response");
+ OIC_LOG(ERROR, TAG, "Error sending response");
ehResult = OC_EH_ERROR;
}
}
OCEntityHandlerResult ret = OC_EH_OK;
OCEntityHandlerResponse response;
- OC_LOG_V(INFO, TAG, "Callback for Room");
+ OIC_LOG_V(INFO, TAG, "Callback for Room");
PrintReceivedMsgInfo(flag, ehRequest );
if(ehRequest && flag == OC_REQUEST_FLAG )
// Send the response
if (OCDoResponse(&response) != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "Error sending response");
+ OIC_LOG(ERROR, TAG, "Error sending response");
ret = OC_EH_ERROR;
}
}
// Send the response
if (OCDoResponse(&response) != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "Error sending response");
+ OIC_LOG(ERROR, TAG, "Error sending response");
ret = OC_EH_ERROR;
}
}
}
else
{
- OC_LOG_V (INFO, TAG, "Received unsupported method %d from client",
+ OIC_LOG_V (INFO, TAG, "Received unsupported method %d from client",
ehRequest->method);
OCRepPayloadDestroy(payload);
ret = OC_EH_ERROR;
OCEntityHandlerResult ret = OC_EH_OK;
OCEntityHandlerResponse response;
- OC_LOG_V(INFO, TAG, "Callback for Light");
+ OIC_LOG_V(INFO, TAG, "Callback for Light");
PrintReceivedMsgInfo(flag, ehRequest );
if(ehRequest && flag == OC_REQUEST_FLAG)
}
else
{
- OC_LOG_V (INFO, TAG, "Received unsupported method %d from client",
+ OIC_LOG_V (INFO, TAG, "Received unsupported method %d from client",
ehRequest->method);
ret = OC_EH_ERROR;
}
// Send the response
if (OCDoResponse(&response) != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "Error sending response");
+ OIC_LOG(ERROR, TAG, "Error sending response");
ret = OC_EH_ERROR;
}
}
OCEntityHandlerResult ret = OC_EH_OK;
OCEntityHandlerResponse response;
- OC_LOG_V(INFO, TAG, "Callback for Fan");
+ OIC_LOG_V(INFO, TAG, "Callback for Fan");
PrintReceivedMsgInfo(flag, ehRequest );
if(ehRequest && flag == OC_REQUEST_FLAG)
}
else
{
- OC_LOG_V (INFO, TAG, "Received unsupported method %d from client",
+ OIC_LOG_V (INFO, TAG, "Received unsupported method %d from client",
ehRequest->method);
ret = OC_EH_ERROR;
}
// Send the response
if (OCDoResponse(&response) != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "Error sending response");
+ OIC_LOG(ERROR, TAG, "Error sending response");
ret = OC_EH_ERROR;
}
}
light.power += 5;
if (gLightUnderObservation)
{
- OC_LOG_V(INFO, TAG,
+ OIC_LOG_V(INFO, TAG,
" =====> Notifying stack of new power level %d\n", light.power);
result = OCNotifyAllObservers (light.handle, OC_NA_QOS);
if (OC_STACK_NO_OBSERVERS == result)
return -1;
}
- OC_LOG(DEBUG, TAG, "OCServer is starting...");
+ OIC_LOG(DEBUG, TAG, "OCServer is starting...");
if (OCInit(NULL, 0, OC_SERVER) != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack init error");
+ OIC_LOG(ERROR, TAG, "OCStack init error");
return 0;
}
pthread_create (&threadId, NULL, ChangeLightRepresentation, (void *)NULL);
// Break from loop with Ctrl-C
- OC_LOG(INFO, TAG, "Entering ocserver main loop...");
+ OIC_LOG(INFO, TAG, "Entering ocserver main loop...");
signal(SIGINT, handleSigInt);
while (!gQuitFlag)
{
if (OCProcess() != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack process error");
+ OIC_LOG(ERROR, TAG, "OCStack process error");
return 0;
}
sleep(2);
pthread_cancel(threadId);
pthread_join(threadId, NULL);
- OC_LOG(INFO, TAG, "Exiting ocserver main loop...");
+ OIC_LOG(INFO, TAG, "Exiting ocserver main loop...");
if (OCStop() != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack process error");
+ OIC_LOG(ERROR, TAG, "OCStack process error");
}
return 0;
OCEntityHandlerFanCb,
NULL,
OC_DISCOVERABLE|OC_OBSERVABLE);
- OC_LOG_V(INFO, TAG, "Created fan resource with result: %s", getResult(res));
+ OIC_LOG_V(INFO, TAG, "Created fan resource with result: %s", getResult(res));
OCResourceHandle light;
res = OCCreateResource(&light,
OCEntityHandlerLightCb,
NULL,
OC_DISCOVERABLE|OC_OBSERVABLE);
- OC_LOG_V(INFO, TAG, "Created light resource with result: %s", getResult(res));
+ OIC_LOG_V(INFO, TAG, "Created light resource with result: %s", getResult(res));
OCResourceHandle room;
OC_DISCOVERABLE);
}
- OC_LOG_V(INFO, TAG, "Created room resource with result: %s", getResult(res));
+ OIC_LOG_V(INFO, TAG, "Created room resource with result: %s", getResult(res));
OCBindResourceInterfaceToResource(room, OC_RSRVD_INTERFACE_LL);
OCBindResourceInterfaceToResource(room, OC_RSRVD_INTERFACE_DEFAULT);
res = OCBindResource(room, light);
- OC_LOG_V(INFO, TAG, "OC Bind Contained Resource to resource: %s", getResult(res));
+ OIC_LOG_V(INFO, TAG, "OC Bind Contained Resource to resource: %s", getResult(res));
res = OCBindResource(room, fan);
- OC_LOG_V(INFO, TAG, "OC Bind Contained Resource to resource: %s", getResult(res));
+ OIC_LOG_V(INFO, TAG, "OC Bind Contained Resource to resource: %s", getResult(res));
}
{
LEDResource *currLEDResource = &LED;
- OC_LOG(INFO, TAG, "Entering constructResponse");
+ OIC_LOG(INFO, TAG, "Entering constructResponse");
if (ehRequest->resource == gLedInstance[0].handle)
{
- OC_LOG(INFO, TAG, "handle 0");
+ OIC_LOG(INFO, TAG, "handle 0");
currLEDResource = &gLedInstance[0];
gResourceUri = const_cast<char *>("a/led/0");
}
else if (ehRequest->resource == gLedInstance[1].handle)
{
- OC_LOG(INFO, TAG, "handle 1");
+ OIC_LOG(INFO, TAG, "handle 1");
currLEDResource = &gLedInstance[1];
gResourceUri = const_cast<char *>("a/led/1");
}
{
if(ehRequest->payload && ehRequest->payload->type != PAYLOAD_TYPE_REPRESENTATION)
{
- OC_LOG(ERROR, TAG, ("Incoming payload not a representation"));
+ OIC_LOG(ERROR, TAG, ("Incoming payload not a representation"));
return nullptr;
}
if (!response)
{
- OC_LOG_V(ERROR, TAG, "Memory allocation for response payload failed.");
+ OIC_LOG_V(ERROR, TAG, "Memory allocation for response payload failed.");
}
OCRepPayloadSetUri (response, gResourceUri);
void ProcessGetPutRequest (OCEntityHandlerRequest *ehRequest)
{
- OC_LOG(INFO, TAG, "Entering ProcessGetPutRequest");
+ OIC_LOG(INFO, TAG, "Entering ProcessGetPutRequest");
OCRepPayload *getResp = constructResponse(ehRequest);
if(!getResp)
{
- OC_LOG(ERROR, TAG, "Failed to construct response");
+ OIC_LOG(ERROR, TAG, "Failed to construct response");
return;
}
// Send the response
if (OCDoResponse(&response) != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "Error sending response");
+ OIC_LOG(ERROR, TAG, "Error sending response");
}
free(getResp);
OCEntityHandlerRequest *CopyRequest(OCEntityHandlerRequest *entityHandlerRequest)
{
- OC_LOG(INFO, TAG, "Copying received request for slow response");
+ OIC_LOG(INFO, TAG, "Copying received request for slow response");
OCEntityHandlerRequest *copyOfRequest =
(OCEntityHandlerRequest *)OICMalloc(sizeof(OCEntityHandlerRequest));
copyOfRequest->query = OICStrdup(entityHandlerRequest->query);
if(!copyOfRequest->query)
{
- OC_LOG(ERROR, TAG, "Copy failed due to allocation failure");
+ OIC_LOG(ERROR, TAG, "Copy failed due to allocation failure");
OICFree(copyOfRequest);
return NULL;
}
if (copyOfRequest)
{
- OC_LOG(INFO, TAG, "Copied client request");
+ OIC_LOG(INFO, TAG, "Copied client request");
}
else
{
- OC_LOG(ERROR, TAG, "Error copying client request");
+ OIC_LOG(ERROR, TAG, "Error copying client request");
}
return copyOfRequest;
}
OCEntityHandlerResult result = OC_EH_ERROR;
OCEntityHandlerRequest *request = NULL;
- OC_LOG_V (INFO, TAG, "Inside entity handler - flags: 0x%x", flag);
+ OIC_LOG_V (INFO, TAG, "Inside entity handler - flags: 0x%x", flag);
if (flag & OC_REQUEST_FLAG)
{
- OC_LOG(INFO, TAG, "Flag includes OC_REQUEST_FLAG");
+ OIC_LOG(INFO, TAG, "Flag includes OC_REQUEST_FLAG");
if (entityHandlerRequest)
{
- OC_LOG_V (INFO, TAG, "request query %s from client",
+ OIC_LOG_V (INFO, TAG, "request query %s from client",
entityHandlerRequest->query);
- OC_LOG_PAYLOAD (INFO, entityHandlerRequest->payload);
+ OIC_LOG_PAYLOAD (INFO, entityHandlerRequest->payload);
// Make deep copy of received request and queue it for slow processing
request = CopyRequest(entityHandlerRequest);
if (request)
{
- OC_LOG(INFO, TAG, "Scheduling slow response for received request");
+ OIC_LOG(INFO, TAG, "Scheduling slow response for received request");
gRequestList.push_back(request);
// Indicate to the stack that this is a slow response
result = OC_EH_SLOW;
}
else
{
- OC_LOG(ERROR, TAG, "Error queuing request for slow response");
+ OIC_LOG(ERROR, TAG, "Error queuing request for slow response");
// Indicate to the stack that this is a slow response
result = OC_EH_ERROR;
}
}
else
{
- OC_LOG(ERROR, TAG, "Invalid request");
+ OIC_LOG(ERROR, TAG, "Invalid request");
result = OC_EH_ERROR;
}
}
{
if (sig == SIGALRM)
{
- OC_LOG (INFO, TAG, "Server starting slow response");
+ OIC_LOG (INFO, TAG, "Server starting slow response");
if (gRequestList.empty())
{
- OC_LOG (INFO, TAG, "No requests to service");
+ OIC_LOG (INFO, TAG, "No requests to service");
return;
}
gRequestList.pop_front();
if (entityHandlerRequest->method == OC_REST_GET)
{
- OC_LOG (INFO, TAG, "Received OC_REST_GET from client");
+ OIC_LOG (INFO, TAG, "Received OC_REST_GET from client");
ProcessGetPutRequest (entityHandlerRequest);
}
else if (entityHandlerRequest->method == OC_REST_PUT)
{
- OC_LOG (INFO, TAG, "Received OC_REST_PUT from client");
+ OIC_LOG (INFO, TAG, "Received OC_REST_PUT from client");
ProcessGetPutRequest (entityHandlerRequest);
}
else
{
- OC_LOG_V (INFO, TAG, "Received unsupported method %d from client",
+ OIC_LOG_V (INFO, TAG, "Received unsupported method %d from client",
entityHandlerRequest->method);
}
// Free the request
int main(int /*argc*/, char** /*argv[]*/)
{
- OC_LOG(DEBUG, TAG, "OCServer is starting...");
+ OIC_LOG(DEBUG, TAG, "OCServer is starting...");
if (OCInit(NULL, 0, OC_SERVER) != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack init error");
+ OIC_LOG(ERROR, TAG, "OCStack init error");
return 0;
}
signal(SIGALRM, AlarmHandler);
// Break from loop with Ctrl-C
- OC_LOG(INFO, TAG, "Entering ocserver main loop...");
+ OIC_LOG(INFO, TAG, "Entering ocserver main loop...");
signal(SIGINT, handleSigInt);
while (!gQuitFlag)
{
if (OCProcess() != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack process error");
+ OIC_LOG(ERROR, TAG, "OCStack process error");
return 0;
}
sleep(2);
}
- OC_LOG(INFO, TAG, "Exiting ocserver main loop...");
+ OIC_LOG(INFO, TAG, "Exiting ocserver main loop...");
// Free requests
if (!gRequestList.empty())
if (OCStop() != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack process error");
+ OIC_LOG(ERROR, TAG, "OCStack process error");
}
return 0;
{
if (!uri)
{
- OC_LOG(ERROR, TAG, "Resource URI cannot be NULL");
+ OIC_LOG(ERROR, TAG, "Resource URI cannot be NULL");
return -1;
}
OCEntityHandlerCb,
NULL,
OC_DISCOVERABLE|OC_OBSERVABLE);
- OC_LOG_V(INFO, TAG, "Created LED resource with result: %s", getResult(res));
+ OIC_LOG_V(INFO, TAG, "Created LED resource with result: %s", getResult(res));
return 0;
}
{
struct timespec timeout;
- OC_LOG(DEBUG, TAG, "OCAMS service is starting...");
+ OIC_LOG(DEBUG, TAG, "OCAMS service is starting...");
// Initialize Persistent Storage for SVR database
OCPersistentStorage ps = { service_fopen, fread, fwrite, fclose, unlink };
if (OCInit(NULL, 0, OC_SERVER) != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack init error");
+ OIC_LOG(ERROR, TAG, "OCStack init error");
return 0;
}
timeout.tv_nsec = 100000000L;
// Break from loop with Ctrl-C
- OC_LOG(INFO, TAG, "Entering ocamsservice main loop...");
+ OIC_LOG(INFO, TAG, "Entering ocamsservice main loop...");
signal(SIGINT, handleSigInt);
while (!gQuitFlag)
{
if (OCProcess() != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack process error");
+ OIC_LOG(ERROR, TAG, "OCStack process error");
return 0;
}
nanosleep(&timeout, NULL);
}
- OC_LOG(INFO, TAG, "Exiting ocamsservice main loop...");
+ OIC_LOG(INFO, TAG, "Exiting ocamsservice main loop...");
if (OCStop() != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack process error");
+ OIC_LOG(ERROR, TAG, "OCStack process error");
}
return 0;
static void PrintUsage()
{
- OC_LOG(INFO, TAG, "Usage : occlient -u <0|1> -t <1|2|3> -c <0|1>");
- OC_LOG(INFO, TAG, "-u <0|1> : Perform multicast/unicast discovery of resources");
- OC_LOG(INFO, TAG, "-t 1 : Discover Resources");
- OC_LOG(INFO, TAG, "-t 2 : Discover Resources and"
+ OIC_LOG(INFO, TAG, "Usage : occlient -u <0|1> -t <1|2|3> -c <0|1>");
+ OIC_LOG(INFO, TAG, "-u <0|1> : Perform multicast/unicast discovery of resources");
+ OIC_LOG(INFO, TAG, "-t 1 : Discover Resources");
+ OIC_LOG(INFO, TAG, "-t 2 : Discover Resources and"
" Initiate Nonconfirmable Get/Put/Post Requests");
- OC_LOG(INFO, TAG, "-t 3 : Discover Resources and Initiate Confirmable Get/Put/Post Requests");
- OC_LOG(INFO, TAG, "-c 0 : Default auto-selection");
- OC_LOG(INFO, TAG, "-c 1 : IP Connectivity Type");
+ OIC_LOG(INFO, TAG, "-t 3 : Discover Resources and Initiate Confirmable Get/Put/Post Requests");
+ OIC_LOG(INFO, TAG, "-c 0 : Default auto-selection");
+ OIC_LOG(INFO, TAG, "-c 1 : IP Connectivity Type");
}
OCStackResult InvokeOCDoResource(std::ostringstream &query,
if (ret != OC_STACK_OK)
{
- OC_LOG_V(ERROR, TAG, "OCDoResource returns error %d with method %d", ret, method);
+ OIC_LOG_V(ERROR, TAG, "OCDoResource returns error %d with method %d", ret, method);
}
return ret;
OCStackApplicationResult putReqCB(void*, OCDoHandle, OCClientResponse * clientResponse)
{
- OC_LOG(INFO, TAG, "Callback Context for PUT recvd successfully");
+ OIC_LOG(INFO, TAG, "Callback Context for PUT recvd successfully");
if(clientResponse)
{
- OC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
- OC_LOG_PAYLOAD(INFO, clientResponse->payload);
- OC_LOG(INFO, TAG, ("=============> Put Response"));
+ OIC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
+ OIC_LOG_PAYLOAD(INFO, clientResponse->payload);
+ OIC_LOG(INFO, TAG, ("=============> Put Response"));
}
return OC_STACK_DELETE_TRANSACTION;
}
OCStackApplicationResult postReqCB(void *, OCDoHandle, OCClientResponse *clientResponse)
{
- OC_LOG(INFO, TAG, "Callback Context for POST recvd successfully");
+ OIC_LOG(INFO, TAG, "Callback Context for POST recvd successfully");
if(clientResponse)
{
- OC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
- OC_LOG_PAYLOAD(INFO, clientResponse->payload);
- OC_LOG(INFO, TAG, ("=============> Post Response"));
+ OIC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
+ OIC_LOG_PAYLOAD(INFO, clientResponse->payload);
+ OIC_LOG(INFO, TAG, ("=============> Post Response"));
}
return OC_STACK_DELETE_TRANSACTION;
}
OCStackApplicationResult getReqCB(void*, OCDoHandle, OCClientResponse * clientResponse)
{
- OC_LOG(INFO, TAG, "Callback Context for GET query recvd successfully");
+ OIC_LOG(INFO, TAG, "Callback Context for GET query recvd successfully");
if(clientResponse)
{
- OC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
- OC_LOG_V(INFO, TAG, "SEQUENCE NUMBER: %d", clientResponse->sequenceNumber);
- OC_LOG_PAYLOAD(INFO, clientResponse->payload);
- OC_LOG(INFO, TAG, ("=============> Get Response"));
+ 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"));
}
return OC_STACK_DELETE_TRANSACTION;
}
OCStackApplicationResult discoveryReqCB(void*, OCDoHandle,
OCClientResponse * clientResponse)
{
- OC_LOG(INFO, TAG, "Callback Context for DISCOVER query recvd successfully");
+ OIC_LOG(INFO, TAG, "Callback Context for DISCOVER query recvd successfully");
if (clientResponse)
{
- OC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
- OC_LOG_V(INFO, TAG,
+ OIC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
+ OIC_LOG_V(INFO, TAG,
"Device =============> Discovered @ %s:%d",
clientResponse->devAddr.addr,
clientResponse->devAddr.port);
if (clientResponse->result == OC_STACK_OK)
{
- OC_LOG_PAYLOAD(INFO, clientResponse->payload);
+ OIC_LOG_PAYLOAD(INFO, clientResponse->payload);
ocConnType = clientResponse->connType;
endpoint = clientResponse->devAddr;
int InitPutRequest(OCQualityOfService qos)
{
- OC_LOG_V(INFO, TAG, "\n\nExecuting %s", __func__);
+ OIC_LOG_V(INFO, TAG, "\n\nExecuting %s", __func__);
std::ostringstream query;
query << coapServerResource;
endpoint.flags = (OCTransportFlags)(endpoint.flags|OC_SECURE);
int InitPostRequest(OCQualityOfService qos)
{
OCStackResult result;
- OC_LOG_V(INFO, TAG, "\n\nExecuting %s", __func__);
+ OIC_LOG_V(INFO, TAG, "\n\nExecuting %s", __func__);
std::ostringstream query;
query << coapServerResource;
endpoint.flags = (OCTransportFlags)(endpoint.flags|OC_SECURE);
if (OC_STACK_OK != result)
{
// Error can happen if for example, network connectivity is down
- OC_LOG(INFO, TAG, "First POST call did not succeed");
+ OIC_LOG(INFO, TAG, "First POST call did not succeed");
}
// Second POST operation (to create an LED instance)
postReqCB, NULL, 0);
if (OC_STACK_OK != result)
{
- OC_LOG(INFO, TAG, "Second POST call did not succeed");
+ OIC_LOG(INFO, TAG, "Second POST call did not succeed");
}
// This POST operation will update the original resourced /a/led
int InitGetRequest(OCQualityOfService qos)
{
- OC_LOG_V(INFO, TAG, "\n\nExecuting %s", __func__);
+ OIC_LOG_V(INFO, TAG, "\n\nExecuting %s", __func__);
std::ostringstream query;
query << coapServerResource;
endpoint.flags = (OCTransportFlags)(endpoint.flags|OC_SECURE);
if (UnicastDiscovery)
{
- OC_LOG(INFO, TAG, "Enter IP address (with optional port) of the Server hosting resource\n");
- OC_LOG(INFO, TAG, "IPv4: 192.168.0.15:45454\n");
- OC_LOG(INFO, TAG, "IPv6: [fe80::20c:29ff:fe1b:9c5]:45454\n");
+ OIC_LOG(INFO, TAG, "Enter IP address (with optional port) of the Server hosting resource\n");
+ OIC_LOG(INFO, TAG, "IPv4: 192.168.0.15:45454\n");
+ OIC_LOG(INFO, TAG, "IPv6: [fe80::20c:29ff:fe1b:9c5]:45454\n");
if (fgets(ipaddr, sizeof (ipaddr), stdin))
{
}
else
{
- OC_LOG(ERROR, TAG, "!! Bad input for IP address. !!");
+ OIC_LOG(ERROR, TAG, "!! Bad input for IP address. !!");
return OC_STACK_INVALID_PARAM;
}
}
cbData.cd = NULL;
/* Start a discovery query*/
- OC_LOG_V(INFO, TAG, "Initiating %s Resource Discovery : %s\n",
+ OIC_LOG_V(INFO, TAG, "Initiating %s Resource Discovery : %s\n",
(UnicastDiscovery) ? "Unicast" : "Multicast",
queryUri);
OC_LOW_QOS, &cbData, NULL, 0);
if (ret != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack resource error");
+ OIC_LOG(ERROR, TAG, "OCStack resource error");
}
return ret;
}
}
else
{
- OC_LOG(INFO, TAG, "Using Default Connectivity type");
+ OIC_LOG(INFO, TAG, "Using Default Connectivity type");
PrintUsage();
}
/* Initialize OCStack*/
if (OCInit(NULL, 0, OC_CLIENT_SERVER) != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack init error");
+ OIC_LOG(ERROR, TAG, "OCStack init error");
return 0;
}
timeout.tv_nsec = 100000000L;
// Break from loop with Ctrl+C
- OC_LOG(INFO, TAG, "Entering occlient main loop...");
+ OIC_LOG(INFO, TAG, "Entering occlient main loop...");
signal(SIGINT, handleSigInt);
while (!gQuitFlag)
{
if (OCProcess() != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack process error");
+ OIC_LOG(ERROR, TAG, "OCStack process error");
return 0;
}
nanosleep(&timeout, NULL);
}
- OC_LOG(INFO, TAG, "Exiting occlient main loop...");
+ OIC_LOG(INFO, TAG, "Exiting occlient main loop...");
if (OCStop() != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack stop error");
+ OIC_LOG(ERROR, TAG, "OCStack stop error");
}
return 0;
while (res)
{
coapServerResource.assign(res->uri);
- OC_LOG_V(INFO, TAG, "Uri -- %s", coapServerResource.c_str());
+ OIC_LOG_V(INFO, TAG, "Uri -- %s", coapServerResource.c_str());
if (res->secure)
{
coapSecureResource = 1;
}
- OC_LOG_V(INFO, TAG, "Secure -- %s", coapSecureResource == 1 ? "YES" : "NO");
+ OIC_LOG_V(INFO, TAG, "Secure -- %s", coapSecureResource == 1 ? "YES" : "NO");
// If we discovered a secure resource, exit from here
if (coapSecureResource)
OCRepPayload* payload = OCRepPayloadCreate();
if(!payload)
{
- OC_LOG(ERROR, TAG, PCF("Failed to allocate Payload"));
+ OIC_LOG(ERROR, TAG, PCF("Failed to allocate Payload"));
return nullptr;
}
{
if(ehRequest->payload && ehRequest->payload->type != PAYLOAD_TYPE_REPRESENTATION)
{
- OC_LOG(ERROR, TAG, PCF("Incoming payload not a representation"));
+ OIC_LOG(ERROR, TAG, PCF("Incoming payload not a representation"));
return nullptr;
}
if (0 == createLEDResource (newLedUri, &gLedInstance[gCurrLedInstance], false, 0))
{
- OC_LOG (INFO, TAG, "Created new LED instance");
+ OIC_LOG (INFO, TAG, "Created new LED instance");
gLedInstance[gCurrLedInstance].state = 0;
gLedInstance[gCurrLedInstance].power = 0;
gCurrLedInstance++;
}
else
{
- OC_LOG_V (INFO, TAG, "Payload was NULL");
+ OIC_LOG_V (INFO, TAG, "Payload was NULL");
ehResult = OC_EH_ERROR;
}
OCEntityHandlerRequest *entityHandlerRequest,
void* /*callbackParam*/)
{
- OC_LOG_V (INFO, TAG, "Inside entity handler - flags: 0x%x", flag);
+ OIC_LOG_V (INFO, TAG, "Inside entity handler - flags: 0x%x", flag);
OCEntityHandlerResult ehResult = OC_EH_ERROR;
OCEntityHandlerResponse response = { 0, 0, OC_EH_ERROR, 0, 0, { },{ 0 }, false };
// Validate pointer
if (!entityHandlerRequest)
{
- OC_LOG (ERROR, TAG, "Invalid request pointer");
+ OIC_LOG (ERROR, TAG, "Invalid request pointer");
return OC_EH_ERROR;
}
if (flag & OC_REQUEST_FLAG)
{
- OC_LOG (INFO, TAG, "Flag includes OC_REQUEST_FLAG");
+ OIC_LOG (INFO, TAG, "Flag includes OC_REQUEST_FLAG");
if (entityHandlerRequest)
{
if (OC_REST_GET == entityHandlerRequest->method)
{
- OC_LOG (INFO, TAG, "Received OC_REST_GET from client");
+ OIC_LOG (INFO, TAG, "Received OC_REST_GET from client");
ehResult = ProcessGetRequest (entityHandlerRequest, &payload);
}
else if (OC_REST_PUT == entityHandlerRequest->method)
{
- OC_LOG (INFO, TAG, "Received OC_REST_PUT from client");
+ OIC_LOG (INFO, TAG, "Received OC_REST_PUT from client");
ehResult = ProcessPutRequest (entityHandlerRequest, &payload);
}
else if (OC_REST_POST == entityHandlerRequest->method)
{
- OC_LOG (INFO, TAG, "Received OC_REST_POST from client");
+ OIC_LOG (INFO, TAG, "Received OC_REST_POST from client");
ehResult = ProcessPostRequest (entityHandlerRequest, &response, &payload);
}
else
{
- OC_LOG_V (INFO, TAG, "Received unsupported method %d from client",
+ OIC_LOG_V (INFO, TAG, "Received unsupported method %d from client",
entityHandlerRequest->method);
ehResult = OC_EH_ERROR;
}
// Send the response
if (OCDoResponse(&response) != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "Error sending response");
+ OIC_LOG(ERROR, TAG, "Error sending response");
ehResult = OC_EH_ERROR;
}
}
{
struct timespec timeout;
- OC_LOG(DEBUG, TAG, "OCServer is starting...");
+ OIC_LOG(DEBUG, TAG, "OCServer is starting...");
// Initialize Persistent Storage for SVR database
OCPersistentStorage ps = { server_fopen, fread, fwrite, fclose, unlink };
if (OCInit(NULL, 0, OC_SERVER) != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack init error");
+ OIC_LOG(ERROR, TAG, "OCStack init error");
return 0;
}
timeout.tv_nsec = 100000000L;
// Break from loop with Ctrl-C
- OC_LOG(INFO, TAG, "Entering ocserver main loop...");
+ OIC_LOG(INFO, TAG, "Entering ocserver main loop...");
signal(SIGINT, handleSigInt);
while (!gQuitFlag)
{
if (OCProcess() != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack process error");
+ OIC_LOG(ERROR, TAG, "OCStack process error");
return 0;
}
nanosleep(&timeout, NULL);
}
- OC_LOG(INFO, TAG, "Exiting ocserver main loop...");
+ OIC_LOG(INFO, TAG, "Exiting ocserver main loop...");
if (OCStop() != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack process error");
+ OIC_LOG(ERROR, TAG, "OCStack process error");
}
return 0;
{
if (!uri)
{
- OC_LOG(ERROR, TAG, "Resource URI cannot be NULL");
+ OIC_LOG(ERROR, TAG, "Resource URI cannot be NULL");
return -1;
}
OCEntityHandlerCb,
NULL,
OC_DISCOVERABLE|OC_OBSERVABLE | OC_SECURE);
- OC_LOG_V(INFO, TAG, "Created LED resource with result: %s", getResult(res));
+ OIC_LOG_V(INFO, TAG, "Created LED resource with result: %s", getResult(res));
return 0;
}
if(clientResponse)
{
cout << "\nStackResult: " << getResult(clientResponse->result);
- //OC_LOG_PAYLOAD(INFO, clientResponse->payload);
+ //OIC_LOG_PAYLOAD(INFO, clientResponse->payload);
}
else
{
cout << "\nStackResult: " << getResult(clientResponse->result);
cout << "\nSEQUENCE NUMBER: " << clientResponse->sequenceNumber;
- //OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);
+ //OIC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);
if (clientResponse->numRcvdVendorSpecificHeaderOptions > 0)
{
cout << "\nStackResult: " << getResult(clientResponse->result);
cout << "\nSEQUENCE NUMBER: " << clientResponse->sequenceNumber;
cout << "\nCallback Context for OBSERVE notification recvd successfully ";
- //OC_LOG_PAYLOAD(INFO, clientResponse->payload);
+ //OIC_LOG_PAYLOAD(INFO, clientResponse->payload);
gNumObserveNotifies++;
if (gNumObserveNotifies == 15) //large number to test observing in DELETE case.
{
cout << "\nStackResult: " << getResult(clientResponse->result);
cout << "\nNONCE NUMBER: " << clientResponse->sequenceNumber;
cout << "\nCallback Context for Presence notification recvd successfully ";
- //OC_LOG_PAYLOAD(INFO, clientResponse->payload);
+ //OIC_LOG_PAYLOAD(INFO, clientResponse->payload);
gNumPresenceNotifies++;
if (gNumPresenceNotifies == 20)
{
{
cout << ":" << clientResponse->devAddr.port;
}
- //OC_LOG_PAYLOAD(INFO, clientResponse->payload);
+ //OIC_LOG_PAYLOAD(INFO, clientResponse->payload);
cout << "\nConnectivity type: " << clientResponse->connType;
g_connType = clientResponse->connType;
g_serverAddr = clientResponse->devAddr;
if (clientResponse)
{
- //OC_LOG truncates the response as it is too long.
- //OC_LOG_PAYLOAD(INFO, clientResponse->payload);
+ //OIC_LOG truncates the response as it is too long.
+ //OIC_LOG_PAYLOAD(INFO, clientResponse->payload);
}
else
{
if (clientResponse)
{
- //OC_LOG truncates the response as it is too long.
+ //OIC_LOG truncates the response as it is too long.
cout << "\nDiscovery response: ";
cout << clientResponse->payload;
}
{
if (OCProcess() != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack process error");
+ OIC_LOG(ERROR, TAG, "OCStack process error");
return 0;
}
usleep(SLEEP_DURATION);
}
// Break from loop with Ctrl+C
- OC_LOG(INFO, TAG, "Entering occlient main loop...");
+ OIC_LOG(INFO, TAG, "Entering occlient main loop...");
signal(SIGINT, handleSigInt);
while (!gQuitFlag)
{
}
else
{
- OC_LOG(INFO, TAG, "Adding client callback with token");
- OC_LOG_BUFFER(INFO, TAG, (const uint8_t *)token, tokenLength);
+ OIC_LOG(INFO, TAG, "Adding client callback with token");
+ OIC_LOG_BUFFER(INFO, TAG, (const uint8_t *)token, tokenLength);
cbNode->callBack = cbData->cb;
cbNode->context = cbData->context;
cbNode->deleteCallback = cbData->cd;
}
cbNode->requestUri = requestUri; // I own it now
cbNode->devAddr = devAddr; // I own it now
- OC_LOG_V(INFO, TAG, "Added Callback for uri : %s", requestUri);
+ OIC_LOG_V(INFO, TAG, "Added Callback for uri : %s", requestUri);
LL_APPEND(cbList, cbNode);
*clientCB = cbNode;
}
if (cbNode)
{
LL_DELETE(cbList, cbNode);
- OC_LOG (INFO, TAG, "Deleting token");
- OC_LOG_BUFFER(INFO, TAG, (const uint8_t *)cbNode->token, cbNode->tokenLength);
+ OIC_LOG (INFO, TAG, "Deleting token");
+ OIC_LOG_BUFFER(INFO, TAG, (const uint8_t *)cbNode->token, cbNode->tokenLength);
CADestroyToken (cbNode->token);
OICFree(cbNode->devAddr);
OICFree(cbNode->handle);
- OC_LOG_V (INFO, TAG, "Deleting callback with uri %s", cbNode->requestUri);
+ OIC_LOG_V (INFO, TAG, "Deleting callback with uri %s", cbNode->requestUri);
OICFree(cbNode->requestUri);
if (cbNode->deleteCallback)
{
if (cbNode->TTL < now)
{
- OC_LOG(INFO, TAG, "Deleting timed-out callback");
+ OIC_LOG(INFO, TAG, "Deleting timed-out callback");
DeleteClientCB(cbNode);
}
}
if (token && *token && tokenLength <= CA_MAX_TOKEN_LEN && tokenLength > 0)
{
- OC_LOG (INFO, TAG, "Looking for token");
- OC_LOG_BUFFER(INFO, TAG, (const uint8_t *)token, tokenLength);
- OC_LOG(INFO, TAG, "\tFound in callback list");
+ OIC_LOG (INFO, TAG, "Looking for token");
+ OIC_LOG_BUFFER(INFO, TAG, (const uint8_t *)token, tokenLength);
+ OIC_LOG(INFO, TAG, "\tFound in callback list");
LL_FOREACH(cbList, out)
{
- OC_LOG_BUFFER(INFO, TAG, (const uint8_t *)out->token, tokenLength);
+ OIC_LOG_BUFFER(INFO, TAG, (const uint8_t *)out->token, tokenLength);
if (memcmp(out->token, token, tokenLength) == 0)
{
}
else if (requestUri)
{
- OC_LOG_V(INFO, TAG, "Looking for uri %s", requestUri);
+ OIC_LOG_V(INFO, TAG, "Looking for uri %s", requestUri);
LL_FOREACH(cbList, out)
{
- OC_LOG_V(INFO, TAG, "\tFound %s", out->requestUri);
+ OIC_LOG_V(INFO, TAG, "\tFound %s", out->requestUri);
if (out->requestUri && strcmp(out->requestUri, requestUri ) == 0)
{
return out;
CheckAndDeleteTimedOutCB(out);
}
}
- OC_LOG(INFO, TAG, "Callback Not found !!");
+ OIC_LOG(INFO, TAG, "Callback Not found !!");
return NULL;
}
}
}
}
- OC_LOG(INFO, TAG, "MulticastNode Not found !!");
+ OIC_LOG(INFO, TAG, "MulticastNode Not found !!");
return NULL;
}
//TODO: Query and URL validation is being done for virtual resource case
// using ValidateUrlQuery function. We should be able to merge it with this
// function.
- OC_LOG(INFO, TAG, "Entering ValidateQuery");
+ OIC_LOG(INFO, TAG, "Entering ValidateQuery");
if (!query)
{
if (!(*query))
{
// Query string is empty
- OC_LOG(INFO, TAG, "Empty query string, use default IF and RT");
+ OIC_LOG(INFO, TAG, "Empty query string, use default IF and RT");
*ifParam = STACK_IF_DEFAULT;
*rtParam = (char *) OCGetResourceTypeName (resource, 0);
return OC_STACK_OK;
// RT not specified in query. Use the first resource type for the resource as default.
*rtParam = (char *) OCGetResourceTypeName (resource, 0);
}
- OC_LOG_V(INFO, TAG, "Query params: IF = %d, RT = %s", *ifParam, *rtParam);
+ OIC_LOG_V(INFO, TAG, "Query params: IF = %d, RT = %s", *ifParam, *rtParam);
return OC_STACK_OK;
}
// as slow response
if (ehResult == OC_EH_SLOW)
{
- OC_LOG(INFO, TAG, "This is a slow resource");
+ OIC_LOG(INFO, TAG, "This is a slow resource");
((OCServerRequest *)ehRequest->requestHandle)->slowFlag = 1;
stackRet = EntityHandlerCodeToOCStackCode(ehResult);
}
return OC_STACK_INVALID_PARAM;
}
- OC_LOG_V(INFO, TAG, "DefaultCollectionEntityHandler with query %s", ehRequest->query);
+ OIC_LOG_V(INFO, TAG, "DefaultCollectionEntityHandler with query %s", ehRequest->query);
if (flag != OC_REQUEST_FLAG)
{
// Get attributes of collection resource and properties of contained resources
// M1 release does not support attributes for collection resource, so the GET
// operation is same as the GET on LL interface.
- OC_LOG(INFO, TAG, "STACK_IF_DEFAULT");
+ OIC_LOG(INFO, TAG, "STACK_IF_DEFAULT");
return HandleLinkedListInterface(ehRequest, STACK_RES_DISCOVERY_NOFILTER, NULL);
case STACK_IF_LL:
- OC_LOG(INFO, TAG, "STACK_IF_LL");
+ OIC_LOG(INFO, TAG, "STACK_IF_LL");
return HandleLinkedListInterface(ehRequest, STACK_RES_DISCOVERY_NOFILTER, NULL);
case STACK_IF_BATCH:
- OC_LOG(INFO, TAG, "STACK_IF_BATCH");
+ OIC_LOG(INFO, TAG, "STACK_IF_BATCH");
((OCServerRequest *)ehRequest->requestHandle)->ehResponseHandler =
HandleAggregateResponse;
return HandleBatchInterface(ehRequest);
case STACK_IF_GROUP:
- OC_LOG(INFO, TAG, "IF_COLLECTION PUT with request ::\n");
- OC_LOG_PAYLOAD(INFO, ehRequest->payload);
+ OIC_LOG(INFO, TAG, "IF_COLLECTION PUT with request ::\n");
+ OIC_LOG_PAYLOAD(INFO, ehRequest->payload);
return BuildCollectionGroupActionCBORResponse(OC_REST_PUT/*flag*/,
(OCResource *) ehRequest->resource, ehRequest);
return HandleBatchInterface(ehRequest);
case STACK_IF_GROUP:
- OC_LOG(INFO, TAG, "IF_COLLECTION POST with request ::\n");
- OC_LOG_PAYLOAD(INFO, ehRequest->payload);
+ OIC_LOG(INFO, TAG, "IF_COLLECTION POST with request ::\n");
+ OIC_LOG_PAYLOAD(INFO, ehRequest->payload);
return BuildCollectionGroupActionCBORResponse(OC_REST_POST/*flag*/,
(OCResource *) ehRequest->resource, ehRequest);
#define TAG "OIC_RI_OBSERVE"
-#define VERIFY_NON_NULL(arg) { if (!arg) {OC_LOG(FATAL, TAG, #arg " is NULL"); goto exit;} }
+#define VERIFY_NON_NULL(arg) { if (!arg) {OIC_LOG(FATAL, TAG, #arg " is NULL"); goto exit;} }
static struct ResourceObserver * g_serverObsList = NULL;
/**
{
if (!resourceObserver)
{
- OC_LOG(ERROR, TAG, "DetermineObserverQoS called with invalid resourceObserver");
+ OIC_LOG(ERROR, TAG, "DetermineObserverQoS called with invalid resourceObserver");
return OC_NA_QOS;
}
if (appQoS != OC_HIGH_QOS)
{
- OC_LOG_V(INFO, TAG, "Current NON count for this observer is %d",
+ OIC_LOG_V(INFO, TAG, "Current NON count for this observer is %d",
resourceObserver->lowQosCount);
#ifdef WITH_PRESENCE
if ((resourceObserver->forceHighQos \
resourceObserver->lowQosCount = 0;
// at some point we have to to send CON to check on the
// availability of observer
- OC_LOG(INFO, TAG, "This time we are sending the notification as High qos");
+ OIC_LOG(INFO, TAG, "This time we are sending the notification as High qos");
decidedQoS = OC_HIGH_QOS;
}
else
OCQualityOfService qos)
#endif
{
- OC_LOG(INFO, TAG, "Entering SendObserverNotification");
+ OIC_LOG(INFO, TAG, "Entering SendObserverNotification");
if (!resPtr)
{
return OC_STACK_INVALID_PARAM;
OCEntityHandlerResponse ehResponse = {0};
//This is effectively the implementation for the presence entity handler.
- OC_LOG(DEBUG, TAG, "This notification is for Presence");
+ OIC_LOG(DEBUG, TAG, "This notification is for Presence");
result = AddServerRequest(&request, 0, 0, 1, OC_REST_GET,
0, resPtr->sequenceNum, qos, resourceObserver->query,
NULL, NULL,
if (numObs == 0)
{
- OC_LOG(INFO, TAG, "Resource has no observers");
+ OIC_LOG(INFO, TAG, "Resource has no observers");
result = OC_STACK_NO_OBSERVERS;
}
else if (observeErrorFlag)
{
- OC_LOG(ERROR, TAG, "Observer notification error");
+ OIC_LOG(ERROR, TAG, "Observer notification error");
result = OC_STACK_ERROR;
}
return result;
OCStackResult result = OC_STACK_ERROR;
bool observeErrorFlag = false;
- OC_LOG(INFO, TAG, "Entering SendListObserverNotification");
+ OIC_LOG(INFO, TAG, "Entering SendListObserverNotification");
while(numIds)
{
observer = GetObserverUsingId (*obsIdList);
result = OCDoResponse(&ehResponse);
if (result == OC_STACK_OK)
{
- OC_LOG_V(INFO, TAG, "Observer id %d notified.", *obsIdList);
+ OIC_LOG_V(INFO, TAG, "Observer id %d notified.", *obsIdList);
// Increment only if OCDoResponse is successful
numSentNotification++;
}
else
{
- OC_LOG_V(INFO, TAG, "Error notifying observer id %d.", *obsIdList);
+ OIC_LOG_V(INFO, TAG, "Error notifying observer id %d.", *obsIdList);
}
}
else
}
else
{
- OC_LOG(ERROR, TAG, "Observer notification error");
+ OIC_LOG(ERROR, TAG, "Observer notification error");
return OC_STACK_ERROR;
}
}
{
ResourceObserver *resObs = NULL;
- OC_LOG(INFO, TAG, "Entering GenerateObserverId");
+ OIC_LOG(INFO, TAG, "Entering GenerateObserverId");
VERIFY_NON_NULL (observationId);
do
resObs = GetObserverUsingId (*observationId);
} while (NULL != resObs);
- OC_LOG_V(INFO, TAG, "GeneratedObservation ID is %u", *observationId);
+ OIC_LOG_V(INFO, TAG, "GeneratedObservation ID is %u", *observationId);
return OC_STACK_OK;
exit:
}
}
}
- OC_LOG(INFO, TAG, "Observer node not found!!");
+ OIC_LOG(INFO, TAG, "Observer node not found!!");
return NULL;
}
if (token && *token)
{
- OC_LOG(INFO, TAG, "Looking for token");
- OC_LOG_BUFFER(INFO, TAG, (const uint8_t *)token, tokenLength);
- OC_LOG(INFO, TAG, "\tFound token:");
+ OIC_LOG(INFO, TAG, "Looking for token");
+ OIC_LOG_BUFFER(INFO, TAG, (const uint8_t *)token, tokenLength);
+ OIC_LOG(INFO, TAG, "\tFound token:");
LL_FOREACH (g_serverObsList, out)
{
- OC_LOG_BUFFER(INFO, TAG, (const uint8_t *)out->token, tokenLength);
+ OIC_LOG_BUFFER(INFO, TAG, (const uint8_t *)out->token, tokenLength);
if ((memcmp(out->token, token, tokenLength) == 0))
{
return out;
}
else
{
- OC_LOG(ERROR, TAG, "Passed in NULL token");
+ OIC_LOG(ERROR, TAG, "Passed in NULL token");
}
- OC_LOG(INFO, TAG, "Observer node not found!!");
+ OIC_LOG(INFO, TAG, "Observer node not found!!");
return NULL;
}
ResourceObserver *obsNode = GetObserverUsingToken (token, tokenLength);
if (obsNode)
{
- OC_LOG_V(INFO, TAG, "deleting observer id %u with token", obsNode->observeId);
- OC_LOG_BUFFER(INFO, TAG, (const uint8_t *)obsNode->token, tokenLength);
+ OIC_LOG_V(INFO, TAG, "deleting observer id %u with token", obsNode->observeId);
+ OIC_LOG_BUFFER(INFO, TAG, (const uint8_t *)obsNode->token, tokenLength);
LL_DELETE (g_serverObsList, obsNode);
OICFree(obsNode->resUri);
OICFree(obsNode->query);
if (numOptions > 0 && !ocHdrOpt)
{
- OC_LOG (INFO, TAG, "options are NULL though number is non zero");
+ OIC_LOG (INFO, TAG, "options are NULL though number is non zero");
return OC_STACK_INVALID_PARAM;
}
if (!options || !numOptions)
{
- OC_LOG (INFO, TAG, "No options present");
+ OIC_LOG (INFO, TAG, "No options present");
return OC_STACK_OK;
}
OCRDPayloadDestroy((OCRDPayload*)payload);
break;
default:
- OC_LOG_V(ERROR, TAG, "Unsupported payload type in destroy: %d", payload->type);
+ OIC_LOG_V(ERROR, TAG, "Unsupported payload type in destroy: %d", payload->type);
OICFree(payload);
break;
}
}
break;
default:
- OC_LOG(ERROR, TAG, "CopyPropertyValueArray invalid type");
+ OIC_LOG(ERROR, TAG, "CopyPropertyValueArray invalid type");
break;
}
}
break;
case OCREP_PROP_NULL:
case OCREP_PROP_ARRAY:
- OC_LOG_V(ERROR, TAG, "FreeRepPayloadValueContents: Illegal type\
+ OIC_LOG_V(ERROR, TAG, "FreeRepPayloadValueContents: Illegal type\
inside an array: %d", val->arr.type);
break;
}
val = val->next;
}
- OC_LOG(ERROR, TAG, "FindAndSetValue reached point after while loop, pointer corruption?");
+ OIC_LOG(ERROR, TAG, "FindAndSetValue reached point after while loop, pointer corruption?");
return NULL;
}
#undef CborNeedsUpdating
if (!payload)
{
- OC_LOG(ERROR, TAG, "Payload parameter NULL");
+ OIC_LOG(ERROR, TAG, "Payload parameter NULL");
return OC_STACK_INVALID_PARAM;
}
if (!outPayload || !size)
{
- OC_LOG(ERROR, TAG, "Out parameter/s parameter NULL");
+ OIC_LOG(ERROR, TAG, "Out parameter/s parameter NULL");
return OC_STACK_INVALID_PARAM;
}
- OC_LOG_V(INFO, TAG, "Converting payload of type %d", payload->type);
+ OIC_LOG_V(INFO, TAG, "Converting payload of type %d", payload->type);
size_t curSize = INIT_SIZE;
uint8_t* out = (uint8_t*)OICCalloc(1, curSize);
case PAYLOAD_TYPE_RD:
return OCRDPayloadToCbor((OCRDPayload*)payload, outPayload, size);
default:
- OC_LOG_V(INFO,TAG, "ConvertPayload default %d", payload->type);
+ OIC_LOG_V(INFO,TAG, "ConvertPayload default %d", payload->type);
return OC_STACK_NOTIMPL;
}
}
}
else if (err != 0)
{
- OC_LOG_V(ERROR, TAG, "Convert Payload failed : %zd", err);
+ OIC_LOG_V(ERROR, TAG, "Convert Payload failed : %zd", err);
return err;
}
else
switch (valArray->type)
{
case OCREP_PROP_NULL:
- OC_LOG(ERROR, TAG, "ConvertArray Invalid NULL");
+ OIC_LOG(ERROR, TAG, "ConvertArray Invalid NULL");
err = CborUnknownError;
break;
case OCREP_PROP_INT:
}
break;
case OCREP_PROP_ARRAY:
- OC_LOG(ERROR, TAG, "ConvertArray Invalid child array");
+ OIC_LOG(ERROR, TAG, "ConvertArray Invalid child array");
err = CborUnknownError;
break;
}
err = err | OCConvertArray(repMap, &value->arr);
break;
default:
- OC_LOG_V(ERROR, TAG, "Invalid Prop type: %d",
+ OIC_LOG_V(ERROR, TAG, "Invalid Prop type: %d",
value->type);
break;
}
if (payload->types)
{
- OC_LOG(INFO, TAG, "Payload has types or interfaces");
+ OIC_LOG(INFO, TAG, "Payload has types or interfaces");
char* joinedTypes = OCStringLLJoin(payload->types);
if (joinedTypes)
{
CborValue rootValue;
bool err = false;
- OC_LOG_V(INFO, TAG, "CBOR Parsing size: %zu", payloadSize);
+ OIC_LOG_V(INFO, TAG, "CBOR Parsing size: %zu", payloadSize);
if((err = cbor_parser_init(payload, payloadSize, 0, &parser, &rootValue)) != false)
{
- OC_LOG_V(ERROR, TAG, "CBOR Parser init failed: %d", err);
+ OIC_LOG_V(ERROR, TAG, "CBOR Parser init failed: %d", err);
return OC_STACK_ERROR;
}
result = OCRDCborToPayload(&rootValue, outPayload);
break;
default:
- OC_LOG_V(ERROR, TAG, "ParsePayload Type default: %d", payloadType);
+ OIC_LOG_V(ERROR, TAG, "ParsePayload Type default: %d", payloadType);
result = OC_STACK_ERROR;
break;
}
if(result != OC_STACK_OK)
{
- OC_LOG_V(INFO, TAG, "Finished parse payload, result is %d", result);
+ OIC_LOG_V(INFO, TAG, "Finished parse payload, result is %d", result);
}
return result;
if(err)
{
- OC_LOG(ERROR, TAG, "Cbor in error condition");
+ OIC_LOG(ERROR, TAG, "Cbor in error condition");
OICFree(securityData);
return OC_STACK_MALFORMED_RESPONSE;
}
err = cbor_value_map_find_value(&rootMap, OC_RSRVD_DEVICE_ID, &curVal);
if (CborNoError != err)
{
- OC_LOG(ERROR, TAG, "Cbor find value failed.");
+ OIC_LOG(ERROR, TAG, "Cbor find value failed.");
goto malformed_cbor;
}
size_t len;
err = cbor_value_dup_text_string(&curVal, &(out->baseURI), &len, NULL);
if (CborNoError != err)
{
- OC_LOG(ERROR, TAG, "baseURI failed.");
+ OIC_LOG(ERROR, TAG, "baseURI failed.");
goto malformed_cbor;
}
}
err = cbor_value_map_find_value(&rootMap, OC_RSRVD_LINKS, &curVal);
if (CborNoError != err)
{
- OC_LOG(ERROR, TAG, "Cbor find value failed.");
+ OIC_LOG(ERROR, TAG, "Cbor find value failed.");
goto malformed_cbor;
}
resource = (OCResourcePayload*)OICCalloc(1, sizeof(OCResourcePayload));
if(!resource)
{
- OC_LOG(ERROR, TAG, "Memory allocation failed");
+ OIC_LOG(ERROR, TAG, "Memory allocation failed");
OCDiscoveryPayloadDestroy(out);
return OC_STACK_NO_MEMORY;
}
err = cbor_value_map_find_value(&resourceMap, OC_RSRVD_HREF, &uriVal);
if (CborNoError != err)
{
- OC_LOG(ERROR, TAG, "Cbor finding href type failed.");
+ OIC_LOG(ERROR, TAG, "Cbor finding href type failed.");
goto malformed_cbor;
}
err = cbor_value_dup_text_string(&uriVal, &(resource->uri), &len, NULL);
if (CborNoError != err)
{
- OC_LOG(ERROR, TAG, "Cbor finding href value failed.");
+ OIC_LOG(ERROR, TAG, "Cbor finding href value failed.");
goto malformed_cbor;
}
// ResourceTypes
err = cbor_value_map_find_value(&resourceMap, OC_RSRVD_RESOURCE_TYPE, &rtVal);
if (CborNoError != err)
{
- OC_LOG(ERROR, TAG, "Cbor finding rt type failed.");
+ OIC_LOG(ERROR, TAG, "Cbor finding rt type failed.");
goto malformed_cbor;
}
if (cbor_value_is_text_string(&rtVal))
err = cbor_value_dup_text_string(&rtVal, &input, &len, NULL);
if (CborNoError != err)
{
- OC_LOG(ERROR, TAG, "Cbor finding rt value failed.");
+ OIC_LOG(ERROR, TAG, "Cbor finding rt value failed.");
goto malformed_cbor;
}
if (input)
err = cbor_value_map_find_value(&resourceMap, OC_RSRVD_INTERFACE, &ifVal);
if (CborNoError != err)
{
- OC_LOG(ERROR, TAG, "Cbor finding if type failed.");
+ OIC_LOG(ERROR, TAG, "Cbor finding if type failed.");
goto malformed_cbor;
}
if (!err && cbor_value_is_text_string(&ifVal))
err = cbor_value_dup_text_string(&ifVal, &input, &len, NULL);
if (CborNoError != err)
{
- OC_LOG(ERROR, TAG, "Cbor finding if value failed.");
+ OIC_LOG(ERROR, TAG, "Cbor finding if value failed.");
goto malformed_cbor;
}
if (input)
err = cbor_value_map_find_value(&resourceMap, OC_RSRVD_POLICY, &policyMap);
if (CborNoError != err)
{
- OC_LOG(ERROR, TAG, "Cbor finding policy type failed.");
+ OIC_LOG(ERROR, TAG, "Cbor finding policy type failed.");
goto malformed_cbor;
}
// Bitmap
err = cbor_value_map_find_value(&policyMap, OC_RSRVD_BITMAP, &val);
if (CborNoError != err)
{
- OC_LOG(ERROR, TAG, "Cbor finding bitmap type failed.");
+ OIC_LOG(ERROR, TAG, "Cbor finding bitmap type failed.");
goto malformed_cbor;
}
uint64_t temp = 0;
err = cbor_value_get_uint64(&val, &temp);
if (CborNoError != err)
{
- OC_LOG(ERROR, TAG, "Cbor finding bitmap value failed.");
+ OIC_LOG(ERROR, TAG, "Cbor finding bitmap value failed.");
goto malformed_cbor;
}
resource->bitmap = (uint8_t)temp;
err = cbor_value_map_find_value(&policyMap, OC_RSRVD_SECURE, &val);
if (CborNoError != err)
{
- OC_LOG(ERROR, TAG, "Cbor finding secure type failed.");
+ OIC_LOG(ERROR, TAG, "Cbor finding secure type failed.");
goto malformed_cbor;
}
if(cbor_value_is_valid(&val))
err = cbor_value_get_boolean(&val, &(resource->secure));
if (CborNoError != err)
{
- OC_LOG(ERROR, TAG, "Cbor finding secure value failed.");
+ OIC_LOG(ERROR, TAG, "Cbor finding secure value failed.");
goto malformed_cbor;
}
// Port
&port);
if (CborNoError != err)
{
- OC_LOG(ERROR, TAG, "Cbor finding port type failed.");
+ OIC_LOG(ERROR, TAG, "Cbor finding port type failed.");
goto malformed_cbor;
}
if (cbor_value_is_valid(&port))
err = cbor_value_get_uint64(&port, &temp);
if (CborNoError != err)
{
- OC_LOG(ERROR, TAG, "Cbor finding port value failed.");
+ OIC_LOG(ERROR, TAG, "Cbor finding port value failed.");
goto malformed_cbor;
}
resource->port = (uint16_t)temp;
err = cbor_value_map_find_value(&policyMap, OC_RSRVD_HOSTING_PORT, &port);
if (CborNoError != err)
{
- OC_LOG(ERROR, TAG, "Cbor finding port type failed.");
+ OIC_LOG(ERROR, TAG, "Cbor finding port type failed.");
goto malformed_cbor;
}
if(cbor_value_is_valid(&port))
err = cbor_value_get_uint64(&port, &temp);
if (CborNoError != err)
{
- OC_LOG(ERROR, TAG, "Cbor finding port value failed.");
+ OIC_LOG(ERROR, TAG, "Cbor finding port value failed.");
goto malformed_cbor;
}
resource->port = (uint16_t)temp;
err = cbor_value_advance(&resourceMap);
if (CborNoError != err)
{
- OC_LOG(ERROR, TAG, "Cbor advance value failed.");
+ OIC_LOG(ERROR, TAG, "Cbor advance value failed.");
goto malformed_cbor;
}
++resourceCount;
OICFree(dname);
OICFree(specVer);
OICFree(dmVer);
- OC_LOG_V(ERROR, TAG, "CBOR in error condition %d", err);
+ OIC_LOG_V(ERROR, TAG, "CBOR in error condition %d", err);
return OC_STACK_MALFORMED_RESPONSE;
}
}
else
{
- OC_LOG(ERROR, TAG, "Root device node was not a map");
+ OIC_LOG(ERROR, TAG, "Root device node was not a map");
return OC_STACK_MALFORMED_RESPONSE;
}
OICFree(info.platformVersion);
OICFree(info.supportUrl);
OICFree(info.systemTime);
- OC_LOG(ERROR, TAG, "CBOR error In ParsePlatformPayload");
+ OIC_LOG(ERROR, TAG, "CBOR error In ParsePlatformPayload");
return OC_STACK_MALFORMED_RESPONSE;
}
}
else
{
- OC_LOG(ERROR, TAG, "Root device node was not a map");
+ OIC_LOG(ERROR, TAG, "Root device node was not a map");
return OC_STACK_MALFORMED_RESPONSE;
}
}
if (subdim[2] != 0)
{
- OC_LOG(ERROR, TAG, "Parse array helper, sub-array too deep");
+ OIC_LOG(ERROR, TAG, "Parse array helper, sub-array too deep");
}
dimensions[1] = dimensions[1] >= subdim[0] ? dimensions[1] : subdim[0];
if (*type != OCREP_PROP_NULL && tempType != OCREP_PROP_NULL
&& *type != tempType)
{
- OC_LOG(ERROR, TAG, "Array parse failed, mixed arrays not allowed (subtype)");
+ OIC_LOG(ERROR, TAG, "Array parse failed, mixed arrays not allowed (subtype)");
return true;
}
else if (*type == OCREP_PROP_NULL)
else if (tempType != OCREP_PROP_NULL && *type != tempType)
{
// this is an invalid situation!
- OC_LOG(ERROR, TAG, "Array parse failed, mixed arrays not allowed");
+ OIC_LOG(ERROR, TAG, "Array parse failed, mixed arrays not allowed");
return true;
}
}
break;
default:
- OC_LOG(ERROR, TAG, "Invalid Array type in Parse Array");
+ OIC_LOG(ERROR, TAG, "Invalid Array type in Parse Array");
err = true;
break;
}
if (err)
{
- OC_LOG(ERROR, TAG, "Array details weren't clear");
+ OIC_LOG(ERROR, TAG, "Array details weren't clear");
return err;
}
if (!arr)
{
- OC_LOG(ERROR, TAG, "Array Parse allocation failed");
+ OIC_LOG(ERROR, TAG, "Array Parse allocation failed");
return true;
}
}
break;
default:
- OC_LOG(ERROR, TAG, "Invalid Array type in Parse Array");
+ OIC_LOG(ERROR, TAG, "Invalid Array type in Parse Array");
err = true;
break;
}
err = err || OCParseArray(curPayload, name, &repMap);
break;
default:
- OC_LOG_V(ERROR, TAG, "Parsing rep property, unknown type %d", repMap.type);
+ OIC_LOG_V(ERROR, TAG, "Parsing rep property, unknown type %d", repMap.type);
err = true;
}
if(err)
{
OCRepPayloadDestroy(rootPayload);
- OC_LOG(ERROR, TAG, "CBOR error in ParseRepPayload");
+ OIC_LOG(ERROR, TAG, "CBOR error in ParseRepPayload");
return OC_STACK_MALFORMED_RESPONSE;
}
}
if(err)
{
OCPayloadDestroy(*outPayload);
- OC_LOG(ERROR, TAG, "CBOR error Parse Presence Payload");
+ OIC_LOG(ERROR, TAG, "CBOR error Parse Presence Payload");
return OC_STACK_MALFORMED_RESPONSE;
}
}
else
{
- OC_LOG(ERROR, TAG, "Root presence node was not a map");
+ OIC_LOG(ERROR, TAG, "Root presence node was not a map");
return OC_STACK_MALFORMED_RESPONSE;
}
}
#define TAG "OIC_RI_RESOURCE"
#define VERIFY_SUCCESS(op, successCode) { if (op != successCode) \
- {OC_LOG_V(FATAL, TAG, "%s failed!!", #op); goto exit;} }
+ {OIC_LOG_V(FATAL, TAG, "%s failed!!", #op); goto exit;} }
-#define VERIFY_NON_NULL(arg, logLevel, retVal) { if (!(arg)) { OC_LOG((logLevel), \
+#define VERIFY_NON_NULL(arg, logLevel, retVal) { if (!(arg)) { OIC_LOG((logLevel), \
TAG, #arg " is NULL"); return (retVal); } }
extern OCResource *headResource;
*filterOne = NULL;
*filterTwo = NULL;
- OC_LOG_V(INFO, TAG, "Extracting params from %s", query);
+ OIC_LOG_V(INFO, TAG, "Extracting params from %s", query);
char *keyValuePair = strtok_r (query, OC_QUERY_SEPARATOR, &restOfQuery);
{
if (numKeyValuePairsParsed >= 2)
{
- OC_LOG(ERROR, TAG, "More than 2 queries params in URI.");
+ OIC_LOG(ERROR, TAG, "More than 2 queries params in URI.");
return OC_STACK_INVALID_QUERY;
}
}
else
{
- OC_LOG_V(ERROR, TAG, "Unsupported query key: %s", key);
+ OIC_LOG_V(ERROR, TAG, "Unsupported query key: %s", key);
return OC_STACK_INVALID_QUERY;
}
++numKeyValuePairsParsed;
keyValuePair = strtok_r(NULL, OC_QUERY_SEPARATOR, &restOfQuery);
}
- OC_LOG_V(INFO, TAG, "Extracted params %s and %s.", *filterOne, *filterTwo);
+ OIC_LOG_V(INFO, TAG, "Extracted params %s and %s.", *filterOne, *filterTwo);
return OC_STACK_OK;
}
if (uri == OC_PRESENCE)
{
//Nothing needs to be done, except for pass a OC_PRESENCE query through as OC_STACK_OK.
- OC_LOG(INFO, TAG, "OC_PRESENCE Request for virtual resource.");
+ OIC_LOG(INFO, TAG, "OC_PRESENCE Request for virtual resource.");
return OC_STACK_OK;
}
#endif
}
pointer = pointer->next;
}
- OC_LOG_V(INFO, TAG, "Resource %s not found", resourceUri);
+ OIC_LOG_V(INFO, TAG, "Resource %s not found", resourceUri);
return NULL;
}
return OC_STACK_INVALID_PARAM;
}
- OC_LOG_V(INFO, TAG, "DetermineResourceHandling for %s", request->resourceUrl);
+ OIC_LOG_V(INFO, TAG, "DetermineResourceHandling for %s", request->resourceUrl);
// Check if virtual resource
if (GetTypeOfVirtualURI(request->resourceUrl) != OC_UNKNOWN_URI)
{
- OC_LOG_V (INFO, TAG, "%s is virtual", request->resourceUrl);
+ OIC_LOG_V (INFO, TAG, "%s is virtual", request->resourceUrl);
*handling = OC_RESOURCE_VIRTUAL;
*resource = headResource;
return OC_STACK_OK;
resourceTypePtr = resourceTypePtr->next;
}
- OC_LOG_V(INFO, TAG, "%s does not contain rt=%s.", resource->uri, resourceTypeFilter);
+ OIC_LOG_V(INFO, TAG, "%s does not contain rt=%s.", resource->uri, resourceTypeFilter);
return false;
}
interfacePtr = interfacePtr->next;
}
- OC_LOG_V(INFO, TAG, "%s does not contain if=%s.", resource->uri, interfaceFilter);
+ OIC_LOG_V(INFO, TAG, "%s does not contain if=%s.", resource->uri, interfaceFilter);
return false;
}
{
if (!resource)
{
- OC_LOG(ERROR, TAG, "Invalid resource");
+ OIC_LOG(ERROR, TAG, "Invalid resource");
return false;
}
if (!((interfaceFilter && *interfaceFilter ) ||
(resourceTypeFilter && *resourceTypeFilter)))
{
- OC_LOG_V(INFO, TAG, "%s no query string for EXPLICIT_DISCOVERABLE \
+ OIC_LOG_V(INFO, TAG, "%s no query string for EXPLICIT_DISCOVERABLE \
resource", resource->uri);
return false;
}
else if ( !(resource->resourceProperties & OC_ACTIVE) ||
!(resource->resourceProperties & OC_DISCOVERABLE))
{
- OC_LOG_V(INFO, TAG, "%s not ACTIVE or DISCOVERABLE", resource->uri);
+ OIC_LOG_V(INFO, TAG, "%s not ACTIVE or DISCOVERABLE", resource->uri);
return false;
}
}
else
{
- OC_LOG_V(ERROR, TAG, "The resource type or interface type doe not exist \
+ OIC_LOG_V(ERROR, TAG, "The resource type or interface type doe not exist \
on the resource directory");
}
return OC_STACK_ERROR;
bool bMulticast = false; // Was the discovery request a multicast request?
OCPayload* payload = NULL;
- OC_LOG(INFO, TAG, "Entering HandleVirtualResource");
+ OIC_LOG(INFO, TAG, "Entering HandleVirtualResource");
OCVirtualResources virtualUriInRequest = GetTypeOfVirtualURI (request->resourceUrl);
}
else
{
- OC_LOG_V(ERROR, TAG, "Error (%d) parsing query.", discoveryResult);
+ OIC_LOG_V(ERROR, TAG, "Error (%d) parsing query.", discoveryResult);
}
}
else if (virtualUriInRequest == OC_DEVICE_URI)
else if (OC_GATEWAY_URI == virtualUriInRequest)
{
// Received request for a gateway
- OC_LOG(INFO, TAG, "Request is for Gateway Virtual Request");
+ OIC_LOG(INFO, TAG, "Request is for Gateway Virtual Request");
discoveryResult = RMHandleGatewayRequest(request, resource);
}
else if(bMulticast == false && (request->devAddr.adapter != OC_ADAPTER_RFCOMM_BTEDR) &&
(request->devAddr.adapter != OC_ADAPTER_GATT_BTLE))
{
- OC_LOG_V(ERROR, TAG, "Sending a (%d) error to (%d) \
+ OIC_LOG_V(ERROR, TAG, "Sending a (%d) error to (%d) \
discovery request", discoveryResult, virtualUriInRequest);
SendNonPersistantDiscoveryResponse(request, resource, NULL,
(discoveryResult == OC_STACK_NO_RESOURCE) ? OC_EH_RESOURCE_NOT_FOUND : OC_EH_ERROR);
else
{
// Ignoring the discovery request as per RFC 7252, Section #8.2
- OC_LOG(INFO, TAG, "Silently ignoring the request since device does not have \
+ OIC_LOG(INFO, TAG, "Silently ignoring the request since device does not have \
any useful data to send");
}
}
OCEntityHandlerResult ehResult = OC_EH_ERROR;
OCEntityHandlerRequest ehRequest = {0};
- OC_LOG(INFO, TAG, "Entering HandleResourceWithDefaultDeviceEntityHandler");
+ OIC_LOG(INFO, TAG, "Entering HandleResourceWithDefaultDeviceEntityHandler");
result = FormOCEntityHandlerRequest(&ehRequest,
(OCRequestHandle) request,
request->method,
(char*) request->resourceUrl, defaultDeviceHandlerCallbackParameter);
if(ehResult == OC_EH_SLOW)
{
- OC_LOG(INFO, TAG, "This is a slow resource");
+ OIC_LOG(INFO, TAG, "This is a slow resource");
request->slowFlag = 1;
}
else if(ehResult == OC_EH_ERROR)
OCEntityHandlerRequest ehRequest = {0};
- OC_LOG(INFO, TAG, "Entering HandleResourceWithEntityHandler");
+ OIC_LOG(INFO, TAG, "Entering HandleResourceWithEntityHandler");
OCPayloadType type = PAYLOAD_TYPE_REPRESENTATION;
// check the security resource
if (request && request->resourceUrl && SRMIsSecurityResourceURI(request->resourceUrl))
if(ehRequest.obsInfo.action == OC_OBSERVE_NO_OPTION)
{
- OC_LOG(INFO, TAG, "No observation requested");
+ OIC_LOG(INFO, TAG, "No observation requested");
ehFlag = OC_REQUEST_FLAG;
}
else if(ehRequest.obsInfo.action == OC_OBSERVE_REGISTER && !collectionResource)
{
- OC_LOG(INFO, TAG, "Observation registration requested");
+ OIC_LOG(INFO, TAG, "Observation registration requested");
ResourceObserver *obs = GetObserverUsingToken (request->requestToken,
request->tokenLength);
if (obs)
{
- OC_LOG (INFO, TAG, "Observer with this token already present");
- OC_LOG (INFO, TAG, "Possibly re-transmitted CON OBS request");
- OC_LOG (INFO, TAG, "Not adding observer. Not responding to client");
- OC_LOG (INFO, TAG, "The first request for this token is already ACKED.");
+ OIC_LOG (INFO, TAG, "Observer with this token already present");
+ OIC_LOG (INFO, TAG, "Possibly re-transmitted CON OBS request");
+ OIC_LOG (INFO, TAG, "Not adding observer. Not responding to client");
+ OIC_LOG (INFO, TAG, "The first request for this token is already ACKED.");
// server requests are usually free'd when the response is sent out
// for the request in ocserverrequest.c : HandleSingleResponse()
if(result == OC_STACK_OK)
{
- OC_LOG(INFO, TAG, "Added observer successfully");
+ OIC_LOG(INFO, TAG, "Added observer successfully");
request->observeResult = OC_STACK_OK;
ehFlag = (OCEntityHandlerFlag)(OC_REQUEST_FLAG | OC_OBSERVE_FLAG);
}
// The error in observeResult for the request will be used when responding to this
// request by omitting the observation option/sequence number.
request->observeResult = OC_STACK_ERROR;
- OC_LOG(ERROR, TAG, "Observer Addition failed");
+ OIC_LOG(ERROR, TAG, "Observer Addition failed");
ehFlag = OC_REQUEST_FLAG;
}
else if(ehRequest.obsInfo.action == OC_OBSERVE_DEREGISTER &&
!collectionResource)
{
- OC_LOG(INFO, TAG, "Deregistering observation requested");
+ OIC_LOG(INFO, TAG, "Deregistering observation requested");
resObs = GetObserverUsingToken (request->requestToken, request->tokenLength);
if(result == OC_STACK_OK)
{
- OC_LOG(INFO, TAG, "Removed observer successfully");
+ OIC_LOG(INFO, TAG, "Removed observer successfully");
request->observeResult = OC_STACK_OK;
}
else
{
result = OC_STACK_OK;
request->observeResult = OC_STACK_ERROR;
- OC_LOG(ERROR, TAG, "Observer Removal failed");
+ OIC_LOG(ERROR, TAG, "Observer Removal failed");
}
}
else
ehResult = resource->entityHandler(ehFlag, &ehRequest, resource->entityHandlerCallbackParam);
if(ehResult == OC_EH_SLOW)
{
- OC_LOG(INFO, TAG, "This is a slow resource");
+ OIC_LOG(INFO, TAG, "This is a slow resource");
request->slowFlag = 1;
}
else if(ehResult == OC_EH_ERROR)
}
case OC_RESOURCE_NOT_COLLECTION_DEFAULT_ENTITYHANDLER:
{
- OC_LOG(INFO, TAG, "OC_RESOURCE_NOT_COLLECTION_DEFAULT_ENTITYHANDLER");
+ OIC_LOG(INFO, TAG, "OC_RESOURCE_NOT_COLLECTION_DEFAULT_ENTITYHANDLER");
return OC_STACK_ERROR;
}
case OC_RESOURCE_NOT_COLLECTION_WITH_ENTITYHANDLER:
}
default:
{
- OC_LOG(INFO, TAG, "Invalid Resource Determination");
+ OIC_LOG(INFO, TAG, "Invalid Resource Determination");
return OC_STACK_ERROR;
}
}
void DeletePlatformInfo()
{
- OC_LOG(INFO, TAG, "Deleting platform info.");
+ OIC_LOG(INFO, TAG, "Deleting platform info.");
OICFree(savedPlatformInfo.platformID);
savedPlatformInfo.platformID = NULL;
if (res != OC_STACK_OK)
{
- OC_LOG_V(ERROR, TAG, "Failed to save platform info. errno(%d)", res);
+ OIC_LOG_V(ERROR, TAG, "Failed to save platform info. errno(%d)", res);
}
else
{
- OC_LOG(INFO, TAG, "Platform info saved.");
+ OIC_LOG(INFO, TAG, "Platform info saved.");
}
return res;
void DeleteDeviceInfo()
{
- OC_LOG(INFO, TAG, "Deleting device info.");
+ OIC_LOG(INFO, TAG, "Deleting device info.");
OICFree(savedDeviceInfo.deviceName);
savedDeviceInfo.deviceName = NULL;
if(OCGetServerInstanceID() == NULL)
{
- OC_LOG(INFO, TAG, "Device ID generation failed");
+ OIC_LOG(INFO, TAG, "Device ID generation failed");
res = OC_STACK_ERROR;
goto exit;
}
- OC_LOG(INFO, TAG, "Device initialized successfully.");
+ OIC_LOG(INFO, TAG, "Device initialized successfully.");
return OC_STACK_OK;
exit:
#include "pdu.h"
// Module Name
-#define VERIFY_NON_NULL(arg) { if (!arg) {OC_LOG(FATAL, TAG, #arg " is NULL"); goto exit;} }
+#define VERIFY_NON_NULL(arg) { if (!arg) {OIC_LOG(FATAL, TAG, #arg " is NULL"); goto exit;} }
#define TAG "OIC_RI_SERVERREQUEST"
serverResponse->requestHandle = requestHandle;
*response = serverResponse;
- OC_LOG(INFO, TAG, "Server Response Added!!");
+ OIC_LOG(INFO, TAG, "Server Response Added!!");
LL_APPEND (serverResponseList, serverResponse);
return OC_STACK_OK;
OICFree(serverRequest->requestToken);
OICFree(serverRequest);
serverRequest = NULL;
- OC_LOG(INFO, TAG, "Server Request Removed!!");
+ OIC_LOG(INFO, TAG, "Server Request Removed!!");
}
}
LL_DELETE(serverResponseList, serverResponse);
OCPayloadDestroy(serverResponse->payload);
OICFree(serverResponse);
- OC_LOG(INFO, TAG, "Server Response Removed!!");
+ OIC_LOG(INFO, TAG, "Server Response Removed!!");
}
}
&(responseInfo->info.numOptions));
if(OC_STACK_OK != rmResult)
{
- OC_LOG(ERROR, TAG, "Add option failed");
+ OIC_LOG(ERROR, TAG, "Add option failed");
return rmResult;
}
#endif
CAResult_t result = CASendResponse(object, responseInfo);
if(CA_STATUS_OK != result)
{
- OC_LOG_V(ERROR, TAG, "CASendResponse failed with CA error %u", result);
+ OIC_LOG_V(ERROR, TAG, "CASendResponse failed with CA error %u", result);
return CAResultToOCResult(result);
}
return OC_STACK_OK;
{
if(!token)
{
- OC_LOG(ERROR, TAG, "Invalid Parameter Token");
+ OIC_LOG(ERROR, TAG, "Invalid Parameter Token");
return NULL;
}
OCServerRequest * out = NULL;
- OC_LOG(INFO, TAG,"Get server request with token");
- OC_LOG_BUFFER(INFO, TAG, (const uint8_t *)token, tokenLength);
+ OIC_LOG(INFO, TAG,"Get server request with token");
+ OIC_LOG_BUFFER(INFO, TAG, (const uint8_t *)token, tokenLength);
- OC_LOG(INFO, TAG,"Found token");
+ OIC_LOG(INFO, TAG,"Found token");
LL_FOREACH (serverRequestList, out)
{
- OC_LOG_BUFFER(INFO, TAG, (const uint8_t *)out->requestToken, tokenLength);
+ OIC_LOG_BUFFER(INFO, TAG, (const uint8_t *)out->requestToken, tokenLength);
if(memcmp(out->requestToken, token, tokenLength) == 0)
{
return out;
}
}
- OC_LOG(ERROR, TAG, "Server Request not found!!");
+ OIC_LOG(ERROR, TAG, "Server Request not found!!");
return NULL;
}
return out;
}
}
- OC_LOG(ERROR, TAG, "Server Request not found!!");
+ OIC_LOG(ERROR, TAG, "Server Request not found!!");
return NULL;
}
return out;
}
}
- OC_LOG(ERROR, TAG, "Server Response not found!!");
+ OIC_LOG(ERROR, TAG, "Server Response not found!!");
return NULL;
}
OCServerRequest * serverRequest = NULL;
- OC_LOG_V(INFO, TAG, "addserverrequest entry!! [%s:%u]", devAddr->addr, devAddr->port);
+ OIC_LOG_V(INFO, TAG, "addserverrequest entry!! [%s:%u]", devAddr->addr, devAddr->port);
serverRequest = (OCServerRequest *) OICCalloc(1, sizeof(OCServerRequest) +
(reqTotalSize ? reqTotalSize : 1) - 1);
serverRequest->devAddr = *devAddr;
*request = serverRequest;
- OC_LOG(INFO, TAG, "Server Request Added!!");
+ OIC_LOG(INFO, TAG, "Server Request Added!!");
LL_APPEND (serverRequestList, serverRequest);
return OC_STACK_OK;
// This should not happen but,
// give it a value just in case but output an error
caResult = CA_CONTENT;
- OC_LOG_V(ERROR, TAG, "Unexpected OC_EH_OK return code for method [%d].", method);
+ OIC_LOG_V(ERROR, TAG, "Unexpected OC_EH_OK return code for method [%d].", method);
}
break;
case OC_EH_ERROR:
}
else
{
- OC_LOG(ERROR, TAG, "default responseInfo type is NON");
+ OIC_LOG(ERROR, TAG, "default responseInfo type is NON");
responseInfo.info.type = CA_MSG_NONCONFIRM;
}
if(!responseInfo.info.options)
{
- OC_LOG(FATAL, TAG, "Memory alloc for options failed");
+ OIC_LOG(FATAL, TAG, "Memory alloc for options failed");
return OC_STACK_NO_MEMORY;
}
&responseInfo.info.payloadSize))
!= OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "Error converting payload");
+ OIC_LOG(ERROR, TAG, "Error converting payload");
OICFree(responseInfo.info.options);
return result;
}
}
#else
- OC_LOG(INFO, TAG, "Calling OCSendResponse with:");
- OC_LOG_V(INFO, TAG, "\tEndpoint address: %s", responseEndpoint.addr);
- OC_LOG_V(INFO, TAG, "\tEndpoint adapter: %s", responseEndpoint.adapter);
- OC_LOG_V(INFO, TAG, "\tResponse result : %s", responseInfo.result);
- OC_LOG_V(INFO, TAG, "\tResponse for uri: %s", responseInfo.info.resourceUri);
+ OIC_LOG(INFO, TAG, "Calling OCSendResponse with:");
+ OIC_LOG_V(INFO, TAG, "\tEndpoint address: %s", responseEndpoint.addr);
+ OIC_LOG_V(INFO, TAG, "\tEndpoint adapter: %s", responseEndpoint.adapter);
+ OIC_LOG_V(INFO, TAG, "\tResponse result : %s", responseInfo.result);
+ OIC_LOG_V(INFO, TAG, "\tResponse for uri: %s", responseInfo.info.resourceUri);
result = OCSendResponse(&responseEndpoint, &responseInfo);
#endif
{
if(!ehResponse || !ehResponse->payload)
{
- OC_LOG(ERROR, TAG, "HandleAggregateResponse invalid parameters");
+ OIC_LOG(ERROR, TAG, "HandleAggregateResponse invalid parameters");
return OC_STACK_INVALID_PARAM;
}
- OC_LOG(INFO, TAG, "Inside HandleAggregateResponse");
+ OIC_LOG(INFO, TAG, "Inside HandleAggregateResponse");
OCServerRequest *serverRequest = GetServerRequestUsingHandle((OCServerRequest *)
ehResponse->requestHandle);
{
if(!serverResponse)
{
- OC_LOG(INFO, TAG, "This is the first response fragment");
+ OIC_LOG(INFO, TAG, "This is the first response fragment");
stackRet = AddServerResponse(&serverResponse, ehResponse->requestHandle);
if (OC_STACK_OK != stackRet)
{
- OC_LOG(ERROR, TAG, "Error adding server response");
+ OIC_LOG(ERROR, TAG, "Error adding server response");
return stackRet;
}
VERIFY_NON_NULL(serverResponse);
if(ehResponse->payload->type != PAYLOAD_TYPE_REPRESENTATION)
{
stackRet = OC_STACK_ERROR;
- OC_LOG(ERROR, TAG, "Error adding payload, as it was the incorrect type");
+ OIC_LOG(ERROR, TAG, "Error adding payload, as it was the incorrect type");
goto exit;
}
if(serverRequest->numResponses == 0)
{
- OC_LOG(INFO, TAG, "This is the last response fragment");
+ OIC_LOG(INFO, TAG, "This is the last response fragment");
ehResponse->payload = serverResponse->payload;
stackRet = HandleSingleResponse(ehResponse);
//Delete the request and response
}
else
{
- OC_LOG(INFO, TAG, "More response fragments to come");
+ OIC_LOG(INFO, TAG, "More response fragments to come");
stackRet = OC_STACK_OK;
}
}
//-----------------------------------------------------------------------------
#define TAG "OIC_RI_STACK"
#define VERIFY_SUCCESS(op, successCode) { if ((op) != (successCode)) \
- {OC_LOG_V(FATAL, TAG, "%s failed!!", #op); goto exit;} }
-#define VERIFY_NON_NULL(arg, logLevel, retVal) { if (!(arg)) { OC_LOG((logLevel), \
+ {OIC_LOG_V(FATAL, TAG, "%s failed!!", #op); goto exit;} }
+#define VERIFY_NON_NULL(arg, logLevel, retVal) { if (!(arg)) { OIC_LOG((logLevel), \
TAG, #arg " is NULL"); return (retVal); } }
-#define VERIFY_NON_NULL_NR(arg, logLevel) { if (!(arg)) { OC_LOG((logLevel), \
+#define VERIFY_NON_NULL_NR(arg, logLevel) { if (!(arg)) { OIC_LOG((logLevel), \
TAG, #arg " is NULL"); return; } }
-#define VERIFY_NON_NULL_V(arg) { if (!arg) {OC_LOG(FATAL, TAG, #arg " is NULL");\
+#define VERIFY_NON_NULL_V(arg) { if (!arg) {OIC_LOG(FATAL, TAG, #arg " is NULL");\
goto exit;} }
//TODO: we should allow the server to define this
&(requestInfo->info.numOptions));
if (OC_STACK_OK != rmResult)
{
- OC_LOG(ERROR, TAG, "Add destination option failed");
+ OIC_LOG(ERROR, TAG, "Add destination option failed");
return rmResult;
}
#endif
CAResult_t result = CASendRequest(object, requestInfo);
if(CA_STATUS_OK != result)
{
- OC_LOG_V(ERROR, TAG, "CASendRequest failed with CA error %u", result);
+ OIC_LOG_V(ERROR, TAG, "CASendRequest failed with CA error %u", result);
return CAResultToOCResult(result);
}
return OC_STACK_OK;
switch(status)
{
case OC_OBSERVER_NOT_INTERESTED:
- OC_LOG(DEBUG, TAG, "observer not interested in our notifications");
+ OIC_LOG(DEBUG, TAG, "observer not interested in our notifications");
observer = GetObserverUsingToken (token, tokenLength);
if(observer)
{
result = DeleteObserverUsingToken (token, tokenLength);
if(result == OC_STACK_OK)
{
- OC_LOG(DEBUG, TAG, "Removed observer successfully");
+ OIC_LOG(DEBUG, TAG, "Removed observer successfully");
}
else
{
result = OC_STACK_OK;
- OC_LOG(DEBUG, TAG, "Observer Removal failed");
+ OIC_LOG(DEBUG, TAG, "Observer Removal failed");
}
break;
case OC_OBSERVER_STILL_INTERESTED:
- OC_LOG(DEBUG, TAG, "observer still interested, reset the failedCount");
+ OIC_LOG(DEBUG, TAG, "observer still interested, reset the failedCount");
observer = GetObserverUsingToken (token, tokenLength);
if(observer)
{
break;
case OC_OBSERVER_FAILED_COMM:
- OC_LOG(DEBUG, TAG, "observer is unreachable");
+ OIC_LOG(DEBUG, TAG, "observer is unreachable");
observer = GetObserverUsingToken (token, tokenLength);
if(observer)
{
result = DeleteObserverUsingToken (token, tokenLength);
if(result == OC_STACK_OK)
{
- OC_LOG(DEBUG, TAG, "Removed observer successfully");
+ OIC_LOG(DEBUG, TAG, "Removed observer successfully");
}
else
{
result = OC_STACK_OK;
- OC_LOG(DEBUG, TAG, "Observer Removal failed");
+ OIC_LOG(DEBUG, TAG, "Observer Removal failed");
}
}
else
result = OC_STACK_CONTINUE;
}
observer->forceHighQos = 1;
- OC_LOG_V(DEBUG, TAG, "Failed count for this observer is %d",observer->failedCommCount);
+ OIC_LOG_V(DEBUG, TAG, "Failed count for this observer is %d",observer->failedCommCount);
}
break;
default:
- OC_LOG(ERROR, TAG, "Unknown status");
+ OIC_LOG(ERROR, TAG, "Unknown status");
result = OC_STACK_ERROR;
break;
}
// This should not happen but,
// give it a value just in case but output an error
ret = CA_CONTENT;
- OC_LOG_V(ERROR, TAG, "Unexpected OC_STACK_OK return code for method [%d].", method);
+ OIC_LOG_V(ERROR, TAG, "Unexpected OC_STACK_OK return code for method [%d].", method);
}
break;
case OC_STACK_RESOURCE_CREATED:
return OC_STACK_INVALID_PARAM;
}
- OC_LOG_V(INFO, TAG, "Update presence TTL, time is %u", GetTicks(0));
+ OIC_LOG_V(INFO, TAG, "Update presence TTL, time is %u", GetTicks(0));
cbNode->presence->TTL = maxAgeSeconds;
cbNode->presence->timeOut[index] = OCGetRandomRange(lowerBound, higherBound);
- OC_LOG_V(DEBUG, TAG, "lowerBound timeout %d", lowerBound);
- OC_LOG_V(DEBUG, TAG, "higherBound timeout %d", higherBound);
- OC_LOG_V(DEBUG, TAG, "timeOut entry %d", cbNode->presence->timeOut[index]);
+ OIC_LOG_V(DEBUG, TAG, "lowerBound timeout %d", lowerBound);
+ OIC_LOG_V(DEBUG, TAG, "higherBound timeout %d", higherBound);
+ OIC_LOG_V(DEBUG, TAG, "timeOut entry %d", cbNode->presence->timeOut[index]);
}
cbNode->presence->TTLlevel = 0;
- OC_LOG_V(DEBUG, TAG, "this TTL level %d", cbNode->presence->TTLlevel);
+ OIC_LOG_V(DEBUG, TAG, "this TTL level %d", cbNode->presence->TTLlevel);
return OC_STACK_OK;
}
if (responseInfo->result != CA_CONTENT)
{
- OC_LOG_V(ERROR, TAG, "HandlePresenceResponse failed %d", responseInfo->result);
+ OIC_LOG_V(ERROR, TAG, "HandlePresenceResponse failed %d", responseInfo->result);
return OC_STACK_ERROR;
}
if (!presenceSubscribe && !multicastPresenceSubscribe)
{
- OC_LOG(ERROR, TAG, "Received a presence notification, but no callback, ignoring");
+ OIC_LOG(ERROR, TAG, "Received a presence notification, but no callback, ignoring");
goto exit;
}
if(result != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "Presence parse failed");
+ OIC_LOG(ERROR, TAG, "Presence parse failed");
goto exit;
}
if(!response.payload || response.payload->type != PAYLOAD_TYPE_PRESENCE)
{
- OC_LOG(ERROR, TAG, "Presence payload was wrong type");
+ OIC_LOG(ERROR, TAG, "Presence payload was wrong type");
result = OC_STACK_ERROR;
goto exit;
}
{
if(cbNode->sequenceNumber == response.sequenceNumber)
{
- OC_LOG(INFO, TAG, "No presence change");
+ OIC_LOG(INFO, TAG, "No presence change");
ResetPresenceTTL(cbNode, maxAge);
- OC_LOG_V(INFO, TAG, "ResetPresenceTTL - TTLlevel:%d\n", cbNode->presence->TTLlevel);
+ OIC_LOG_V(INFO, TAG, "ResetPresenceTTL - TTLlevel:%d\n", cbNode->presence->TTLlevel);
goto exit;
}
if(maxAge == 0)
{
- OC_LOG(INFO, TAG, "Stopping presence");
+ OIC_LOG(INFO, TAG, "Stopping presence");
response.result = OC_STACK_PRESENCE_STOPPED;
if(cbNode->presence)
{
if(!(cbNode->presence))
{
- OC_LOG(ERROR, TAG, "Could not allocate memory for cbNode->presence");
+ OIC_LOG(ERROR, TAG, "Could not allocate memory for cbNode->presence");
result = OC_STACK_NO_MEMORY;
goto exit;
}
cbNode->presence->timeOut = (uint32_t *)
OICMalloc(PresenceTimeOutSize * sizeof(uint32_t));
if(!(cbNode->presence->timeOut)){
- OC_LOG(ERROR, TAG,
+ OIC_LOG(ERROR, TAG,
"Could not allocate memory for cbNode->presence->timeOut");
OICFree(cbNode->presence);
result = OC_STACK_NO_MEMORY;
{
if(mcNode->nonce == response.sequenceNumber)
{
- OC_LOG(INFO, TAG, "No presence change (Multicast)");
+ OIC_LOG(INFO, TAG, "No presence change (Multicast)");
goto exit;
}
mcNode->nonce = response.sequenceNumber;
if(maxAge == 0)
{
- OC_LOG(INFO, TAG, "Stopping presence");
+ OIC_LOG(INFO, TAG, "Stopping presence");
response.result = OC_STACK_PRESENCE_STOPPED;
}
}
char* uri = OICStrdup(presenceUri);
if (!uri)
{
- OC_LOG(INFO, TAG,
+ OIC_LOG(INFO, TAG,
"No Memory for URI to store in the presence node");
result = OC_STACK_NO_MEMORY;
goto exit;
result = AddMCPresenceNode(&mcNode, uri, response.sequenceNumber);
if(result == OC_STACK_NO_MEMORY)
{
- OC_LOG(INFO, TAG,
+ OIC_LOG(INFO, TAG,
"No Memory for Multicast Presence Node");
OICFree(uri);
goto exit;
VERIFY_NON_NULL_NR(endPoint, FATAL);
VERIFY_NON_NULL_NR(responseInfo, FATAL);
- OC_LOG(INFO, TAG, "Enter HandleCAResponses");
+ OIC_LOG(INFO, TAG, "Enter HandleCAResponses");
#if defined (ROUTING_GATEWAY) || defined (ROUTING_EP)
#ifdef ROUTING_GATEWAY
&needRIHandling);
if(ret != OC_STACK_OK || !needRIHandling)
{
- OC_LOG_V(INFO, TAG, "Routing status![%d]. Not forwarding to RI", ret);
+ OIC_LOG_V(INFO, TAG, "Routing status![%d]. Not forwarding to RI", ret);
return;
}
#endif
if(cbNode)
{
- OC_LOG(INFO, TAG, "There is a cbNode associated with the response token");
+ OIC_LOG(INFO, TAG, "There is a cbNode associated with the response token");
if(responseInfo->result == CA_EMPTY)
{
- OC_LOG(INFO, TAG, "Receiving A ACK/RESET for this token");
+ OIC_LOG(INFO, TAG, "Receiving A ACK/RESET for this token");
// We do not have a case for the client to receive a RESET
if(responseInfo->info.type == CA_MSG_ACKNOWLEDGE)
{
//This is the case of receiving an ACK on a request to a slow resource!
- OC_LOG(INFO, TAG, "This is a pure ACK");
+ OIC_LOG(INFO, TAG, "This is a pure ACK");
//TODO: should we inform the client
// app that at least the request was received at the server?
}
}
else if(responseInfo->result == CA_RETRANSMIT_TIMEOUT)
{
- OC_LOG(INFO, TAG, "Receiving A Timeout for this token");
- OC_LOG(INFO, TAG, "Calling into application address space");
+ OIC_LOG(INFO, TAG, "Receiving A Timeout for this token");
+ OIC_LOG(INFO, TAG, "Calling into application address space");
OCClientResponse response =
{.devAddr = {.adapter = OC_DEFAULT_ADAPTER}};
}
else
{
- OC_LOG(INFO, TAG, "This is a regular response, A client call back is found");
- OC_LOG(INFO, TAG, "Calling into application address space");
+ OIC_LOG(INFO, TAG, "This is a regular response, A client call back is found");
+ OIC_LOG(INFO, TAG, "Calling into application address space");
OCClientResponse response =
{.devAddr = {.adapter = OC_DEFAULT_ADAPTER}};
}
else
{
- OC_LOG_V(ERROR, TAG, "Unknown Payload type in Discovery: %d %s",
+ OIC_LOG_V(ERROR, TAG, "Unknown Payload type in Discovery: %d %s",
cbNode->method, cbNode->requestUri);
return;
}
}
if (type == PAYLOAD_TYPE_INVALID)
{
- OC_LOG_V(INFO, TAG, "Assuming PAYLOAD_TYPE_REPRESENTATION: %d %s",
+ OIC_LOG_V(INFO, TAG, "Assuming PAYLOAD_TYPE_REPRESENTATION: %d %s",
cbNode->method, cbNode->requestUri);
type = PAYLOAD_TYPE_REPRESENTATION;
}
}
else
{
- OC_LOG_V(ERROR, TAG, "Unknown Payload type: %d %s",
+ OIC_LOG_V(ERROR, TAG, "Unknown Payload type: %d %s",
cbNode->method, cbNode->requestUri);
return;
}
responseInfo->info.payload,
responseInfo->info.payloadSize))
{
- OC_LOG(ERROR, TAG, "Error converting payload");
+ OIC_LOG(ERROR, TAG, "Error converting payload");
OCPayloadDestroy(response.payload);
return;
}
if(response.numRcvdVendorSpecificHeaderOptions > MAX_HEADER_OPTIONS)
{
- OC_LOG(ERROR, TAG, "#header options are more than MAX_HEADER_OPTIONS");
+ OIC_LOG(ERROR, TAG, "#header options are more than MAX_HEADER_OPTIONS");
OCPayloadDestroy(response.payload);
return;
}
response.sequenceNumber > OC_OFFSET_SEQUENCE_NUMBER &&
response.sequenceNumber <= cbNode->sequenceNumber)
{
- OC_LOG_V(INFO, TAG, "Received stale notification. Number :%d",
+ OIC_LOG_V(INFO, TAG, "Received stale notification. Number :%d",
response.sequenceNumber);
}
else
if(observer)
{
- OC_LOG(INFO, TAG, "There is an observer associated with the response token");
+ OIC_LOG(INFO, TAG, "There is an observer associated with the response token");
if(responseInfo->result == CA_EMPTY)
{
- OC_LOG(INFO, TAG, "Receiving A ACK/RESET for this token");
+ OIC_LOG(INFO, TAG, "Receiving A ACK/RESET for this token");
if(responseInfo->info.type == CA_MSG_RESET)
{
- OC_LOG(INFO, TAG, "This is a RESET");
+ OIC_LOG(INFO, TAG, "This is a RESET");
OCStackFeedBack(responseInfo->info.token, responseInfo->info.tokenLength,
OC_OBSERVER_NOT_INTERESTED);
}
else if(responseInfo->info.type == CA_MSG_ACKNOWLEDGE)
{
- OC_LOG(INFO, TAG, "This is a pure ACK");
+ OIC_LOG(INFO, TAG, "This is a pure ACK");
OCStackFeedBack(responseInfo->info.token, responseInfo->info.tokenLength,
OC_OBSERVER_STILL_INTERESTED);
}
}
else if(responseInfo->result == CA_RETRANSMIT_TIMEOUT)
{
- OC_LOG(INFO, TAG, "Receiving Time Out for an observer");
+ OIC_LOG(INFO, TAG, "Receiving Time Out for an observer");
OCStackFeedBack(responseInfo->info.token, responseInfo->info.tokenLength,
OC_OBSERVER_FAILED_COMM);
}
if(myStackMode == OC_CLIENT || myStackMode == OC_CLIENT_SERVER
|| myStackMode == OC_GATEWAY)
{
- OC_LOG(INFO, TAG, "This is a client, but no cbNode was found for token");
+ OIC_LOG(INFO, TAG, "This is a client, but no cbNode was found for token");
if(responseInfo->result == CA_EMPTY)
{
- OC_LOG(INFO, TAG, "Receiving CA_EMPTY in the ocstack");
+ OIC_LOG(INFO, TAG, "Receiving CA_EMPTY in the ocstack");
}
else
{
- OC_LOG(INFO, TAG, "Received a message without callbacks. Sending RESET");
+ OIC_LOG(INFO, TAG, "Received a message without callbacks. Sending RESET");
SendDirectStackResponse(endPoint, responseInfo->info.messageId, CA_EMPTY,
CA_MSG_RESET, 0, NULL, NULL, 0, NULL);
}
if(myStackMode == OC_SERVER || myStackMode == OC_CLIENT_SERVER
|| myStackMode == OC_GATEWAY)
{
- OC_LOG(INFO, TAG, "This is a server, but no observer was found for token");
+ OIC_LOG(INFO, TAG, "This is a server, but no observer was found for token");
if (responseInfo->info.type == CA_MSG_ACKNOWLEDGE)
{
- OC_LOG_V(INFO, TAG, "Received ACK at server for messageId : %d",
+ OIC_LOG_V(INFO, TAG, "Received ACK at server for messageId : %d",
responseInfo->info.messageId);
}
if (responseInfo->info.type == CA_MSG_RESET)
{
- OC_LOG_V(INFO, TAG, "Received RESET at server for messageId : %d",
+ OIC_LOG_V(INFO, TAG, "Received RESET at server for messageId : %d",
responseInfo->info.messageId);
}
}
return;
}
- OC_LOG(INFO, TAG, "Exit HandleCAResponses");
+ OIC_LOG(INFO, TAG, "Exit HandleCAResponses");
}
/*
*/
void HandleCAErrorResponse(const CAEndpoint_t *endPoint, const CAErrorInfo_t *errrorInfo)
{
- OC_LOG(INFO, TAG, "Enter HandleCAErrorResponse");
+ OIC_LOG(INFO, TAG, "Enter HandleCAErrorResponse");
if(NULL == endPoint)
{
- OC_LOG(ERROR, TAG, "endPoint is NULL");
+ OIC_LOG(ERROR, TAG, "endPoint is NULL");
return;
}
if(NULL == errrorInfo)
{
- OC_LOG(ERROR, TAG, "errrorInfo is NULL");
+ OIC_LOG(ERROR, TAG, "errrorInfo is NULL");
return;
}
- OC_LOG(INFO, TAG, "Exit HandleCAErrorResponse");
+ OIC_LOG(INFO, TAG, "Exit HandleCAErrorResponse");
}
/*
&(respInfo.info.numOptions));
if(OC_STACK_OK != result)
{
- OC_LOG_V(ERROR, TAG, "Add routing option failed [%d]", result);
+ OIC_LOG_V(ERROR, TAG, "Add routing option failed [%d]", result);
return result;
}
#endif
OICFree (respInfo.info.options);
if(CA_STATUS_OK != caResult)
{
- OC_LOG(ERROR, TAG, "CASendResponse error");
+ OIC_LOG(ERROR, TAG, "CASendResponse error");
return CAResultToOCResult(caResult);
}
return OC_STACK_OK;
//This function will be called back by CA layer when a request is received
void HandleCARequests(const CAEndpoint_t* endPoint, const CARequestInfo_t* requestInfo)
{
- OC_LOG(INFO, TAG, "Enter HandleCARequests");
+ OIC_LOG(INFO, TAG, "Enter HandleCARequests");
if(!endPoint)
{
- OC_LOG(ERROR, TAG, "endPoint is NULL");
+ OIC_LOG(ERROR, TAG, "endPoint is NULL");
return;
}
if(!requestInfo)
{
- OC_LOG(ERROR, TAG, "requestInfo is NULL");
+ OIC_LOG(ERROR, TAG, "requestInfo is NULL");
return;
}
&needRIHandling);
if(OC_STACK_OK != ret || !needRIHandling)
{
- OC_LOG_V(INFO, TAG, "Routing status![%d]. Not forwarding to RI", ret);
+ OIC_LOG_V(INFO, TAG, "Routing status![%d]. Not forwarding to RI", ret);
return;
}
#endif
OCServerProtocolRequest serverRequest = {0};
- OC_LOG_V(INFO, TAG, "Endpoint URI : %s", requestInfo->info.resourceUri);
+ OIC_LOG_V(INFO, TAG, "Endpoint URI : %s", requestInfo->info.resourceUri);
char * uriWithoutQuery = NULL;
char * query = NULL;
if (requestResult != OC_STACK_OK || !uriWithoutQuery)
{
- OC_LOG_V(ERROR, TAG, "getQueryFromUri() failed with OC error code %d\n", requestResult);
+ OIC_LOG_V(ERROR, TAG, "getQueryFromUri() failed with OC error code %d\n", requestResult);
return;
}
- OC_LOG_V(INFO, TAG, "URI without query: %s", uriWithoutQuery);
- OC_LOG_V(INFO, TAG, "Query : %s", query);
+ OIC_LOG_V(INFO, TAG, "URI without query: %s", uriWithoutQuery);
+ OIC_LOG_V(INFO, TAG, "Query : %s", query);
if(strlen(uriWithoutQuery) < MAX_URI_LENGTH)
{
}
else
{
- OC_LOG(ERROR, TAG, "URI length exceeds MAX_URI_LENGTH.");
+ OIC_LOG(ERROR, TAG, "URI length exceeds MAX_URI_LENGTH.");
OICFree(uriWithoutQuery);
OICFree(query);
return;
}
else
{
- OC_LOG(ERROR, TAG, "Query length exceeds MAX_QUERY_LENGTH.");
+ OIC_LOG(ERROR, TAG, "Query length exceeds MAX_QUERY_LENGTH.");
OICFree(query);
return;
}
serverRequest.method = OC_REST_DELETE;
break;
default:
- OC_LOG_V(ERROR, TAG, "Received CA method %d not supported", requestInfo->method);
+ OIC_LOG_V(ERROR, TAG, "Received CA method %d not supported", requestInfo->method);
SendDirectStackResponse(endPoint, requestInfo->info.messageId, CA_BAD_REQ,
requestInfo->info.type, requestInfo->info.numOptions,
requestInfo->info.options, requestInfo->info.token,
return;
}
- OC_LOG_BUFFER(INFO, TAG, (const uint8_t *)requestInfo->info.token,
+ OIC_LOG_BUFFER(INFO, TAG, (const uint8_t *)requestInfo->info.token,
requestInfo->info.tokenLength);
serverRequest.tokenLength = requestInfo->info.tokenLength;
if (!serverRequest.requestToken)
{
- OC_LOG(FATAL, TAG, "Allocation for token failed.");
+ OIC_LOG(FATAL, TAG, "Allocation for token failed.");
SendDirectStackResponse(endPoint, requestInfo->info.messageId, CA_INTERNAL_SERVER_ERROR,
requestInfo->info.type, requestInfo->info.numOptions,
requestInfo->info.options, requestInfo->info.token,
GetObserveHeaderOption(&serverRequest.observationOption, requestInfo->info.options, &tempNum);
if (requestInfo->info.numOptions > MAX_HEADER_OPTIONS)
{
- OC_LOG(ERROR, TAG,
+ OIC_LOG(ERROR, TAG,
"The request info numOptions is greater than MAX_HEADER_OPTIONS");
SendDirectStackResponse(endPoint, requestInfo->info.messageId, CA_BAD_OPT,
requestInfo->info.type, requestInfo->info.numOptions,
}
else if(requestResult != OC_STACK_OK)
{
- OC_LOG_V(ERROR, TAG, "HandleStackRequests failed. error: %d", requestResult);
+ OIC_LOG_V(ERROR, TAG, "HandleStackRequests failed. error: %d", requestResult);
CAResponseResult_t stackResponse =
OCToCAStackResult(requestResult, serverRequest.method);
// The token is copied in there, and is thus still owned by this function.
OICFree(serverRequest.payload);
OICFree(serverRequest.requestToken);
- OC_LOG(INFO, TAG, "Exit HandleCARequests");
+ OIC_LOG(INFO, TAG, "Exit HandleCARequests");
}
OCStackResult HandleStackRequests(OCServerProtocolRequest * protocolRequest)
{
- OC_LOG(INFO, TAG, "Entering HandleStackRequests (OCStack Layer)");
+ OIC_LOG(INFO, TAG, "Entering HandleStackRequests (OCStack Layer)");
OCStackResult result = OC_STACK_ERROR;
ResourceHandling resHandling;
OCResource *resource;
if(!protocolRequest)
{
- OC_LOG(ERROR, TAG, "protocolRequest is NULL");
+ OIC_LOG(ERROR, TAG, "protocolRequest is NULL");
return OC_STACK_INVALID_PARAM;
}
protocolRequest->tokenLength);
if(!request)
{
- OC_LOG(INFO, TAG, "This is a new Server Request");
+ OIC_LOG(INFO, TAG, "This is a new Server Request");
result = AddServerRequest(&request, protocolRequest->coapID,
protocolRequest->delayedResNeeded, 0, protocolRequest->method,
protocolRequest->numRcvdVendorSpecificHeaderOptions,
&protocolRequest->devAddr);
if (OC_STACK_OK != result)
{
- OC_LOG(ERROR, TAG, "Error adding server request");
+ OIC_LOG(ERROR, TAG, "Error adding server request");
return result;
}
if(!request)
{
- OC_LOG(ERROR, TAG, "Out of Memory");
+ OIC_LOG(ERROR, TAG, "Out of Memory");
return OC_STACK_NO_MEMORY;
}
}
else
{
- OC_LOG(INFO, TAG, "This is either a repeated or blocked Server Request");
+ OIC_LOG(INFO, TAG, "This is either a repeated or blocked Server Request");
}
if(request->requestComplete)
{
- OC_LOG(INFO, TAG, "This Server Request is complete");
+ OIC_LOG(INFO, TAG, "This Server Request is complete");
result = DetermineResourceHandling (request, &resHandling, &resource);
if (result == OC_STACK_OK)
{
}
else
{
- OC_LOG(INFO, TAG, "This Server Request is incomplete");
+ OIC_LOG(INFO, TAG, "This Server Request is incomplete");
result = OC_STACK_CONTINUE;
}
return result;
if (!info.platformID)
{
- OC_LOG(ERROR, TAG, "No platform ID found.");
+ OIC_LOG(ERROR, TAG, "No platform ID found.");
return false;
}
if(lenManufacturerName == 0 || lenManufacturerName > MAX_MANUFACTURER_NAME_LENGTH)
{
- OC_LOG(ERROR, TAG, "Manufacturer name fails length requirements.");
+ OIC_LOG(ERROR, TAG, "Manufacturer name fails length requirements.");
return false;
}
}
else
{
- OC_LOG(ERROR, TAG, "No manufacturer name present");
+ OIC_LOG(ERROR, TAG, "No manufacturer name present");
return false;
}
{
if(strlen(info.manufacturerUrl) > MAX_MANUFACTURER_URL_LENGTH)
{
- OC_LOG(ERROR, TAG, "Manufacturer url fails length requirements.");
+ OIC_LOG(ERROR, TAG, "Manufacturer url fails length requirements.");
return false;
}
}
{
if(stackState == OC_STACK_INITIALIZED)
{
- OC_LOG(INFO, TAG, "Subsequent calls to OCInit() without calling \
+ OIC_LOG(INFO, TAG, "Subsequent calls to OCInit() without calling \
OCStop() between them are ignored.");
return OC_STACK_OK;
}
#ifndef ROUTING_GATEWAY
if (OC_GATEWAY == mode)
{
- OC_LOG(ERROR, TAG, "Routing Manager not supported");
+ OIC_LOG(ERROR, TAG, "Routing Manager not supported");
return OC_STACK_INVALID_PARAM;
}
#endif
#ifdef RA_ADAPTER
if(!gRASetInfo)
{
- OC_LOG(ERROR, TAG, "Need to call OCSetRAInfo before calling OCInit");
+ OIC_LOG(ERROR, TAG, "Need to call OCSetRAInfo before calling OCInit");
return OC_STACK_ERROR;
}
#endif
OCStackResult result = OC_STACK_ERROR;
- OC_LOG(INFO, TAG, "Entering OCInit");
+ OIC_LOG(INFO, TAG, "Entering OCInit");
// Validate mode
if (!((mode == OC_CLIENT) || (mode == OC_SERVER) || (mode == OC_CLIENT_SERVER)
|| (mode == OC_GATEWAY)))
{
- OC_LOG(ERROR, TAG, "Invalid mode");
+ OIC_LOG(ERROR, TAG, "Invalid mode");
return OC_STACK_ERROR;
}
myStackMode = mode;
case OC_CLIENT:
CARegisterHandler(HandleCARequests, HandleCAResponses, HandleCAErrorResponse);
result = CAResultToOCResult(CAStartDiscoveryServer());
- OC_LOG(INFO, TAG, "Client mode: CAStartDiscoveryServer");
+ OIC_LOG(INFO, TAG, "Client mode: CAStartDiscoveryServer");
break;
case OC_SERVER:
SRMRegisterHandler(HandleCARequests, HandleCAResponses, HandleCAErrorResponse);
result = CAResultToOCResult(CAStartListeningServer());
- OC_LOG(INFO, TAG, "Server mode: CAStartListeningServer");
+ OIC_LOG(INFO, TAG, "Server mode: CAStartListeningServer");
break;
case OC_CLIENT_SERVER:
case OC_GATEWAY:
exit:
if(result != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "Stack initialization error");
+ OIC_LOG(ERROR, TAG, "Stack initialization error");
deleteAllResources();
CATerminate();
stackState = OC_STACK_UNINITIALIZED;
OCStackResult OCStop()
{
- OC_LOG(INFO, TAG, "Entering OCStop");
+ OIC_LOG(INFO, TAG, "Entering OCStop");
if (stackState == OC_STACK_UNINIT_IN_PROGRESS)
{
- OC_LOG(DEBUG, TAG, "Stack already stopping, exiting");
+ OIC_LOG(DEBUG, TAG, "Stack already stopping, exiting");
return OC_STACK_OK;
}
else if (stackState != OC_STACK_INITIALIZED)
{
- OC_LOG(ERROR, TAG, "Stack not initialized");
+ OIC_LOG(ERROR, TAG, "Stack not initialized");
return OC_STACK_ERROR;
}
{
if(stackState != OC_STACK_INITIALIZED)
{
- OC_LOG(ERROR, TAG, "OCStack is not initalized. Cannot start multicast server.");
+ OIC_LOG(ERROR, TAG, "OCStack is not initalized. Cannot start multicast server.");
return OC_STACK_ERROR;
}
CAResult_t ret = CAStartListeningServer();
if (CA_STATUS_OK != ret)
{
- OC_LOG_V(ERROR, TAG, "Failed starting listening server: %d", ret);
+ OIC_LOG_V(ERROR, TAG, "Failed starting listening server: %d", ret);
return OC_STACK_ERROR;
}
return OC_STACK_OK;
CAResult_t ret = CAStopListeningServer();
if (CA_STATUS_OK != ret)
{
- OC_LOG_V(ERROR, TAG, "Failed stopping listening server: %d", ret);
+ OIC_LOG_V(ERROR, TAG, "Failed stopping listening server: %d", ret);
return OC_STACK_ERROR;
}
return OC_STACK_OK;
OCHeaderOption *options,
uint8_t numOptions)
{
- OC_LOG(INFO, TAG, "Entering OCDoResource");
+ OIC_LOG(INFO, TAG, "Entering OCDoResource");
// Validate input parameters
VERIFY_NON_NULL(cbData, FATAL, OC_STACK_INVALID_CALLBACK);
if (result != OC_STACK_OK)
{
- OC_LOG_V(DEBUG, TAG, "Unable to parse uri: %s", requestUri);
+ OIC_LOG_V(DEBUG, TAG, "Unable to parse uri: %s", requestUri);
goto exit;
}
if (!devAddr && !destination)
{
- OC_LOG(DEBUG, TAG, "no devAddr and no destination");
+ OIC_LOG(DEBUG, TAG, "no devAddr and no destination");
result = OC_STACK_INVALID_PARAM;
goto exit;
}
caResult = CAGenerateToken(&token, tokenLength);
if (caResult != CA_STATUS_OK)
{
- OC_LOG(ERROR, TAG, "CAGenerateToken error");
+ OIC_LOG(ERROR, TAG, "CAGenerateToken error");
result= OC_STACK_ERROR;
goto exit;
}
OCConvertPayload(payload, &requestInfo.info.payload, &requestInfo.info.payloadSize))
!= OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "Failed to create CBOR Payload");
+ OIC_LOG(ERROR, TAG, "Failed to create CBOR Payload");
goto exit;
}
requestInfo.info.payloadFormat = CA_FORMAT_APPLICATION_CBOR;
if (result != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "CACreateEndpoint error");
+ OIC_LOG(ERROR, TAG, "CACreateEndpoint error");
goto exit;
}
exit:
if (result != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCDoResource error");
+ OIC_LOG(ERROR, TAG, "OCDoResource error");
FindAndDeleteClientCB(clientCB);
CADestroyToken(token);
if (handle)
ClientCB *clientCB = GetClientCB(NULL, 0, handle, NULL);
if (!clientCB)
{
- OC_LOG(ERROR, TAG, "Callback not found. Called OCCancel on same resource twice?");
+ OIC_LOG(ERROR, TAG, "Callback not found. Called OCCancel on same resource twice?");
return OC_STACK_ERROR;
}
case OC_REST_OBSERVE:
case OC_REST_OBSERVE_ALL:
- OC_LOG_V(INFO, TAG, "Canceling observation for resource %s",
+ OIC_LOG_V(INFO, TAG, "Canceling observation for resource %s",
clientCB->requestUri);
if (qos != OC_HIGH_QOS)
{
break;
}
- OC_LOG(INFO, TAG, "Cancelling observation as CONFIRMABLE");
+ OIC_LOG(INFO, TAG, "Cancelling observation as CONFIRMABLE");
requestInfo.info.type = qualityOfServiceToMessageType(qos);
requestInfo.info.token = clientCB->token;
break;
case OC_REST_DISCOVER:
- OC_LOG_V(INFO, TAG, "Cancelling discovery callback for resource %s",
+ OIC_LOG_V(INFO, TAG, "Cancelling discovery callback for resource %s",
clientCB->requestUri);
FindAndDeleteClientCB(clientCB);
break;
*/
OCStackResult OCRegisterPersistentStorageHandler(OCPersistentStorage* persistentStorageHandler)
{
- OC_LOG(INFO, TAG, "RegisterPersistentStorageHandler !!");
+ OIC_LOG(INFO, TAG, "RegisterPersistentStorageHandler !!");
if(!persistentStorageHandler)
{
- OC_LOG(ERROR, TAG, "The persistent storage handler is invalid");
+ OIC_LOG(ERROR, TAG, "The persistent storage handler is invalid");
return OC_STACK_INVALID_PARAM;
}
else
!persistentStorageHandler->unlink ||
!persistentStorageHandler->write)
{
- OC_LOG(ERROR, TAG, "The persistent storage handler is invalid");
+ OIC_LOG(ERROR, TAG, "The persistent storage handler is invalid");
return OC_STACK_INVALID_PARAM;
}
}
// the following line floods the log with messages that are irrelevant
// to most purposes. Uncomment as needed.
- //OC_LOG(INFO, TAG, "Entering RequestPresence");
+ //OIC_LOG(INFO, TAG, "Entering RequestPresence");
ClientCB* cbNode = NULL;
OCClientResponse clientResponse;
OCStackApplicationResult cbResult = OC_STACK_DELETE_TRANSACTION;
}
uint32_t now = GetTicks(0);
- OC_LOG_V(DEBUG, TAG, "this TTL level %d",
+ OIC_LOG_V(DEBUG, TAG, "this TTL level %d",
cbNode->presence->TTLlevel);
- OC_LOG_V(DEBUG, TAG, "current ticks %d", now);
+ OIC_LOG_V(DEBUG, TAG, "current ticks %d", now);
if (cbNode->presence->TTLlevel > PresenceTimeOutSize)
{
if (cbNode->presence->TTLlevel < PresenceTimeOutSize)
{
- OC_LOG_V(DEBUG, TAG, "timeout ticks %d",
+ OIC_LOG_V(DEBUG, TAG, "timeout ticks %d",
cbNode->presence->timeOut[cbNode->presence->TTLlevel]);
}
if (cbNode->presence->TTLlevel >= PresenceTimeOutSize)
{
- OC_LOG(DEBUG, TAG, "No more timeout ticks");
+ OIC_LOG(DEBUG, TAG, "No more timeout ticks");
clientResponse.sequenceNumber = 0;
clientResponse.result = OC_STACK_PRESENCE_TIMEOUT;
// Increment the TTLLevel (going to a next state), so we don't keep
// sending presence notification to client.
cbNode->presence->TTLlevel++;
- OC_LOG_V(DEBUG, TAG, "moving to TTL level %d",
+ OIC_LOG_V(DEBUG, TAG, "moving to TTL level %d",
cbNode->presence->TTLlevel);
cbResult = cbNode->callBack(cbNode->context, cbNode->handle, &clientResponse);
CAInfo_t requestData = {.type = CA_MSG_CONFIRM};
CARequestInfo_t requestInfo = {.method = CA_GET};
- OC_LOG(DEBUG, TAG, "time to test server presence");
+ OIC_LOG(DEBUG, TAG, "time to test server presence");
CopyDevAddrToEndpoint(cbNode->devAddr, &endpoint);
}
cbNode->presence->TTLlevel++;
- OC_LOG_V(DEBUG, TAG, "moving to TTL level %d", cbNode->presence->TTLlevel);
+ OIC_LOG_V(DEBUG, TAG, "moving to TTL level %d", cbNode->presence->TTLlevel);
}
exit:
if (result != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCProcessPresence error");
+ OIC_LOG(ERROR, TAG, "OCProcessPresence error");
}
return result;
if (OC_MAX_PRESENCE_TTL_SECONDS < ttl)
{
presenceResource.presenceTTL = OC_MAX_PRESENCE_TTL_SECONDS;
- OC_LOG(INFO, TAG, "Setting Presence TTL to max value");
+ OIC_LOG(INFO, TAG, "Setting Presence TTL to max value");
}
else if (0 == ttl)
{
presenceResource.presenceTTL = OC_DEFAULT_PRESENCE_TTL_SECONDS;
- OC_LOG(INFO, TAG, "Setting Presence TTL to default value");
+ OIC_LOG(INFO, TAG, "Setting Presence TTL to default value");
}
else
{
presenceResource.presenceTTL = ttl;
}
- OC_LOG_V(DEBUG, TAG, "Presence TTL is %" PRIu32 " seconds", presenceResource.presenceTTL);
+ OIC_LOG_V(DEBUG, TAG, "Presence TTL is %" PRIu32 " seconds", presenceResource.presenceTTL);
if (OC_PRESENCE_UNINITIALIZED == presenceState)
{
CAResult_t caResult = CAGenerateToken(&caToken, tokenLength);
if (caResult != CA_STATUS_OK)
{
- OC_LOG(ERROR, TAG, "CAGenerateToken error");
+ OIC_LOG(ERROR, TAG, "CAGenerateToken error");
CADestroyToken(caToken);
return OC_STACK_ERROR;
}
if(result != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG,
+ OIC_LOG(ERROR, TAG,
"Changing the presence resource properties to ACTIVE not successful");
return result;
}
OCStackResult OCSetPlatformInfo(OCPlatformInfo platformInfo)
{
- OC_LOG(INFO, TAG, "Entering OCSetPlatformInfo");
+ OIC_LOG(INFO, TAG, "Entering OCSetPlatformInfo");
if(myStackMode == OC_SERVER || myStackMode == OC_CLIENT_SERVER || myStackMode == OC_GATEWAY)
{
OCStackResult OCSetDeviceInfo(OCDeviceInfo deviceInfo)
{
- OC_LOG(INFO, TAG, "Entering OCSetDeviceInfo");
+ OIC_LOG(INFO, TAG, "Entering OCSetDeviceInfo");
if (!deviceInfo.deviceName || deviceInfo.deviceName[0] == '\0')
{
- OC_LOG(ERROR, TAG, "Null or empty device name.");
+ OIC_LOG(ERROR, TAG, "Null or empty device name.");
return OC_STACK_INVALID_PARAM;
}
OCResource *pointer = NULL;
OCStackResult result = OC_STACK_ERROR;
- OC_LOG(INFO, TAG, "Entering OCCreateResource");
+ OIC_LOG(INFO, TAG, "Entering OCCreateResource");
if(myStackMode == OC_CLIENT)
{
// Validate parameters
if(!uri || uri[0]=='\0' || strlen(uri)>=MAX_URI_LENGTH )
{
- OC_LOG(ERROR, TAG, "URI is empty or too long");
+ OIC_LOG(ERROR, TAG, "URI is empty or too long");
return OC_STACK_INVALID_URI;
}
// Is it presented during resource discovery?
if (!handle || !resourceTypeName || resourceTypeName[0] == '\0' )
{
- OC_LOG(ERROR, TAG, "Input parameter is NULL");
+ OIC_LOG(ERROR, TAG, "Input parameter is NULL");
return OC_STACK_INVALID_PARAM;
}
> (OC_ACTIVE | OC_DISCOVERABLE | OC_OBSERVABLE | OC_SLOW | OC_SECURE |
OC_EXPLICIT_DISCOVERABLE))
{
- OC_LOG(ERROR, TAG, "Invalid property");
+ OIC_LOG(ERROR, TAG, "Invalid property");
return OC_STACK_INVALID_PARAM;
}
{
if (strncmp(uri, pointer->uri, MAX_URI_LENGTH) == 0)
{
- OC_LOG_V(ERROR, TAG, "Resource %s already exists", uri);
+ OIC_LOG_V(ERROR, TAG, "Resource %s already exists", uri);
return OC_STACK_INVALID_PARAM;
}
pointer = pointer->next;
result = BindResourceTypeToResource(pointer, resourceTypeName);
if (result != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "Error adding resourcetype");
+ OIC_LOG(ERROR, TAG, "Error adding resourcetype");
goto exit;
}
result = BindResourceInterfaceToResource(pointer, resourceInterfaceName);
if (result != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "Error adding resourceinterface");
+ OIC_LOG(ERROR, TAG, "Error adding resourceinterface");
goto exit;
}
OCResource *resource = NULL;
uint8_t i = 0;
- OC_LOG(INFO, TAG, "Entering OCBindResource");
+ OIC_LOG(INFO, TAG, "Entering OCBindResource");
// Validate parameters
VERIFY_NON_NULL(collectionHandle, ERROR, OC_STACK_ERROR);
// Container cannot contain itself
if (collectionHandle == resourceHandle)
{
- OC_LOG(ERROR, TAG, "Added handle equals collection handle");
+ OIC_LOG(ERROR, TAG, "Added handle equals collection handle");
return OC_STACK_INVALID_PARAM;
}
resource = findResource((OCResource *) collectionHandle);
if (!resource)
{
- OC_LOG(ERROR, TAG, "Collection handle not found");
+ OIC_LOG(ERROR, TAG, "Collection handle not found");
return OC_STACK_INVALID_PARAM;
}
if (!resource->rsrcResources[i])
{
resource->rsrcResources[i] = (OCResource *) resourceHandle;
- OC_LOG(INFO, TAG, "resource bound");
+ OIC_LOG(INFO, TAG, "resource bound");
#ifdef WITH_PRESENCE
if (presenceResource.handle)
OCResource *resource = NULL;
uint8_t i = 0;
- OC_LOG(INFO, TAG, "Entering OCUnBindResource");
+ OIC_LOG(INFO, TAG, "Entering OCUnBindResource");
// Validate parameters
VERIFY_NON_NULL(collectionHandle, ERROR, OC_STACK_ERROR);
// Container cannot contain itself
if (collectionHandle == resourceHandle)
{
- OC_LOG(ERROR, TAG, "removing handle equals collection handle");
+ OIC_LOG(ERROR, TAG, "removing handle equals collection handle");
return OC_STACK_INVALID_PARAM;
}
resource = findResource((OCResource *) collectionHandle);
if (!resource)
{
- OC_LOG(ERROR, TAG, "Collection handle not found");
+ OIC_LOG(ERROR, TAG, "Collection handle not found");
return OC_STACK_INVALID_PARAM;
}
if (resourceHandle == resource->rsrcResources[i])
{
resource->rsrcResources[i] = (OCResource *) NULL;
- OC_LOG(INFO, TAG, "resource unbound");
+ OIC_LOG(INFO, TAG, "resource unbound");
// Send notification when resource is unbounded successfully.
#ifdef WITH_PRESENCE
}
}
- OC_LOG(INFO, TAG, "resource not found in collection");
+ OIC_LOG(INFO, TAG, "resource not found in collection");
// Unable to add resourceHandle, so return error
return OC_STACK_ERROR;
if (!ValidateResourceTypeInterface(resourceTypeName))
{
- OC_LOG(ERROR, TAG, "resource type illegal (see RFC 6690)");
+ OIC_LOG(ERROR, TAG, "resource type illegal (see RFC 6690)");
return OC_STACK_INVALID_PARAM;
}
if (!ValidateResourceTypeInterface(resourceInterfaceName))
{
- OC_LOG(ERROR, TAG, "resource /interface illegal (see RFC 6690)");
+ OIC_LOG(ERROR, TAG, "resource /interface illegal (see RFC 6690)");
return OC_STACK_INVALID_PARAM;
}
- OC_LOG_V(INFO, TAG, "Binding %s interface to %s", resourceInterfaceName, resource->uri);
+ OIC_LOG_V(INFO, TAG, "Binding %s interface to %s", resourceInterfaceName, resource->uri);
pointer = (OCResourceInterface *) OICCalloc(1, sizeof(OCResourceInterface));
if (!pointer)
resource = findResource((OCResource *) handle);
if (!resource)
{
- OC_LOG(ERROR, TAG, "Resource not found");
+ OIC_LOG(ERROR, TAG, "Resource not found");
return OC_STACK_ERROR;
}
resource = findResource((OCResource *) handle);
if (!resource)
{
- OC_LOG(ERROR, TAG, "Resource not found");
+ OIC_LOG(ERROR, TAG, "Resource not found");
return OC_STACK_ERROR;
}
{
if (!handle)
{
- OC_LOG(ERROR, TAG, "Invalid handle for deletion");
+ OIC_LOG(ERROR, TAG, "Invalid handle for deletion");
return OC_STACK_INVALID_PARAM;
}
OCResource *resource = findResource((OCResource *) handle);
if (resource == NULL)
{
- OC_LOG(ERROR, TAG, "Resource not found");
+ OIC_LOG(ERROR, TAG, "Resource not found");
return OC_STACK_NO_RESOURCE;
}
if (deleteResource((OCResource *) handle) != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "Error deleting resource");
+ OIC_LOG(ERROR, TAG, "Error deleting resource");
return OC_STACK_ERROR;
}
resource = findResource((OCResource *)handle);
if (!resource)
{
- OC_LOG(ERROR, TAG, "Resource not found");
+ OIC_LOG(ERROR, TAG, "Resource not found");
return OC_STACK_ERROR;
}
resource = findResource((OCResource *)handle);
if (!resource)
{
- OC_LOG(ERROR, TAG, "Resource not found");
+ OIC_LOG(ERROR, TAG, "Resource not found");
return NULL;
}
OCMethod method = OC_REST_NOMETHOD;
uint32_t maxAge = 0;
- OC_LOG(INFO, TAG, "Notifying all observers");
+ OIC_LOG(INFO, TAG, "Notifying all observers");
#ifdef WITH_PRESENCE
if(handle == presenceResource.handle)
{
const OCRepPayload *payload,
OCQualityOfService qos)
{
- OC_LOG(INFO, TAG, "Entering OCNotifyListOfObservers");
+ OIC_LOG(INFO, TAG, "Entering OCNotifyListOfObservers");
OCResource *resPtr = NULL;
//TODO: we should allow the server to define this
OCStackResult result = OC_STACK_ERROR;
OCServerRequest *serverRequest = NULL;
- OC_LOG(INFO, TAG, "Entering OCDoResponse");
+ OIC_LOG(INFO, TAG, "Entering OCDoResponse");
// Validate input parameters
VERIFY_NON_NULL(ehResponse, ERROR, OC_STACK_INVALID_PARAM);
if (resourceProperties
> (OC_ACTIVE | OC_DISCOVERABLE | OC_OBSERVABLE | OC_SLOW))
{
- OC_LOG(ERROR, TAG, "Invalid property");
+ OIC_LOG(ERROR, TAG, "Invalid property");
return OC_STACK_INVALID_PARAM;
}
if(!enable)
OCResource *temp = NULL;
if(!resource)
{
- OC_LOG(DEBUG,TAG,"resource is NULL");
+ OIC_LOG(DEBUG,TAG,"resource is NULL");
return OC_STACK_INVALID_PARAM;
}
- OC_LOG_V (INFO, TAG, "Deleting resource %s", resource->uri);
+ OIC_LOG_V (INFO, TAG, "Deleting resource %s", resource->uri);
temp = headResource;
while (temp)
{
if (!strcmp(resourceType->resourcetypename, pointer->resourcetypename))
{
- OC_LOG_V(INFO, TAG, "Type %s already exists", resourceType->resourcetypename);
+ OIC_LOG_V(INFO, TAG, "Type %s already exists", resourceType->resourcetypename);
OICFree(resourceType->resourcetypename);
OICFree(resourceType);
return;
}
resourceType->next = NULL;
- OC_LOG_V(INFO, TAG, "Added type %s to %s", resourceType->resourcetypename, resource->uri);
+ OIC_LOG_V(INFO, TAG, "Added type %s to %s", resourceType->resourcetypename, resource->uri);
}
OCResourceType *findResourceTypeAtIndex(OCResourceHandle handle, uint8_t index)
if (GetDoxmDeviceID(&sid) != OC_STACK_OK)
{
- OC_LOG(FATAL, TAG, "Generate UUID for Server Instance failed!");
+ OIC_LOG(FATAL, TAG, "Generate UUID for Server Instance failed!");
return NULL;
}
generated = true;
if(OCConvertUuidToString(sid->id, sidStr) != RAND_UUID_OK)
{
- OC_LOG(FATAL, TAG, "Generate UUID String for Server Instance failed!");
+ OIC_LOG(FATAL, TAG, "Generate UUID String for Server Instance failed!");
return NULL;
}
void AddScheduledResource(ScheduledResourceInfo **head,
ScheduledResourceInfo* add)
{
- OC_LOG(INFO, TAG, "AddScheduledResource Entering...");
+ OIC_LOG(INFO, TAG, "AddScheduledResource Entering...");
#ifndef WITH_ARDUINO
pthread_mutex_lock(&lock);
ScheduledResourceInfo* GetScheduledResource(ScheduledResourceInfo *head)
{
- OC_LOG(INFO, TAG, "GetScheduledResource Entering...");
+ OIC_LOG(INFO, TAG, "GetScheduledResource Entering...");
#ifndef WITH_ARDUINO
pthread_mutex_lock(&lock);
if (diffTm <= (time_t) 0)
{
- OC_LOG(INFO, TAG, "return Call INFO.");
+ OIC_LOG(INFO, TAG, "return Call INFO.");
goto exit;
}
#endif
if (tmp == NULL)
{
- OC_LOG(INFO, TAG, "Cannot Find Call Info.");
+ OIC_LOG(INFO, TAG, "Cannot Find Call Info.");
}
return tmp;
}
ScheduledResourceInfo* GetScheduledResourceByActionSetName(ScheduledResourceInfo *head, char *setName)
{
- OC_LOG(INFO, TAG, "GetScheduledResourceByActionSetName Entering...");
+ OIC_LOG(INFO, TAG, "GetScheduledResourceByActionSetName Entering...");
#ifndef WITH_ARDUINO
pthread_mutex_lock(&lock);
{
if (strcmp(tmp->actionset->actionsetName, setName) == 0)
{
- OC_LOG(INFO, TAG, "return Call INFO.");
+ OIC_LOG(INFO, TAG, "return Call INFO.");
goto exit;
}
tmp = tmp->next;
#endif
if (tmp == NULL)
{
- OC_LOG(INFO, TAG, "Cannot Find Call Info.");
+ OIC_LOG(INFO, TAG, "Cannot Find Call Info.");
}
return tmp;
}
#ifndef WITH_ARDUINO
pthread_mutex_lock(&lock);
#endif
- OC_LOG(INFO, TAG, "RemoveScheduledResource Entering...");
+ OIC_LOG(INFO, TAG, "RemoveScheduledResource Entering...");
ScheduledResourceInfo *tmp = NULL;
if (del == NULL)
OCAction *action = NULL;
OCCapability *capa = NULL;
- OC_LOG(INFO, TAG, "Build ActionSet Instance.");
+ OIC_LOG(INFO, TAG, "Build ActionSet Instance.");
*set = (OCActionSet*) OICMalloc(sizeof(OCActionSet));
VARIFY_POINTER_NULL(*set, result, exit)
}
#endif
- OC_LOG_V(INFO, TAG, "ActionSet Name : %s", (*set)->actionsetName);
+ OIC_LOG_V(INFO, TAG, "ActionSet Name : %s", (*set)->actionsetName);
iterToken = (char *) strtok_r(NULL, ACTION_DELIMITER, &iterTokenPtr);
while (iterToken)
if (strcmp(key, "uri") == 0)
{
- OC_LOG(INFO, TAG, "Build OCAction Instance.");
+ OIC_LOG(INFO, TAG, "Build OCAction Instance.");
action = (OCAction*) OICMalloc(sizeof(OCAction));
VARIFY_POINTER_NULL(action, result, exit)
{
if ((key != NULL) && (value != NULL))
{
- OC_LOG(INFO, TAG, "Build OCCapability Instance.");
+ OIC_LOG(INFO, TAG, "Build OCCapability Instance.");
capa = (OCCapability*) OICMalloc(sizeof(OCCapability));
VARIFY_POINTER_NULL(capa, result, exit)
{
(void)context;
(void)clientResponse;
- OC_LOG(INFO, TAG, "Entering ActionSetCB");
+ OIC_LOG(INFO, TAG, "Entering ActionSetCB");
ClientRequestInfo *info = GetClientRequestInfo(clientRequstList, handle);
if(NULL == clientResponse->payload)
{
- OC_LOG(ERROR, TAG, "Error sending response");
+ OIC_LOG(ERROR, TAG, "Error sending response");
return OC_STACK_DELETE_TRANSACTION;
}
// Send the response
if (OCDoResponse(&response) != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "Error sending response");
+ OIC_LOG(ERROR, TAG, "Error sending response");
return OC_STACK_DELETE_TRANSACTION;
}
char *jsonStr;
uint16_t jsonLen;
- OC_LOG(INFO, TAG, "Entering BuildActionJSON");
+ OIC_LOG(INFO, TAG, "Entering BuildActionJSON");
json = cJSON_CreateObject();
cJSON_AddItemToObject(json, "rep", body = cJSON_CreateObject());
if (!payload)
{
- OC_LOG(INFO, TAG, "Failed to create put payload object");
+ OIC_LOG(INFO, TAG, "Failed to create put payload object");
return NULL;
}
void DoScheduledGroupAction()
{
- OC_LOG(INFO, TAG, "DoScheduledGroupAction Entering...");
+ OIC_LOG(INFO, TAG, "DoScheduledGroupAction Entering...");
ScheduledResourceInfo* info = GetScheduledResource(scheduleResourceList);
if (info == NULL)
{
- OC_LOG(INFO, TAG, "Target resource is NULL");
+ OIC_LOG(INFO, TAG, "Target resource is NULL");
goto exit;
}
else if (info->resource == NULL)
{
- OC_LOG(INFO, TAG, "Target resource is NULL");
+ OIC_LOG(INFO, TAG, "Target resource is NULL");
goto exit;
}
else if (info->actionset == NULL)
{
- OC_LOG(INFO, TAG, "Target ActionSet is NULL");
+ OIC_LOG(INFO, TAG, "Target ActionSet is NULL");
goto exit;
}
else if (info->ehRequest == NULL)
{
- OC_LOG(INFO, TAG, "Target ActionSet is NULL");
+ OIC_LOG(INFO, TAG, "Target ActionSet is NULL");
goto exit;
}
#ifndef WITH_ARDUINO
if (schedule)
{
- OC_LOG(INFO, TAG, "Building New Call Info.");
+ OIC_LOG(INFO, TAG, "Building New Call Info.");
memset(schedule, 0, sizeof(ScheduledResourceInfo));
if (info->actionset->timesteps > 0)
&schedule->timer_id,
&DoScheduledGroupAction);
- OC_LOG(INFO, TAG, "Reregisteration.");
+ OIC_LOG(INFO, TAG, "Reregisteration.");
#ifndef WITH_ARDUINO
pthread_mutex_unlock(&lock);
#endif
{
OCStackResult stackRet = OC_STACK_ERROR;
- OC_LOG(INFO, TAG, "Group Action is requested.");
+ OIC_LOG(INFO, TAG, "Group Action is requested.");
char *doWhat = NULL;
char *details = NULL;
if(stackRet != OC_STACK_OK)
{
- OC_LOG_V(ERROR, TAG, "ExtractKeyValueFromRequest failed: %d", stackRet);
+ OIC_LOG_V(ERROR, TAG, "ExtractKeyValueFromRequest failed: %d", stackRet);
return stackRet;
}
if (method == OC_REST_PUT)
{
- OC_LOG(INFO, TAG, "Group Action[PUT].");
+ OIC_LOG(INFO, TAG, "Group Action[PUT].");
if (strcmp(doWhat, ACTIONSET) == 0)
{
{
DeleteActionSet( &actionSet );
}
- OC_LOG(INFO, TAG, "Duplicated ActionSet ");
+ OIC_LOG(INFO, TAG, "Duplicated ActionSet ");
}
}
else
if(!payload)
{
- OC_LOG(ERROR, TAG, "Failed to allocate Payload");
+ OIC_LOG(ERROR, TAG, "Failed to allocate Payload");
stackRet = OC_STACK_ERROR;
}
else
// Send the response
if (OCDoResponse(&response) != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "Error sending response");
+ OIC_LOG(ERROR, TAG, "Error sending response");
stackRet = OC_STACK_ERROR;
}
}
if (GetActionSet(details, resource->actionsetHead,
&actionset) != OC_STACK_OK)
{
- OC_LOG(INFO, TAG, "ERROR");
+ OIC_LOG(INFO, TAG, "ERROR");
stackRet = OC_STACK_ERROR;
}
if (actionset == NULL)
{
- OC_LOG(INFO, TAG, "Cannot Find ActionSet");
+ OIC_LOG(INFO, TAG, "Cannot Find ActionSet");
stackRet = OC_STACK_ERROR;
}
else
{
- OC_LOG(INFO, TAG, "Group Action[POST].");
+ OIC_LOG(INFO, TAG, "Group Action[POST].");
if (actionset->type == NONE)
{
- OC_LOG_V(INFO, TAG, "Execute ActionSet : %s",
+ OIC_LOG_V(INFO, TAG, "Execute ActionSet : %s",
actionset->actionsetName);
unsigned int num = GetNumOfTargetResource(
actionset->head);
}
else
{
- OC_LOG_V(INFO, TAG, "Execute Scheduled ActionSet : %s",
+ OIC_LOG_V(INFO, TAG, "Execute Scheduled ActionSet : %s",
actionset->actionsetName);
delay =
if (schedule)
{
- OC_LOG(INFO, TAG, "Building New Call Info.");
+ OIC_LOG(INFO, TAG, "Building New Call Info.");
memset(schedule, 0,
sizeof(ScheduledResourceInfo));
#ifndef WITH_ARDUINO
#endif
if (delay > 0)
{
- OC_LOG_V(INFO, TAG, "delay_time is %ld seconds.",
+ OIC_LOG_V(INFO, TAG, "delay_time is %ld seconds.",
actionset->timesteps);
#ifndef WITH_ARDUINO
pthread_mutex_lock(&lock);
if(!payload)
{
- OC_LOG(ERROR, TAG, "Failed to allocate Payload");
+ OIC_LOG(ERROR, TAG, "Failed to allocate Payload");
stackRet = OC_STACK_ERROR;
}
else
// Send the response
if (OCDoResponse(&response) != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "Error sending response");
+ OIC_LOG(ERROR, TAG, "Error sending response");
stackRet = OC_STACK_ERROR;
}
}
{
if (!outPayload || !size)
{
- OC_LOG(ERROR, TAG, "Invalid parameters.");
+ OIC_LOG(ERROR, TAG, "Invalid parameters.");
return OC_STACK_INVALID_PARAM;
}
cborEncoderResult = cbor_encoder_create_map(&encoder, &map, CborIndefiniteLength);
if (CborNoError != cborEncoderResult)
{
- OC_LOG(ERROR, TAG, "Failed creating discovery map.");
+ OIC_LOG(ERROR, TAG, "Failed creating discovery map.");
goto cbor_error;
}
if (CborNoError != ConditionalAddTextStringToMap(&map, OC_RSRVD_DEVICE_NAME,
sizeof(OC_RSRVD_DEVICE_NAME) - 1, (char *)rdPayload->rdDiscovery->n.deviceName))
{
- OC_LOG(ERROR, TAG, "Failed setting OC_RSRVD_DEVICE_NAME.");
+ OIC_LOG(ERROR, TAG, "Failed setting OC_RSRVD_DEVICE_NAME.");
goto cbor_error;
}
if (CborNoError != ConditionalAddTextStringToMap(&map, OC_RSRVD_DEVICE_ID,
sizeof(OC_RSRVD_DEVICE_ID) - 1, (char *)rdPayload->rdDiscovery->di.id))
{
- OC_LOG(ERROR, TAG, "Failed setting OC_RSRVD_DEVICE_ID.");
+ OIC_LOG(ERROR, TAG, "Failed setting OC_RSRVD_DEVICE_ID.");
goto cbor_error;
}
uint64_t sel = (uint8_t) rdPayload->rdDiscovery->sel;
if (CborNoError != ConditionalAddIntToMap(&map, OC_RSRVD_RD_DISCOVERY_SEL,
sizeof(OC_RSRVD_RD_DISCOVERY_SEL) - 1, &sel))
{
- OC_LOG(ERROR, TAG, "Failed setting OC_RSRVD_RD_DISCOVERY_SEL.");
+ OIC_LOG(ERROR, TAG, "Failed setting OC_RSRVD_RD_DISCOVERY_SEL.");
goto cbor_error;
}
cborEncoderResult = cbor_encoder_close_container(&encoder, &map);
if (CborNoError != cborEncoderResult)
{
- OC_LOG(ERROR, TAG, "Failed closing discovery map.");
+ OIC_LOG(ERROR, TAG, "Failed closing discovery map.");
goto cbor_error;
}
}
cborEncoderResult = cbor_encoder_create_array(&encoder, &colArray, CborIndefiniteLength);
if (CborNoError != cborEncoderResult)
{
- OC_LOG(ERROR, TAG, "Failed creating collection array.");
+ OIC_LOG(ERROR, TAG, "Failed creating collection array.");
goto cbor_error;
}
{
if (OC_STACK_OK != OCTagsPayloadToCbor(rdPublish->tags, &colArray))
{
- OC_LOG(ERROR, TAG, "Failed creating tags payload.");
+ OIC_LOG(ERROR, TAG, "Failed creating tags payload.");
goto cbor_error;
}
if (OC_STACK_OK != OCLinksPayloadToCbor(rdPublish->setLinks, &colArray))
{
- OC_LOG(ERROR, TAG, "Failed creating links payload.");
+ OIC_LOG(ERROR, TAG, "Failed creating links payload.");
goto cbor_error;
}
rdPublish = rdPublish->next;
cborEncoderResult = cbor_encoder_close_container(&encoder, &colArray);
if (CborNoError != cborEncoderResult)
{
- OC_LOG(ERROR, TAG, "Failed closing collection array.");
+ OIC_LOG(ERROR, TAG, "Failed closing collection array.");
goto cbor_error;
}
}
cborEncoderResult = cbor_encoder_create_map(&encoder, &map, CborIndefiniteLength);
if (CborNoError != cborEncoderResult)
{
- OC_LOG(ERROR, TAG, "Failed creating discovery map.");
+ OIC_LOG(ERROR, TAG, "Failed creating discovery map.");
goto cbor_error;
}
cborEncoderResult = cbor_encoder_close_container(&encoder, &map);
if (CborNoError != cborEncoderResult)
{
- OC_LOG(ERROR, TAG, "Failed creating discovery map.");
+ OIC_LOG(ERROR, TAG, "Failed creating discovery map.");
goto cbor_error;
}
}
CborError cborEncoderResult = cbor_encoder_create_map(setMap, &tagsMap, CborIndefiniteLength);
if (CborNoError != cborEncoderResult)
{
- OC_LOG(ERROR, TAG, "Failed creating TAGS map.");
+ OIC_LOG(ERROR, TAG, "Failed creating TAGS map.");
return OC_STACK_ERROR;
}
if (CborNoError != ConditionalAddTextStringToMap(&tagsMap, OC_RSRVD_DEVICE_NAME,
sizeof(OC_RSRVD_DEVICE_NAME) - 1, (char *)tags->n.deviceName))
{
- OC_LOG(ERROR, TAG, "Failed adding OC_RSRVD_DEVICE_NAME in TAGS map.");
+ OIC_LOG(ERROR, TAG, "Failed adding OC_RSRVD_DEVICE_NAME in TAGS map.");
return OC_STACK_ERROR;
}
if (CborNoError != ConditionalAddTextStringToMap(&tagsMap, OC_RSRVD_DEVICE_ID,
sizeof(OC_RSRVD_DEVICE_ID) - 1, (char *)tags->di.id))
{
- OC_LOG(ERROR, TAG, "Failed adding OC_RSRVD_DEVICE_ID in TAGS map.");
+ OIC_LOG(ERROR, TAG, "Failed adding OC_RSRVD_DEVICE_ID in TAGS map.");
return OC_STACK_ERROR;
}
if (CborNoError != ConditionalAddTextStringToMap(&tagsMap, OC_RSRVD_RTS,
sizeof(OC_RSRVD_RTS) - 1, (char *)tags->rts))
{
- OC_LOG(ERROR, TAG, "Failed adding OC_RSRVD_RTS in TAGS map.");
+ OIC_LOG(ERROR, TAG, "Failed adding OC_RSRVD_RTS in TAGS map.");
return OC_STACK_ERROR;
}
if (CborNoError != ConditionalAddTextStringToMap(&tagsMap, OC_RSRVD_DREL,
sizeof(OC_RSRVD_DREL) - 1, (char *)tags->drel))
{
- OC_LOG(ERROR, TAG, "Failed adding OC_RSRVD_DREL in TAGS map.");
+ OIC_LOG(ERROR, TAG, "Failed adding OC_RSRVD_DREL in TAGS map.");
return OC_STACK_ERROR;
}
if (CborNoError != ConditionalAddTextStringToMap(&tagsMap, OC_RSRVD_BASE_URI,
sizeof(OC_RSRVD_BASE_URI) - 1, (char *)tags->baseURI))
{
- OC_LOG(ERROR, TAG, "Failed adding OC_RSRVD_BASE_URI in TAGS map.");
+ OIC_LOG(ERROR, TAG, "Failed adding OC_RSRVD_BASE_URI in TAGS map.");
return OC_STACK_ERROR;
}
uint64_t temp = (uint64_t)tags->bitmap;
if (CborNoError != ConditionalAddIntToMap(&tagsMap, OC_RSRVD_BITMAP,
sizeof(OC_RSRVD_BITMAP) - 1, &temp))
{
- OC_LOG(ERROR, TAG, "Failed adding OC_RSRVD_BITMAP in TAGS map.");
+ OIC_LOG(ERROR, TAG, "Failed adding OC_RSRVD_BITMAP in TAGS map.");
return OC_STACK_ERROR;
}
temp = (uint64_t)tags->port;
if (CborNoError != ConditionalAddIntToMap(&tagsMap, OC_RSRVD_HOSTING_PORT,
sizeof(OC_RSRVD_HOSTING_PORT) - 1, &temp))
{
- OC_LOG(ERROR, TAG, "Failed adding OC_RSRVD_HOSTING_PORT in TAGS map.");
+ OIC_LOG(ERROR, TAG, "Failed adding OC_RSRVD_HOSTING_PORT in TAGS map.");
return OC_STACK_ERROR;
}
temp = (uint64_t)tags->ins;
if (CborNoError != ConditionalAddIntToMap(&tagsMap, OC_RSRVD_INS,
sizeof(OC_RSRVD_INS) - 1, &temp))
{
- OC_LOG(ERROR, TAG, "Failed adding OC_RSRVD_INS in TAGS map.");
+ OIC_LOG(ERROR, TAG, "Failed adding OC_RSRVD_INS in TAGS map.");
return OC_STACK_ERROR;
}
temp = (uint64_t)tags->ttl;
if (CborNoError != ConditionalAddIntToMap(&tagsMap, OC_RSRVD_TTL,
sizeof(OC_RSRVD_TTL) - 1, &temp))
{
- OC_LOG(ERROR, TAG, "Failed adding OC_RSRVD_TTL in TAGS map.");
+ OIC_LOG(ERROR, TAG, "Failed adding OC_RSRVD_TTL in TAGS map.");
return OC_STACK_ERROR;
}
cborEncoderResult = cbor_encoder_close_container(setMap, &tagsMap);
if (CborNoError != cborEncoderResult)
{
- OC_LOG(ERROR, TAG, "Failed closing TAGS map.");
+ OIC_LOG(ERROR, TAG, "Failed closing TAGS map.");
return OC_STACK_ERROR;
}
return OC_STACK_OK;
cborEncoderResult = cbor_encoder_create_array(setMap, &linksArray, CborIndefiniteLength);
if (CborNoError != cborEncoderResult)
{
- OC_LOG(ERROR, TAG, "Failed creating LINKS array.");
+ OIC_LOG(ERROR, TAG, "Failed creating LINKS array.");
return OC_STACK_ERROR;
}
while (rtPtr)
CborIndefiniteLength);
if (CborNoError != cborEncoderResult)
{
- OC_LOG(ERROR, TAG, "Failed creating LINKS map.");
+ OIC_LOG(ERROR, TAG, "Failed creating LINKS map.");
return OC_STACK_ERROR;
}
if (CborNoError != ConditionalAddTextStringToMap(&linksMap, OC_RSRVD_HREF,
sizeof(OC_RSRVD_HREF) - 1, rtPtr->href))
{
- OC_LOG(ERROR, TAG, "Failed adding OC_RSRVD_HREF in LINKS map.");
+ OIC_LOG(ERROR, TAG, "Failed adding OC_RSRVD_HREF in LINKS map.");
return OC_STACK_ERROR;
}
if (CborNoError != ConditionalAddTextStringToMap(&linksMap, OC_RSRVD_REL,
sizeof(OC_RSRVD_REL) - 1, rtPtr->rel))
{
- OC_LOG(ERROR, TAG, "Failed adding OC_RSRVD_REL in LINKS map.");
+ OIC_LOG(ERROR, TAG, "Failed adding OC_RSRVD_REL in LINKS map.");
return OC_STACK_ERROR;
}
if (CborNoError != ConditionalAddTextStringToMap(&linksMap, OC_RSRVD_TITLE,
sizeof(OC_RSRVD_TITLE) - 1, rtPtr->title))
{
- OC_LOG(ERROR, TAG, "Failed adding OC_RSRVD_TITLE in LINKS map.");
+ OIC_LOG(ERROR, TAG, "Failed adding OC_RSRVD_TITLE in LINKS map.");
return OC_STACK_ERROR;
}
if (CborNoError != ConditionalAddTextStringToMap(&linksMap, OC_RSRVD_URI,
sizeof(OC_RSRVD_URI) - 1, rtPtr->uri))
{
- OC_LOG(ERROR, TAG, "Failed adding OC_RSRVD_URI in LINKS map.");
+ OIC_LOG(ERROR, TAG, "Failed adding OC_RSRVD_URI in LINKS map.");
return OC_STACK_ERROR;
}
if (CborNoError != AddStringLLToMap(&linksMap, OC_RSRVD_RESOURCE_TYPE,
sizeof(OC_RSRVD_RESOURCE_TYPE) - 1, rtPtr->rt))
{
- OC_LOG(ERROR, TAG, "Failed adding OC_RSRVD_RESOURCE_TYPE in LINKS map.");
+ OIC_LOG(ERROR, TAG, "Failed adding OC_RSRVD_RESOURCE_TYPE in LINKS map.");
return OC_STACK_ERROR;
}
if (CborNoError != AddStringLLToMap(&linksMap, OC_RSRVD_INTERFACE,
sizeof(OC_RSRVD_INTERFACE) - 1, rtPtr->itf))
{
- OC_LOG(ERROR, TAG, "Failed adding OC_RSRVD_INTERFACE in LINKS map.");
+ OIC_LOG(ERROR, TAG, "Failed adding OC_RSRVD_INTERFACE in LINKS map.");
return OC_STACK_ERROR;
}
if (CborNoError != AddStringLLToMap(&linksMap, OC_RSRVD_MEDIA_TYPE,
sizeof(OC_RSRVD_MEDIA_TYPE) - 1, rtPtr->mt))
{
- OC_LOG(ERROR, TAG, "Failed adding OC_RSRVD_MEDIA_TYPE in LINKS map.");
+ OIC_LOG(ERROR, TAG, "Failed adding OC_RSRVD_MEDIA_TYPE in LINKS map.");
return OC_STACK_ERROR;
}
uint64_t temp = (uint64_t)rtPtr->ins;
if (CborNoError != ConditionalAddIntToMap(&linksMap, OC_RSRVD_INS,
sizeof(OC_RSRVD_INS) - 1, &temp))
{
- OC_LOG(ERROR, TAG, "Failed adding OC_RSRVD_INS in LINKS map.");
+ OIC_LOG(ERROR, TAG, "Failed adding OC_RSRVD_INS in LINKS map.");
return OC_STACK_ERROR;
}
cborEncoderResult = cbor_encoder_close_container(&linksArray, &linksMap);
if (CborNoError != cborEncoderResult)
{
- OC_LOG(ERROR, TAG, "Failed closing LINKS map.");
+ OIC_LOG(ERROR, TAG, "Failed closing LINKS map.");
return OC_STACK_ERROR;
}
rtPtr = rtPtr->next;
cborEncoderResult = cbor_encoder_close_container(setMap, &linksArray);
if (CborNoError != cborEncoderResult)
{
- OC_LOG(ERROR, TAG, "Failed closing LINKS array.");
+ OIC_LOG(ERROR, TAG, "Failed closing LINKS array.");
return OC_STACK_ERROR;;
}
return OC_STACK_OK;
// Move from tags payload to links array.
if (CborNoError != cbor_value_advance(rdCBORPayload))
{
- OC_LOG(DEBUG, TAG, "Failed advancing from tags payload to links.");
+ OIC_LOG(DEBUG, TAG, "Failed advancing from tags payload to links.");
OCFreeLinksResource(linksPayload);
OCFreeTagsResource(tagsPayload);
goto cbor_error;
goto cbor_error;
}
}
- OC_LOG_PAYLOAD(DEBUG, (OCPayload *) rdPayload);
+ OIC_LOG_PAYLOAD(DEBUG, (OCPayload *) rdPayload);
*outPayload = (OCPayload *)rdPayload;
return OC_STACK_OK;
no_memory:
- OC_LOG(ERROR, TAG, "Failed allocating memory.");
+ OIC_LOG(ERROR, TAG, "Failed allocating memory.");
OCRDPayloadDestroy(rdPayload);
return OC_STACK_NO_MEMORY;
cborFindResult = cbor_value_dup_text_string(&curVal, value, &len, NULL);
if (CborNoError != cborFindResult)
{
- OC_LOG_V(ERROR, TAG, "Failed finding value for tag %s .", tags);
+ OIC_LOG_V(ERROR, TAG, "Failed finding value for tag %s .", tags);
return cborFindResult;
}
}
cborFindResult = cbor_value_get_uint64(&curVal, value);
if (CborNoError != cborFindResult)
{
- OC_LOG_V(ERROR, TAG, "Failed finding value for tag %s .", tags);
+ OIC_LOG_V(ERROR, TAG, "Failed finding value for tag %s .", tags);
return cborFindResult;
}
}
CborError cborFindResult = cbor_value_enter_container(linksArray, &linksMap);
if (CborNoError != cborFindResult)
{
- OC_LOG(ERROR, TAG, "Failed enter links map");
+ OIC_LOG(ERROR, TAG, "Failed enter links map");
return OC_STACK_ERROR;
}
OCLinksPayload *setLinks = (OCLinksPayload *)OICCalloc(1, sizeof(OCLinksPayload));
if (!setLinks)
{
- OC_LOG(ERROR, TAG, "Failed allocating memory.");
+ OIC_LOG(ERROR, TAG, "Failed allocating memory.");
OCFreeLinksResource(*linksPayload);
return OC_STACK_NO_MEMORY;
}
cborFindResult = cbor_value_advance(&linksMap);
if (CborNoError != cborFindResult)
{
- OC_LOG(ERROR, TAG, "Failed advancing links map");
+ OIC_LOG(ERROR, TAG, "Failed advancing links map");
OCFreeLinksResource(*linksPayload);
OCFreeLinksResource(setLinks);
return OC_STACK_ERROR;
return tags;
memory_allocation_failed:
- OC_LOG(ERROR, TAG, "Memory allocation failed.");
+ OIC_LOG(ERROR, TAG, "Memory allocation failed.");
OCFreeTagsResource(tags);
return NULL;
}
OCLinksPayload *links = (OCLinksPayload *)OICCalloc(1, sizeof(OCLinksPayload));
if (!links)
{
- OC_LOG(ERROR, TAG, "Failed allocating memory.");
+ OIC_LOG(ERROR, TAG, "Failed allocating memory.");
return NULL;
}
if (href)
return links;
memory_allocation_failed:
- OC_LOG(ERROR, TAG, "Memory allocation failed.");
+ OIC_LOG(ERROR, TAG, "Memory allocation failed.");
OCFreeLinksResource(links);
return NULL;
}
OCResourceCollectionPayload *pl = (OCResourceCollectionPayload *)OICCalloc(1, sizeof(OCResourceCollectionPayload));
if(!pl)
{
- OC_LOG(ERROR, TAG, "Failed allocating memory for the OCResourceCollectionPayload.");
+ OIC_LOG(ERROR, TAG, "Failed allocating memory for the OCResourceCollectionPayload.");
return NULL;
}
pl->tags = tags;
{
if (tags->n.deviceName)
{
- OC_LOG_V(level, TAG, " Device Name : %s ",tags->n.deviceName);
+ OIC_LOG_V(level, TAG, " Device Name : %s ",tags->n.deviceName);
}
if (tags->baseURI)
{
- OC_LOG_V(level, TAG, " Base URI : %s ",tags->baseURI);
+ OIC_LOG_V(level, TAG, " Base URI : %s ",tags->baseURI);
}
- OC_LOG_V(level, TAG, " Device ID : %s ",tags->di.id);
- OC_LOG_V(level, TAG, " Bitmap : %d ",tags->bitmap);
- OC_LOG_V(level, TAG, " Port : %d ",tags->port);
- OC_LOG_V(level, TAG, " Ins : %d ",tags->ins);
- OC_LOG_V(level, TAG, " Ttl : %d ",tags->ttl);
+ OIC_LOG_V(level, TAG, " Device ID : %s ",tags->di.id);
+ OIC_LOG_V(level, TAG, " Bitmap : %d ",tags->bitmap);
+ OIC_LOG_V(level, TAG, " Port : %d ",tags->port);
+ OIC_LOG_V(level, TAG, " Ins : %d ",tags->ins);
+ OIC_LOG_V(level, TAG, " Ttl : %d ",tags->ttl);
if (tags->rts)
{
- OC_LOG_V(level, TAG, " RTS : %s ",tags->rts);
+ OIC_LOG_V(level, TAG, " RTS : %s ",tags->rts);
}
if (tags->drel)
{
- OC_LOG_V(level, TAG, " DREL : %s ",tags->drel);
+ OIC_LOG_V(level, TAG, " DREL : %s ",tags->drel);
}
}
else
{
if (links->href)
{
- OC_LOG_V(level, TAG, " href: %s ",links->href);
+ OIC_LOG_V(level, TAG, " href: %s ",links->href);
}
- OC_LOG(level, TAG, " RT: ");
+ OIC_LOG(level, TAG, " RT: ");
OCStringLL *rt = links->rt;
while (rt)
{
if (rt->value)
{
- OC_LOG_V(level, TAG, " %s", rt->value);
+ OIC_LOG_V(level, TAG, " %s", rt->value);
}
rt = rt->next;
}
- OC_LOG(level, TAG, " IF: ");
+ OIC_LOG(level, TAG, " IF: ");
OCStringLL *itf = links->itf;
while (itf)
{
if (itf->value)
{
- OC_LOG_V(level, TAG, " %s", itf->value);
+ OIC_LOG_V(level, TAG, " %s", itf->value);
}
itf = itf->next;
}
- OC_LOG(level, TAG, " MT: ");
+ OIC_LOG(level, TAG, " MT: ");
OCStringLL *mt = links->mt;
while (mt)
{
if (mt->value)
{
- OC_LOG_V(level, TAG, " %s", mt->value);
+ OIC_LOG_V(level, TAG, " %s", mt->value);
}
mt = mt->next;
}
- OC_LOG_V(level, TAG, " INS: %d", links->ins);
- OC_LOG_V(level, TAG, " OBS: %d", links->obs);
+ OIC_LOG_V(level, TAG, " INS: %d", links->ins);
+ OIC_LOG_V(level, TAG, " OBS: %d", links->obs);
if (links->rel)
{
- OC_LOG_V(level, TAG, " REL: %s", links->rel);
+ OIC_LOG_V(level, TAG, " REL: %s", links->rel);
}
if (links->title)
{
- OC_LOG_V(level, TAG, " TITLE: %s", links->title);
+ OIC_LOG_V(level, TAG, " TITLE: %s", links->title);
}
if (links->uri)
{
- OC_LOG_V(level, TAG, " URI: %s", links->uri);
+ OIC_LOG_V(level, TAG, " URI: %s", links->uri);
}
links = links->next;
}
void EXPECT_EQ(int a, int b) {
if (a == b) {
- OC_LOG(INFO, TAG, "PASS");
+ OIC_LOG(INFO, TAG, "PASS");
} else {
- OC_LOG(ERROR, TAG, "**FAIL**");
+ OIC_LOG(ERROR, TAG, "**FAIL**");
}
}
void EXPECT_STREQ(const char *a, const char *b) {
if (strcmp(a, b) == 0) {
- OC_LOG(INFO, TAG, "PASS");
+ OIC_LOG(INFO, TAG, "PASS");
} else {
- OC_LOG(ERROR, TAG, "**FAIL**");
+ OIC_LOG(ERROR, TAG, "**FAIL**");
}
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
extern "C" void asyncDoResourcesCallback(OCStackResult result, OCRepresentationHandle representation) {
- OC_LOG(INFO, TAG, "Entering asyncDoResourcesCallback");
+ OIC_LOG(INFO, TAG, "Entering asyncDoResourcesCallback");
EXPECT_EQ(OC_STACK_OK, result);
OCResource *resource = (OCResource *)representation;
- OC_LOG_V(INFO, TAG, "URI = %s", resource->uri);
+ OIC_LOG_V(INFO, TAG, "URI = %s", resource->uri);
EXPECT_STREQ(SERVICE_URI, resource->uri);
}
void EXPECT_EQ(int a, int b) {
if (a == b) {
- OC_LOG(INFO, TAG, ("PASS"));
+ OIC_LOG(INFO, TAG, ("PASS"));
} else {
- OC_LOG(ERROR, TAG, ("FAIL"));
+ OIC_LOG(ERROR, TAG, ("FAIL"));
}
}
void EXPECT_STREQ(const char *a, const char *b) {
if (strcmp(a, b) == 0) {
- OC_LOG(INFO, TAG, ("PASS"));
+ OIC_LOG(INFO, TAG, ("PASS"));
} else {
- OC_LOG(ERROR, TAG, ("FAIL"));
+ OIC_LOG(ERROR, TAG, ("FAIL"));
}
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
#if 0 // Turn off logger tests
void test0() {
- OC_LOG(INFO, tag, msg);
+ OIC_LOG(INFO, tag, msg);
}
void test1() {
- OC_LOG(INFO, 0, msg);
+ OIC_LOG(INFO, 0, msg);
}
void test2() {
- OC_LOG(INFO, tag, 0);
+ OIC_LOG(INFO, tag, 0);
}
void test3() {
- OC_LOG(INFO, 0, 0);
+ OIC_LOG(INFO, 0, 0);
}
void test4() {
- OC_LOG(DEBUG, tag, debugMsg);
- OC_LOG(INFO, tag, infoMsg);
- OC_LOG(WARNING, tag, warningMsg);
- OC_LOG(ERROR, tag, errorMsg);
- OC_LOG(FATAL, tag, fatalMsg);
+ OIC_LOG(DEBUG, tag, debugMsg);
+ OIC_LOG(INFO, tag, infoMsg);
+ OIC_LOG(WARNING, tag, warningMsg);
+ OIC_LOG(ERROR, tag, errorMsg);
+ OIC_LOG(FATAL, tag, fatalMsg);
}
void test5() {
- OC_LOG(DEBUG, tag, multiLineMsg);
+ OIC_LOG(DEBUG, tag, multiLineMsg);
}
for (int i = 0; i < (int)(sizeof buffer); i++) {
buffer[i] = i;
}
- OC_LOG_BUFFER(DEBUG, tag, buffer, sizeof buffer);
+ OIC_LOG_BUFFER(DEBUG, tag, buffer, sizeof buffer);
// Log buffer, 128 bytes is a good boundary (8 rows of 16 values)
uint8_t buffer1[128];
for (int i = 0; i < (int)(sizeof buffer1); i++) {
buffer1[i] = i;
}
- OC_LOG_BUFFER(DEBUG, tag, buffer1, sizeof buffer1);
+ OIC_LOG_BUFFER(DEBUG, tag, buffer1, sizeof buffer1);
// 1 below 128 byte boundary
uint8_t buffer2[127];
for (int i = 0; i < (int)(sizeof buffer2); i++) {
buffer2[i] = i;
}
- OC_LOG_BUFFER(DEBUG, tag, buffer2, sizeof buffer2);
+ OIC_LOG_BUFFER(DEBUG, tag, buffer2, sizeof buffer2);
// 1 above 128 byte boundary
uint8_t buffer3[129];
for (int i = 0; i < (int)(sizeof buffer3); i++) {
buffer3[i] = i;
}
- OC_LOG_BUFFER(DEBUG, tag, buffer3, sizeof buffer3);
+ OIC_LOG_BUFFER(DEBUG, tag, buffer3, sizeof buffer3);
}
#endif
extern "C" void asyncDoResourcesCallback(OCStackResult result, OCRepresentationHandle representation) {
- OC_LOG(INFO, TAG, ("Entering asyncDoResourcesCallback"));
+ OIC_LOG(INFO, TAG, ("Entering asyncDoResourcesCallback"));
EXPECT_EQ(OC_STACK_OK, result);
OCResource *resource = (OCResource *)representation;
- OC_LOG_V(INFO, TAG, "URI = %s", resource->uri);
+ OIC_LOG_V(INFO, TAG, "URI = %s", resource->uri);
EXPECT_STREQ(SERVICE_URI, resource->uri);
}
void test0() {
- OC_LOG(INFO, TAG, ("test0"));
+ OIC_LOG(INFO, TAG, ("test0"));
EXPECT_EQ(OC_STACK_OK, OCInit(0, 5683, OC_SERVER));
}
void test1() {
- OC_LOG(INFO, TAG, ("test1"));
+ OIC_LOG(INFO, TAG, ("test1"));
EXPECT_EQ(OC_STACK_OK, OCInit("127.0.0.1", 0, OC_SERVER));
}
void test2() {
- OC_LOG(INFO, TAG, ("test2"));
+ OIC_LOG(INFO, TAG, ("test2"));
EXPECT_EQ(OC_STACK_OK, OCInit(0, 0, OC_SERVER));
}
void test3() {
- OC_LOG(INFO, TAG, ("test3"));
+ OIC_LOG(INFO, TAG, ("test3"));
EXPECT_EQ(OC_STACK_ERROR, OCInit(0, 0, (OCMode)10));
}
void test4() {
- OC_LOG(INFO, TAG, ("test4"));
+ OIC_LOG(INFO, TAG, ("test4"));
EXPECT_EQ(OC_STACK_OK, OCInit("127.0.0.1", 5683, OC_CLIENT));
EXPECT_EQ(OC_STACK_OK, OCInit("127.0.0.1", 5683, OC_SERVER));
EXPECT_EQ(OC_STACK_OK, OCInit("127.0.0.1", 5683, OC_CLIENT_SERVER));
}
void test5() {
- OC_LOG(INFO, TAG, ("test5"));
+ OIC_LOG(INFO, TAG, ("test5"));
EXPECT_EQ(OC_STACK_OK, OCInit("127.0.0.1", 5683, OC_CLIENT));
EXPECT_EQ(OC_STACK_OK, OCDoResource(OC_REST_GET, OC_EXPLICIT_DEVICE_DISCOVERY_URI, 0, 0, asyncDoResourcesCallback), NULL, 0);
EXPECT_EQ(OC_STACK_OK, OCUpdateResources(SERVICE_URI));
}
void test6() {
- OC_LOG(INFO, TAG, ("test6"));
+ OIC_LOG(INFO, TAG, ("test6"));
EXPECT_EQ(OC_STACK_OK, OCInit("127.0.0.1", 5683, OC_CLIENT));
EXPECT_EQ(OC_STACK_OK, OCStop());
EXPECT_EQ(OC_STACK_ERROR, OCStop());
}
void test7() {
- OC_LOG(INFO, TAG, ("test7"));
+ OIC_LOG(INFO, TAG, ("test7"));
EXPECT_EQ(OC_STACK_OK, OCInit("127.0.0.1", 5683, OC_CLIENT));
EXPECT_EQ(OC_STACK_OK, OCDoResource(OC_REST_GET, OC_EXPLICIT_DEVICE_DISCOVERY_URI, 0, 0, asyncDoResourcesCallback), NULL, 0);
EXPECT_EQ(OC_STACK_INVALID_URI, OCUpdateResources(0));
void setup()
{
// Add your initialization code here
- OC_LOG_INIT();
+ OIC_LOG_INIT();
test0();
delay(2000);
#define TAG ("ocserver")
void ocInitialize () {
- OC_LOG(DEBUG, TAG, ("IP addr is:"));
- OC_LOG_BUFFER(INFO, TAG, (uint8_t*)ipAddr, sizeof(ipAddr));
+ OIC_LOG(DEBUG, TAG, ("IP addr is:"));
+ OIC_LOG_BUFFER(INFO, TAG, (uint8_t*)ipAddr, sizeof(ipAddr));
delay(2000);
OCInit (NULL, 0, OC_SERVER);
}
// This is a function called back when a device is discovered
OCStackApplicationResult applicationDiscoverCB(
OCClientResponse * clientResponse) {
- OC_LOG(INFO, TAG, "Entering applicationDiscoverCB (Application Layer CB)");
- OC_LOG_V(INFO, TAG, "Device =============> Discovered %s @ %s:%d",
+ OIC_LOG(INFO, TAG, "Entering applicationDiscoverCB (Application Layer CB)");
+ OIC_LOG_V(INFO, TAG, "Device =============> Discovered %s @ %s:%d",
clientResponse->resJSONPayload,
clientResponse->devAddr.addr,
clientResponse->devAddr.port);
}
int main() {
- OC_LOG_V(INFO, TAG, "Starting occlient on address %s",addr);
+ OIC_LOG_V(INFO, TAG, "Starting occlient on address %s",addr);
/* Initialize OCStack*/
if (OCInit(NULL, 0, OC_CLIENT) != OC_STACK_OK) {
- OC_LOG(ERROR, TAG, "OCStack init error");
+ OIC_LOG(ERROR, TAG, "OCStack init error");
return 0;
}
strcpy(szQueryUri, OC_EXPLICIT_DEVICE_DISCOVERY_URI);
if (OCDoResource(NULL, OC_REST_GET, szQueryUri, 0, 0, OC_LOW_QOS,
0, 0, 0) != OC_STACK_OK) {
- OC_LOG(ERROR, TAG, "OCStack resource error");
+ OIC_LOG(ERROR, TAG, "OCStack resource error");
return 0;
}
// Break from loop with Ctrl+C
- OC_LOG(INFO, TAG, "Entering occlient main loop...");
+ OIC_LOG(INFO, TAG, "Entering occlient main loop...");
signal(SIGINT, handleSigInt);
while (!gQuitFlag) {
if (OCProcess() != OC_STACK_OK) {
- OC_LOG(ERROR, TAG, "OCStack process error");
+ OIC_LOG(ERROR, TAG, "OCStack process error");
return 0;
}
sleep(1);
- }OC_LOG(INFO, TAG, "Exiting occlient main loop...");
+ }
+
+ OIC_LOG(INFO, TAG, "Exiting occlient main loop...");
if (OCStop() != OC_STACK_OK) {
- OC_LOG(ERROR, TAG, "OCStack stop error");
+ OIC_LOG(ERROR, TAG, "OCStack stop error");
}
return 0;
}
int main() {
- OC_LOG_V(INFO, TAG, "Starting ocserver on address %s:%d",addr,port);
+ OIC_LOG_V(INFO, TAG, "Starting ocserver on address %s:%d",addr,port);
if (OCInit(NULL, 0, OC_SERVER) != OC_STACK_OK) {
- OC_LOG(ERROR, TAG, "OCStack init error");
+ OIC_LOG(ERROR, TAG, "OCStack init error");
return 0;
}
*/
if(createLightResource() != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, "OCStack cannot create resource...");
+ OIC_LOG(ERROR, TAG, "OCStack cannot create resource...");
}
// Break from loop with Ctrl-C
- OC_LOG(INFO, TAG, "Entering ocserver main loop...");
+ OIC_LOG(INFO, TAG, "Entering ocserver main loop...");
signal(SIGINT, handleSigInt);
while (!gQuitFlag) {
if (OCProcess() != OC_STACK_OK) {
- OC_LOG(ERROR, TAG, "OCStack process error");
+ OIC_LOG(ERROR, TAG, "OCStack process error");
return 0;
}
sleep(1);
}
- OC_LOG(INFO, TAG, "Exiting ocserver main loop...");
+ OIC_LOG(INFO, TAG, "Exiting ocserver main loop...");
if (OCStop() != OC_STACK_OK) {
- OC_LOG(ERROR, TAG, "OCStack process error");
+ OIC_LOG(ERROR, TAG, "OCStack process error");
}
return 0;
extern "C" OCStackApplicationResult asyncDoResourcesCallback(void* ctx,
OCDoHandle /*handle*/, OCClientResponse * clientResponse)
{
- OC_LOG(INFO, TAG, "Entering asyncDoResourcesCallback");
+ OIC_LOG(INFO, TAG, "Entering asyncDoResourcesCallback");
EXPECT_EQ(OC_STACK_OK, clientResponse->result);
if(ctx == (void*)DEFAULT_CONTEXT_VALUE) {
- OC_LOG_V(INFO, TAG, "Callback Context recvd successfully");
+ OIC_LOG_V(INFO, TAG, "Callback Context recvd successfully");
}
- OC_LOG_V(INFO, TAG, "result = %d", clientResponse->result);
+ OIC_LOG_V(INFO, TAG, "result = %d", clientResponse->result);
return OC_STACK_KEEP_TRANSACTION;
}
OCEntityHandlerRequest * /*entityHandlerRequest*/,
void* /*callbackParam*/)
{
- OC_LOG(INFO, TAG, "Entering entityHandler");
+ OIC_LOG(INFO, TAG, "Entering entityHandler");
return OC_EH_OK;
}
//-----------------------------------------------------------------------------
void InitStack(OCMode mode)
{
- OC_LOG(INFO, TAG, "Entering InitStack");
+ OIC_LOG(INFO, TAG, "Entering InitStack");
EXPECT_EQ(OC_STACK_OK, OCInit(NULL, 0, mode));
- OC_LOG(INFO, TAG, "Leaving InitStack");
+ OIC_LOG(INFO, TAG, "Leaving InitStack");
}
uint8_t InitNumExpectedResources()
OCCallbackData cbData;
OCDoHandle handle;
- OC_LOG(INFO, TAG, "Starting DoResourceDeviceDiscovery test ");
+ OIC_LOG(INFO, TAG, "Starting DoResourceDeviceDiscovery test ");
InitStack(OC_CLIENT);
/* Start a discovery query*/
OCCallbackData cbData;
OCDoHandle handle;
- OC_LOG(INFO, TAG, "Starting UpdateResourceNullURI test");
+ OIC_LOG(INFO, TAG, "Starting UpdateResourceNullURI test");
InitStack(OC_CLIENT);
/* Start a discovery query*/
TEST(StackResource, CreateResourceBadParams)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting CreateResourceBadParams test");
+ OIC_LOG(INFO, TAG, "Starting CreateResourceBadParams test");
InitStack(OC_SERVER);
OCResourceHandle handle;
TEST(StackResource, CreateResourceBadUri)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting CreateResourceBadUri test");
+ OIC_LOG(INFO, TAG, "Starting CreateResourceBadUri test");
InitStack(OC_SERVER);
const char *uri65 = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKL";
TEST(StackResource, CreateResourceSuccess)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting CreateResourceSuccess test");
+ OIC_LOG(INFO, TAG, "Starting CreateResourceSuccess test");
InitStack(OC_SERVER);
OCResourceHandle handle;
TEST(StackResource, CreateResourceSuccessWithResourcePolicyPropNone)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting CreateResourceSuccessWithResourcePolicyPropNone test");
+ OIC_LOG(INFO, TAG, "Starting CreateResourceSuccessWithResourcePolicyPropNone test");
InitStack(OC_SERVER);
OCResourceHandle handle;
TEST(StackResource, CreateResourceWithClientStackMode)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting CreateResourceSuccess test");
+ OIC_LOG(INFO, TAG, "Starting CreateResourceSuccess test");
InitStack(OC_CLIENT);
OCResourceHandle handle;
TEST(StackResource, CreateResourceFailDuplicateUri)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting CreateResourceFailDuplicateUri test");
+ OIC_LOG(INFO, TAG, "Starting CreateResourceFailDuplicateUri test");
InitStack(OC_SERVER);
OCResourceHandle handle;
TEST(StackResource, CreateResourceMultipleResources)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting CreateResourceMultipleResources test");
+ OIC_LOG(INFO, TAG, "Starting CreateResourceMultipleResources test");
InitStack(OC_SERVER);
OCResourceHandle handle1;
TEST(StackResource, CreateResourceBadResoureType)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting CreateResourceBadResoureType test");
+ OIC_LOG(INFO, TAG, "Starting CreateResourceBadResoureType test");
InitStack(OC_SERVER);
OCResourceHandle handle;
TEST(StackResource, CreateResourceGoodResourceType)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting CreateResourceGoodResourceType test");
+ OIC_LOG(INFO, TAG, "Starting CreateResourceGoodResourceType test");
InitStack(OC_SERVER);
OCResourceHandle handle;
TEST(StackResource, ResourceTypeName)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting ResourceTypeName test");
+ OIC_LOG(INFO, TAG, "Starting ResourceTypeName test");
InitStack(OC_SERVER);
OCResourceHandle handle;
TEST(StackResource, ResourceTypeAttrRepresentation)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting ResourceTypeAttrRepresentation test");
+ OIC_LOG(INFO, TAG, "Starting ResourceTypeAttrRepresentation test");
InitStack(OC_SERVER);
OCResourceHandle handle;
TEST(StackResource, ResourceTypeInterface)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting ResourceTypeInterface test");
+ OIC_LOG(INFO, TAG, "Starting ResourceTypeInterface test");
InitStack(OC_SERVER);
OCResourceHandle handle;
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting ResourceDefaultInterfaceAlwaysFirst test");
+ OIC_LOG(INFO, TAG, "Starting ResourceDefaultInterfaceAlwaysFirst test");
InitStack(OC_SERVER);
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting ResourceDuplicateDefaultInterfaces test");
+ OIC_LOG(INFO, TAG, "Starting ResourceDuplicateDefaultInterfaces test");
InitStack(OC_SERVER);
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting ResourceDuplicateInterfaces test");
+ OIC_LOG(INFO, TAG, "Starting ResourceDuplicateInterfaces test");
InitStack(OC_SERVER);
TEST(StackResource, ResourceTypeInterfaceMethods)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting ResourceTypeInterfaceMethods test");
+ OIC_LOG(INFO, TAG, "Starting ResourceTypeInterfaceMethods test");
InitStack(OC_SERVER);
OCResourceHandle handle;
TEST(StackResource, GetResourceProperties)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting GetResourceProperties test");
+ OIC_LOG(INFO, TAG, "Starting GetResourceProperties test");
InitStack(OC_SERVER);
OCResourceHandle handle;
TEST(StackResource, StackTestResourceDiscoverOneResourceBad)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting StackTestResourceDiscoverOneResourceBad test");
+ OIC_LOG(INFO, TAG, "Starting StackTestResourceDiscoverOneResourceBad test");
InitStack(OC_SERVER);
uint8_t numResources = 0;
EXPECT_EQ(OC_STACK_OK, OCGetNumberOfResources(&numResources));
TEST(StackResource, StackTestResourceDiscoverOneResource)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting StackTestResourceDiscoverOneResource test");
+ OIC_LOG(INFO, TAG, "Starting StackTestResourceDiscoverOneResource test");
InitStack(OC_SERVER);
OCResourceHandle handle;
TEST(StackResource, StackTestResourceDiscoverManyResources)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting StackTestResourceDiscoverManyResources test");
+ OIC_LOG(INFO, TAG, "Starting StackTestResourceDiscoverManyResources test");
InitStack(OC_SERVER);
OCResourceHandle handle1;
TEST(StackBind, BindResourceTypeNameBad)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting BindResourceTypeNameBad test");
+ OIC_LOG(INFO, TAG, "Starting BindResourceTypeNameBad test");
InitStack(OC_SERVER);
OCResourceHandle handle;
TEST(StackBind, BindResourceTypeNameGood)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting BindResourceTypeNameGood test");
+ OIC_LOG(INFO, TAG, "Starting BindResourceTypeNameGood test");
InitStack(OC_SERVER);
OCResourceHandle handle;
TEST(StackBind, BindResourceTypeAttribRepGood)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting BindResourceTypeAttribRepGood test");
+ OIC_LOG(INFO, TAG, "Starting BindResourceTypeAttribRepGood test");
InitStack(OC_SERVER);
OCResourceHandle handle;
TEST(StackBind, BindResourceInterfaceNameBad)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting BindResourceInterfaceNameBad test");
+ OIC_LOG(INFO, TAG, "Starting BindResourceInterfaceNameBad test");
InitStack(OC_SERVER);
OCResourceHandle handle;
TEST(StackBind, BindResourceInterfaceNameGood)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting BindResourceInterfaceNameGood test");
+ OIC_LOG(INFO, TAG, "Starting BindResourceInterfaceNameGood test");
InitStack(OC_SERVER);
OCResourceHandle handle;
TEST(StackBind, BindResourceInterfaceMethodsBad)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting BindResourceInterfaceMethodsBad test");
+ OIC_LOG(INFO, TAG, "Starting BindResourceInterfaceMethodsBad test");
InitStack(OC_SERVER);
OCResourceHandle handle;
TEST(StackBind, BindResourceInterfaceMethodsGood)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting BindResourceInterfaceMethodsGood test");
+ OIC_LOG(INFO, TAG, "Starting BindResourceInterfaceMethodsGood test");
InitStack(OC_SERVER);
OCResourceHandle handle;
TEST(StackBind, BindContainedResourceBad)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting BindContainedResourceBad test");
+ OIC_LOG(INFO, TAG, "Starting BindContainedResourceBad test");
InitStack(OC_SERVER);
OCResourceHandle containerHandle;
TEST(StackBind, BindContainedResourceGood)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting BindContainedResourceGood test");
+ OIC_LOG(INFO, TAG, "Starting BindContainedResourceGood test");
InitStack(OC_SERVER);
uint8_t numResources = 0;
TEST(StackBind, BindEntityHandlerBad)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting BindEntityHandlerBad test");
+ OIC_LOG(INFO, TAG, "Starting BindEntityHandlerBad test");
InitStack(OC_SERVER);
OCResourceHandle handle;
TEST(StackBind, BindEntityHandlerGood)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting BindEntityHandlerGood test");
+ OIC_LOG(INFO, TAG, "Starting BindEntityHandlerGood test");
InitStack(OC_SERVER);
OCResourceHandle handle;
TEST(StackResourceAccess, GetResourceByIndex)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting GetResourceByIndex test");
+ OIC_LOG(INFO, TAG, "Starting GetResourceByIndex test");
InitStack(OC_SERVER);
uint8_t numResources = 0;
TEST(StackResourceAccess, DeleteHeadResource)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting DeleteHeadResource test");
+ OIC_LOG(INFO, TAG, "Starting DeleteHeadResource test");
InitStack(OC_SERVER);
uint8_t numResources = 0;
TEST(StackResourceAccess, DeleteHeadResource2)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting DeleteHeadResource2 test");
+ OIC_LOG(INFO, TAG, "Starting DeleteHeadResource2 test");
InitStack(OC_SERVER);
uint8_t numResources = 0;
TEST(StackResourceAccess, DeleteLastResource)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting DeleteLastResource test");
+ OIC_LOG(INFO, TAG, "Starting DeleteLastResource test");
InitStack(OC_SERVER);
uint8_t numResources = 0;
TEST(StackResourceAccess, DeleteMiddleResource)
{
itst::DeadmanTimer killSwitch(SHORT_TEST_TIMEOUT);
- OC_LOG(INFO, TAG, "Starting DeleteMiddleResource test");
+ OIC_LOG(INFO, TAG, "Starting DeleteMiddleResource test");
InitStack(OC_SERVER);
uint8_t numResources = 0;