projects
/
platform
/
upstream
/
iotivity.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' into notification-service
[platform/upstream/iotivity.git]
/
resource
/
csdk
/
connectivity
/
src
/
cainterfacecontroller.c
diff --git
a/resource/csdk/connectivity/src/cainterfacecontroller.c
b/resource/csdk/connectivity/src/cainterfacecontroller.c
index
64b3f68
..
5153b69
100644
(file)
--- a/
resource/csdk/connectivity/src/cainterfacecontroller.c
+++ b/
resource/csdk/connectivity/src/cainterfacecontroller.c
@@
-55,9
+55,9
@@
static uint32_t g_numberOfAdapters = 0;
static CANetworkPacketReceivedCallback g_networkPacketReceivedCallback = NULL;
static CANetworkPacketReceivedCallback g_networkPacketReceivedCallback = NULL;
-static CAAdapter
ChangeCallback
g_adapterChangeCallback = NULL;
+static CAAdapter
StateChangedCB
g_adapterChangeCallback = NULL;
-static CAConnection
ChangeCallback
g_connChangeCallback = NULL;
+static CAConnection
StateChangedCB
g_connChangeCallback = NULL;
static CAErrorHandleCallback g_errorHandleCallback = NULL;
static CAErrorHandleCallback g_errorHandleCallback = NULL;
@@
-75,7
+75,7
@@
static int CAGetAdapterIndex(CATransportAdapter_t cType)
static void CARegisterCallback(CAConnectivityHandler_t handler)
{
static void CARegisterCallback(CAConnectivityHandler_t handler)
{
- if(handler.startAdapter == NULL ||
+ if
(handler.startAdapter == NULL ||
handler.startListenServer == NULL ||
handler.stopListenServer == NULL ||
handler.startDiscoveryServer == NULL ||
handler.startListenServer == NULL ||
handler.stopListenServer == NULL ||
handler.startDiscoveryServer == NULL ||
@@
-129,11
+129,19
@@
static void CAAdapterChangedCallback(CATransportAdapter_t adapter, CANetworkStat
// Call the callback.
if (g_adapterChangeCallback != NULL)
{
// Call the callback.
if (g_adapterChangeCallback != NULL)
{
- g_adapterChangeCallback(adapter, status);
+ if (CA_INTERFACE_UP == status)
+ {
+ g_adapterChangeCallback(adapter, true);
+ }
+ else if (CA_INTERFACE_DOWN == status)
+ {
+ g_adapterChangeCallback(adapter, false);
+ }
}
OIC_LOG_V(DEBUG, TAG, "[%d]adapter status is changed to [%d]", adapter, status);
}
}
OIC_LOG_V(DEBUG, TAG, "[%d]adapter status is changed to [%d]", adapter, status);
}
+#if defined(TCP_ADAPTER) || defined(EDR_ADAPTER) || defined(LE_ADAPTER)
static void CAConnectionChangedCallback(const CAEndpoint_t *info, bool isConnected)
{
// Call the callback.
static void CAConnectionChangedCallback(const CAEndpoint_t *info, bool isConnected)
{
// Call the callback.
@@
-143,6
+151,7
@@
static void CAConnectionChangedCallback(const CAEndpoint_t *info, bool isConnect
}
OIC_LOG_V(DEBUG, TAG, "[%s] connection status is changed to [%d]", info->addr, isConnected);
}
}
OIC_LOG_V(DEBUG, TAG, "[%s] connection status is changed to [%d]", info->addr, isConnected);
}
+#endif
static void CAAdapterErrorHandleCallback(const CAEndpoint_t *endpoint,
const void *data, uint32_t dataLen,
static void CAAdapterErrorHandleCallback(const CAEndpoint_t *endpoint,
const void *data, uint32_t dataLen,
@@
-200,8
+209,8
@@
void CASetPacketReceivedCallback(CANetworkPacketReceivedCallback callback)
g_networkPacketReceivedCallback = callback;
}
g_networkPacketReceivedCallback = callback;
}
-void CASetNetworkMonitorCallbacks(CAAdapter
ChangeCallback
adapterCB,
- CAConnection
ChangeCallback
connCB)
+void CASetNetworkMonitorCallbacks(CAAdapter
StateChangedCB
adapterCB,
+ CAConnection
StateChangedCB
connCB)
{
OIC_LOG(DEBUG, TAG, "Set network monitoring callback");
{
OIC_LOG(DEBUG, TAG, "Set network monitoring callback");
@@
-291,7
+300,7
@@
CAResult_t CAGetNetworkInfo(CAEndpoint_t **info, uint32_t *size)
OIC_LOG_V(DEBUG,
TAG,
OIC_LOG_V(DEBUG,
TAG,
- "%
zu
adapter network info size is %" PRIu32 " res:%d",
+ "%
" PRIu32 "
adapter network info size is %" PRIu32 " res:%d",
index,
tempSize[index],
res);
index,
tempSize[index],
res);
@@
-308,7
+317,10
@@
CAResult_t CAGetNetworkInfo(CAEndpoint_t **info, uint32_t *size)
{
return res;
}
{
return res;
}
- return CA_STATUS_FAILED;
+ else
+ {
+ return CA_STATUS_FAILED;
+ }
}
// #3. add data into result
}
// #3. add data into result
@@
-358,7
+370,8
@@
memory_error_exit:
return CA_MEMORY_ALLOC_FAILED;
}
return CA_MEMORY_ALLOC_FAILED;
}
-CAResult_t CASendUnicastData(const CAEndpoint_t *endpoint, const void *data, uint32_t length)
+CAResult_t CASendUnicastData(const CAEndpoint_t *endpoint, const void *data, uint32_t length,
+ CADataType_t dataType)
{
if (endpoint == NULL)
{
{
if (endpoint == NULL)
{
@@
-403,7
+416,7
@@
CAResult_t CASendUnicastData(const CAEndpoint_t *endpoint, const void *data, uin
if (NULL != g_adapterHandler[index].sendData)
{
OIC_LOG(DEBUG, TAG, "unicast message to adapter");
if (NULL != g_adapterHandler[index].sendData)
{
OIC_LOG(DEBUG, TAG, "unicast message to adapter");
- sentDataLen = g_adapterHandler[index].sendData(endpoint, data, length);
+ sentDataLen = g_adapterHandler[index].sendData(endpoint, data, length
, dataType
);
}
if (sentDataLen != (int32_t)length)
}
if (sentDataLen != (int32_t)length)
@@
-420,7
+433,8
@@
CAResult_t CASendUnicastData(const CAEndpoint_t *endpoint, const void *data, uin
return CA_STATUS_OK;
}
return CA_STATUS_OK;
}
-CAResult_t CASendMulticastData(const CAEndpoint_t *endpoint, const void *data, uint32_t length)
+CAResult_t CASendMulticastData(const CAEndpoint_t *endpoint, const void *data, uint32_t length,
+ CADataType_t dataType)
{
u_arraylist_t *list = CAGetSelectedNetworkList();
if (!list)
{
u_arraylist_t *list = CAGetSelectedNetworkList();
if (!list)
@@
-435,7
+449,7
@@
CAResult_t CASendMulticastData(const CAEndpoint_t *endpoint, const void *data, u
{
void* ptrType = u_arraylist_get(list, i);
{
void* ptrType = u_arraylist_get(list, i);
- if(NULL == ptrType)
+ if
(NULL == ptrType)
{
continue;
}
{
continue;
}
@@
-448,9
+462,8
@@
CAResult_t CASendMulticastData(const CAEndpoint_t *endpoint, const void *data, u
int index = CAGetAdapterIndex(connType);
if (0 > index)
int index = CAGetAdapterIndex(connType);
if (0 > index)
- if (-1 == index)
{
{
- OIC_LOG(
DEBUG
, TAG, "unknown connectivity type!");
+ OIC_LOG(
ERROR
, TAG, "unknown connectivity type!");
continue;
}
continue;
}
@@
-465,7
+478,7
@@
CAResult_t CASendMulticastData(const CAEndpoint_t *endpoint, const void *data, u
return CA_MEMORY_ALLOC_FAILED;
}
memcpy(payload, data, length);
return CA_MEMORY_ALLOC_FAILED;
}
memcpy(payload, data, length);
- sentDataLen = g_adapterHandler[index].sendDataToAll(endpoint, payload, length);
+ sentDataLen = g_adapterHandler[index].sendDataToAll(endpoint, payload, length
, dataType
);
OICFree(payload);
}
OICFree(payload);
}