[ARDUINO] Fixed send data failure in IP adapter
authorvimala.v <vimala.v@samsung.com>
Wed, 29 Jul 2015 11:15:03 +0000 (16:45 +0530)
committerErich Keane <erich.keane@intel.com>
Thu, 30 Jul 2015 16:21:48 +0000 (16:21 +0000)
Change-Id: I8f3cbd6414fca8f92e22f5d3d7ce8c3eebcb4b71
Signed-off-by: vimala.v <vimala.v@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1975
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Erich Keane <erich.keane@intel.com>
resource/csdk/connectivity/src/ip_adapter/arduino/caipclient_eth.cpp
resource/csdk/connectivity/src/ip_adapter/arduino/caipserver_eth.cpp
resource/csdk/connectivity/src/ip_adapter/arduino/caipserver_wifi.cpp
resource/csdk/connectivity/src/ip_adapter/caipadapter.c

index 3e234df..cd31bec 100644 (file)
@@ -33,6 +33,7 @@
 #include "caipadapterutils_eth.h"
 #include "caadapterutils.h"
 #include "oic_malloc.h"
+#include "oic_string.h"
 
 #define TAG "IPC"
 
@@ -44,6 +45,8 @@ static int g_sockID = 0;
  */
 static uint16_t g_unicastPort = 0;
 
+#define IPv4_MULTICAST     "224.0.1.187"
+
 void CAIPSetUnicastSocket(int socketID)
 {
     OIC_LOG(DEBUG, TAG, "IN");
@@ -83,14 +86,16 @@ void CAIPSendData(CAEndpoint_t *endpoint, const void *buf,
     uint16_t port = endpoint->port;
     if (isMulticast)
     {
+        port = CA_COAP;
+        OICStrcpy(endpoint->addr, sizeof(endpoint->addr), IPv4_MULTICAST);
         if (CAArduinoInitMulticastUdpSocket(endpoint->addr, port,
                                             g_unicastPort, &socketID) != CA_STATUS_OK)
         {
             OIC_LOG(ERROR, TAG, "init mcast err");
             return;
         }
-        OIC_LOG_V(DEBUG, TAG, "MPORT:%d", port);
-        OIC_LOG_V(DEBUG, TAG, "LPORT:%d", g_unicastPort);
+        OIC_LOG_V(DEBUG, TAG, "MPORT:%u", port);
+        OIC_LOG_V(DEBUG, TAG, "LPORT:%u", g_unicastPort);
         OIC_LOG_V(DEBUG, TAG, "SOCKET ID:%d", socketID);
     }
     else
index 09098dc..099e6d3 100644 (file)
@@ -102,7 +102,7 @@ CAResult_t CAIPStartUnicastServer(const char *localAddress, uint16_t *port,
     g_unicastSocket = serverFD;
     CAIPSetUnicastSocket(g_unicastSocket);
     CAIPSetUnicastPort(g_unicastPort);
-    OIC_LOG_V(DEBUG, TAG, "g_unicastPort: %d", g_unicastPort);
+    OIC_LOG_V(DEBUG, TAG, "g_unicastPort: %u", g_unicastPort);
     OIC_LOG_V(DEBUG, TAG, "g_unicastSocket: %d", g_unicastSocket);
     OIC_LOG(DEBUG, TAG, "OUT");
     return CA_STATUS_OK;
index 153dc52..0086b22 100644 (file)
@@ -105,7 +105,7 @@ CAResult_t CAIPStartUnicastServer(const char *localAddress, uint16_t *port,
         return CA_STATUS_FAILED;
     }
 
-    OIC_LOG_V(DEBUG, TAG, "port: %d", *port);
+    OIC_LOG_V(DEBUG, TAG, "port: %u", *port);
 
     Udp.begin((uint16_t ) *port);
     gServerRunning = true;
index dd9ceca..c2dea29 100644 (file)
@@ -354,6 +354,7 @@ static int32_t CAQueueIPData(bool isMulticast, const CAEndpoint_t *endpoint,
 #ifdef SINGLE_THREAD
 
     CAIPSendData(endpoint, data, dataLength, isMulticast);
+    return dataLength;
 
 #else