OC log and OC log V used almost 3500bytes of RAM in Mega board because of improper log usage.
Updated code using PCF properly in OC logging to save almost 3500 bytes of RAM memory.
Verfied changes on both Arduino Due and Mega boards and found Working fine.
Change-Id: I9ca134d5cff9c8a91707a18bd9279089533a9b99
Signed-off-by: koushik.girijala <g.koushik@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/2363
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Ashok Babu Channa <ashok.channa@samsung.com>
Reviewed-by: Abhishek Pandey <abhi.siso@samsung.com>
Reviewed-by: Jon A. Cruz <jonc@osg.samsung.com>
#ifdef ENABLE_MALLOC_DEBUG
void *ptr = malloc(size);
- count++;
+ if (ptr)
+ {
+ count++;
+ }
OIC_LOG_V(INFO, TAG, "malloc: ptr=%p, size=%u, count=%u", ptr, size, count);
return ptr;
#else
#ifdef ENABLE_MALLOC_DEBUG
void *ptr = calloc(num, size);
- OIC_LOG_V(INFO, TAG, "calloc: ptr=%p, num=%u, size=%u", ptr, num, size);
+ if (ptr)
+ {
+ count++;
+ }
+ OIC_LOG_V(INFO, TAG, "calloc: ptr=%p, num=%u, size=%u, count=%u", ptr, num, size, count);
return ptr;
#else
return calloc(num, size);
// Use the PCF macro to wrap strings stored in FLASH on the Arduino
// Example: OC_LOG(INFO, TAG, PCF("Entering function"));
#ifdef ARDUINO
+
+#ifdef __cplusplus
#define PCF(str) ((PROGMEM const char *)(F(str)))
+#else
+ #define PCF(str) ((PROGMEM const char *)(PSTR(str)))
+#endif //__cplusplus
#else
#define PCF(str) str
#endif
#define OC_LOG_BUFFER(level, tag, buffer, bufferSize)
#else // These macros are defined for Linux, Android, and Arduino
#define OC_LOG_INIT() OCLogInit()
- #define OC_LOG(level, tag, logStr) OCLog((level), (tag), (logStr))
- #define OC_LOG_BUFFER(level, tag, buffer, bufferSize) OCLogBuffer((level), (tag), (buffer), (bufferSize))
+ #define OC_LOG_BUFFER(level, tag, buffer, bufferSize) OCLogBuffer((level), PCF(tag), (buffer), (bufferSize))
#ifdef ARDUINO
#define OC_LOG_CONFIG(ctx)
#define OC_LOG_SHUTDOWN()
+ #define OC_LOG(level, tag, logStr) OCLog((level), PCF(tag), PCF(logStr))
// Use full namespace for logInit to avoid function name collision
#define OC_LOG_INIT() OCLogInit()
// Don't define variable argument log function for Arduino
- #define OC_LOG_V(level, tag, ...) OCLogv((level), (tag), __VA_ARGS__)
+ #define OC_LOG_V(level, tag, format, ...) OCLogv((level), PCF(tag), PCF(format), __VA_ARGS__)
#else
#define OC_LOG_CONFIG(ctx) OCLogConfig((ctx))
+ #define OC_LOG(level, tag, logStr) OCLog((level), (tag), (logStr))
#define OC_LOG_SHUTDOWN() OCLogShutdown()
// Define variable argument log function for Linux and Android
#define OC_LOG_V(level, tag, ...) OCLogv((level), (tag), __VA_ARGS__)
* @param tag - Module name
* @param format - variadic log string
*/
- void OCLogv(LogLevel level, PROGMEM const char * tag, const char * format, ...)
+ void OCLogv(LogLevel level, PROGMEM const char * tag, PROGMEM const char * format, ...)
{
char buffer[LINE_BUFFER_SIZE];
va_list ap;
}
Serial.print(F(": "));
+#ifdef __AVR__
+ vsnprintf_P(buffer, sizeof(buffer), format, ap);
+#else
vsnprintf(buffer, sizeof(buffer), format, ap);
+#endif
for(char *p = &buffer[0]; *p; p++) // emulate cooked mode for newlines
{
if(*p == '\n')
Serial.println();
va_end(ap);
}
- /**
- * Output a variable argument list log string with the specified priority level.
- * Only defined for Arduino as depicted below.
- *
- * @param level - DEBUG, INFO, WARNING, ERROR, FATAL
- * @param tag - Module name
- * @param format - variadic log string
- */
- void OCLogv(LogLevel level, PROGMEM const char * tag, const __FlashStringHelper *format, ...)
- {
- char buffer[LINE_BUFFER_SIZE];
- va_list ap;
- va_start(ap, format);
-
- GET_PROGMEM_BUFFER(buffer, &(LEVEL[level]));
- Serial.print(buffer);
-
- char c;
- Serial.print(F(": "));
-
- while ((c = pgm_read_byte(tag))) {
- Serial.write(c);
- tag++;
- }
- Serial.print(F(": "));
-
- #ifdef __AVR__
- vsnprintf_P(buffer, sizeof(buffer), (const char *)format, ap); // progmem for AVR
- #else
- vsnprintf(buffer, sizeof(buffer), (const char *)format, ap); // for the rest of the world
- #endif
- for(char *p = &buffer[0]; *p; p++) // emulate cooked mode for newlines
- {
- if(*p == '\n')
- {
- Serial.write('\r');
- }
- Serial.write(*p);
- }
- Serial.println();
- va_end(ap);
- }
-
#endif
-
-
-
#include "ArduinoLoggerTest.h"
#include "logger.h"
-PROGMEM const char tag[] = "Arduino";
-PROGMEM const char msg[] = "Arduino Logger Test";
+#define tag "Arduino"
+#define msg "Arduino Logger Test"
-PROGMEM const char debugMsg[] = "this is a DEBUG message";
-PROGMEM const char infoMsg[] = "this is a INFO message";
-PROGMEM const char warningMsg[] = "this is a WARNING message";
-PROGMEM const char errorMsg[] = "this is a ERROR message";
-PROGMEM const char fatalMsg[] = "this is a FATAL message";
+#define debugMsg "this is a DEBUG message"
+#define infoMsg "this is a INFO message"
+#define warningMsg "this is a WARNING message"
+#define errorMsg "this is a ERROR message"
+#define fatalMsg "this is a FATAL message"
-PROGMEM const char multiLineMsg[] = "this is a DEBUG message\non multiple\nlines";
+#define multiLineMsg "this is a DEBUG message\non multiple\nlines"
//-----------------------------------------------------------------------------
*
*/
#define VERIFY_SUCCESS(tag, op, logLevel) do{ if (!(op)) \
- {OC_LOG((logLevel), tag, PCF(#op " failed!!")); goto exit; } }while(0)
+ {OC_LOG((logLevel), tag, #op " failed!!"); goto exit; } }while(0)
/**
* @def VERIFY_NON_NULL
*
*/
#define VERIFY_NON_NULL(tag, arg, logLevel) do{ if (NULL == (arg)) \
- { OC_LOG((logLevel), tag, PCF(#arg " is NULL")); goto exit; } }while(0)
+ { OC_LOG((logLevel), tag, #arg " is NULL"); goto exit; } }while(0)
/**
* This method initializes the OicParseQueryIter_t struct
OCRepPayload* payload = OCRepPayloadCreate();
if(!payload)
{
- OC_LOG(ERROR, TAG, PCF("Failed to allocate Payload"));
+ OC_LOG(ERROR, TAG, "Failed to allocate Payload");
return NULL;
}
{
if(ehRequest->payload && ehRequest->payload->type != PAYLOAD_TYPE_REPRESENTATION)
{
- OC_LOG(ERROR, TAG, PCF("Incoming payload not a representation"));
+ OC_LOG(ERROR, TAG, "Incoming payload not a representation");
return NULL;
}
OCRepPayload* payload = OCRepPayloadCreate();
if(!payload)
{
- OC_LOG(ERROR, TAG, PCF("Failed to allocate Payload"));
+ OC_LOG(ERROR, TAG, "Failed to allocate Payload");
return NULL;
}
{
if(ehRequest->payload && ehRequest->payload->type != PAYLOAD_TYPE_REPRESENTATION)
{
- OC_LOG(ERROR, TAG, PCF("Incoming payload not a representation"));
+ OC_LOG(ERROR, TAG, "Incoming payload not a representation");
return NULL;
}
* must define "OCStackResult res" for setting error code.
* */
#define PM_VERIFY_SUCCESS(tag, op, errCode, logLevel) { if (!(op)) \
- {OC_LOG((logLevel), tag, PCF(#op " failed!!")); res = errCode; goto bail;} }
+ {OC_LOG((logLevel), tag, #op " failed!!"); res = errCode; goto bail;} }
/**
* @def PM_VERIFY_NON_NULL
* @brief Macro to verify argument is not equal to NULL.
* @note Invoking function must define "bail:" label for goto functionality to work correctly.
* */
#define PM_VERIFY_NON_NULL(tag, arg, errCode, logLevel) { if (NULL == (arg)) \
- { OC_LOG((logLevel), tag, PCF(#arg " is NULL")); res = errCode; goto bail;} }
+ { OC_LOG((logLevel), tag, #arg " is NULL"); res = errCode; goto bail;} }
OCStackResult PMGeneratePairWiseCredentials(OicSecCredType_t type, size_t keySize,
const OicUuid_t *ptDeviceId,
#include <strings.h>
#endif
-#define TAG PCF("SRM-ACL")
+#define TAG "SRM-ACL"
OicSecAcl_t *gAcl = NULL;
static OCResourceHandle gAclHandle = NULL;
size_t i;
if(NULL == ace)
{
- OC_LOG (INFO, TAG, PCF("Invalid Parameter"));
+ OC_LOG (INFO, TAG, "Invalid Parameter");
return;
}
static OCStackResult RemoveACE(const OicUuid_t * subject,
const char * resource)
{
- OC_LOG(INFO, TAG, PCF("IN RemoveACE"));
+ OC_LOG(INFO, TAG, "IN RemoveACE");
OicSecAcl_t *acl = NULL;
OicSecAcl_t *tempAcl = NULL;
if(memcmp(subject->id, &WILDCARD_SUBJECT_ID, sizeof(subject->id)) == 0)
{
- OC_LOG_V (INFO, TAG, PCF("%s received invalid parameter"), __func__ );
+ OC_LOG_V (INFO, TAG, "%s received invalid parameter", __func__ );
return OC_STACK_INVALID_PARAM;
}
OICFree(jsonStr);
- OC_LOG_V (INFO, TAG, PCF("%s RetVal %d"), __func__ , ehRet);
+ OC_LOG_V (INFO, TAG, "%s RetVal %d", __func__ , ehRet);
return ehRet;
}
// Send payload to request originator
SendSRMResponse(ehRequest, ehRet, NULL);
- OC_LOG_V (INFO, TAG, PCF("%s RetVal %d"), __func__ , ehRet);
+ OC_LOG_V (INFO, TAG, "%s RetVal %d", __func__ , ehRet);
return ehRet;
}
static OCEntityHandlerResult HandleACLDeleteRequest(const OCEntityHandlerRequest *ehRequest)
{
- OC_LOG (INFO, TAG, PCF("Processing ACLDeleteRequest"));
+ OC_LOG (INFO, TAG, "Processing ACLDeleteRequest");
OCEntityHandlerResult ehRet = OC_EH_ERROR;
if(NULL == ehRequest->query)
OCEntityHandlerRequest * ehRequest,
void* callbackParameter)
{
- OC_LOG(INFO, TAG, PCF("Received request ACLEntityHandler"));
+ OC_LOG(INFO, TAG, "Received request ACLEntityHandler");
(void)callbackParameter;
OCEntityHandlerResult ehRet = OC_EH_ERROR;
if (flag & OC_REQUEST_FLAG)
{
// TODO : Handle PUT and DEL methods
- OC_LOG (INFO, TAG, PCF("Flag includes OC_REQUEST_FLAG"));
+ OC_LOG (INFO, TAG, "Flag includes OC_REQUEST_FLAG");
switch (ehRequest->method)
{
case OC_REST_GET:
if (OC_STACK_OK != ret)
{
- OC_LOG (FATAL, TAG, PCF("Unable to instantiate ACL resource"));
+ OC_LOG (FATAL, TAG, "Unable to instantiate ACL resource");
DeInitACLResource();
}
return ret;
#include <stdlib.h>
#include <string.h>
-#define TAG PCF("SRM-AMACL")
+#define TAG "SRM-AMACL"
OicSecAmacl_t *gAmacl = NULL;
static OCResourceHandle gAmaclHandle = NULL;
OICFree(jsonStr);
- OC_LOG_V (INFO, TAG, PCF("%s RetVal %d"), __func__ , ehRet);
+ OC_LOG_V (INFO, TAG, "%s RetVal %d", __func__ , ehRet);
return ehRet;
}
// Send payload to request originator
SendSRMResponse(ehRequest, ehRet, NULL);
- OC_LOG_V (INFO, TAG, PCF("%s RetVal %d"), __func__ , ehRet);
+ OC_LOG_V (INFO, TAG, "%s RetVal %d", __func__ , ehRet);
return ehRet;
}
if (flag & OC_REQUEST_FLAG)
{
- OC_LOG (INFO, TAG, PCF("Flag includes OC_REQUEST_FLAG"));
+ OC_LOG (INFO, TAG, "Flag includes OC_REQUEST_FLAG");
switch (ehRequest->method)
{
case OC_REST_GET:
if (OC_STACK_OK != ret)
{
- OC_LOG (FATAL, TAG, PCF("Unable to instantiate Amacl resource"));
+ OC_LOG (FATAL, TAG, "Unable to instantiate Amacl resource");
DeInitAmaclResource();
}
return ret;
#endif
#include <stdint.h>
-#define TAG PCF("SRM-CREDL")
+#define TAG "SRM-CREDL"
static OicSecCred_t *gCred = NULL;
{
if(NULL == cred)
{
- OC_LOG (INFO, TAG, PCF("Invalid Parameter"));
+ OC_LOG (INFO, TAG, "Invalid Parameter");
return;
}
//Note: Need further clarification on roleID data type
static OCEntityHandlerResult HandleDeleteRequest(const OCEntityHandlerRequest *ehRequest)
{
- OC_LOG_V (INFO, TAG, PCF("Processing CredDeleteRequest"));
+ OC_LOG(INFO, TAG, "Processing CredDeleteRequest");
OCEntityHandlerResult ehRet = OC_EH_ERROR;
}
if (flag & OC_REQUEST_FLAG)
{
- OC_LOG (INFO, TAG, PCF("Flag includes OC_REQUEST_FLAG"));
+ OC_LOG (INFO, TAG, "Flag includes OC_REQUEST_FLAG");
//TODO : Handle PUT/DEL methods
switch(ehRequest->method)
{
if (OC_STACK_OK != ret)
{
- OC_LOG (FATAL, TAG, PCF("Unable to instantiate Cred resource"));
+ OC_LOG (FATAL, TAG, "Unable to instantiate Cred resource");
DeInitCredResource();
}
return ret;
#include <strings.h>
#endif
-#define TAG PCF("SRM-DOXM")
+#define TAG "SRM-DOXM"
static OicSecDoxm_t *gDoxm = NULL;
static OCResourceHandle gDoxmHandle = NULL;
// access rules. Eventually, the PE and PM code will
// not send a request to the /doxm Entity Handler at all
// if it should not respond.
- OC_LOG (INFO, TAG, PCF("In ValidateQuery"));
+ OC_LOG (INFO, TAG, "In ValidateQuery");
if(NULL == gDoxm)
{
return false;
char* jsonStr = NULL;
OCEntityHandlerResult ehRet = OC_EH_OK;
- OC_LOG (INFO, TAG, PCF("Doxm EntityHandle processing GET request"));
+ OC_LOG (INFO, TAG, "Doxm EntityHandle processing GET request");
//Checking if Get request is a query.
if(ehRequest->query)
{
- OC_LOG (INFO, TAG, PCF("HandleDoxmGetRequest processing query"));
+ OC_LOG (INFO, TAG, "HandleDoxmGetRequest processing query");
if(!ValidateQuery((unsigned char *)ehRequest->query))
{
ehRet = OC_EH_ERROR;
// Send response payload to request originator
if(OC_STACK_OK != SendSRMResponse(ehRequest, ehRet, jsonStr))
{
- OC_LOG (ERROR, TAG, PCF("SendSRMResponse failed in HandleDoxmGetRequest"));
+ OC_LOG (ERROR, TAG, "SendSRMResponse failed in HandleDoxmGetRequest");
}
OICFree(jsonStr);
sizeof(base64Buff), &outLen);
VERIFY_SUCCESS(TAG, b64Ret == B64_OK, ERROR);
- OC_LOG (INFO, TAG, PCF("Doxm EntityHandle generating Credential"));
+ OC_LOG (INFO, TAG, "Doxm EntityHandle generating Credential");
cred = GenerateCredential(&ptDoxm->owner, SYMMETRIC_PAIR_WISE_KEY,
NULL, base64Buff, ownLen, &ptDoxm->owner);
VERIFY_NON_NULL(TAG, cred, ERROR);
static OCEntityHandlerResult HandleDoxmPutRequest (const OCEntityHandlerRequest * ehRequest)
{
- OC_LOG (INFO, TAG, PCF("Doxm EntityHandle processing PUT request"));
+ OC_LOG (INFO, TAG, "Doxm EntityHandle processing PUT request");
OCEntityHandlerResult ehRet = OC_EH_ERROR;
OicUuid_t emptyOwner = {.id = {0}};
*/
if ((false == gDoxm->owned) && (false == newDoxm->owned))
{
- OC_LOG (INFO, TAG, PCF("Doxm EntityHandle enabling AnonECDHCipherSuite"));
+ OC_LOG (INFO, TAG, "Doxm EntityHandle enabling AnonECDHCipherSuite");
#ifdef __WITH_DTLS__
ehRet = (CAEnableAnonECDHCipherSuite(true) == CA_STATUS_OK) ? OC_EH_OK : OC_EH_ERROR;
#endif //__WITH_DTLS__
OCServerRequest *request = (OCServerRequest *)ehRequest->requestHandle;
//Generating OwnerPSK
- OC_LOG (INFO, TAG, PCF("Doxm EntityHandle generating OwnerPSK"));
+ OC_LOG (INFO, TAG, "Doxm EntityHandle generating OwnerPSK");
//Generate new credential for provisioning tool
ehRet = AddOwnerPSK((CAEndpoint_t *)&request->devAddr, newDoxm,
//Send payload to request originator
if(OC_STACK_OK != SendSRMResponse(ehRequest, ehRet, NULL))
{
- OC_LOG (ERROR, TAG, PCF("SendSRMResponse failed in HandlePstatPostRequest"));
+ OC_LOG (ERROR, TAG, "SendSRMResponse failed in HandlePstatPostRequest");
}
DeleteDoxmBinData(newDoxm);
if (flag & OC_REQUEST_FLAG)
{
- OC_LOG (INFO, TAG, PCF("Flag includes OC_REQUEST_FLAG"));
+ OC_LOG (INFO, TAG, "Flag includes OC_REQUEST_FLAG");
switch (ehRequest->method)
{
case OC_REST_GET:
if (OC_STACK_OK != ret)
{
- OC_LOG (FATAL, TAG, PCF("Unable to instantiate Doxm resource"));
+ OC_LOG (FATAL, TAG, "Unable to instantiate Doxm resource");
DeInitDoxmResource();
}
return ret;
{
if (OCGenerateUuid(gDoxm->deviceID.id) != RAND_UUID_OK)
{
- OC_LOG(FATAL, TAG, PCF("Generate UUID for Server Instance failed!"));
+ OC_LOG(FATAL, TAG, "Generate UUID for Server Instance failed!");
return ret;
}
ret = OC_STACK_OK;
if (UpdatePersistentStorage(gDoxm))
{
//TODO: After registering PSI handler in all samples, do ret = OC_STACK_OK here.
- OC_LOG(FATAL, TAG, PCF("UpdatePersistentStorage failed!"));
+ OC_LOG(FATAL, TAG, "UpdatePersistentStorage failed!");
}
}
else
*/
static OicSecDoxm_t* GetDoxmDefault()
{
- OC_LOG (INFO, TAG, PCF("GetDoxmToDefault"));
+ OC_LOG (INFO, TAG, "GetDoxmToDefault");
return &gDefaultDoxm;
}
}
else
{
- OC_LOG (ERROR, TAG, PCF("CheckDeviceID failed"));
+ OC_LOG (ERROR, TAG, "CheckDeviceID failed");
}
OICFree(jsonSVRDatabase);
return ret;
#include "logger.h"
#include "pinoxmcommon.h"
-#define TAG PCF("PIN_OXM_COMMON")
+#define TAG "PIN_OXM_COMMON"
static GeneratePinCallback gGenPinCallback = NULL;
static InputPinCallback gInputPinCallback = NULL;
#include "iotvticalendar.h"
#include <string.h>
-#define TAG PCF("SRM-PE")
+#define TAG "SRM-PE"
/**
* Return the uint16_t CRUDN permission corresponding to passed CAMethod_t.
if(IOTVTICAL_VALID_ACCESS == IsRequestWithinValidTime(acl->periods[i],
acl->recurrences[i]))
{
- OC_LOG(INFO, TAG, PCF("Access request is in allowed time period"));
+ OC_LOG(INFO, TAG, "Access request is in allowed time period");
return true;
}
}
- OC_LOG(INFO, TAG, PCF("Access request is in invalid time period"));
+ OC_LOG(INFO, TAG, "Access request is in invalid time period");
return false;
#else
*/
void ProcessAccessRequest(PEContext_t *context)
{
- OC_LOG(INFO, TAG, PCF("Entering ProcessAccessRequest()"));
+ OC_LOG(INFO, TAG, "Entering ProcessAccessRequest()");
if(NULL != context)
{
const OicSecAcl_t *currentAcl = NULL;
context->retVal = ACCESS_DENIED_SUBJECT_NOT_FOUND;
do
{
- OC_LOG(INFO, TAG, PCF("ProcessAccessRequest(): getting ACL..."));
+ OC_LOG(INFO, TAG, "ProcessAccessRequest(): getting ACL...");
currentAcl = GetACLResourceData(context->subject, &savePtr);
if(NULL != currentAcl)
{
// Found the subject, so how about resource?
- OC_LOG(INFO, TAG, PCF("ProcessAccessRequest(): \
- found ACL matching subject."));
+ OC_LOG(INFO, TAG, "ProcessAccessRequest(): \
+ found ACL matching subject.");
context->retVal = ACCESS_DENIED_RESOURCE_NOT_FOUND;
- OC_LOG(INFO, TAG, PCF("ProcessAccessRequest(): \
- Searching for resource..."));
+ OC_LOG(INFO, TAG, "ProcessAccessRequest(): \
+ Searching for resource...");
if(IsResourceInAcl(context->resource, currentAcl))
{
- OC_LOG(INFO, TAG, PCF("ProcessAccessRequest(): \
- found matching resource in ACL."));
+ OC_LOG(INFO, TAG, "ProcessAccessRequest(): \
+ found matching resource in ACL.");
context->matchingAclFound = true;
// Found the resource, so it's down to valid period & permission.
}
else
{
- OC_LOG(INFO, TAG, PCF("ProcessAccessRequest(): \
- no ACL found matching subject ."));
+ OC_LOG(INFO, TAG, "ProcessAccessRequest(): \
+ no ACL found matching subject .");
}
}
while((NULL != currentAcl) && (false == context->matchingAclFound));
if(IsAccessGranted(context->retVal))
{
- OC_LOG(INFO, TAG, PCF("ProcessAccessRequest(): \
- Leaving ProcessAccessRequest(ACCESS_GRANTED)"));
+ OC_LOG(INFO, TAG, "ProcessAccessRequest(): \
+ Leaving ProcessAccessRequest(ACCESS_GRANTED)");
}
else
{
- OC_LOG(INFO, TAG, PCF("ProcessAccessRequest(): \
- Leaving ProcessAccessRequest(ACCESS_DENIED)"));
+ OC_LOG(INFO, TAG, "ProcessAccessRequest(): \
+ Leaving ProcessAccessRequest(ACCESS_DENIED)");
}
}
else
{
- OC_LOG(INFO, TAG, PCF("ProcessAccessRequest(): \
- Leaving ProcessAccessRequest(context is NULL)"));
+ OC_LOG(INFO, TAG, "ProcessAccessRequest(): \
+ Leaving ProcessAccessRequest(context is NULL)");
}
}
#include <stdlib.h>
#include <string.h>
-#define TAG PCF("SRM-PSI")
+#define TAG "SRM-PSI"
//SVR database buffer block size
const size_t DB_FILE_SIZE_BLOCK = 1023;
int size = GetSVRDatabaseSize(ps);
if (0 == size)
{
- OC_LOG (ERROR, TAG, PCF("FindSVRDatabaseSize failed"));
+ OC_LOG (ERROR, TAG, "FindSVRDatabaseSize failed");
return NULL;
}
size_t bytesRead = ps->read(jsonStr, 1, size, fp);
jsonStr[bytesRead] = '\0';
- OC_LOG_V(INFO, TAG, PCF("Read %d bytes from SVR database file"), bytesRead);
+ OC_LOG_V(INFO, TAG, "Read %d bytes from SVR database file", bytesRead);
ps->close(fp);
fp = NULL;
}
else
{
- OC_LOG (ERROR, TAG, PCF("Unable to open SVR database file!!"));
+ OC_LOG (ERROR, TAG, "Unable to open SVR database file!!");
}
}
{
ret = OC_STACK_OK;
}
- OC_LOG_V(INFO, TAG, PCF("Written %d bytes into SVR database file"), bytesWritten);
+ OC_LOG_V(INFO, TAG, "Written %d bytes into SVR database file", bytesWritten);
ps->close(fp);
fp = NULL;
}
else
{
- OC_LOG (ERROR, TAG, PCF("Unable to open SVR database file!! "));
+ OC_LOG (ERROR, TAG, "Unable to open SVR database file!! ");
}
}
#include <stdlib.h>
#include <string.h>
-#define TAG PCF("SRM-PSTAT")
+#define TAG "SRM-PSTAT"
static OicSecDpom_t gSm = SINGLE_SERVICE_CLIENT_DRIVEN;
static OicSecPstat_t gDefaultPstat =
cJSON_Delete(jsonRoot);
if (OC_STACK_OK != ret)
{
- OC_LOG (ERROR, TAG, PCF("JSONToPstatBin failed"));
+ OC_LOG (ERROR, TAG, "JSONToPstatBin failed");
DeletePstatBinData(pstat);
pstat = NULL;
}
{
gPstat->isOp = true;
gPstat->cm = NORMAL;
- OC_LOG (INFO, TAG, PCF("CommitHash is valid and isOp is TRUE"));
+ OC_LOG (INFO, TAG, "CommitHash is valid and isOp is TRUE");
}
else
{
- OC_LOG (INFO, TAG, PCF("CommitHash is not valid"));
+ OC_LOG (INFO, TAG, "CommitHash is not valid");
}
}
cJSON *omJson = cJSON_GetObjectItem(jsonPstat, OIC_JSON_OM_NAME);
//Send payload to request originator
if(OC_STACK_OK != SendSRMResponse(ehRequest, ehRet, NULL))
{
- OC_LOG (ERROR, TAG, PCF("SendSRMResponse failed in HandlePstatPostRequest"));
+ OC_LOG (ERROR, TAG, "SendSRMResponse failed in HandlePstatPostRequest");
}
cJSON_Delete(postJson);
return ehRet;
// This method will handle REST request (GET/POST) for /oic/sec/pstat
if (flag & OC_REQUEST_FLAG)
{
- OC_LOG (INFO, TAG, PCF("Flag includes OC_REQUEST_FLAG"));
+ OC_LOG (INFO, TAG, "Flag includes OC_REQUEST_FLAG");
switch (ehRequest->method)
{
case OC_REST_GET:
if (ret != OC_STACK_OK)
{
- OC_LOG (FATAL, TAG, PCF("Unable to instantiate pstat resource"));
+ OC_LOG (FATAL, TAG, "Unable to instantiate pstat resource");
DeInitPstatResource();
}
return ret;
#include "utlist.h"
#include <string.h>
-#define TAG PCF("SRM-RM")
+#define TAG "SRM-RM"
/**
* This method is used by all secure resource modules to send responses to REST queries.
OCStackResult SendSRMResponse(const OCEntityHandlerRequest *ehRequest,
OCEntityHandlerResult ehRet, const char *rspPayload)
{
- OC_LOG (INFO, TAG, PCF("SRM sending SRM response"));
+ OC_LOG (INFO, TAG, "SRM sending SRM response");
OCEntityHandlerResponse response = {.requestHandle = NULL};
if (ehRequest)
{
#include "oic_string.h"
#include <string.h>
-#define TAG PCF("SRM")
+#define TAG "SRM"
//Request Callback handler
static CARequestCallback gRequestHandler = NULL;
*/
void SRMRequestHandler(const CAEndpoint_t *endPoint, const CARequestInfo_t *requestInfo)
{
- OC_LOG(INFO, TAG, PCF("Received request from remote device"));
+ OC_LOG(INFO, TAG, "Received request from remote device");
if (!endPoint || !requestInfo)
{
- OC_LOG(ERROR, TAG, PCF("Invalid arguments"));
+ OC_LOG(ERROR, TAG, "Invalid arguments");
return;
}
}
if (position > MAX_URI_LENGTH)
{
- OC_LOG(ERROR, TAG, PCF("URI length is too long"));
+ OC_LOG(ERROR, TAG, "URI length is too long");
return;
}
SRMAccessResponse_t response = ACCESS_DENIED;
if (CA_STATUS_OK != CASendResponse(endPoint, &responseInfo))
{
- OC_LOG(ERROR, TAG, PCF("Failed in sending response to a unauthorized request!"));
+ OC_LOG(ERROR, TAG, "Failed in sending response to a unauthorized request!");
}
}
*/
void SRMResponseHandler(const CAEndpoint_t *endPoint, const CAResponseInfo_t *responseInfo)
{
- OC_LOG(INFO, TAG, PCF("Received response from remote device"));
+ OC_LOG(INFO, TAG, "Received response from remote device");
// isProvResponse flag is to check whether response is catered by provisioning APIs or not.
// When token sent by CA response matches with token generated by provisioning request,
*/
void SRMErrorHandler(const CAEndpoint_t *endPoint, const CAErrorInfo_t *errorInfo)
{
- OC_LOG(INFO, TAG, PCF("Received error from remote device"));
+ OC_LOG(INFO, TAG, "Received error from remote device");
if (gErrorHandler)
{
gErrorHandler(endPoint, errorInfo);
CAResponseCallback respHandler,
CAErrorCallback errHandler)
{
- OC_LOG(INFO, TAG, PCF("SRMRegisterHandler !!"));
+ OC_LOG(INFO, TAG, "SRMRegisterHandler !!");
if( !reqHandler || !respHandler || !errHandler)
{
- OC_LOG(ERROR, TAG, PCF("Callback handlers are invalid"));
+ OC_LOG(ERROR, TAG, "Callback handlers are invalid");
return OC_STACK_INVALID_PARAM;
}
gRequestHandler = reqHandler;
*/
OCStackResult SRMRegisterPersistentStorageHandler(OCPersistentStorage* persistentStorageHandler)
{
- OC_LOG(INFO, TAG, PCF("SRMRegisterPersistentStorageHandler !!"));
+ OC_LOG(INFO, TAG, "SRMRegisterPersistentStorageHandler !!");
if(!persistentStorageHandler)
{
- OC_LOG(ERROR, TAG, PCF("The persistent storage handler is invalid"));
+ OC_LOG(ERROR, TAG, "The persistent storage handler is invalid");
return OC_STACK_INVALID_PARAM;
}
gPersistentStorageHandler = persistentStorageHandler;
#include "oic_malloc.h"
#include "base64.h"
-#define TAG PCF("SRM-UTILITY")
+#define TAG "SRM-UTILITY"
/**
* This method initializes the OicParseQueryIter_t struct
*/
void ParseQueryIterInit(unsigned char * query, OicParseQueryIter_t * parseIter)
{
- OC_LOG (INFO, TAG, PCF("Initializing coap iterator"));
+ OC_LOG (INFO, TAG, "Initializing coap iterator");
if((NULL == query) || (NULL == parseIter))
return;
*/
OicParseQueryIter_t * GetNextQuery(OicParseQueryIter_t * parseIter)
{
- OC_LOG (INFO, TAG, PCF("Getting Next Query"));
+ OC_LOG (INFO, TAG, "Getting Next Query");
if(NULL == parseIter)
return NULL;
#include <stdlib.h>
#include <string.h>
-#define TAG PCF("SRM-SVC")
+#define TAG "SRM-SVC"
OicSecSvc_t *gSvc = NULL;
static OCResourceHandle gSvcHandle = NULL;
OICFree(jsonStr);
- OC_LOG_V (INFO, TAG, PCF("%s RetVal %d"), __func__ , ehRet);
+ OC_LOG_V (INFO, TAG, "%s RetVal %d", __func__ , ehRet);
return ehRet;
}
// Send payload to request originator
SendSRMResponse(ehRequest, ehRet, NULL);
- OC_LOG_V (INFO, TAG, PCF("%s RetVal %d"), __func__ , ehRet);
+ OC_LOG_V (INFO, TAG, "%s RetVal %d", __func__ , ehRet);
return ehRet;
}
if (OC_STACK_OK != ret)
{
- OC_LOG (FATAL, TAG, PCF("Unable to instantiate SVC resource"));
+ OC_LOG (FATAL, TAG, "Unable to instantiate SVC resource");
DeInitSVCResource();
}
return ret;
{
OCStackResult ret = OC_STACK_ERROR;
- OC_LOG_V (INFO, TAG, PCF("Begin %s "), __func__ );
+ OC_LOG_V (INFO, TAG, "Begin %s ", __func__ );
// Read SVC resource from PS
char* jsonSVRDatabase = GetSVRDatabase();
DeInitSVCResource();
}
- OC_LOG_V (INFO, TAG, PCF("%s RetVal %d"), __func__ , ret);
+ OC_LOG_V (INFO, TAG, "%s RetVal %d", __func__ , ret);
return ret;
}
using namespace std;
-#define TAG PCF("SRM-ACL-UT")
+#define TAG "SRM-ACL-UT"
#ifdef __cplusplus
extern "C" {
#include "srmutility.h"
#include "logger.h"
-#define TAG PCF("SRM-CRED-UT")
+#define TAG "SRM-CRED-UT"
#ifdef __cplusplus
extern "C" {
const OicSecCred_t *credTmp1 = NULL;
for(credTmp1 = cred; credTmp1; credTmp1 = credTmp1->next)
{
- OC_LOG_V(INFO, TAG, PCF("\ncred->credId = %d"), credTmp1->credId);
- OC_LOG_V(INFO, TAG, PCF("cred->subject.id = %s"), credTmp1->subject.id);
- OC_LOG_V(INFO, TAG, PCF("cred->credType = %d"), credTmp1->credType);
+ OC_LOG_V(INFO, TAG, "\ncred->credId = %d", credTmp1->credId);
+ OC_LOG_V(INFO, TAG, "cred->subject.id = %s", credTmp1->subject.id);
+ OC_LOG_V(INFO, TAG, "cred->credType = %d", credTmp1->credType);
if(credTmp1->privateData.data)
{
- OC_LOG_V(INFO, TAG, PCF("cred->privateData.data = %s"), credTmp1->privateData.data);
+ OC_LOG_V(INFO, TAG, "cred->privateData.data = %s", credTmp1->privateData.data);
}
if(credTmp1->publicData.data)
{
- OC_LOG_V(INFO, TAG, PCF("cred->publicData.data = %s"), credTmp1->publicData.data);
+ OC_LOG_V(INFO, TAG, "cred->publicData.data = %s", credTmp1->publicData.data);
}
- OC_LOG_V(INFO, TAG, PCF("cred->ownersLen = %zd"), credTmp1->ownersLen);
+ OC_LOG_V(INFO, TAG, "cred->ownersLen = %zd", credTmp1->ownersLen);
for(size_t i = 0; i < cred->ownersLen; i++)
{
- OC_LOG_V(INFO, TAG, PCF("cred->owners[%zd].id = %s"), i, credTmp1->owners[i].id);
+ OC_LOG_V(INFO, TAG, "cred->owners[%zd].id = %s", i, credTmp1->owners[i].id);
}
}
}
json = BinToCredJSON(cred);
- OC_LOG_V(INFO, TAG, PCF("BinToCredJSON:%s\n"), json);
+ OC_LOG_V(INFO, TAG, "BinToCredJSON:%s\n", json);
EXPECT_TRUE(json != NULL);
DeleteCredList(cred);
OICFree(json);
#include "oic_malloc.h"
#include "logger.h"
-#define TAG PCF("SRM-DOXM")
+#define TAG "SRM-DOXM"
#ifdef __cplusplus
extern "C" {
OicSecDoxm_t * doxm = getBinDoxm();
char * json = BinToDoxmJSON(doxm);
- OC_LOG_V(INFO, TAG, PCF("BinToDoxmJSON:%s"), json);
+ OC_LOG_V(INFO, TAG, "BinToDoxmJSON:%s", json);
EXPECT_TRUE(json != NULL);
DeleteDoxmBinData(doxm);
#include "iotvticalendar.h"
#include "logger.h"
-#define TAG PCF("CALENDAR-UT")
+#define TAG "CALENDAR-UT"
static void printPeriod(IotvtICalPeriod_t *period)
{
return;
}
- OC_LOG_V(INFO, TAG, PCF("period->startDateTime.tm_year = %d"),period->startDateTime.tm_year);
- OC_LOG_V(INFO, TAG, PCF("period->startDateTime.tm_mon = %d"),period->startDateTime.tm_mon);
- OC_LOG_V(INFO, TAG, PCF("period->startDateTime.tm_mday = %d"),period->startDateTime.tm_mday);
- OC_LOG_V(INFO, TAG, PCF("period->startDateTime.tm_hour = %d"),period->startDateTime.tm_hour);
- OC_LOG_V(INFO, TAG, PCF("period->startDateTime.tm_min = %d"),period->startDateTime.tm_min);
- OC_LOG_V(INFO, TAG, PCF("period->startDateTime.tm_sec = %d"),period->startDateTime.tm_sec);
-
- OC_LOG_V(INFO, TAG, PCF("period->endDateTime.tm_year = %d"),period->endDateTime.tm_year);
- OC_LOG_V(INFO, TAG, PCF("period->endDateTime.tm_mon = %d"),period->endDateTime.tm_mon);
- OC_LOG_V(INFO, TAG, PCF("period->endDateTime.tm_mday = %d"),period->endDateTime.tm_mday);
- OC_LOG_V(INFO, TAG, PCF("period->endDateTime.tm_hour = %d"),period->endDateTime.tm_hour);
- OC_LOG_V(INFO, TAG, PCF("period->endDateTime.tm_min = %d"),period->endDateTime.tm_min);
- OC_LOG_V(INFO, TAG, PCF("period->startDateTime.tm_sec = %d"),period->endDateTime.tm_sec);
+ OC_LOG_V(INFO, TAG, "period->startDateTime.tm_year = %d",period->startDateTime.tm_year);
+ OC_LOG_V(INFO, TAG, "period->startDateTime.tm_mon = %d",period->startDateTime.tm_mon);
+ OC_LOG_V(INFO, TAG, "period->startDateTime.tm_mday = %d",period->startDateTime.tm_mday);
+ OC_LOG_V(INFO, TAG, "period->startDateTime.tm_hour = %d",period->startDateTime.tm_hour);
+ OC_LOG_V(INFO, TAG, "period->startDateTime.tm_min = %d",period->startDateTime.tm_min);
+ OC_LOG_V(INFO, TAG, "period->startDateTime.tm_sec = %d",period->startDateTime.tm_sec);
+
+ OC_LOG_V(INFO, TAG, "period->endDateTime.tm_year = %d",period->endDateTime.tm_year);
+ OC_LOG_V(INFO, TAG, "period->endDateTime.tm_mon = %d",period->endDateTime.tm_mon);
+ OC_LOG_V(INFO, TAG, "period->endDateTime.tm_mday = %d",period->endDateTime.tm_mday);
+ OC_LOG_V(INFO, TAG, "period->endDateTime.tm_hour = %d",period->endDateTime.tm_hour);
+ OC_LOG_V(INFO, TAG, "period->endDateTime.tm_min = %d",period->endDateTime.tm_min);
+ OC_LOG_V(INFO, TAG, "period->startDateTime.tm_sec = %d",period->endDateTime.tm_sec);
}
static void printRecur(IotvtICalRecur_t *recur)
{
- OC_LOG_V(INFO, TAG, PCF("recur->freq = %d"), recur->freq);
- OC_LOG_V(INFO, TAG, PCF("recur->until.tm_year = %d"), recur->until.tm_year);
- OC_LOG_V(INFO, TAG, PCF("recur->until.tm_mon = %d"), recur->until.tm_mon);
- OC_LOG_V(INFO, TAG, PCF("recur->until.tm_mday = %d"), recur->until.tm_mday);
+ OC_LOG_V(INFO, TAG, "recur->freq = %d", recur->freq);
+ OC_LOG_V(INFO, TAG, "recur->until.tm_year = %d", recur->until.tm_year);
+ OC_LOG_V(INFO, TAG, "recur->until.tm_mon = %d", recur->until.tm_mon);
+ OC_LOG_V(INFO, TAG, "recur->until.tm_mday = %d", recur->until.tm_mday);
if(recur->byDay & SUNDAY)
{
- OC_LOG_V(INFO, TAG, PCF("recur->byDay = %s"), "Sunday");
+ OC_LOG_V(INFO, TAG, "recur->byDay = %s", "Sunday");
}
if(recur->byDay & MONDAY)
{
- OC_LOG_V(INFO, TAG, PCF("recur->byDay = %s"), "Monday");
+ OC_LOG_V(INFO, TAG, "recur->byDay = %s", "Monday");
}
if(recur->byDay & TUESDAY)
{
- OC_LOG_V(INFO, TAG, PCF("recur->byDay = %s"), "Tuesday");
+ OC_LOG_V(INFO, TAG, "recur->byDay = %s", "Tuesday");
}
if(recur->byDay & WEDNESDAY)
{
- OC_LOG_V(INFO, TAG, PCF("recur->byDay = %s"), "Wednesday");
+ OC_LOG_V(INFO, TAG, "recur->byDay = %s", "Wednesday");
}
if(recur->byDay & THURSDAY)
{
- OC_LOG_V(INFO, TAG, PCF("recur->byDay = %s"), "Thursday");
+ OC_LOG_V(INFO, TAG, "recur->byDay = %s", "Thursday");
}
if(recur->byDay & FRIDAY)
{
- OC_LOG_V(INFO, TAG, PCF("recur->byDay = %s"), "Friday");
+ OC_LOG_V(INFO, TAG, "recur->byDay = %s", "Friday");
}
if(recur->byDay & SATURDAY)
{
- OC_LOG_V(INFO, TAG, PCF("recur->byDay = %s"), "Saturday");
+ OC_LOG_V(INFO, TAG, "recur->byDay = %s", "Saturday");
}
}
tzset();
localtime_r(&rt, &t2);
- OC_LOG_V(INFO, TAG, PCF("t1 = %02d:%02d:%02d"), t1.tm_hour, t1.tm_min, t1.tm_sec );
- OC_LOG_V(INFO, TAG, PCF("t2 = %02d:%02d:%02d"), t2.tm_hour, t2.tm_min, t2.tm_sec );
+ OC_LOG_V(INFO, TAG, "t1 = %02d:%02d:%02d", t1.tm_hour, t1.tm_min, t1.tm_sec );
+ OC_LOG_V(INFO, TAG, "t2 = %02d:%02d:%02d", t2.tm_hour, t2.tm_min, t2.tm_sec );
}while(t1.tm_hour != t2.tm_hour);
if(byDay > 0)
{
#endif
+// PL_TAG is made as generic predefined tag because of build problems in arduino for using logging
+#define PL_TAG "PayloadLog"
+
#ifdef TB_LOG
- #define OC_LOG_PAYLOAD(level, tag, payload) OCPayloadLog((level),(tag),(payload))
+ #define OC_LOG_PAYLOAD(level, payload) OCPayloadLog((level),(payload))
#define UUID_SIZE (16)
#define UUID_LENGTH (37)
const char *convertTriggerEnumToString(OCPresenceTrigger trigger);
OCPresenceTrigger convertTriggerStringToEnum(const char * triggerStr);
-static inline void OCPayloadLogRep(LogLevel level, const char* tag, OCRepPayload* payload)
+static inline void OCPayloadLogRep(LogLevel level, OCRepPayload* payload)
{
- OC_LOG(level, tag, PCF("Payload Type: Representation"));
+ OC_LOG(level, (PL_TAG), "Payload Type: Representation");
OCRepPayload* rep = payload;
int i = 1;
while(rep)
{
- OC_LOG_V(level, tag, "\tResource #%d", i);
- OC_LOG_V(level, tag, "\tURI:%s", rep->uri);
- OC_LOG(level, tag, PCF("\tResource Types:"));
+ 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:");
OCStringLL* strll = rep->types;
while(strll)
{
- OC_LOG_V(level, tag, "\t\t%s", strll->value);
+ OC_LOG_V(level, PL_TAG, "\t\t%s", strll->value);
strll = strll->next;
}
- OC_LOG(level, tag, PCF("\tInterfaces:"));
+ OC_LOG(level, PL_TAG, "\tInterfaces:");
strll = rep->interfaces;
while(strll)
{
- OC_LOG_V(level, tag, "\t\t%s", strll->value);
+ OC_LOG_V(level, PL_TAG, "\t\t%s", strll->value);
strll = strll->next;
}
// TODO Finish Logging: Values
OCRepPayloadValue* val = rep->values;
- OC_LOG(level, tag, PCF("\tValues:"));
+ OC_LOG(level, PL_TAG, "\tValues:");
while(val)
{
switch(val->type)
{
case OCREP_PROP_NULL:
- OC_LOG_V(level, tag, "\t\t%s: NULL", val->name);
+ OC_LOG_V(level, PL_TAG, "\t\t%s: NULL", val->name);
break;
case OCREP_PROP_INT:
- OC_LOG_V(level, tag, "\t\t%s(int):%lld", val->name, val->i);
+ OC_LOG_V(level, PL_TAG, "\t\t%s(int):%lld", val->name, val->i);
break;
case OCREP_PROP_DOUBLE:
- OC_LOG_V(level, tag, "\t\t%s(double):%f", val->name, val->d);
+ OC_LOG_V(level, PL_TAG, "\t\t%s(double):%f", val->name, val->d);
break;
case OCREP_PROP_BOOL:
- OC_LOG_V(level, tag, "\t\t%s(bool):%s", val->name, val->b ? "true" : "false");
+ OC_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, tag, "\t\t%s(string):%s", val->name, val->str);
+ OC_LOG_V(level, PL_TAG, "\t\t%s(string):%s", val->name, val->str);
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, tag, "\t\t%s(OCRep):%s", val->name, val->obj->uri);
+ OC_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, tag, "\t\t%s(int array):%lld x %lld x %lld",
+ OC_LOG_V(level, PL_TAG, "\t\t%s(int array):%lld x %lld x %lld",
val->name,
val->arr.dimensions[0], val->arr.dimensions[1],
val->arr.dimensions[2]);
break;
case OCREP_PROP_DOUBLE:
- OC_LOG_V(level, tag, "\t\t%s(double array):%lld x %lld x %lld",
+ OC_LOG_V(level, PL_TAG, "\t\t%s(double array):%lld x %lld x %lld",
val->name,
val->arr.dimensions[0], val->arr.dimensions[1],
val->arr.dimensions[2]);
break;
case OCREP_PROP_BOOL:
- OC_LOG_V(level, tag, "\t\t%s(bool array):%lld x %lld x %lld",
+ OC_LOG_V(level, PL_TAG, "\t\t%s(bool array):%lld x %lld x %lld",
val->name,
val->arr.dimensions[0], val->arr.dimensions[1],
val->arr.dimensions[2]);
break;
case OCREP_PROP_STRING:
- OC_LOG_V(level, tag, "\t\t%s(string array):%lld x %lld x %lld",
+ OC_LOG_V(level, PL_TAG, "\t\t%s(string array):%lld x %lld x %lld",
val->name,
val->arr.dimensions[0], val->arr.dimensions[1],
val->arr.dimensions[2]);
break;
case OCREP_PROP_OBJECT:
- OC_LOG_V(level, tag, "\t\t%s(OCRep array):%lld x %lld x %lld",
+ OC_LOG_V(level, PL_TAG, "\t\t%s(OCRep array):%lld x %lld x %lld",
val->name,
val->arr.dimensions[0], val->arr.dimensions[1],
val->arr.dimensions[2]);
break;
default:
- OC_LOG_V(ERROR, tag, "\t\t%s <-- Unknown/unsupported array type!",
+ OC_LOG_V(ERROR, PL_TAG, "\t\t%s <-- Unknown/unsupported array type!",
val->name);
break;
}
break;
default:
- OC_LOG_V(ERROR, tag, "\t\t%s <-- Unknown type!", val->name);
+ OC_LOG_V(ERROR, PL_TAG, "\t\t%s <-- Unknown type!", val->name);
break;
}
val = val -> next;
}
-static inline void OCPayloadLogDiscovery(LogLevel level, const char* tag,
- OCDiscoveryPayload* payload)
+static inline void OCPayloadLogDiscovery(LogLevel level, OCDiscoveryPayload* payload)
{
- OC_LOG(level, tag, PCF("Payload Type: Discovery"));
+ OC_LOG(level, PL_TAG, "Payload Type: Discovery");
int i = 1;
if(!payload->resources)
{
- OC_LOG(level, tag, PCF("\tNO Resources"));
+ OC_LOG(level, PL_TAG, "\tNO Resources");
return;
}
while(res)
{
- OC_LOG_V(level, tag, "\tResource #%d", i);
- OC_LOG_V(level, tag, "\tURI:%s", res->uri);
- OC_LOG(level, tag, PCF("\tSID:"));
- OC_LOG_BUFFER(level, tag, res->sid, UUID_SIZE);
- OC_LOG(level, tag, PCF("\tResource Types:"));
+ OC_LOG_V(level, PL_TAG, "\tResource #%d", i);
+ OC_LOG_V(level, PL_TAG, "\tURI:%s", res->uri);
+ OC_LOG(level, PL_TAG, "\tSID:");
+ OC_LOG_BUFFER(level, PL_TAG, res->sid, UUID_SIZE);
+ OC_LOG(level, PL_TAG, "\tResource Types:");
OCStringLL* strll = res->types;
while(strll)
{
- OC_LOG_V(level, tag, "\t\t%s", strll->value);
+ OC_LOG_V(level, PL_TAG, "\t\t%s", strll->value);
strll = strll->next;
}
- OC_LOG(level, tag, PCF("\tInterfaces:"));
+ OC_LOG(level, PL_TAG, "\tInterfaces:");
strll = res->interfaces;
while(strll)
{
- OC_LOG_V(level, tag, "\t\t%s", strll->value);
+ OC_LOG_V(level, PL_TAG, "\t\t%s", strll->value);
strll = strll->next;
}
- OC_LOG_V(level, tag, "\tBitmap: %u", res->bitmap);
- OC_LOG_V(level, tag, "\tSecure?: %s", res->secure ? "true" : "false");
- OC_LOG_V(level, tag, "\tPort: %u", res->port);
- OC_LOG(level, tag, PCF(""));
+ 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, "");
res = res->next;
++i;
}
}
-static inline void OCPayloadLogDevice(LogLevel level, const char* tag, OCDevicePayload* payload)
+static inline void OCPayloadLogDevice(LogLevel level, OCDevicePayload* payload)
{
- OC_LOG(level, tag, PCF("Payload Type: Device"));
- OC_LOG_V(level, tag, "\tURI:%s", payload->uri);
- OC_LOG(level, tag, PCF("\tSID:"));
- OC_LOG_BUFFER(level, tag, payload->sid, UUID_SIZE);
- OC_LOG_V(level, tag, "\tDevice Name:%s", payload->deviceName);
- OC_LOG_V(level, tag, "\tSpec Version%s", payload->specVersion);
- OC_LOG_V(level, tag, "\tData Model Version:%s", payload->dataModelVersion);
+ OC_LOG(level, PL_TAG, "Payload Type: Device");
+ OC_LOG_V(level, PL_TAG, "\tURI:%s", payload->uri);
+ 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);
}
-static inline void OCPayloadLogPlatform(LogLevel level, const char* tag, OCPlatformPayload* payload)
+static inline void OCPayloadLogPlatform(LogLevel level, OCPlatformPayload* payload)
{
- OC_LOG(level, tag, PCF("Payload Type: Platform"));
- OC_LOG_V(level, tag, "\tURI:%s", payload->uri);
- OC_LOG_V(level, tag, "\tPlatform ID:%s", payload->info.platformID);
- OC_LOG_V(level, tag, "\tMfg Name:%s", payload->info.manufacturerName);
- OC_LOG_V(level, tag, "\tMfg URL:%s", payload->info.manufacturerUrl);
- OC_LOG_V(level, tag, "\tModel Number:%s", payload->info.modelNumber);
- OC_LOG_V(level, tag, "\tDate of Mfg:%s", payload->info.dateOfManufacture);
- OC_LOG_V(level, tag, "\tPlatform Version:%s", payload->info.platformVersion);
- OC_LOG_V(level, tag, "\tOS Version:%s", payload->info.operatingSystemVersion);
- OC_LOG_V(level, tag, "\tHardware Version:%s", payload->info.hardwareVersion);
- OC_LOG_V(level, tag, "\tFirmware Version:%s", payload->info.firmwareVersion);
- OC_LOG_V(level, tag, "\tSupport URL:%s", payload->info.supportUrl);
- OC_LOG_V(level, tag, "\tSystem Time:%s", payload->info.systemTime);
+ 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);
}
-static inline void OCPayloadLogPresence(LogLevel level, const char* tag, OCPresencePayload* payload)
+static inline void OCPayloadLogPresence(LogLevel level, OCPresencePayload* payload)
{
- OC_LOG(level, tag, PCF("Payload Type: Presence"));
- OC_LOG_V(level, tag, "\tSequence Number:%u", payload->sequenceNumber);
- OC_LOG_V(level, tag, "\tMax Age:%d", payload->maxAge);
- OC_LOG_V(level, tag, "\tTrigger:%s", convertTriggerEnumToString(payload->trigger));
- OC_LOG_V(level, tag, "\tResource Type:%s", payload->resourceType);
+ 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);
}
-static inline void OCPayloadLogSecurity(LogLevel level, const char* tag,
- OCSecurityPayload* payload)
+static inline void OCPayloadLogSecurity(LogLevel level, OCSecurityPayload* payload)
{
- OC_LOG(level, tag, PCF("Payload Type: Security"));
- OC_LOG_V(level, tag, "\tSecurity Data: %s", payload->securityData);
+ OC_LOG(level, PL_TAG, "Payload Type: Security");
+ OC_LOG_V(level, PL_TAG, "\tSecurity Data: %s", payload->securityData);
}
-static inline void OCPayloadLog(LogLevel level, const char* tag, OCPayload* payload)
+static inline void OCPayloadLog(LogLevel level, OCPayload* payload)
{
if(!payload)
{
- OC_LOG(level, tag, PCF("NULL Payload"));
+ OC_LOG(level, PL_TAG, "NULL Payload");
return;
}
switch(payload->type)
{
case PAYLOAD_TYPE_REPRESENTATION:
- OCPayloadLogRep(level, tag, (OCRepPayload*)payload);
+ OCPayloadLogRep(level, (OCRepPayload*)payload);
break;
case PAYLOAD_TYPE_DISCOVERY:
- OCPayloadLogDiscovery(level, tag, (OCDiscoveryPayload*)payload);
+ OCPayloadLogDiscovery(level, (OCDiscoveryPayload*)payload);
break;
case PAYLOAD_TYPE_DEVICE:
- OCPayloadLogDevice(level, tag, (OCDevicePayload*)payload);
+ OCPayloadLogDevice(level, (OCDevicePayload*)payload);
break;
case PAYLOAD_TYPE_PLATFORM:
- OCPayloadLogPlatform(level, tag, (OCPlatformPayload*)payload);
+ OCPayloadLogPlatform(level, (OCPlatformPayload*)payload);
break;
case PAYLOAD_TYPE_PRESENCE:
- OCPayloadLogPresence(level, tag, (OCPresencePayload*)payload);
+ OCPayloadLogPresence(level, (OCPresencePayload*)payload);
break;
case PAYLOAD_TYPE_SECURITY:
- OCPayloadLogSecurity(level, tag, (OCSecurityPayload*)payload);
+ OCPayloadLogSecurity(level, (OCSecurityPayload*)payload);
break;
default:
- OC_LOG_V(level, tag, "Unknown Payload Type: %d", payload->type);
+ OC_LOG_V(level, PL_TAG, "Unknown Payload Type: %d", payload->type);
break;
}
}
#else
- #define OC_LOG_PAYLOAD(level, tag, payload)
+ #define OC_LOG_PAYLOAD(level, payload)
#endif
#ifdef __cplusplus
const char *getResult(OCStackResult result);
-PROGMEM const char TAG[] = "ArduinoServer";
+#define TAG "ArduinoServer"
int gLightUnderObservation = 0;
void createLightResource();
// check for the presence of the shield:
if (WiFi.status() == WL_NO_SHIELD)
{
- OC_LOG(ERROR, TAG, PCF("WiFi shield not present"));
+ OC_LOG(ERROR, TAG, ("WiFi shield not present"));
return -1;
}
OC_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, PCF("!!!!! Upgrade WiFi Shield Firmware version !!!!!!"));
+ OC_LOG(DEBUG, TAG, ("!!!!! Upgrade WiFi Shield Firmware version !!!!!!"));
return -1;
}
// wait 10 seconds for connection:
delay(10000);
}
- OC_LOG(DEBUG, TAG, PCF("Connected to wifi"));
+ OC_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]);
OCRepPayload* payload = OCRepPayloadCreate();
if(!payload)
{
- OC_LOG(ERROR, TAG, PCF("Failed to allocate Payload"));
+ OC_LOG(ERROR, TAG, ("Failed to allocate Payload"));
return OC_EH_ERROR;
}
if(entityHandlerRequest && (flag & OC_REQUEST_FLAG))
{
- OC_LOG (INFO, TAG, PCF("Flag includes OC_REQUEST_FLAG"));
+ OC_LOG (INFO, TAG, ("Flag includes OC_REQUEST_FLAG"));
if(OC_REST_GET == entityHandlerRequest->method)
{
{
if (OC_OBSERVE_REGISTER == entityHandlerRequest->obsInfo.action)
{
- OC_LOG (INFO, TAG, PCF("Received OC_OBSERVE_REGISTER from client"));
+ OC_LOG (INFO, TAG, ("Received OC_OBSERVE_REGISTER from client"));
gLightUnderObservation = 1;
}
else if (OC_OBSERVE_DEREGISTER == entityHandlerRequest->obsInfo.action)
{
- OC_LOG (INFO, TAG, PCF("Received OC_OBSERVE_DEREGISTER from client"));
+ OC_LOG (INFO, TAG, ("Received OC_OBSERVE_DEREGISTER from client"));
gLightUnderObservation = 0;
}
}
// Add your initialization code here
// Note : This will initialize Serial port on Arduino at 115200 bauds
OC_LOG_INIT();
- OC_LOG(DEBUG, TAG, PCF("OCServer is starting..."));
+ OC_LOG(DEBUG, TAG, ("OCServer is starting..."));
// Connect to Ethernet or WiFi network
if (ConnectToNetwork() != 0)
{
- OC_LOG(ERROR, TAG, PCF("Unable to connect to network"));
+ OC_LOG(ERROR, TAG, ("Unable to connect to network"));
return;
}
// Initialize the OC Stack in Server mode
if (OCInit(NULL, 0, OC_SERVER) != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, PCF("OCStack init error"));
+ OC_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, PCF("OCStack process error"));
+ OC_LOG(ERROR, TAG, ("OCStack process error"));
return;
}
ChangeLightRepresentation(NULL);
if (clientResponse)
{
OC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
- OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);
- OC_LOG(INFO, TAG, PCF("=============> Put Response"));
+ OC_LOG_PAYLOAD(INFO, clientResponse->payload);
+ OC_LOG(INFO, TAG, ("=============> Put Response"));
}
else
{
if (clientResponse)
{
OC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
- OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);
- OC_LOG(INFO, TAG, PCF("=============> Post Response"));
+ OC_LOG_PAYLOAD(INFO, clientResponse->payload);
+ OC_LOG(INFO, TAG, ("=============> Post Response"));
}
else
{
if (clientResponse)
{
OC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
- OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);
- OC_LOG(INFO, TAG, PCF("=============> Delete Response"));
+ OC_LOG_PAYLOAD(INFO, clientResponse->payload);
+ OC_LOG(INFO, TAG, ("=============> Delete Response"));
}
else
{
OC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
OC_LOG_V(INFO, TAG, "SEQUENCE NUMBER: %d", clientResponse->sequenceNumber);
- OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);
- OC_LOG(INFO, TAG, PCF("=============> Get Response"));
+ OC_LOG_PAYLOAD(INFO, clientResponse->payload);
+ OC_LOG(INFO, TAG, ("=============> Get Response"));
if (clientResponse->numRcvdVendorSpecificHeaderOptions > 0)
{
OC_LOG_V(INFO, TAG, "SEQUENCE NUMBER: %d", clientResponse->sequenceNumber);
OC_LOG_V(INFO, TAG, "Callback Context for OBSERVE notification recvd successfully %d",
gNumObserveNotifies);
- OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);
- OC_LOG(INFO, TAG, PCF("=============> Obs Response"));
+ OC_LOG_PAYLOAD(INFO, clientResponse->payload);
+ OC_LOG(INFO, TAG, ("=============> Obs Response"));
gNumObserveNotifies++;
if (gNumObserveNotifies == 15) //large number to test observing in DELETE case.
{
OC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
OC_LOG_V(INFO, TAG, "Callback Context for Presence notification recvd successfully %d",
gNumPresenceNotifies);
- OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);
- OC_LOG(INFO, TAG, PCF("=============> Presence Response"));
+ OC_LOG_PAYLOAD(INFO, clientResponse->payload);
+ OC_LOG(INFO, TAG, ("=============> Presence Response"));
gNumPresenceNotifies++;
if (gNumPresenceNotifies == 20)
{
"Device =============> Discovered @ %s:%d",
clientResponse->devAddr.addr,
clientResponse->devAddr.port);
- OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);
+ OC_LOG_PAYLOAD(INFO, clientResponse->payload);
ConnType = clientResponse->connType;
serverAddr = clientResponse->devAddr;
if (clientResponse)
{
- OC_LOG(INFO, TAG, PCF("Discovery Response:"));
- OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);
+ OC_LOG(INFO, TAG, ("Discovery Response:"));
+ OC_LOG_PAYLOAD(INFO, clientResponse->payload);
}
else
{
if (clientResponse)
{
- OC_LOG(INFO, TAG, PCF("Discovery Response:"));
- OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);
+ OC_LOG(INFO, TAG, ("Discovery Response:"));
+ OC_LOG_PAYLOAD(INFO, clientResponse->payload);
}
else
{
if(clientResponse)
{
- OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);
- OC_LOG(INFO, TAG, PCF("=============> Put Response"));
+ OC_LOG_PAYLOAD(INFO, clientResponse->payload);
+ OC_LOG(INFO, TAG, ("=============> Put Response"));
}
else
{
if(clientResponse)
{
- OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);
- OC_LOG(INFO, TAG, PCF("=============> Post Response"));
+ OC_LOG_PAYLOAD(INFO, clientResponse->payload);
+ OC_LOG(INFO, TAG, ("=============> Post Response"));
}
else
{
{
OC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
OC_LOG_V(INFO, TAG, "SEQUENCE NUMBER: %d", clientResponse->sequenceNumber);
- OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);
- OC_LOG(INFO, TAG, PCF("=============> Get Response"));
+ OC_LOG_PAYLOAD(INFO, clientResponse->payload);
+ OC_LOG(INFO, TAG, ("=============> Get Response"));
if (clientResponse->numRcvdVendorSpecificHeaderOptions > 0 )
{
"Device =============> Discovered @ %s:%d",
clientResponse->devAddr.addr,
clientResponse->devAddr.port);
- OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);
+ OC_LOG_PAYLOAD(INFO, clientResponse->payload);
collectUniqueResource(clientResponse);
}
const char *getResult(OCStackResult result);
std::string getQueryStrForGetPut();
-#define TAG PCF("occlient")
+#define TAG ("occlient")
#define DEFAULT_CONTEXT_VALUE 0x99
#ifndef MAX_LENGTH_IPv4_ADDR
#define MAX_LENGTH_IPv4_ADDR 16
if(ctx == (void*)DEFAULT_CONTEXT_VALUE)
{
OC_LOG_V(INFO, TAG, "Callback Context for PUT query recvd successfully");
- OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);
+ OC_LOG_PAYLOAD(INFO, clientResponse->payload);
}
return OC_STACK_KEEP_TRANSACTION;
if(clientResponse->sequenceNumber == 0)
{
OC_LOG_V(INFO, TAG, "Callback Context for GET query recvd successfully");
- OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);
+ OC_LOG_PAYLOAD(INFO, clientResponse->payload);
}
else
{
OC_LOG_V(INFO, TAG, "Callback Context for Get recvd successfully %d",
gNumObserveNotifies);
- OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);;
+ OC_LOG_PAYLOAD(INFO, clientResponse->payload);;
gNumObserveNotifies++;
if (gNumObserveNotifies == 3)
{
"Device =============> Discovered @ %s:%d",
clientResponse->devAddr.addr,
clientResponse->devAddr.port);
- OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);
+ OC_LOG_PAYLOAD(INFO, clientResponse->payload);
ConnType = clientResponse->connType;
cbData.cd = NULL;
OC_LOG_V(INFO, TAG, "OBSERVE payload from client =");
OCPayload* payload = putPayload();
- OC_LOG_PAYLOAD(INFO, TAG, payload);
+ OC_LOG_PAYLOAD(INFO, payload);
OCPayloadDestroy(payload);
ret = OCDoResource(&handle, OC_REST_OBSERVE, obsReg.str().c_str(),
cbData.cd = NULL;
OC_LOG_V(INFO, TAG, "PUT payload from client = ");
OCPayload* payload = putPayload();
- OC_LOG_PAYLOAD(INFO, TAG, payload);
+ OC_LOG_PAYLOAD(INFO, payload);
OCPayloadDestroy(payload);
ret = OCDoResource(NULL, OC_REST_PUT, getQuery.str().c_str(),
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, TAG, clientResponse->payload);
+ OC_LOG_PAYLOAD(INFO, clientResponse->payload);
if(clientResponse->rcvdVendorSpecificHeaderOptions &&
clientResponse->numRcvdVendorSpecificHeaderOptions)
OC_LOG_V(INFO, TAG, "Discovered @ %s:%u =============> ",
clientResponse->devAddr.addr, clientResponse->devAddr.port);
- OC_LOG_PAYLOAD (INFO, TAG, clientResponse->payload);
+ OC_LOG_PAYLOAD (INFO, clientResponse->payload);
endpoint = clientResponse->devAddr;
OC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
OC_LOG_V(INFO, TAG, "SEQUENCE NUMBER: %d", clientResponse->sequenceNumber);
- OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);
+ OC_LOG_PAYLOAD(INFO, clientResponse->payload);
if(clientResponse->numRcvdVendorSpecificHeaderOptions > 0)
{
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, TAG, clientResponse->payload);
+ OC_LOG_PAYLOAD(INFO, clientResponse->payload);
gNumObserveNotifies++;
if (gNumObserveNotifies == maxNotification)
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, TAG, clientResponse->payload);
+ OC_LOG_PAYLOAD(INFO, clientResponse->payload);
gNumPresenceNotifies++;
if (gNumPresenceNotifies == maxNotification)
}
OC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
- OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);
+ OC_LOG_PAYLOAD(INFO, clientResponse->payload);
responseAddr = clientResponse->devAddr;
if(clientResponse)
{
- OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);
+ OC_LOG_PAYLOAD(INFO, clientResponse->payload);
}
else
{
if(clientResponse)
{
- OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);
+ OC_LOG_PAYLOAD(INFO, clientResponse->payload);
}
else
{
{
if(ehRequest->payload && ehRequest->payload->type != PAYLOAD_TYPE_REPRESENTATION)
{
- OC_LOG(ERROR, TAG, PCF("Incoming payload not a representation"));
+ OC_LOG(ERROR, TAG, ("Incoming payload not a representation"));
return nullptr;
}
{
OC_LOG_V (INFO, TAG, "request query %s from client",
entityHandlerRequest->query);
- OC_LOG_PAYLOAD (INFO, TAG, entityHandlerRequest->payload);
+ OC_LOG_PAYLOAD (INFO, entityHandlerRequest->payload);
// Make deep copy of received request and queue it for slow processing
request = CopyRequest(entityHandlerRequest);
if(clientResponse)
{
OC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
- OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);
- OC_LOG(INFO, TAG, PCF("=============> Put Response"));
+ OC_LOG_PAYLOAD(INFO, clientResponse->payload);
+ OC_LOG(INFO, TAG, ("=============> Put Response"));
}
return OC_STACK_DELETE_TRANSACTION;
}
if(clientResponse)
{
OC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
- OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);
- OC_LOG(INFO, TAG, PCF("=============> Post Response"));
+ OC_LOG_PAYLOAD(INFO, clientResponse->payload);
+ OC_LOG(INFO, TAG, ("=============> Post Response"));
}
return OC_STACK_DELETE_TRANSACTION;
}
{
OC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
OC_LOG_V(INFO, TAG, "SEQUENCE NUMBER: %d", clientResponse->sequenceNumber);
- OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);
- OC_LOG(INFO, TAG, PCF("=============> Get Response"));
+ OC_LOG_PAYLOAD(INFO, clientResponse->payload);
+ OC_LOG(INFO, TAG, ("=============> Get Response"));
}
return OC_STACK_DELETE_TRANSACTION;
}
if (clientResponse->result == OC_STACK_OK)
{
- OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);
+ OC_LOG_PAYLOAD(INFO, clientResponse->payload);
ocConnType = clientResponse->connType;
endpoint = clientResponse->devAddr;
if(clientResponse)
{
cout << "\nStackResult: " << getResult(clientResponse->result);
- //OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);
+ //OC_LOG_PAYLOAD(INFO, clientResponse->payload);
}
else
{
cout << "\nStackResult: " << getResult(clientResponse->result);
cout << "\nSEQUENCE NUMBER: " << clientResponse->sequenceNumber;
cout << "\nCallback Context for OBSERVE notification recvd successfully ";
- //OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);
+ //OC_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, TAG, clientResponse->payload);
+ //OC_LOG_PAYLOAD(INFO, clientResponse->payload);
gNumPresenceNotifies++;
if (gNumPresenceNotifies == 20)
{
{
cout << ":" << clientResponse->devAddr.port;
}
- //OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);
+ //OC_LOG_PAYLOAD(INFO, clientResponse->payload);
cout << "\nConnectivity type: " << clientResponse->connType;
OC_CONNTYPE = clientResponse->connType;
parseClientResponse(clientResponse);
if(clientResponse)
{
//OC_LOG truncates the response as it is too long.
- //OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);
+ //OC_LOG_PAYLOAD(INFO, clientResponse->payload);
}
else
{
#include "cainterface.h"
/// Module Name
-#define TAG PCF("occlientcb")
+#define TAG "occlientcb"
struct ClientCB *cbList = NULL;
static OCMulticastNode * mcPresenceNodes = NULL;
}
else
{
- OC_LOG(INFO, TAG, PCF("Adding client callback with token"));
+ OC_LOG(INFO, TAG, "Adding client callback with token");
OC_LOG_BUFFER(INFO, TAG, (const uint8_t *)token, tokenLength);
cbNode->callBack = cbData->cb;
cbNode->context = cbData->context;
if(cbNode)
{
LL_DELETE(cbList, cbNode);
- OC_LOG (INFO, TAG, PCF("Deleting token"));
+ OC_LOG (INFO, TAG, "Deleting token");
OC_LOG_BUFFER(INFO, TAG, (const uint8_t *)cbNode->token, cbNode->tokenLength);
CADestroyToken (cbNode->token);
OICFree(cbNode->devAddr);
if (cbNode->TTL < now)
{
- OC_LOG(INFO, TAG, PCF("Deleting timed-out callback"));
+ OC_LOG(INFO, TAG, "Deleting timed-out callback");
DeleteClientCB(cbNode);
}
}
if(token && *token && tokenLength <= CA_MAX_TOKEN_LEN && tokenLength > 0)
{
- OC_LOG (INFO, TAG, PCF ("Looking for token"));
+ OC_LOG (INFO, TAG, "Looking for token");
OC_LOG_BUFFER(INFO, TAG, (const uint8_t *)token, tokenLength);
- OC_LOG(INFO, TAG, PCF("\tFound in callback list"));
+ OC_LOG(INFO, TAG, "\tFound in callback list");
LL_FOREACH(cbList, out)
{
OC_LOG_BUFFER(INFO, TAG, (const uint8_t *)out->token, tokenLength);
CheckAndDeleteTimedOutCB(out);
}
}
- OC_LOG(INFO, TAG, PCF("Callback Not found !!"));
+ OC_LOG(INFO, TAG, "Callback Not found !!");
return NULL;
}
}
}
}
- OC_LOG(INFO, TAG, PCF("MulticastNode Not found !!"));
+ OC_LOG(INFO, TAG, "MulticastNode Not found !!");
return NULL;
}
#include "oicgroup.h"
-#define TAG PCF("occollection")
+#define TAG "occollection"
#define NUM_PARAM_IN_QUERY 2 // The expected number of parameters in a query
#define NUM_FIELDS_IN_QUERY 2 // The expected number of fields in a query
//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, PCF("Entering ValidateQuery"));
+ OC_LOG(INFO, TAG, "Entering ValidateQuery");
if (!query)
return OC_STACK_ERROR;
if (!(*query))
{
// Query string is empty
- OC_LOG_V(INFO, TAG, PCF("Empty query string, use default IF and RT"));
+ OC_LOG(INFO, TAG, "Empty query string, use default IF and RT");
*ifParam = STACK_IF_DEFAULT;
*rtParam = (char *) OCGetResourceTypeName (resource, 0);
return OC_STACK_OK;
// as slow response
if(ehResult == OC_EH_SLOW)
{
- OC_LOG(INFO, TAG, PCF("This is a slow resource"));
+ OC_LOG(INFO, TAG, "This is a slow resource");
((OCServerRequest *)ehRequest->requestHandle)->slowFlag = 1;
stackRet = EntityHandlerCodeToOCStackCode(ehResult);
}
// 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, PCF("STACK_IF_DEFAULT"));
+ OC_LOG(INFO, TAG, "STACK_IF_DEFAULT");
return HandleLinkedListInterface(ehRequest, STACK_RES_DISCOVERY_NOFILTER, NULL);
case STACK_IF_LL:
- OC_LOG(INFO, TAG, PCF("STACK_IF_LL"));
+ OC_LOG(INFO, TAG, "STACK_IF_LL");
return HandleLinkedListInterface(ehRequest, STACK_RES_DISCOVERY_NOFILTER, NULL);
case STACK_IF_BATCH:
- OC_LOG(INFO, TAG, PCF("STACK_IF_BATCH"));
+ OC_LOG(INFO, TAG, "STACK_IF_BATCH");
((OCServerRequest *)ehRequest->requestHandle)->ehResponseHandler =
HandleAggregateResponse;
return HandleBatchInterface(ehRequest);
case STACK_IF_GROUP:
- OC_LOG(INFO, TAG, PCF("IF_COLLECTION PUT with request ::\n"));
- OC_LOG_PAYLOAD(INFO, TAG, ehRequest->payload);
+ OC_LOG(INFO, TAG, "IF_COLLECTION PUT with request ::\n");
+ OC_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, PCF("IF_COLLECTION POST with request ::\n"));
- OC_LOG_PAYLOAD(INFO, TAG, ehRequest->payload);
+ OC_LOG(INFO, TAG, "IF_COLLECTION POST with request ::\n");
+ OC_LOG_PAYLOAD(INFO, ehRequest->payload);
return BuildCollectionGroupActionCBORResponse(OC_REST_POST/*flag*/,
(OCResource *) ehRequest->resource, ehRequest);
// Module Name
-#define MOD_NAME PCF("ocobserve")
+#define MOD_NAME "ocobserve"
-#define TAG PCF("OCStackObserve")
+#define TAG "OCStackObserve"
#define VERIFY_NON_NULL(arg) { if (!arg) {OC_LOG(FATAL, TAG, #arg " is NULL"); goto exit;} }
resourceObserver->lowQosCount = 0;
// at some point we have to to send CON to check on the
// availability of observer
- OC_LOG(INFO, TAG, PCF("This time we are sending the notification as High qos"));
+ OC_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, PCF("Entering SendObserverNotification"));
+ OC_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, PCF("This notification is for Presence"));
+ OC_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, PCF("Resource has no observers"));
+ OC_LOG(INFO, TAG, "Resource has no observers");
result = OC_STACK_NO_OBSERVERS;
}
else if (observeErrorFlag)
{
- OC_LOG(ERROR, TAG, PCF("Observer notification error"));
+ OC_LOG(ERROR, TAG, "Observer notification error");
result = OC_STACK_ERROR;
}
return result;
OCStackResult result = OC_STACK_ERROR;
bool observeErrorFlag = false;
- OC_LOG(INFO, TAG, PCF("Entering SendListObserverNotification"));
+ OC_LOG(INFO, TAG, "Entering SendListObserverNotification");
while(numIds)
{
observer = GetObserverUsingId (*obsIdList);
}
else
{
- OC_LOG(ERROR, TAG, PCF("Observer notification error"));
+ OC_LOG(ERROR, TAG, "Observer notification error");
return OC_STACK_ERROR;
}
}
{
ResourceObserver *resObs = NULL;
- OC_LOG(INFO, TAG, PCF("Entering GenerateObserverId"));
+ OC_LOG(INFO, TAG, "Entering GenerateObserverId");
VERIFY_NON_NULL (observationId);
do
}
}
}
- OC_LOG(INFO, TAG, PCF("Observer node not found!!"));
+ OC_LOG(INFO, TAG, "Observer node not found!!");
return NULL;
}
if(token && *token)
{
- OC_LOG(INFO, TAG,PCF("Looking for token"));
+ OC_LOG(INFO, TAG, "Looking for token");
OC_LOG_BUFFER(INFO, TAG, (const uint8_t *)token, tokenLength);
- OC_LOG(INFO, TAG,PCF("\tFound token:"));
+ OC_LOG(INFO, TAG, "\tFound token:");
LL_FOREACH (serverObsList, out)
{
}
else
{
- OC_LOG(ERROR, TAG,PCF("Passed in NULL token"));
+ OC_LOG(ERROR, TAG, "Passed in NULL token");
}
- OC_LOG(INFO, TAG, PCF("Observer node not found!!"));
+ OC_LOG(INFO, TAG, "Observer node not found!!");
return NULL;
}
}
break;
default:
- OC_LOG(ERROR, TAG, PCF("CopyPropertyValueArray invalid type"));
+ OC_LOG(ERROR, TAG, "CopyPropertyValueArray invalid type");
break;
}
}
val = val->next;
}
- OC_LOG(ERROR, TAG, PCF("FindAndSetValue reached point after while loop, pointer corruption?"));
+ OC_LOG(ERROR, TAG, "FindAndSetValue reached point after while loop, pointer corruption?");
return NULL;
}
#include "ocresourcehandler.h"
#include "cbor.h"
-#define TAG PCF("OCPayloadConvert")
+#define TAG "OCPayloadConvert"
// Arbitrarily chosen size that seems to contain the majority of packages
#define INIT_SIZE (255)
#undef CborNeedsUpdating
if (!payload)
{
- OC_LOG(ERROR, TAG, PCF("Payload parameter NULL"));
+ OC_LOG(ERROR, TAG, "Payload parameter NULL");
return OC_STACK_INVALID_PARAM;
}
if (!outPayload || !size)
{
- OC_LOG(ERROR, TAG, PCF("Out parameter/s parameter NULL"));
+ OC_LOG(ERROR, TAG, "Out parameter/s parameter NULL");
return OC_STACK_INVALID_PARAM;
}
switch(valArray->type)
{
case OCREP_PROP_NULL:
- OC_LOG(ERROR, TAG, PCF("ConvertArray Invalid NULL"));
+ OC_LOG(ERROR, TAG, "ConvertArray Invalid NULL");
err = CborUnknownError;
break;
case OCREP_PROP_INT:
err = OCConvertSingleRepPayload(&array, valArray->objArray[i]);
break;
case OCREP_PROP_ARRAY:
- OC_LOG(ERROR, TAG, PCF("ConvertArray Invalid child array"));
+ OC_LOG(ERROR, TAG, "ConvertArray Invalid child array");
err = CborUnknownError;
break;
}
// resource types, interfaces
if(payload->types || payload->interfaces)
{
- OC_LOG_V(INFO, TAG, "Payload has types or interfaces");
+ OC_LOG(INFO, TAG, "Payload has types or interfaces");
err = err | cbor_encode_text_string(&map,
OC_RSRVD_PROPERTY,
sizeof(OC_RSRVD_PROPERTY) - 1);
#include "ocpayload.h"
#include "cbor.h"
-#define TAG PCF("OCPayloadParse")
+#define TAG "OCPayloadParse"
static OCStackResult OCParseDiscoveryPayload(OCPayload** outPayload, CborValue* arrayVal);
static OCStackResult OCParseDevicePayload(OCPayload** outPayload, CborValue* arrayVal);
}
else
{
- OC_LOG_V(ERROR, TAG, PCF("Cbor main value not a map"));
+ OC_LOG(ERROR, TAG, "Cbor main value not a map");
return OC_STACK_MALFORMED_RESPONSE;
}
if(err)
{
- OC_LOG_V(ERROR, TAG, "Cbor in error condition");
+ OC_LOG(ERROR, TAG, "Cbor in error condition");
OICFree(securityData);
return OC_STACK_MALFORMED_RESPONSE;
}
OCResourcePayload* resource = (OCResourcePayload*)OICCalloc(1, sizeof(OCResourcePayload));
if(!resource)
{
- OC_LOG_V(ERROR, TAG, "Memory allocation failed");
+ OC_LOG(ERROR, TAG, "Memory allocation failed");
OCDiscoveryPayloadDestroy(out);
return OC_STACK_NO_MEMORY;
}
llPtr = resource->types;
if(!llPtr)
{
- OC_LOG(ERROR, TAG, PCF("Memory allocation failed"));
+ OC_LOG(ERROR, TAG, "Memory allocation failed");
OICFree(resource->uri);
OICFree(resource->sid);
OICFree(resource);
llPtr = llPtr->next;
if(!llPtr)
{
- OC_LOG(ERROR, TAG, PCF("Memory allocation failed"));
+ OC_LOG(ERROR, TAG, "Memory allocation failed");
OICFree(resource->uri);
OICFree(resource->sid);
OCFreeOCStringLL(resource->types);
}
else
{
- OC_LOG(ERROR, TAG, PCF("Unknown state in resource type copying"));
+ OC_LOG(ERROR, TAG, "Unknown state in resource type copying");
OICFree(resource->uri);
OICFree(resource->sid);
OCFreeOCStringLL(resource->types);
llPtr = resource->interfaces;
if(!llPtr)
{
- OC_LOG_V(ERROR, TAG, "Memory allocation failed");
+ OC_LOG(ERROR, TAG, "Memory allocation failed");
OICFree(resource->uri);
OICFree(resource->sid);
OCFreeOCStringLL(resource->types);
llPtr = llPtr->next;
if(!llPtr)
{
- OC_LOG_V(ERROR, TAG, "Memory allocation failed");
+ OC_LOG(ERROR, TAG, "Memory allocation failed");
OICFree(resource->uri);
OICFree(resource->sid);
OCFreeOCStringLL(resource->types);
}
else
{
- OC_LOG(ERROR, TAG, PCF("Unknown state in resource interfaces copying"));
+ OC_LOG(ERROR, TAG, "Unknown state in resource interfaces copying");
OICFree(resource->uri);
OICFree(resource->sid);
OCFreeOCStringLL(resource->types);
}
else
{
- OC_LOG(ERROR, TAG, PCF("Root device node was not a map"));
+ OC_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, PCF("CBOR error In ParsePlatformPayload"));
+ OC_LOG(ERROR, TAG, "CBOR error In ParsePlatformPayload");
return OC_STACK_MALFORMED_RESPONSE;
}
}
else
{
- OC_LOG(ERROR, TAG, PCF("Root device node was not a map"));
+ OC_LOG(ERROR, TAG, "Root device node was not a map");
return OC_STACK_MALFORMED_RESPONSE;
}
}
if(err)
{
OCRepPayloadDestroy(rootPayload);
- OC_LOG_V(ERROR, TAG, PCF("CBOR error in ParseRepPayload"));
+ OC_LOG(ERROR, TAG, "CBOR error in ParseRepPayload");
return OC_STACK_MALFORMED_RESPONSE;
}
}
if(err)
{
OCPayloadDestroy(*outPayload);
- OC_LOG_V(ERROR, TAG, PCF("CBOR error Parse Presence Payload"));
+ OC_LOG(ERROR, TAG, "CBOR error Parse Presence Payload");
return OC_STACK_MALFORMED_RESPONSE;
}
}
else
{
- OC_LOG(ERROR, TAG, PCF("Root presence node was not a map"));
+ OC_LOG(ERROR, TAG, "Root presence node was not a map");
return OC_STACK_MALFORMED_RESPONSE;
}
}
/// Module Name
-#define TAG PCF("ocresource")
+#define TAG "ocresource"
#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), \
- TAG, PCF(#arg " is NULL")); return (retVal); } }
+ TAG, #arg " is NULL"); return (retVal); } }
extern OCResource *headResource;
static OCPlatformInfo savedPlatformInfo = {0};
{
if (numKeyValuePairsParsed >= 2)
{
- OC_LOG(ERROR, TAG, PCF("More than 2 queries params in URI."));
+ OC_LOG(ERROR, TAG, "More than 2 queries params in URI.");
return OC_STACK_INVALID_QUERY;
}
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, PCF("OC_PRESENCE Request for virtual resource."));
+ OC_LOG(INFO, TAG, "OC_PRESENCE Request for virtual resource.");
return OC_STACK_OK;
}
#endif
resourceTypePtr = resourceTypePtr->next;
}
- OC_LOG_V(INFO, TAG, PCF("%s does not contain rt=%s."), resource->uri, resourceTypeFilter);
+ OC_LOG_V(INFO, TAG, "%s does not contain rt=%s.", resource->uri, resourceTypeFilter);
return false;
}
interfacePtr = interfacePtr->next;
}
- OC_LOG_V(INFO, TAG, PCF("%s does not contain if=%s."), resource->uri, interfaceFilter);
+ OC_LOG_V(INFO, TAG, "%s does not contain if=%s.", resource->uri, interfaceFilter);
return false;
}
{
if (!resource)
{
- OC_LOG(ERROR, TAG, PCF("Invalid resource"));
+ OC_LOG(ERROR, TAG, "Invalid resource");
return false;
}
if (!((interfaceFilter && *interfaceFilter ) ||
(resourceTypeFilter && *resourceTypeFilter)))
{
- OC_LOG_V(INFO, TAG, PCF("%s no query string for EXPLICIT_DISCOVERABLE \
- resource"), resource->uri);
+ OC_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, PCF("%s not ACTIVE or DISCOVERABLE"), resource->uri);
+ OC_LOG_V(INFO, TAG, "%s not ACTIVE or DISCOVERABLE", resource->uri);
return false;
}
bool bMulticast = false; // Was the discovery request a multicast request?
OCPayload* payload = NULL;
- OC_LOG(INFO, TAG, PCF("Entering HandleVirtualResource"));
+ OC_LOG(INFO, TAG, "Entering HandleVirtualResource");
OCVirtualResources virtualUriInRequest = GetTypeOfVirtualURI (request->resourceUrl);
else
{
// Ignoring the discovery request as per RFC 7252, Section #8.2
- OC_LOG_V(INFO, TAG, "Silently ignoring the request since device does not have \
+ OC_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, PCF("Entering HandleResourceWithDefaultDeviceEntityHandler"));
+ OC_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, PCF("This is a slow resource"));
+ OC_LOG(INFO, TAG, "This is a slow resource");
request->slowFlag = 1;
}
else if(ehResult == OC_EH_ERROR)
OCEntityHandlerRequest ehRequest = {0};
- OC_LOG(INFO, TAG, PCF("Entering HandleResourceWithEntityHandler"));
+ OC_LOG(INFO, TAG, "Entering HandleResourceWithEntityHandler");
result = FormOCEntityHandlerRequest(&ehRequest,
(OCRequestHandle)request,
if(ehRequest.obsInfo.action == OC_OBSERVE_NO_OPTION)
{
- OC_LOG(INFO, TAG, PCF("No observation requested"));
+ OC_LOG(INFO, TAG, "No observation requested");
ehFlag = OC_REQUEST_FLAG;
}
else if(ehRequest.obsInfo.action == OC_OBSERVE_REGISTER && !collectionResource)
{
- OC_LOG(INFO, TAG, PCF("Observation registration requested"));
+ OC_LOG(INFO, TAG, "Observation registration requested");
result = GenerateObserverId(&ehRequest.obsInfo.obsId);
VERIFY_SUCCESS(result, OC_STACK_OK);
if(result == OC_STACK_OK)
{
- OC_LOG(INFO, TAG, PCF("Added observer successfully"));
+ OC_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, PCF("Observer Addition failed"));
+ OC_LOG(ERROR, TAG, "Observer Addition failed");
ehFlag = OC_REQUEST_FLAG;
}
else if(ehRequest.obsInfo.action == OC_OBSERVE_DEREGISTER &&
!collectionResource)
{
- OC_LOG(INFO, TAG, PCF("Deregistering observation requested"));
+ OC_LOG(INFO, TAG, "Deregistering observation requested");
resObs = GetObserverUsingToken (request->requestToken, request->tokenLength);
if(result == OC_STACK_OK)
{
- OC_LOG(INFO, TAG, PCF("Removed observer successfully"));
+ OC_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, PCF("Observer Removal failed"));
+ OC_LOG(ERROR, TAG, "Observer Removal failed");
}
}
else
ehResult = resource->entityHandler(ehFlag, &ehRequest, resource->entityHandlerCallbackParam);
if(ehResult == OC_EH_SLOW)
{
- OC_LOG(INFO, TAG, PCF("This is a slow resource"));
+ OC_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, PCF("OC_RESOURCE_NOT_COLLECTION_DEFAULT_ENTITYHANDLER"));
+ OC_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, PCF("Invalid Resource Determination"));
+ OC_LOG(INFO, TAG, "Invalid Resource Determination");
return OC_STACK_ERROR;
}
}
void DeletePlatformInfo()
{
- OC_LOG(INFO, TAG, PCF("Deleting platform info."));
+ OC_LOG(INFO, TAG, "Deleting platform info.");
OICFree(savedPlatformInfo.platformID);
savedPlatformInfo.platformID = NULL;
if (res != OC_STACK_OK)
{
- OC_LOG_V(ERROR, TAG, PCF("Failed to save platform info. errno(%d)"), res);
+ OC_LOG_V(ERROR, TAG, "Failed to save platform info. errno(%d)", res);
}
else
{
- OC_LOG(ERROR, TAG, PCF("Platform info saved."));
+ OC_LOG(ERROR, TAG, "Platform info saved.");
}
return res;
void DeleteDeviceInfo()
{
- OC_LOG(INFO, TAG, PCF("Deleting device info."));
+ OC_LOG(INFO, TAG, "Deleting device info.");
OICFree(savedDeviceInfo.deviceName);
savedDeviceInfo.deviceName = NULL;
if(OCGetServerInstanceID() == NULL)
{
- OC_LOG(INFO, TAG, PCF("Device ID generation failed"));
+ OC_LOG(INFO, TAG, "Device ID generation failed");
res = OC_STACK_ERROR;
goto exit;
}
- OC_LOG(INFO, TAG, PCF("Device initialized successfully."));
+ OC_LOG(INFO, TAG, "Device initialized successfully.");
return OC_STACK_OK;
exit:
// Module Name
#define VERIFY_NON_NULL(arg) { if (!arg) {OC_LOG(FATAL, TAG, #arg " is NULL"); goto exit;} }
-#define TAG PCF("ocserverrequest")
+#define TAG "ocserverrequest"
static struct OCServerRequest * serverRequestList = NULL;
static struct OCServerResponse * serverResponseList = NULL;
serverResponse->requestHandle = requestHandle;
*response = serverResponse;
- OC_LOG(INFO, TAG, PCF("Server Response Added!!"));
+ OC_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, PCF("Server Request Removed!!"));
+ OC_LOG(INFO, TAG, "Server Request Removed!!");
}
}
LL_DELETE(serverResponseList, serverResponse);
OICFree(serverResponse->payload);
OICFree(serverResponse);
- OC_LOG(INFO, TAG, PCF("Server Response Removed!!"));
+ OC_LOG(INFO, TAG, "Server Response Removed!!");
}
}
{
if(!token)
{
- OC_LOG(ERROR, TAG, PCF("Invalid Parameter Token"));
+ OC_LOG(ERROR, TAG, "Invalid Parameter Token");
return NULL;
}
OCServerRequest * out = NULL;
- OC_LOG(INFO, TAG,PCF("Get server request with token"));
+ OC_LOG(INFO, TAG,"Get server request with token");
OC_LOG_BUFFER(INFO, TAG, (const uint8_t *)token, tokenLength);
- OC_LOG(INFO, TAG,PCF("Found token"));
+ OC_LOG(INFO, TAG,"Found token");
LL_FOREACH (serverRequestList, out)
{
OC_LOG_BUFFER(INFO, TAG, (const uint8_t *)out->requestToken, tokenLength);
return out;
}
}
- OC_LOG(ERROR, TAG, PCF("Server Request not found!!"));
+ OC_LOG(ERROR, TAG, "Server Request not found!!");
return NULL;
}
return out;
}
}
- OC_LOG(ERROR, TAG, PCF("Server Request not found!!"));
+ OC_LOG(ERROR, TAG, "Server Request not found!!");
return NULL;
}
return out;
}
}
- OC_LOG(ERROR, TAG, PCF("Server Response not found!!"));
+ OC_LOG(ERROR, TAG, "Server Response not found!!");
return NULL;
}
serverRequest->devAddr = *devAddr;
*request = serverRequest;
- OC_LOG(INFO, TAG, PCF("Server Request Added!!"));
+ OC_LOG(INFO, TAG, "Server Request Added!!");
LL_APPEND (serverRequestList, serverRequest);
return OC_STACK_OK;
if(!responseInfo.info.options)
{
- OC_LOG(FATAL, TAG, PCF("Memory alloc for options failed"));
+ OC_LOG(FATAL, TAG, "Memory alloc for options failed");
return OC_STACK_NO_MEMORY;
}
}
#else
- OC_LOG(INFO, TAG, PCF("Calling CASendResponse with:"));
+ OC_LOG(INFO, TAG, "Calling CASendResponse 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);
CAResult_t caResult = CASendResponse(&responseEndpoint, &responseInfo);
if(caResult != CA_STATUS_OK)
{
- OC_LOG(ERROR, TAG, PCF("CASendResponse failed"));
+ OC_LOG(ERROR, TAG, "CASendResponse failed");
result = CAResultToOCResult(caResult);
}
else
if(!ehResponse || !ehResponse->payload)
{
- OC_LOG(ERROR, TAG, PCF("HandleAggregateResponse invalid parameters"));
+ OC_LOG(ERROR, TAG, "HandleAggregateResponse invalid parameters");
return OC_STACK_INVALID_PARAM;
}
{
if(!serverResponse)
{
- OC_LOG(INFO, TAG, PCF("This is the first response fragment"));
+ OC_LOG(INFO, TAG, "This is the first response fragment");
stackRet = AddServerResponse(&serverResponse, ehResponse->requestHandle);
if (OC_STACK_OK != stackRet)
{
- OC_LOG(ERROR, TAG, PCF("Error adding server response"));
+ OC_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, PCF("Error adding payload, as it was the incorrect type"));
+ OC_LOG(ERROR, TAG, "Error adding payload, as it was the incorrect type");
goto exit;
}
if(serverRequest->numResponses == 0)
{
- OC_LOG(INFO, TAG, PCF("This is the last response fragment"));
+ OC_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, PCF("More response fragments to come"));
+ OC_LOG(INFO, TAG, "More response fragments to come");
stackRet = OC_STACK_OK;
}
}
//-----------------------------------------------------------------------------
// Macros
//-----------------------------------------------------------------------------
-#define TAG PCF("OCStack")
+#define TAG "OCStack"
#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), \
- TAG, PCF(#arg " is NULL")); return (retVal); } }
+ TAG, #arg " is NULL"); return (retVal); } }
#define VERIFY_NON_NULL_NR(arg, logLevel) { if (!(arg)) { OC_LOG((logLevel), \
- TAG, PCF(#arg " is NULL")); return; } }
+ TAG, #arg " is NULL"); return; } }
#define VERIFY_NON_NULL_V(arg) { if (!arg) {OC_LOG_V(FATAL, TAG, "%s is NULL", #arg);\
goto exit;} }
switch(status)
{
case OC_OBSERVER_NOT_INTERESTED:
- OC_LOG(DEBUG, TAG, PCF("observer not interested in our notifications"));
+ OC_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, PCF("Removed observer successfully"));
+ OC_LOG(DEBUG, TAG, "Removed observer successfully");
}
else
{
result = OC_STACK_OK;
- OC_LOG(DEBUG, TAG, PCF("Observer Removal failed"));
+ OC_LOG(DEBUG, TAG, "Observer Removal failed");
}
break;
case OC_OBSERVER_STILL_INTERESTED:
- OC_LOG(DEBUG, TAG, PCF("observer still interested, reset the failedCount"));
+ OC_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, PCF("observer is unreachable"));
+ OC_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, PCF("Removed observer successfully"));
+ OC_LOG(DEBUG, TAG, "Removed observer successfully");
}
else
{
result = OC_STACK_OK;
- OC_LOG(DEBUG, TAG, PCF("Observer Removal failed"));
+ OC_LOG(DEBUG, TAG, "Observer Removal failed");
}
}
else
}
break;
default:
- OC_LOG(ERROR, TAG, PCF("Unknown status"));
+ OC_LOG(ERROR, TAG, "Unknown status");
result = OC_STACK_ERROR;
break;
}
if (!presenceSubscribe && !multicastPresenceSubscribe)
{
- OC_LOG(ERROR, TAG, PCF("Received a presence notification, but no callback, ignoring"));
+ OC_LOG(ERROR, TAG, "Received a presence notification, but no callback, ignoring");
goto exit;
}
if(result != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, PCF("Presence parse failed"));
+ OC_LOG(ERROR, TAG, "Presence parse failed");
goto exit;
}
if(!response.payload || response.payload->type != PAYLOAD_TYPE_PRESENCE)
{
- OC_LOG(ERROR, TAG, PCF("Presence payload was wrong type"));
+ OC_LOG(ERROR, TAG, "Presence payload was wrong type");
result = OC_STACK_ERROR;
goto exit;
}
{
if(cbNode->sequenceNumber == response.sequenceNumber)
{
- OC_LOG(INFO, TAG, PCF("No presence change"));
+ OC_LOG(INFO, TAG, "No presence change");
goto exit;
}
if(maxAge == 0)
{
- OC_LOG(INFO, TAG, PCF("Stopping presence"));
+ OC_LOG(INFO, TAG, "Stopping presence");
response.result = OC_STACK_PRESENCE_STOPPED;
if(cbNode->presence)
{
if(!(cbNode->presence))
{
- OC_LOG(ERROR, TAG, PCF("Could not allocate memory for cbNode->presence"));
+ OC_LOG(ERROR, TAG, "Could not allocate memory for cbNode->presence");
result = OC_STACK_NO_MEMORY;
goto exit;
}
OICMalloc(PresenceTimeOutSize * sizeof(uint32_t));
if(!(cbNode->presence->timeOut)){
OC_LOG(ERROR, TAG,
- PCF("Could not allocate memory for cbNode->presence->timeOut"));
+ "Could not allocate memory for cbNode->presence->timeOut");
OICFree(cbNode->presence);
result = OC_STACK_NO_MEMORY;
goto exit;
{
if(mcNode->nonce == response.sequenceNumber)
{
- OC_LOG(INFO, TAG, PCF("No presence change (Multicast)"));
+ OC_LOG(INFO, TAG, "No presence change (Multicast)");
goto exit;
}
mcNode->nonce = response.sequenceNumber;
if(maxAge == 0)
{
- OC_LOG(INFO, TAG, PCF("Stopping presence"));
+ OC_LOG(INFO, TAG, "Stopping presence");
response.result = OC_STACK_PRESENCE_STOPPED;
}
}
if (!uri)
{
OC_LOG(INFO, TAG,
- PCF("No Memory for URI to store in the presence node"));
+ "No Memory for URI to store in the presence node");
result = OC_STACK_NO_MEMORY;
goto exit;
}
if(result == OC_STACK_NO_MEMORY)
{
OC_LOG(INFO, TAG,
- PCF("No Memory for Multicast Presence Node"));
+ "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, PCF("Enter HandleCAResponses"));
+ OC_LOG(INFO, TAG, "Enter HandleCAResponses");
if(responseInfo->info.resourceUri &&
strcmp(responseInfo->info.resourceUri, OC_RSRVD_PRESENCE_URI) == 0)
if(cbNode)
{
- OC_LOG(INFO, TAG, PCF("There is a cbNode associated with the response token"));
+ OC_LOG(INFO, TAG, "There is a cbNode associated with the response token");
if(responseInfo->result == CA_EMPTY)
{
- OC_LOG(INFO, TAG, PCF("Receiving A ACK/RESET for this token"));
+ OC_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, PCF("This is a pure ACK"));
+ OC_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, PCF("Receiving A Timeout for this token"));
- OC_LOG(INFO, TAG, PCF("Calling into application address space"));
+ OC_LOG(INFO, TAG, "Receiving A Timeout for this token");
+ OC_LOG(INFO, TAG, "Calling into application address space");
OCClientResponse response =
{.devAddr = {.adapter = OC_DEFAULT_ADAPTER}};
}
else
{
- OC_LOG(INFO, TAG, PCF("This is a regular response, A client call back is found"));
- OC_LOG(INFO, TAG, PCF("Calling into application address space"));
+ OC_LOG(INFO, TAG, "This is a regular response, A client call back is found");
+ OC_LOG(INFO, TAG, "Calling into application address space");
OCClientResponse response =
{.devAddr = {.adapter = OC_DEFAULT_ADAPTER}};
OC_STACK_OK != OCParsePayload(&response.payload, responseInfo->info.payload,
responseInfo->info.payloadSize))
{
- OC_LOG(ERROR, TAG, PCF("Error converting payload"));
+ OC_LOG(ERROR, TAG, "Error converting payload");
OCPayloadDestroy(response.payload);
return;
}
if(response.numRcvdVendorSpecificHeaderOptions > MAX_HEADER_OPTIONS)
{
- OC_LOG(ERROR, TAG, PCF("#header options are more than MAX_HEADER_OPTIONS"));
+ OC_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, PCF("Received stale notification. Number :%d"),
+ OC_LOG_V(INFO, TAG, "Received stale notification. Number :%d",
response.sequenceNumber);
}
else
if(observer)
{
- OC_LOG(INFO, TAG, PCF("There is an observer associated with the response token"));
+ OC_LOG(INFO, TAG, "There is an observer associated with the response token");
if(responseInfo->result == CA_EMPTY)
{
- OC_LOG(INFO, TAG, PCF("Receiving A ACK/RESET for this token"));
+ OC_LOG(INFO, TAG, "Receiving A ACK/RESET for this token");
if(responseInfo->info.type == CA_MSG_RESET)
{
- OC_LOG(INFO, TAG, PCF("This is a RESET"));
+ OC_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, PCF("This is a pure ACK"));
+ OC_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, PCF("Receiving Time Out for an observer"));
+ OC_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)
{
- OC_LOG(INFO, TAG, PCF("This is a client, but no cbNode was found for token"));
+ OC_LOG(INFO, TAG, "This is a client, but no cbNode was found for token");
if(responseInfo->result == CA_EMPTY)
{
- OC_LOG(INFO, TAG, PCF("Receiving CA_EMPTY in the ocstack"));
+ OC_LOG(INFO, TAG, "Receiving CA_EMPTY in the ocstack");
}
else
{
- OC_LOG(INFO, TAG, PCF("Received a message without callbacks. Sending RESET"));
+ OC_LOG(INFO, TAG, "Received a message without callbacks. Sending RESET");
SendDirectStackResponse(endPoint, responseInfo->info.messageId, CA_EMPTY,
CA_MSG_RESET, 0, NULL, NULL, 0);
}
if(myStackMode == OC_SERVER || myStackMode == OC_CLIENT_SERVER)
{
- OC_LOG(INFO, TAG, PCF("This is a server, but no observer was found for token"));
+ OC_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, PCF("Received ACK at server for messageId : %d"),
+ OC_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, PCF("Received RESET at server for messageId : %d"),
+ OC_LOG_V(INFO, TAG, "Received RESET at server for messageId : %d",
responseInfo->info.messageId);
}
}
return;
}
- OC_LOG(INFO, TAG, PCF("Exit HandleCAResponses"));
+ OC_LOG(INFO, TAG, "Exit HandleCAResponses");
}
/*
*/
void HandleCAErrorResponse(const CAEndpoint_t *endPoint, const CAErrorInfo_t *errrorInfo)
{
- OC_LOG(INFO, TAG, PCF("Enter HandleCAErrorResponse"));
+ OC_LOG(INFO, TAG, "Enter HandleCAErrorResponse");
if(NULL == endPoint)
{
- OC_LOG(ERROR, TAG, PCF("endPoint is NULL"));
+ OC_LOG(ERROR, TAG, "endPoint is NULL");
return;
}
if(NULL == errrorInfo)
{
- OC_LOG(ERROR, TAG, PCF("errrorInfo is NULL"));
+ OC_LOG(ERROR, TAG, "errrorInfo is NULL");
return;
}
- OC_LOG(INFO, TAG, PCF("Exit HandleCAErrorResponse"));
+ OC_LOG(INFO, TAG, "Exit HandleCAErrorResponse");
}
/*
CAResult_t caResult = CASendResponse(endPoint, &respInfo);
if(caResult != CA_STATUS_OK)
{
- OC_LOG(ERROR, TAG, PCF("CASendResponse error"));
+ OC_LOG(ERROR, TAG, "CASendResponse error");
return OC_STACK_ERROR;
}
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, PCF("Enter HandleCARequests"));
+ OC_LOG(INFO, TAG, "Enter HandleCARequests");
if(!endPoint)
{
- OC_LOG(ERROR, TAG, PCF("endPoint is NULL"));
+ OC_LOG(ERROR, TAG, "endPoint is NULL");
return;
}
if(!requestInfo)
{
- OC_LOG(ERROR, TAG, PCF("requestInfo is NULL"));
+ OC_LOG(ERROR, TAG, "requestInfo is NULL");
return;
}
OCServerProtocolRequest serverRequest = {0};
- OC_LOG_V(INFO, TAG, PCF("Endpoint URI : %s"), requestInfo->info.resourceUri);
+ OC_LOG_V(INFO, TAG, "Endpoint URI : %s", requestInfo->info.resourceUri);
char * uriWithoutQuery = NULL;
char * query = NULL;
OC_LOG_V(ERROR, TAG, "getQueryFromUri() failed with OC error code %d\n", requestResult);
return;
}
- OC_LOG_V(INFO, TAG, PCF("URI without query: %s"), uriWithoutQuery);
- OC_LOG_V(INFO, TAG, PCF("Query : %s"), query);
+ OC_LOG_V(INFO, TAG, "URI without query: %s", uriWithoutQuery);
+ OC_LOG_V(INFO, TAG, "Query : %s", query);
if(strlen(uriWithoutQuery) < MAX_URI_LENGTH)
{
}
else
{
- OC_LOG(ERROR, TAG, PCF("URI length exceeds MAX_URI_LENGTH."));
+ OC_LOG(ERROR, TAG, "URI length exceeds MAX_URI_LENGTH.");
OICFree(uriWithoutQuery);
OICFree(query);
return;
}
else
{
- OC_LOG(ERROR, TAG, PCF("Query length exceeds MAX_QUERY_LENGTH."));
+ OC_LOG(ERROR, TAG, "Query length exceeds MAX_QUERY_LENGTH.");
OICFree(query);
return;
}
if (requestInfo->info.numOptions > MAX_HEADER_OPTIONS)
{
OC_LOG(ERROR, TAG,
- PCF("The request info numOptions is greater than MAX_HEADER_OPTIONS"));
+ "The request info numOptions is greater than MAX_HEADER_OPTIONS");
SendDirectStackResponse(endPoint, requestInfo->info.messageId, CA_BAD_OPT,
requestInfo->info.type, requestInfo->info.numOptions,
requestInfo->info.options, requestInfo->info.token,
}
else if(requestResult != OC_STACK_OK)
{
- OC_LOG_V(ERROR, TAG, PCF("HandleStackRequests failed. error: %d"), requestResult);
+ OC_LOG_V(ERROR, TAG, "HandleStackRequests failed. error: %d", requestResult);
CAResponseResult_t stackResponse = OCToCAStackResult(requestResult);
// The token is copied in there, and is thus still owned by this function.
OICFree(serverRequest.payload);
OICFree(serverRequest.requestToken);
- OC_LOG(INFO, TAG, PCF("Exit HandleCARequests"));
+ OC_LOG(INFO, TAG, "Exit HandleCARequests");
}
OCStackResult HandleStackRequests(OCServerProtocolRequest * protocolRequest)
{
- OC_LOG(INFO, TAG, PCF("Entering HandleStackRequests (OCStack Layer)"));
+ OC_LOG(INFO, TAG, "Entering HandleStackRequests (OCStack Layer)");
OCStackResult result = OC_STACK_ERROR;
ResourceHandling resHandling;
OCResource *resource;
if(!protocolRequest)
{
- OC_LOG(ERROR, TAG, PCF("protocolRequest is NULL"));
+ OC_LOG(ERROR, TAG, "protocolRequest is NULL");
return OC_STACK_INVALID_PARAM;
}
protocolRequest->tokenLength);
if(!request)
{
- OC_LOG(INFO, TAG, PCF("This is a new Server Request"));
+ OC_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, PCF("Error adding server request"));
+ OC_LOG(ERROR, TAG, "Error adding server request");
return result;
}
if(!request)
{
- OC_LOG(ERROR, TAG, PCF("Out of Memory"));
+ OC_LOG(ERROR, TAG, "Out of Memory");
return OC_STACK_NO_MEMORY;
}
}
else
{
- OC_LOG(INFO, TAG, PCF("This is either a repeated or blocked Server Request"));
+ OC_LOG(INFO, TAG, "This is either a repeated or blocked Server Request");
}
if(request->requestComplete)
{
- OC_LOG(INFO, TAG, PCF("This Server Request is complete"));
+ OC_LOG(INFO, TAG, "This Server Request is complete");
result = DetermineResourceHandling (request, &resHandling, &resource);
if (result == OC_STACK_OK)
{
}
else
{
- OC_LOG(INFO, TAG, PCF("This Server Request is incomplete"));
+ OC_LOG(INFO, TAG, "This Server Request is incomplete");
result = OC_STACK_CONTINUE;
}
return result;
if (!info.platformID)
{
- OC_LOG(ERROR, TAG, PCF("No platform ID found."));
+ OC_LOG(ERROR, TAG, "No platform ID found.");
return false;
}
if(lenManufacturerName == 0 || lenManufacturerName > MAX_MANUFACTURER_NAME_LENGTH)
{
- OC_LOG(ERROR, TAG, PCF("Manufacturer name fails length requirements."));
+ OC_LOG(ERROR, TAG, "Manufacturer name fails length requirements.");
return false;
}
}
else
{
- OC_LOG(ERROR, TAG, PCF("No manufacturer name present"));
+ OC_LOG(ERROR, TAG, "No manufacturer name present");
return false;
}
{
if(strlen(info.manufacturerUrl) > MAX_MANUFACTURER_URL_LENGTH)
{
- OC_LOG(ERROR, TAG, PCF("Manufacturer url fails length requirements."));
+ OC_LOG(ERROR, TAG, "Manufacturer url fails length requirements.");
return false;
}
}
{
if(stackState == OC_STACK_INITIALIZED)
{
- OC_LOG(INFO, TAG, PCF("Subsequent calls to OCInit() without calling \
- OCStop() between them are ignored."));
+ OC_LOG(INFO, TAG, "Subsequent calls to OCInit() without calling \
+ OCStop() between them are ignored.");
return OC_STACK_OK;
}
#ifdef RA_ADAPTER
if(!gRASetInfo)
{
- OC_LOG(ERROR, TAG, PCF("Need to call OCSetRAInfo before calling OCInit"));
+ OC_LOG(ERROR, TAG, "Need to call OCSetRAInfo before calling OCInit");
return OC_STACK_ERROR;
}
#endif
OCStackResult result = OC_STACK_ERROR;
- OC_LOG(INFO, TAG, PCF("Entering OCInit"));
+ OC_LOG(INFO, TAG, "Entering OCInit");
// Validate mode
if (!((mode == OC_CLIENT) || (mode == OC_SERVER) || (mode == OC_CLIENT_SERVER)))
{
- OC_LOG(ERROR, TAG, PCF("Invalid mode"));
+ OC_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, PCF("Client mode: CAStartDiscoveryServer"));
+ OC_LOG(INFO, TAG, "Client mode: CAStartDiscoveryServer");
break;
case OC_SERVER:
SRMRegisterHandler(HandleCARequests, HandleCAResponses, HandleCAErrorResponse);
result = CAResultToOCResult(CAStartListeningServer());
- OC_LOG(INFO, TAG, PCF("Server mode: CAStartListeningServer"));
+ OC_LOG(INFO, TAG, "Server mode: CAStartListeningServer");
break;
case OC_CLIENT_SERVER:
SRMRegisterHandler(HandleCARequests, HandleCAResponses, HandleCAErrorResponse);
exit:
if(result != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, PCF("Stack initialization error"));
+ OC_LOG(ERROR, TAG, "Stack initialization error");
deleteAllResources();
CATerminate();
stackState = OC_STACK_UNINITIALIZED;
OCStackResult OCStop()
{
- OC_LOG(INFO, TAG, PCF("Entering OCStop"));
+ OC_LOG(INFO, TAG, "Entering OCStop");
if (stackState == OC_STACK_UNINIT_IN_PROGRESS)
{
- OC_LOG(DEBUG, TAG, PCF("Stack already stopping, exiting"));
+ OC_LOG(DEBUG, TAG, "Stack already stopping, exiting");
return OC_STACK_OK;
}
else if (stackState != OC_STACK_INITIALIZED)
{
- OC_LOG(ERROR, TAG, PCF("Stack not initialized"));
+ OC_LOG(ERROR, TAG, "Stack not initialized");
return OC_STACK_ERROR;
}
OCHeaderOption *options,
uint8_t numOptions)
{
- OC_LOG(INFO, TAG, PCF("Entering OCDoResource"));
+ OC_LOG(INFO, TAG, "Entering OCDoResource");
// Validate input parameters
VERIFY_NON_NULL(cbData, FATAL, OC_STACK_INVALID_CALLBACK);
if (!devAddr && !destination)
{
- OC_LOG_V(DEBUG, TAG, "no devAddr and no destination");
+ OC_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, PCF("CAGenerateToken error"));
+ OC_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, PCF("Failed to create CBOR Payload"));
+ OC_LOG(ERROR, TAG, "Failed to create CBOR Payload");
goto exit;
}
requestInfo.info.payloadFormat = CA_FORMAT_CBOR;
if (result != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, PCF("CACreateEndpoint error"));
+ OC_LOG(ERROR, TAG, "CACreateEndpoint error");
goto exit;
}
caResult = CASendRequest(&endpoint, &requestInfo);
if (caResult != CA_STATUS_OK)
{
- OC_LOG(ERROR, TAG, PCF("CASendRequest"));
+ OC_LOG(ERROR, TAG, "CASendRequest");
result = OC_STACK_COMM_ERROR;
goto exit;
}
exit:
if (result != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, PCF("OCDoResource error"));
+ OC_LOG(ERROR, TAG, "OCDoResource error");
FindAndDeleteClientCB(clientCB);
CADestroyToken(token);
if (handle)
ClientCB *clientCB = GetClientCB(NULL, 0, handle, NULL);
if (!clientCB)
{
- OC_LOG(ERROR, TAG, PCF("Client callback not found. Called OCCancel twice?"));
+ OC_LOG(ERROR, TAG, "Client callback not found. Called OCCancel twice?");
goto Error;
}
}
else
{
- OC_LOG(INFO, TAG, PCF("Cancelling observation as CONFIRMABLE"));
+ OC_LOG(INFO, TAG, "Cancelling observation as CONFIRMABLE");
}
requestData.type = qualityOfServiceToMessageType(qos);
caResult = CASendRequest(&endpoint, &requestInfo);
if (caResult != CA_STATUS_OK)
{
- OC_LOG(ERROR, TAG, PCF("CASendRequest error"));
+ OC_LOG(ERROR, TAG, "CASendRequest error");
ret = OC_STACK_ERROR;
}
ret = CAResultToOCResult (caResult);
*/
OCStackResult OCRegisterPersistentStorageHandler(OCPersistentStorage* persistentStorageHandler)
{
- OC_LOG(INFO, TAG, PCF("RegisterPersistentStorageHandler !!"));
+ OC_LOG(INFO, TAG, "RegisterPersistentStorageHandler !!");
if(!persistentStorageHandler)
{
- OC_LOG(ERROR, TAG, PCF("The persistent storage handler is invalid"));
+ OC_LOG(ERROR, TAG, "The persistent storage handler is invalid");
return OC_STACK_INVALID_PARAM;
}
else
!persistentStorageHandler->unlink ||
!persistentStorageHandler->write)
{
- OC_LOG(ERROR, TAG, PCF("The persistent storage handler is invalid"));
+ OC_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, PCF("Entering RequestPresence"));
+ //OC_LOG(INFO, TAG, "Entering RequestPresence");
ClientCB* cbNode = NULL;
OCClientResponse clientResponse;
OCStackApplicationResult cbResult = OC_STACK_DELETE_TRANSACTION;
}
if (cbNode->presence->TTLlevel >= PresenceTimeOutSize)
{
- OC_LOG(DEBUG, TAG, PCF("No more timeout ticks"));
+ OC_LOG(DEBUG, TAG, "No more timeout ticks");
clientResponse.sequenceNumber = 0;
clientResponse.result = OC_STACK_PRESENCE_TIMEOUT;
CAInfo_t requestData = {.type = CA_MSG_CONFIRM};
CARequestInfo_t requestInfo = {.method = CA_GET};
- OC_LOG(DEBUG, TAG, PCF("time to test server presence"));
+ OC_LOG(DEBUG, TAG, "time to test server presence");
CopyDevAddrToEndpoint(cbNode->devAddr, &endpoint);
if (caResult != CA_STATUS_OK)
{
- OC_LOG(ERROR, TAG, PCF("CASendRequest error"));
+ OC_LOG(ERROR, TAG, "CASendRequest error");
goto exit;
}
exit:
if (result != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, PCF("OCProcessPresence error"));
+ OC_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, PCF("Setting Presence TTL to max value"));
+ OC_LOG(INFO, TAG, "Setting Presence TTL to max value");
}
else if (0 == ttl)
{
presenceResource.presenceTTL = OC_DEFAULT_PRESENCE_TTL_SECONDS;
- OC_LOG(INFO, TAG, PCF("Setting Presence TTL to default value"));
+ OC_LOG(INFO, TAG, "Setting Presence TTL to default value");
}
else
{
CAResult_t caResult = CAGenerateToken(&caToken, tokenLength);
if (caResult != CA_STATUS_OK)
{
- OC_LOG(ERROR, TAG, PCF("CAGenerateToken error"));
+ OC_LOG(ERROR, TAG, "CAGenerateToken error");
CADestroyToken(caToken);
return OC_STACK_ERROR;
}
if(result != OC_STACK_OK)
{
OC_LOG(ERROR, TAG,
- PCF("Changing the presence resource properties to ACTIVE not successful"));
+ "Changing the presence resource properties to ACTIVE not successful");
return result;
}
OCStackResult OCSetPlatformInfo(OCPlatformInfo platformInfo)
{
- OC_LOG(INFO, TAG, PCF("Entering OCSetPlatformInfo"));
+ OC_LOG(INFO, TAG, "Entering OCSetPlatformInfo");
if(myStackMode == OC_SERVER || myStackMode == OC_CLIENT_SERVER)
{
OCStackResult OCSetDeviceInfo(OCDeviceInfo deviceInfo)
{
- OC_LOG(INFO, TAG, PCF("Entering OCSetDeviceInfo"));
+ OC_LOG(INFO, TAG, "Entering OCSetDeviceInfo");
if (!deviceInfo.deviceName || deviceInfo.deviceName[0] == '\0')
{
- OC_LOG(ERROR, TAG, PCF("Null or empty device name."));
+ OC_LOG(ERROR, TAG, "Null or empty device name.");
return OC_STACK_INVALID_PARAM;
}
char *str = NULL;
OCStackResult result = OC_STACK_ERROR;
- OC_LOG(INFO, TAG, PCF("Entering OCCreateResource"));
+ OC_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, PCF("URI is empty or too long"));
+ OC_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, PCF("Input parameter is NULL"));
+ OC_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, PCF("Invalid property"));
+ OC_LOG(ERROR, TAG, "Invalid property");
return OC_STACK_INVALID_PARAM;
}
result = BindResourceTypeToResource(pointer, resourceTypeName);
if (result != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, PCF("Error adding resourcetype"));
+ OC_LOG(ERROR, TAG, "Error adding resourcetype");
goto exit;
}
result = BindResourceInterfaceToResource(pointer, resourceInterfaceName);
if (result != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, PCF("Error adding resourceinterface"));
+ OC_LOG(ERROR, TAG, "Error adding resourceinterface");
goto exit;
}
OCResource *resource = NULL;
uint8_t i = 0;
- OC_LOG(INFO, TAG, PCF("Entering OCBindResource"));
+ OC_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, PCF("Added handle equals collection handle"));
+ OC_LOG(ERROR, TAG, "Added handle equals collection handle");
return OC_STACK_INVALID_PARAM;
}
resource = findResource((OCResource *) collectionHandle);
if (!resource)
{
- OC_LOG(ERROR, TAG, PCF("Collection handle not found"));
+ OC_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, PCF("resource bound"));
+ OC_LOG(INFO, TAG, "resource bound");
#ifdef WITH_PRESENCE
if (presenceResource.handle)
OCResource *resource = NULL;
uint8_t i = 0;
- OC_LOG(INFO, TAG, PCF("Entering OCUnBindResource"));
+ OC_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, PCF("removing handle equals collection handle"));
+ OC_LOG(ERROR, TAG, "removing handle equals collection handle");
return OC_STACK_INVALID_PARAM;
}
resource = findResource((OCResource *) collectionHandle);
if (!resource)
{
- OC_LOG(ERROR, TAG, PCF("Collection handle not found"));
+ OC_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, PCF("resource unbound"));
+ OC_LOG(INFO, TAG, "resource unbound");
// Send notification when resource is unbounded successfully.
#ifdef WITH_PRESENCE
}
}
- OC_LOG(INFO, TAG, PCF("resource not found in collection"));
+ OC_LOG(INFO, TAG, "resource not found in collection");
// Unable to add resourceHandle, so return error
return OC_STACK_ERROR;
resource = findResource((OCResource *) handle);
if (!resource)
{
- OC_LOG(ERROR, TAG, PCF("Resource not found"));
+ OC_LOG(ERROR, TAG, "Resource not found");
return OC_STACK_ERROR;
}
resource = findResource((OCResource *) handle);
if (!resource)
{
- OC_LOG(ERROR, TAG, PCF("Resource not found"));
+ OC_LOG(ERROR, TAG, "Resource not found");
return OC_STACK_ERROR;
}
{
if (!handle)
{
- OC_LOG(ERROR, TAG, PCF("Invalid handle for deletion"));
+ OC_LOG(ERROR, TAG, "Invalid handle for deletion");
return OC_STACK_INVALID_PARAM;
}
OCResource *resource = findResource((OCResource *) handle);
if (resource == NULL)
{
- OC_LOG(ERROR, TAG, PCF("Resource not found"));
+ OC_LOG(ERROR, TAG, "Resource not found");
return OC_STACK_NO_RESOURCE;
}
if (deleteResource((OCResource *) handle) != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, PCF("Error deleting resource"));
+ OC_LOG(ERROR, TAG, "Error deleting resource");
return OC_STACK_ERROR;
}
resource = findResource((OCResource *)handle);
if (!resource)
{
- OC_LOG(ERROR, TAG, PCF("Resource not found"));
+ OC_LOG(ERROR, TAG, "Resource not found");
return OC_STACK_ERROR;
}
resource = findResource((OCResource *)handle);
if (!resource)
{
- OC_LOG(ERROR, TAG, PCF("Resource not found"));
+ OC_LOG(ERROR, TAG, "Resource not found");
return NULL;
}
OCMethod method = OC_REST_NOMETHOD;
uint32_t maxAge = 0;
- OC_LOG(INFO, TAG, PCF("Notifying all observers"));
+ OC_LOG(INFO, TAG, "Notifying all observers");
#ifdef WITH_PRESENCE
- if (handle == presenceResource.handle)
+ if(handle == presenceResource.handle)
{
return OC_STACK_OK;
}
const OCRepPayload *payload,
OCQualityOfService qos)
{
- OC_LOG(INFO, TAG, PCF("Entering OCNotifyListOfObservers"));
+ OC_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, PCF("Entering OCDoResponse"));
+ OC_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, PCF("Invalid property"));
+ OC_LOG(ERROR, TAG, "Invalid property");
return OC_STACK_INVALID_PARAM;
}
if(!enable)
OCResource *temp = NULL;
if(!resource)
{
- OC_LOG_V(DEBUG,TAG,"resource is NULL");
+ OC_LOG(DEBUG,TAG,"resource is NULL");
return OC_STACK_INVALID_PARAM;
}
if (GetDoxmDeviceID(&sid) != OC_STACK_OK)
{
- OC_LOG(FATAL, TAG, PCF("Generate UUID for Server Instance failed!"));
+ OC_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, PCF("Generate UUID String for Server Instance failed!"));
+ OC_LOG(FATAL, TAG, "Generate UUID String for Server Instance failed!");
return NULL;
}
#include <pthread.h>
#endif
-#define TAG PCF("OICGROUP")
+#define TAG "OICGROUP"
#define DESC_DELIMITER "\""
#define ACTION_DELIMITER "*"
void AddScheduledResource(ScheduledResourceInfo **head,
ScheduledResourceInfo* add)
{
- OC_LOG(INFO, TAG, PCF("AddScheduledResource Entering..."));
+ OC_LOG(INFO, TAG, "AddScheduledResource Entering...");
#ifndef WITH_ARDUINO
pthread_mutex_lock(&lock);
ScheduledResourceInfo* GetScheduledResource(ScheduledResourceInfo *head)
{
- OC_LOG(INFO, TAG, PCF("GetScheduledResource Entering..."));
+ OC_LOG(INFO, TAG, "GetScheduledResource Entering...");
#ifndef WITH_ARDUINO
pthread_mutex_lock(&lock);
if (diffTm <= (time_t) 0)
{
- OC_LOG(INFO, TAG, PCF("return Call INFO."));
+ OC_LOG(INFO, TAG, "return Call INFO.");
goto exit;
}
#endif
if (tmp == NULL)
{
- OC_LOG(INFO, TAG, PCF("Cannot Find Call Info."));
+ OC_LOG(INFO, TAG, "Cannot Find Call Info.");
}
return tmp;
}
ScheduledResourceInfo* GetScheduledResourceByActionSetName(ScheduledResourceInfo *head, char *setName)
{
- OC_LOG(INFO, TAG, PCF("GetScheduledResourceByActionSetName Entering..."));
+ OC_LOG(INFO, TAG, "GetScheduledResourceByActionSetName Entering...");
#ifndef WITH_ARDUINO
pthread_mutex_lock(&lock);
{
if (strcmp(tmp->actionset->actionsetName, setName) == 0)
{
- OC_LOG(INFO, TAG, PCF("return Call INFO."));
+ OC_LOG(INFO, TAG, "return Call INFO.");
goto exit;
}
tmp = tmp->next;
#endif
if (tmp == NULL)
{
- OC_LOG(INFO, TAG, PCF("Cannot Find Call Info."));
+ OC_LOG(INFO, TAG, "Cannot Find Call Info.");
}
return tmp;
}
#ifndef WITH_ARDUINO
pthread_mutex_lock(&lock);
#endif
- OC_LOG(INFO, TAG, PCF("RemoveScheduledResource Entering..."));
+ OC_LOG(INFO, TAG, "RemoveScheduledResource Entering...");
ScheduledResourceInfo *tmp = NULL;
if (del == NULL)
OCAction *action = NULL;
OCCapability *capa = NULL;
- OC_LOG(INFO, TAG, PCF("Build ActionSet Instance."));
+ OC_LOG(INFO, TAG, "Build ActionSet Instance.");
*set = (OCActionSet*) OICMalloc(sizeof(OCActionSet));
VARIFY_POINTER_NULL(*set, result, exit)
if (strcmp(key, "uri") == 0)
{
- OC_LOG(INFO, TAG, PCF("Build OCAction Instance."));
+ OC_LOG(INFO, TAG, "Build OCAction Instance.");
if(action)
{
{
if ((key != NULL) && (value != NULL))
{
- OC_LOG(INFO, TAG, PCF("Build OCCapability Instance."));
+ OC_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, PCF("Entering ActionSetCB"));
+ OC_LOG(INFO, TAG, "Entering ActionSetCB");
ClientRequestInfo *info = GetClientRequestInfo(clientRequstList, handle);
char *jsonStr;
uint16_t jsonLen;
- OC_LOG(INFO, TAG, PCF("Entering BuildActionJSON"));
+ OC_LOG(INFO, TAG, "Entering BuildActionJSON");
json = cJSON_CreateObject();
cJSON_AddItemToObject(json, "rep", body = cJSON_CreateObject());
if (!payload)
{
- OC_LOG(INFO, TAG, PCF("Failed to create put payload object"));
+ OC_LOG(INFO, TAG, "Failed to create put payload object");
return NULL;
}
void DoScheduledGroupAction()
{
- OC_LOG(INFO, TAG, PCF("DoScheduledGroupAction Entering..."));
+ OC_LOG(INFO, TAG, "DoScheduledGroupAction Entering...");
ScheduledResourceInfo* info = GetScheduledResource(scheduleResourceList);
if (info == NULL)
{
- OC_LOG(INFO, TAG, PCF("Target resource is NULL"));
+ OC_LOG(INFO, TAG, "Target resource is NULL");
goto exit;
}
else if (info->resource == NULL)
{
- OC_LOG(INFO, TAG, PCF("Target resource is NULL"));
+ OC_LOG(INFO, TAG, "Target resource is NULL");
goto exit;
}
else if (info->actionset == NULL)
{
- OC_LOG(INFO, TAG, PCF("Target ActionSet is NULL"));
+ OC_LOG(INFO, TAG, "Target ActionSet is NULL");
goto exit;
}
else if (info->ehRequest == NULL)
{
- OC_LOG(INFO, TAG, PCF("Target ActionSet is NULL"));
+ OC_LOG(INFO, TAG, "Target ActionSet is NULL");
goto exit;
}
#ifndef WITH_ARDUINO
if (schedule)
{
- OC_LOG(INFO, TAG, PCF("Building New Call Info."));
+ OC_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, PCF("Reregisteration."));
+ OC_LOG(INFO, TAG, "Reregisteration.");
#ifndef WITH_ARDUINO
pthread_mutex_unlock(&lock);
#endif
{
OCStackResult stackRet = OC_STACK_ERROR;
- OC_LOG(INFO, TAG, PCF("Group Action is requested."));
+ OC_LOG(INFO, TAG, "Group Action is requested.");
char *doWhat = NULL;
char *details = NULL;
if (method == OC_REST_PUT)
{
- OC_LOG(INFO, TAG, PCF("Group Action[PUT]."));
+ OC_LOG(INFO, TAG, "Group Action[PUT].");
if (strcmp(doWhat, ACTIONSET) == 0)
{
{
DeleteActionSet( &actionSet );
}
- OC_LOG(INFO, TAG, PCF("Duplicated ActionSet "));
+ OC_LOG(INFO, TAG, "Duplicated ActionSet ");
}
}
else
if(!payload)
{
- OC_LOG(ERROR, TAG, PCF("Failed to allocate Payload"));
+ OC_LOG(ERROR, TAG, "Failed to allocate Payload");
stackRet = OC_STACK_ERROR;
}
else
if (GetActionSet(details, resource->actionsetHead,
&actionset) != OC_STACK_OK)
{
- OC_LOG(INFO, TAG, PCF("ERROR"));
+ OC_LOG(INFO, TAG, "ERROR");
stackRet = OC_STACK_ERROR;
}
if (actionset == NULL)
{
- OC_LOG(INFO, TAG, PCF("Cannot Find ActionSet"));
+ OC_LOG(INFO, TAG, "Cannot Find ActionSet");
stackRet = OC_STACK_ERROR;
}
else
{
- OC_LOG(INFO, TAG, PCF("Group Action[POST]."));
+ OC_LOG(INFO, TAG, "Group Action[POST].");
if (actionset->type == NONE)
{
OC_LOG_V(INFO, TAG, "Execute ActionSet : %s",
if (schedule)
{
- OC_LOG(INFO, TAG, PCF("Building New Call Info."));
+ OC_LOG(INFO, TAG, "Building New Call Info.");
memset(schedule, 0,
sizeof(ScheduledResourceInfo));
if(!payload)
{
- OC_LOG(ERROR, TAG, PCF("Failed to allocate Payload"));
+ OC_LOG(ERROR, TAG, "Failed to allocate Payload");
stackRet = OC_STACK_ERROR;
}
else
#include "ocstackinternal.h"
#include <string.h>
-#define PCF(str) ((PROGMEM const char *)(F(str)))
-
-PROGMEM const char TAG[] = "Arduino";
+#define TAG "Arduino"
static OCUri SERVICE_URI = "coap://127.0.0.1:5683/";
#if 0 // Turn off logger test stuff
void EXPECT_EQ(int a, int b) {
if (a == b) {
- OC_LOG(INFO, TAG, PCF("PASS"));
+ OC_LOG(INFO, TAG, ("PASS"));
} else {
- OC_LOG(ERROR, TAG, PCF("FAIL"));
+ OC_LOG(ERROR, TAG, ("FAIL"));
}
}
void EXPECT_STREQ(const char *a, const char *b) {
if (strcmp(a, b) == 0) {
- OC_LOG(INFO, TAG, PCF("PASS"));
+ OC_LOG(INFO, TAG, ("PASS"));
} else {
- OC_LOG(ERROR, TAG, PCF("FAIL"));
+ OC_LOG(ERROR, TAG, ("FAIL"));
}
}
//-----------------------------------------------------------------------------
#endif
extern "C" void asyncDoResourcesCallback(OCStackResult result, OCRepresentationHandle representation) {
- OC_LOG(INFO, TAG, PCF("Entering asyncDoResourcesCallback"));
+ OC_LOG(INFO, TAG, ("Entering asyncDoResourcesCallback"));
EXPECT_EQ(OC_STACK_OK, result);
OCResource *resource = (OCResource *)representation;
}
void test0() {
- OC_LOG(INFO, TAG, PCF("test0"));
+ OC_LOG(INFO, TAG, ("test0"));
EXPECT_EQ(OC_STACK_OK, OCInit(0, 5683, OC_SERVER));
}
void test1() {
- OC_LOG(INFO, TAG, PCF("test1"));
+ OC_LOG(INFO, TAG, ("test1"));
EXPECT_EQ(OC_STACK_OK, OCInit("127.0.0.1", 0, OC_SERVER));
}
void test2() {
- OC_LOG(INFO, TAG, PCF("test2"));
+ OC_LOG(INFO, TAG, ("test2"));
EXPECT_EQ(OC_STACK_OK, OCInit(0, 0, OC_SERVER));
}
void test3() {
- OC_LOG(INFO, TAG, PCF("test3"));
+ OC_LOG(INFO, TAG, ("test3"));
EXPECT_EQ(OC_STACK_ERROR, OCInit(0, 0, (OCMode)10));
}
void test4() {
- OC_LOG(INFO, TAG, PCF("test4"));
+ OC_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, PCF("test5"));
+ OC_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, PCF("test6"));
+ OC_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, PCF("test7"));
+ OC_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));
static uint8_t ETHERNET_MAC[] = {0x90, 0xA2, 0xDA, 0x0F, 0x2B, 0x72 };
-#define TAG PCF("ocserver")
+#define TAG ("ocserver")
void ocInitialize () {
- OC_LOG(DEBUG, TAG, PCF("IP addr is:"));
+ OC_LOG(DEBUG, TAG, ("IP addr is:"));
OC_LOG_BUFFER(INFO, TAG, (uint8_t*)ipAddr, sizeof(ipAddr));
delay(2000);
OCInit (NULL, 0, OC_SERVER);
#include <ocstack.h>
#include <logger.h>
-#define TAG PCF("occlient")
+#define TAG ("occlient")
int gQuitFlag = 0;
#include <ocstack.h>
#include <logger.h>
-#define TAG PCF("ocserver")
+#define TAG ("ocserver")
int gQuitFlag = 0;
OCStackResult createLightResource();
#include <string.h>
#include <unistd.h>
-#define TAG PCF("MAIN")
+#define TAG ("MAIN")
static int customLogger = 0;
extern "C" {
#endif // __cplusplus
-#define HOSTING_TAG PCF("Hosting")
+#define HOSTING_TAG "Hosting"
/**
* Start resource hosting.
va_start(args, format);
vsnprintf(buffer, sizeof buffer - 1, format, args);
va_end(args);
- OCLog(level, PCF("Hosting"), buffer);
+ OCLog(level, "Hosting", buffer);
}
HostingObject::HostingObject()
{
namespace Service
{
- #define BROKER_TAG PCF("BROKER")
+ #define BROKER_TAG "BROKER"
#define BROKER_DEVICE_PRESENCE_TIMEROUT (15000l)
#define BROKER_SAFE_SECOND (5l)
#define BROKER_SAFE_MILLISECOND (BROKER_SAFE_SECOND * (1000))
class DataCache;
-#define CACHE_TAG PCF("CACHE")
+#define CACHE_TAG "CACHE"
#define CACHE_DEFAULT_REPORT_MILLITIME 10000
#define CACHE_DEFAULT_EXPIRED_MILLITIME 15000
#include "ScopeLogger.h"
-#define TAG PCF("RCSDiscoveryManager")
+#define TAG "RCSDiscoveryManager"
using namespace OIC::Service;
#include "ScopeLogger.h"
-#define TAG PCF("RCSRemoteResourceObject")
+#define TAG "RCSRemoteResourceObject"
namespace
{
// check for the presence of the shield:
if (WiFi.status() == WL_NO_SHIELD)
{
- OC_LOG(ERROR, TAG, PCF("WiFi shield not present"));
+ OC_LOG(ERROR, TAG, ("WiFi shield not present"));
return -1;
}
OC_LOG_V(INFO, TAG, "WiFi Shield Firmware version %s", fwVersion);
if ( strncmp(fwVersion, INTEL_WIFI_SHIELD_FW_VER, sizeof(INTEL_WIFI_SHIELD_FW_VER)) != 0 )
{
- OC_LOG(DEBUG, TAG, PCF("!!!!! Upgrade WiFi Shield Firmware version !!!!!!"));
+ OC_LOG(DEBUG, TAG, ("!!!!! Upgrade WiFi Shield Firmware version !!!!!!"));
return -1;
}
// wait 10 seconds for connection:
delay(10000);
}
- OC_LOG(DEBUG, TAG, PCF("Connected to wifi"));
+ OC_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]);
if (entityHandlerRequest && (flag & OC_REQUEST_FLAG))
{
- OC_LOG (INFO, TAG, PCF("Flag includes OC_REQUEST_FLAG"));
+ OC_LOG (INFO, TAG, ("Flag includes OC_REQUEST_FLAG"));
if (OC_REST_GET == entityHandlerRequest->method)
{
if (JsonGenerator( REFER, (char *)entityHandlerRequest->resJSONPayload, \
{
if (OC_OBSERVE_REGISTER == entityHandlerRequest->obsInfo->action)
{
- OC_LOG (INFO, TAG, PCF("Received OC_OBSERVE_REGISTER from client"));
+ OC_LOG (INFO, TAG, ("Received OC_OBSERVE_REGISTER from client"));
g_REFERUnderObservation = 1;
}
else if (OC_OBSERVE_DEREGISTER == entityHandlerRequest->obsInfo->action)
{
- OC_LOG (INFO, TAG, PCF("Received OC_OBSERVE_DEREGISTER from client"));
+ OC_LOG (INFO, TAG, ("Received OC_OBSERVE_DEREGISTER from client"));
}
}
// Add your initialization code here
OC_LOG_INIT();
- OC_LOG(DEBUG, TAG, PCF("OCServer is starting..."));
+ OC_LOG(DEBUG, TAG, ("OCServer is starting..."));
// Connect to Ethernet or WiFi network
if (ConnectToNetwork() != 0)
// Initialize the OC Stack in Server mode
if (OCInit(NULL, OC_WELL_KNOWN_PORT, OC_SERVER) != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, PCF("OCStack init error"));
+ OC_LOG(ERROR, TAG, ("OCStack init error"));
return;
}
delay(5000);
if (OCProcess() != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, PCF("OCStack process error"));
+ OC_LOG(ERROR, TAG, ("OCStack process error"));
return;
}
ChangeREFERRepresentation(NULL);
{
if (flag & OC_REQUEST_FLAG)
{
- OC_LOG (INFO, TAG, PCF("Flag includes OC_REQUEST_FLAG"));
+ OC_LOG (INFO, TAG, ("Flag includes OC_REQUEST_FLAG"));
if (OC_REST_GET == entityHandlerRequest->method)
{
if ( JsonGenerator( (char *)entityHandlerRequest->resJSONPayload,
}
else if (flag & OC_OBSERVE_FLAG)
{
- OC_LOG (INFO, TAG, PCF("Flag includes OC_OBSERVE_FLAG"));
+ OC_LOG (INFO, TAG, ("Flag includes OC_OBSERVE_FLAG"));
if (OC_OBSERVE_REGISTER == entityHandlerRequest->obsInfo->action)
{
- OC_LOG (INFO, TAG, PCF("Received OC_OBSERVE_REGISTER from client"));
+ OC_LOG (INFO, TAG, ("Received OC_OBSERVE_REGISTER from client"));
g_PROXIUnderObservation = 1;
}
else if (OC_OBSERVE_DEREGISTER == entityHandlerRequest->obsInfo->action)
{
- OC_LOG (INFO, TAG, PCF("Received OC_OBSERVE_DEREGISTER from client"));
+ OC_LOG (INFO, TAG, ("Received OC_OBSERVE_DEREGISTER from client"));
}
}
// Add your initialization code here
OC_LOG_INIT();
- OC_LOG(DEBUG, TAG, PCF("OCServer is starting..."));
+ OC_LOG(DEBUG, TAG, ("OCServer is starting..."));
// uint16_t port = OC_WELL_KNOWN_PORT;
// Connect to Ethernet or WiFi network
// Initialize the OC Stack in Server mode
if (OCInit(NULL, OC_WELL_KNOWN_PORT, OC_SERVER) != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, PCF("OCStack init error"));
+ OC_LOG(ERROR, TAG, ("OCStack init error"));
return;
}
// of Arduino microcontroller. Modify it as per specfic application needs.
if (OCProcess() != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, PCF("OCStack process error"));
+ OC_LOG(ERROR, TAG, ("OCStack process error"));
return;
}
// check for the presence of the shield:
if (WiFi.status() == WL_NO_SHIELD)
{
- OC_LOG(ERROR, TAG, PCF("WiFi shield not present"));
+ OC_LOG(ERROR, TAG, ("WiFi shield not present"));
return -1;
}
OC_LOG_V(INFO, TAG, "WiFi Shield Firmware version %s", fwVersion);
if ( strncmp(fwVersion, INTEL_WIFI_SHIELD_FW_VER, sizeof(INTEL_WIFI_SHIELD_FW_VER)) != 0 )
{
- OC_LOG(DEBUG, TAG, PCF("!!!!! Upgrade WiFi Shield Firmware version !!!!!!"));
+ OC_LOG(DEBUG, TAG, ("!!!!! Upgrade WiFi Shield Firmware version !!!!!!"));
return -1;
}
// wait 10 seconds for connection:
delay(10000);
}
- OC_LOG(DEBUG, TAG, PCF("Connected to wifi"));
+ OC_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]);
if (entityHandlerRequest && (flag & OC_REQUEST_FLAG))
{
- OC_LOG (INFO, TAG, PCF("Flag includes OC_REQUEST_FLAG"));
+ OC_LOG (INFO, TAG, ("Flag includes OC_REQUEST_FLAG"));
if (OC_REST_GET == entityHandlerRequest->method)
{
if (JsonGenerator( TH, payload, MAX_RESPONSE_LENGTH))
{
if (OC_OBSERVE_REGISTER == entityHandlerRequest->obsInfo.action)
{
- OC_LOG (INFO, TAG, PCF("Received OC_OBSERVE_REGISTER from client"));
+ OC_LOG (INFO, TAG, ("Received OC_OBSERVE_REGISTER from client"));
g_THUnderObservation = 1;
}
else if (OC_OBSERVE_DEREGISTER == entityHandlerRequest->obsInfo.action)
{
- OC_LOG (INFO, TAG, PCF("Received OC_OBSERVE_DEREGISTER from client"));
+ OC_LOG (INFO, TAG, ("Received OC_OBSERVE_DEREGISTER from client"));
}
}
// Add your initialization code here
OC_LOG_INIT();
- OC_LOG(DEBUG, TAG, PCF("OCServer is starting..."));
+ OC_LOG(DEBUG, TAG, ("OCServer is starting..."));
uint16_t port = OC_WELL_KNOWN_PORT;
// Connect to Ethernet or WiFi network
// Initialize the OC Stack in Server mode
if (OCInit(NULL, port, OC_SERVER) != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, PCF("OCStack init error"));
+ OC_LOG(ERROR, TAG, ("OCStack init error"));
return;
}
OCStartPresence(60);
if (OCProcess() != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, PCF("OCStack process error"));
+ OC_LOG(ERROR, TAG, ("OCStack process error"));
return;
}
ChangeTHRepresentation(NULL);
// check for the presence of the shield:
if (WiFi.status() == WL_NO_SHIELD)
{
- OC_LOG(ERROR, TAG, PCF("WiFi shield not present"));
+ OC_LOG(ERROR, TAG, ("WiFi shield not present"));
return -1;
}
OC_LOG_V(INFO, TAG, "WiFi Shield Firmware version %s", fwVersion);
if ( strncmp(fwVersion, INTEL_WIFI_SHIELD_FW_VER, sizeof(INTEL_WIFI_SHIELD_FW_VER)) != 0 )
{
- OC_LOG(DEBUG, TAG, PCF("!!!!! Upgrade WiFi Shield Firmware version !!!!!!"));
+ OC_LOG(DEBUG, TAG, ("!!!!! Upgrade WiFi Shield Firmware version !!!!!!"));
return -1;
}
// wait 10 seconds for connection:
delay(10000);
}
- OC_LOG(DEBUG, TAG, PCF("Connected to wifi"));
+ OC_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]);
if (entityHandlerRequest && (flag & OC_REQUEST_FLAG))
{
- OC_LOG (INFO, TAG, PCF("Flag includes OC_REQUEST_FLAG"));
+ OC_LOG (INFO, TAG, ("Flag includes OC_REQUEST_FLAG"));
if (OC_REST_GET == entityHandlerRequest->method)
{
if (JsonGenerator( TH, payload, MAX_RESPONSE_LENGTH))
{
if (OC_OBSERVE_REGISTER == entityHandlerRequest->obsInfo.action)
{
- OC_LOG (INFO, TAG, PCF("Received OC_OBSERVE_REGISTER from client"));
+ OC_LOG (INFO, TAG, ("Received OC_OBSERVE_REGISTER from client"));
g_THUnderObservation = 1;
}
else if (OC_OBSERVE_DEREGISTER == entityHandlerRequest->obsInfo.action)
{
- OC_LOG (INFO, TAG, PCF("Received OC_OBSERVE_DEREGISTER from client"));
+ OC_LOG (INFO, TAG, ("Received OC_OBSERVE_DEREGISTER from client"));
}
}
// Add your initialization code here
OC_LOG_INIT();
- OC_LOG(DEBUG, TAG, PCF("OCServer is starting..."));
+ OC_LOG(DEBUG, TAG, ("OCServer is starting..."));
uint16_t port = OC_WELL_KNOWN_PORT;
// Connect to Ethernet or WiFi network
// Initialize the OC Stack in Server mode
if (OCInit(NULL, port, OC_SERVER) != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, PCF("OCStack init error"));
+ OC_LOG(ERROR, TAG, ("OCStack init error"));
return;
}
OCStartPresence(60);
if (OCProcess() != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, PCF("OCStack process error"));
+ OC_LOG(ERROR, TAG, ("OCStack process error"));
return;
}
ChangeTHRepresentation(NULL);
// check for the presence of the shield:
if (WiFi.status() == WL_NO_SHIELD)
{
- OC_LOG(ERROR, TAG, PCF("WiFi shield not present"));
+ OC_LOG(ERROR, TAG, ("WiFi shield not present"));
return -1;
}
OC_LOG_V(INFO, TAG, "WiFi Shield Firmware version %s", fwVersion);
if ( strncmp(fwVersion, INTEL_WIFI_SHIELD_FW_VER, sizeof(INTEL_WIFI_SHIELD_FW_VER)) != 0 )
{
- OC_LOG(DEBUG, TAG, PCF("!!!!! Upgrade WiFi Shield Firmware version !!!!!!"));
+ OC_LOG(DEBUG, TAG, ("!!!!! Upgrade WiFi Shield Firmware version !!!!!!"));
return -1;
}
// wait 10 seconds for connection:
delay(10000);
}
- OC_LOG(DEBUG, TAG, PCF("Connected to wifi"));
+ OC_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]);
if (entityHandlerRequest && (flag & OC_REQUEST_FLAG))
{
- OC_LOG (INFO, TAG, PCF("Flag includes OC_REQUEST_FLAG"));
+ OC_LOG (INFO, TAG, ("Flag includes OC_REQUEST_FLAG"));
if (OC_REST_GET == entityHandlerRequest->method)
{
if (JsonGenerator((char *)entityHandlerRequest->resJSONPayload, \
{
if (OC_OBSERVE_REGISTER == entityHandlerRequest->obsInfo->action)
{
- OC_LOG (INFO, TAG, PCF("Received OC_OBSERVE_REGISTER from client"));
+ OC_LOG (INFO, TAG, ("Received OC_OBSERVE_REGISTER from client"));
g_PROXIUnderObservation = 1;
}
else if (OC_OBSERVE_DEREGISTER == entityHandlerRequest->obsInfo->action)
{
- OC_LOG (INFO, TAG, PCF("Received OC_OBSERVE_DEREGISTER from client"));
+ OC_LOG (INFO, TAG, ("Received OC_OBSERVE_DEREGISTER from client"));
}
}
// Add your initialization code here
OC_LOG_INIT();
- OC_LOG(DEBUG, TAG, PCF("OCServer is starting..."));
+ OC_LOG(DEBUG, TAG, ("OCServer is starting..."));
// uint16_t port = OC_WELL_KNOWN_PORT;
// Connect to Ethernet or WiFi network
// Initialize the OC Stack in Server mode
if (OCInit(NULL, OC_WELL_KNOWN_PORT, OC_SERVER) != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, PCF("OCStack init error"));
+ OC_LOG(ERROR, TAG, ("OCStack init error"));
return;
}
if (OCProcess() != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, PCF("OCStack process error"));
+ OC_LOG(ERROR, TAG, ("OCStack process error"));
return;
}
#if (ARDUINO == 0)