[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 3e234dfab84775a8dbf0f26147848e5797665e54..cd31bec1f79dfa2b9de2519b5ba7a625bbaf3676 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 09098dccd642484e3f0a3560a6d549e92800337b..099e6d3c112d8c3f7598214b2a3be2acb2cb1ee2 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 153dc52eb294d29fcd36c11a5ef4c70195f07558..0086b22175e2bcb4e30faafdc977df6c005ac27a 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 dd9ceca20cd0f636506e3037e6b5fe0b4825460e..c2dea29bbcb56df627c503c9f03e9f4d16eb5509 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