{
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;
}