Fix for Memory management in Arduino
authorkoushik.girijala <g.koushik@samsung.com>
Wed, 14 Oct 2015 11:56:05 +0000 (17:26 +0530)
committerJon A. Cruz <jonc@osg.samsung.com>
Mon, 7 Dec 2015 07:18:46 +0000 (07:18 +0000)
Modified code to make more heap available in arduino MEGA

Change-Id: I62ebc1bcf08331d7d90871bb2a6dd201f4ae7e4b
Signed-off-by: vimala.v <vimala.v@samsung.com>
Signed-off-by: koushik.girijala <g.koushik@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/3879
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Jon A. Cruz <jonc@osg.samsung.com>
resource/csdk/connectivity/common/inc/logger.h
resource/csdk/connectivity/src/camessagehandler.c
resource/csdk/routing/src/routingutility.c
resource/csdk/stack/src/ocstack.c

index 5e7ff5c..a58def7 100644 (file)
@@ -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
index cc6a452..b101098 100644 (file)
@@ -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
     {
index 7f342a7..a0925c2 100644 (file)
@@ -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);
index f977f09..026e5f0 100755 (executable)
@@ -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;
 }