From: Ossama Othman Date: Mon, 7 Dec 2015 21:52:24 +0000 (-0800) Subject: [IOT-898] Propagate result of CA discovery/listen start call. X-Git-Tag: 1.2.0+RC1~785 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9db9642480b52e51166d8b952d5e0372086eb5c8;p=platform%2Fupstream%2Fiotivity.git [IOT-898] Propagate result of CA discovery/listen start call. Capture and return the result of CA discovery and listen start function calls to allow for better differentiation of transport adapter initialization and communication errors. Change-Id: Ib5717600708e36792c020cb1c3b9f9caeaad9839 Signed-off-by: Ossama Othman Reviewed-on: https://gerrit.iotivity.org/gerrit/4443 Tested-by: jenkins-iotivity Reviewed-by: Jon A. Cruz --- diff --git a/resource/csdk/connectivity/src/bt_le_adapter/caleadapter.c b/resource/csdk/connectivity/src/bt_le_adapter/caleadapter.c index 571a89064..26e0852e0 100644 --- a/resource/csdk/connectivity/src/bt_le_adapter/caleadapter.c +++ b/resource/csdk/connectivity/src/bt_le_adapter/caleadapter.c @@ -1774,14 +1774,14 @@ static CAResult_t CAStartLEListeningServer() return CA_STATUS_FAILED; } - CAStartLEGattServer(); + result = CAStartLEGattServer(); ca_mutex_lock(g_bleIsServerMutex); g_isServer = true; ca_mutex_unlock(g_bleIsServerMutex); OIC_LOG(DEBUG, CALEADAPTER_TAG, "OUT"); - return CA_STATUS_OK; + return result; #else // Routing Gateway only supports BLE client mode. OIC_LOG(ERROR, CALEADAPTER_TAG, "LE server not supported in Routing Gateway"); @@ -1821,14 +1821,14 @@ static CAResult_t CAStartLEDiscoveryServer() return CA_STATUS_FAILED; } - CAStartLEGattClient(); + result = CAStartLEGattClient(); ca_mutex_lock(g_bleIsServerMutex); g_isServer = false; ca_mutex_unlock(g_bleIsServerMutex); OIC_LOG(DEBUG, CALEADAPTER_TAG, "OUT"); - return CA_STATUS_OK; + return result; } static CAResult_t CAReadLEData() diff --git a/resource/csdk/connectivity/src/cainterfacecontroller.c b/resource/csdk/connectivity/src/cainterfacecontroller.c index 71124d3f9..33244131a 100644 --- a/resource/csdk/connectivity/src/cainterfacecontroller.c +++ b/resource/csdk/connectivity/src/cainterfacecontroller.c @@ -469,11 +469,13 @@ CAResult_t CAStartListeningServerAdapters() { OIC_LOG(DEBUG, TAG, "IN"); + CAResult_t result = CA_STATUS_FAILED; + u_arraylist_t *list = CAGetSelectedNetworkList(); if (!list) { OIC_LOG(ERROR, TAG, "No selected network"); - return CA_STATUS_FAILED; + return result; } for (uint32_t i = 0; i < u_arraylist_length(list); i++) @@ -496,12 +498,19 @@ CAResult_t CAStartListeningServerAdapters() if (g_adapterHandler[index].startListenServer != NULL) { - g_adapterHandler[index].startListenServer(); + const CAResult_t tmp = + g_adapterHandler[index].startListenServer(); + + // Successful listen if at least one adapter started. + if (CA_STATUS_OK == tmp) + { + result = tmp; + } } } OIC_LOG(DEBUG, TAG, "OUT"); - return CA_STATUS_OK; + return result; } CAResult_t CAStopListeningServerAdapters() @@ -546,12 +555,14 @@ CAResult_t CAStartDiscoveryServerAdapters() { OIC_LOG(DEBUG, TAG, "IN"); + CAResult_t result = CA_STATUS_FAILED; + u_arraylist_t *list = CAGetSelectedNetworkList(); if (!list) { OIC_LOG(ERROR, TAG, "No selected network"); - return CA_STATUS_FAILED; + return result; } for (uint32_t i = 0; i < u_arraylist_length(list); i++) @@ -575,12 +586,19 @@ CAResult_t CAStartDiscoveryServerAdapters() if (g_adapterHandler[index].startDiscoveryServer != NULL) { - g_adapterHandler[index].startDiscoveryServer(); + const CAResult_t tmp = + g_adapterHandler[index].startDiscoveryServer(); + + // Successful discovery if at least one adapter started. + if (CA_STATUS_OK == tmp) + { + result = tmp; + } } } OIC_LOG(DEBUG, TAG, "OUT"); - return CA_STATUS_OK; + return result; } void CATerminateAdapters() diff --git a/resource/csdk/connectivity/src/ip_adapter/caipadapter.c b/resource/csdk/connectivity/src/ip_adapter/caipadapter.c index 998e26c42..4bb258fcc 100644 --- a/resource/csdk/connectivity/src/ip_adapter/caipadapter.c +++ b/resource/csdk/connectivity/src/ip_adapter/caipadapter.c @@ -349,10 +349,9 @@ CAResult_t CAStopIPListeningServer() if (CA_STATUS_OK != ret) { OIC_LOG_V(ERROR, TAG, "Failed to stop listening server![%d]", ret); - return ret; } OIC_LOG(DEBUG, TAG, "OUT"); - return CA_STATUS_OK; + return ret; } CAResult_t CAStartIPDiscoveryServer()