From 18b3666da91657c136719877faa8b9e1a5c49207 Mon Sep 17 00:00:00 2001 From: "koushik.girijala" Date: Wed, 14 Oct 2015 17:26:05 +0530 Subject: [PATCH] Fix for Memory management in Arduino Modified code to make more heap available in arduino MEGA Change-Id: I62ebc1bcf08331d7d90871bb2a6dd201f4ae7e4b Signed-off-by: vimala.v Signed-off-by: koushik.girijala Reviewed-on: https://gerrit.iotivity.org/gerrit/3879 Tested-by: jenkins-iotivity Reviewed-by: Jon A. Cruz --- resource/csdk/connectivity/common/inc/logger.h | 6 ++++-- resource/csdk/connectivity/src/camessagehandler.c | 4 ++-- resource/csdk/routing/src/routingutility.c | 2 +- resource/csdk/stack/src/ocstack.c | 6 +++--- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/resource/csdk/connectivity/common/inc/logger.h b/resource/csdk/connectivity/common/inc/logger.h index 5e7ff5c..a58def7 100644 --- a/resource/csdk/connectivity/common/inc/logger.h +++ b/resource/csdk/connectivity/common/inc/logger.h @@ -187,8 +187,6 @@ void OICLogv(LogLevel level, PROGMEM const char *tag, const int16_t lineNum, #define OIC_LOG_BUFFER(level, tag, buffer, bufferSize) #else // These macros are defined for Linux, Android, and Arduino #define OIC_LOG_INIT() OICLogInit() -#define OIC_LOG_BUFFER(level, tag, buffer, bufferSize)\ - OICLogBuffer((level), (tag), (buffer), (bufferSize)) #ifdef ARDUINO #define OIC_LOG_CONFIG(ctx) @@ -197,11 +195,15 @@ void OICLogv(LogLevel level, PROGMEM const char *tag, const int16_t lineNum, #define OIC_LOG_V(level, tag, ...) // To enable OIC_LOG_V, uncomment the below //#define OIC_LOG_V(level, tag, format, ...) OICLogv((level), PCF(tag), __LINE__, PCF(format), __VA_ARGS__) +#define OIC_LOG_BUFFER(level, tag, buffer, bufferSize)\ + OICLogBuffer((level), PCF(tag), (buffer), (bufferSize)) #else #define OIC_LOG_CONFIG(ctx) OICLogConfig((ctx)) #define OIC_LOG_SHUTDOWN() OICLogShutdown() #define OIC_LOG(level, tag, logStr) OICLog((level), (tag), (logStr)) #define OIC_LOG_V(level, tag, ...) OICLogv((level), (tag), __VA_ARGS__) +#define OIC_LOG_BUFFER(level, tag, buffer, bufferSize)\ + OICLogBuffer((level), tag, (buffer), (bufferSize)) #endif //ARDUINO #endif //__TIZEN__ #else //TB_LOG diff --git a/resource/csdk/connectivity/src/camessagehandler.c b/resource/csdk/connectivity/src/camessagehandler.c index cc6a452..b101098 100644 --- a/resource/csdk/connectivity/src/camessagehandler.c +++ b/resource/csdk/connectivity/src/camessagehandler.c @@ -1277,7 +1277,7 @@ static void CALogPayloadInfo(CAInfo_t *info) { for (uint32_t i = 0; i < info->numOptions; i++) { - OIC_LOG_V(DEBUG, TAG, "optionID: %d", info->options[i].optionID); + OIC_LOG_V(DEBUG, TAG, "optionID: %u", info->options[i].optionID); OIC_LOG_V(DEBUG, TAG, "list: %s", info->options[i].optionData); } @@ -1295,7 +1295,7 @@ static void CALogPayloadInfo(CAInfo_t *info) OIC_LOG_BUFFER(DEBUG, TAG, (const uint8_t *) info->token, info->tokenLength); } - OIC_LOG_V(DEBUG, TAG, "msgID: %d", info->messageId); + OIC_LOG_V(DEBUG, TAG, "msgID: %u", info->messageId); } else { diff --git a/resource/csdk/routing/src/routingutility.c b/resource/csdk/routing/src/routingutility.c index 7f342a7..a0925c2 100644 --- a/resource/csdk/routing/src/routingutility.c +++ b/resource/csdk/routing/src/routingutility.c @@ -203,7 +203,7 @@ void RMGetRouteOptionIndex(const CAHeaderOption_t *options, uint8_t numOptions, RM_NULL_CHECK_VOID(index, TAG, "index"); for (uint32_t i = 0; i < numOptions; i++) { - OC_LOG_V(DEBUG, TAG, "Request- optionID: %d", options[i].optionID); + OC_LOG_V(DEBUG, TAG, "Request- optionID: %u", options[i].optionID); if (RM_OPTION_MESSAGE_SWITCHING == options[i].optionID) { OC_LOG_V(INFO, TAG, "Found Option at %d", i); diff --git a/resource/csdk/stack/src/ocstack.c b/resource/csdk/stack/src/ocstack.c index f977f09..026e5f0 100755 --- a/resource/csdk/stack/src/ocstack.c +++ b/resource/csdk/stack/src/ocstack.c @@ -129,7 +129,7 @@ static const char COAP_TCP[] = "coap+tcp:"; TAG, #arg " is NULL"); return (retVal); } } #define VERIFY_NON_NULL_NR(arg, logLevel) { if (!(arg)) { OC_LOG((logLevel), \ TAG, #arg " is NULL"); return; } } -#define VERIFY_NON_NULL_V(arg) { if (!arg) {OC_LOG_V(FATAL, TAG, "%s is NULL", #arg);\ +#define VERIFY_NON_NULL_V(arg) { if (!arg) {OC_LOG(FATAL, TAG, #arg " is NULL");\ goto exit;} } //TODO: we should allow the server to define this @@ -3729,12 +3729,12 @@ OCStackResult initResources() &(((OCResource *) presenceResource.handle)->resourceProperties), OC_ACTIVE, 0); #endif - +#ifndef WITH_ARDUINO if (result == OC_STACK_OK) { result = SRMInitSecureResources(); } - +#endif return result; } -- 2.7.4