Replaced printf with Serial.println() in arduino CASample
authorvimala.v <vimala.v@samsung.com>
Thu, 9 Jul 2015 11:54:41 +0000 (17:24 +0530)
committerErich Keane <erich.keane@intel.com>
Fri, 10 Jul 2015 15:41:50 +0000 (15:41 +0000)
Change-Id: I8ab085b2ca330789255d8397d42cf483a9d97187
Signed-off-by: vimala.v <vimala.v@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1600
Reviewed-by: Abhishek Pandey <abhi.siso@samsung.com>
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Erich Keane <erich.keane@intel.com>
resource/csdk/connectivity/samples/arduino/casample.cpp

index 9d0c879..52040c2 100644 (file)
@@ -91,7 +91,7 @@ void GetData(char *readInput, size_t bufferLength, size_t *dataLength)
 
     readInput[len] = '\0';
     Serial.flush();
-    Serial.print("PD:");
+    Serial.print("PD: ");
     Serial.println(readInput);
     (*dataLength) = len;
 }
@@ -639,18 +639,19 @@ void GetNetworkInfo()
         free(tempInfo);
         return;
     }
-    printf("=========");
-    printf("Network info total size is %d\n\n", tempSize);
+    Serial.println("=========");
+    Serial.print("Network info total size is ");
+    Serial.println(tempSize);
     int index;
     for (index = 0; index < tempSize; index++)
     {
-        Serial.println("Type:");
+        Serial.print("Type: ");
         Serial.println(tempInfo[index].adapter);
         if (CA_ADAPTER_IP == tempInfo[index].adapter)
         {
-            Serial.println("Address:");
+            Serial.print("Address: ");
             Serial.println(tempInfo[index].addr);
-            Serial.println("Port:");
+            Serial.print("Port: ");
             Serial.println(tempInfo[index].port);
         }
     }
@@ -696,15 +697,15 @@ void RequestHandler(const CAEndpoint_t *object, const CARequestInfo_t *requestIn
         return;
     }
 
-    Serial.println("RAddr: ");
+    Serial.print("RAddr: ");
     Serial.println(object->addr);
-    Serial.println("Port: ");
+    Serial.print("Port: ");
     Serial.println(object->port);
-    Serial.println("uri: ");
+    Serial.print("uri: ");
     Serial.println(requestInfo->info.resourceUri);
-    Serial.println("data: ");
+    Serial.print("data: ");
     Serial.println(requestInfo->info.payload);
-    Serial.println("Type: ");
+    Serial.print("Type: ");
     Serial.println(requestInfo->info.type);
 
     if (requestInfo->info.options)
@@ -713,11 +714,11 @@ void RequestHandler(const CAEndpoint_t *object, const CARequestInfo_t *requestIn
         uint32_t i;
         for (i = 0; i < len; i++)
         {
-            Serial.println("Option:");
+            Serial.print("Option: ");
             Serial.println(i+1);
-            Serial.println("ID:");
+            Serial.print("ID: ");
             Serial.println(requestInfo->info.options[i].optionID);
-            Serial.println("Data:");
+            Serial.print("Data: ");
             Serial.println((char*)requestInfo->info.options[i].optionData);
         }
     }
@@ -748,41 +749,24 @@ void ResponseHandler(const CAEndpoint_t *object, const CAResponseInfo_t *respons
 
 void ErrorHandler(const CAEndpoint_t *rep, const CAErrorInfo_t* errorInfo)
 {
-    printf("+++++++++++++++++++++++++++++++++++ErrorInfo+++++++++++++++++++++++++++++++++++\n");
+    Serial.println("ErrorInfo");
 
     if(errorInfo)
     {
         const CAInfo_t *info = &errorInfo->info;
-        printf("Error Handler, ErrorInfo :\n");
-        printf("Error Handler result    : %d\n", errorInfo->result);
-        printf("Error Handler token     : %s\n", info->token);
-        printf("Error Handler messageId : %d\n", (uint16_t) info->messageId);
-        printf("Error Handler type      : %d\n", info->type);
-        printf("Error Handler resourceUri : %s\n", info->resourceUri);
-        printf("Error Handler payload   : %s\n", info->payload);
-
-        if(CA_ADAPTER_NOT_ENABLED == errorInfo->result)
-        {
-            printf("CA_ADAPTER_NOT_ENABLED, enable the adapter\n");
-        }
-        else if(CA_SEND_FAILED == errorInfo->result)
-        {
-            printf("CA_SEND_FAILED, unable to send the message, check parameters\n");
-        }
-        else if(CA_MEMORY_ALLOC_FAILED == errorInfo->result)
-        {
-            printf("CA_MEMORY_ALLOC_FAILED, insufficient memory\n");
-        }
-        else if(CA_SOCKET_OPERATION_FAILED == errorInfo->result)
-        {
-            printf("CA_SOCKET_OPERATION_FAILED, socket operation failed\n");
-        }
-        else if(CA_STATUS_FAILED == errorInfo->result)
-        {
-            printf("CA_STATUS_FAILED, message could not be delivered, internal error\n");
-        }
+        Serial.print("result: ");
+        Serial.println(errorInfo->result);
+        Serial.print("token: ");
+        Serial.println(info->token);
+        Serial.print("messageId: ");
+        Serial.println(info->messageId);
+        Serial.print("type: ");
+        Serial.println(info->type);
+        Serial.print("resourceUri: ");
+        Serial.println(info->resourceUri);
+        Serial.print("payload: ");
+        Serial.println(info->payload);
     }
-    printf("++++++++++++++++++++++++++++++++End of ErrorInfo++++++++++++++++++++++++++++++++\n");
 
     return;
 }