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");
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()
{
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++)
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()
{
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++)
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()