From: jihwan.seo Date: Wed, 18 Jan 2017 09:09:52 +0000 (+0900) Subject: To support BLE server disable flag in BT configure. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bd3607018235bcd205b53a7c1177a700aab1c3aa;p=contrib%2Fiotivity.git To support BLE server disable flag in BT configure. we can select disable/enable flag of ble server even through there are both client and server mode in OCMode of PlatformConfig. it will help to reduce battery consumption issue in both mode with ALL transports Change-Id: I2e4179c1c6b673313d751770a1885774280cc428 Signed-off-by: jihwan.seo Reviewed-on: https://gerrit.iotivity.org/gerrit/16909 Tested-by: jenkins-iotivity Reviewed-by: Dan Mihai Reviewed-by: Larry Sachs Reviewed-by: Rick Bell Reviewed-by: Ashok Babu Channa --- diff --git a/resource/csdk/connectivity/api/cacommon.h b/resource/csdk/connectivity/api/cacommon.h index 8b6ab8b..a952477 100755 --- a/resource/csdk/connectivity/api/cacommon.h +++ b/resource/csdk/connectivity/api/cacommon.h @@ -231,8 +231,9 @@ typedef enum { CA_DEFAULT_BT_FLAGS = 0, // flags for BLE transport - CA_LE_ADV_DISABLE = 0x1, // disable BLE advertisement - CA_LE_ADV_ENABLE = 0x2, // enable BLE advertisement + CA_LE_ADV_DISABLE = 0x1, // disable BLE advertisement. + CA_LE_ADV_ENABLE = 0x2, // enable BLE advertisement. + CA_LE_SERVER_DISABLE = (1 << 4), // disable gatt server. // flags for EDR transport CA_EDR_SERVER_DISABLE = (1 << 7) } CATransportBTFlags_t; diff --git a/resource/csdk/connectivity/src/bt_le_adapter/android/calenwmonitor.c b/resource/csdk/connectivity/src/bt_le_adapter/android/calenwmonitor.c index f9a0a63..82bc169 100644 --- a/resource/csdk/connectivity/src/bt_le_adapter/android/calenwmonitor.c +++ b/resource/csdk/connectivity/src/bt_le_adapter/android/calenwmonitor.c @@ -312,7 +312,11 @@ Java_org_iotivity_ca_CaLeClientInterface_caLeStateChangedCallback(JNIEnv *env, j { CANetworkStatus_t newStatus = CA_INTERFACE_UP; CALEClientCreateDeviceList(); - CALEServerCreateCachedDeviceList(); + + if (!(caglobals.bleFlags & CA_LE_SERVER_DISABLE)) + { + CALEServerCreateCachedDeviceList(); + } g_bleDeviceStateChangedCallback(newStatus); } diff --git a/resource/csdk/connectivity/src/bt_le_adapter/caleadapter.c b/resource/csdk/connectivity/src/bt_le_adapter/caleadapter.c index 5e86577..1b31ee1 100644 --- a/resource/csdk/connectivity/src/bt_le_adapter/caleadapter.c +++ b/resource/csdk/connectivity/src/bt_le_adapter/caleadapter.c @@ -2642,6 +2642,13 @@ static CAResult_t CALEAdapterGattServerStart() { OIC_LOG(DEBUG, CALEADAPTER_TAG, "Before CAStartLEGattServer"); + if (caglobals.bleFlags & CA_LE_SERVER_DISABLE) + { + OIC_LOG_V(INFO, CALEADAPTER_TAG, "server's flag is disabled in configuration [%d]", + caglobals.bleFlags); + return CA_STATUS_OK; + } + CAResult_t result = CAStartLEGattServer(); #ifndef SINGLE_THREAD @@ -2670,8 +2677,16 @@ static CAResult_t CALEAdapterGattServerStart() static CAResult_t CALEAdapterGattServerStop() { + OIC_LOG(DEBUG, CALEADAPTER_TAG, "Server Stop"); + + if (caglobals.bleFlags & CA_LE_SERVER_DISABLE) + { + OIC_LOG_V(INFO, CALEADAPTER_TAG, "server flag of configure is disable [%d]", + caglobals.bleFlags); + return CA_STATUS_OK; + } + #ifndef SINGLE_THREAD - OIC_LOG(DEBUG, CALEADAPTER_TAG, "CALEAdapterGattServerStop"); CAResult_t res = CAStopLEGattServer(); if (CA_STATUS_OK != res) @@ -2984,6 +2999,14 @@ static void CATerminateLE() static CAResult_t CAStartLEListeningServer() { OIC_LOG(DEBUG, CALEADAPTER_TAG, "IN - CAStartLEListeningServer"); + + if (caglobals.bleFlags & CA_LE_SERVER_DISABLE) + { + OIC_LOG_V(INFO, CALEADAPTER_TAG, "server flag of configure is disable [%d]", + caglobals.bleFlags); + return CA_STATUS_OK; + } + #ifndef ROUTING_GATEWAY CAResult_t result = CA_STATUS_OK; #ifndef SINGLE_THREAD diff --git a/resource/csdk/connectivity/util/src/cautilinterface.c b/resource/csdk/connectivity/util/src/cautilinterface.c index 57e8261..2a56b5c 100644 --- a/resource/csdk/connectivity/util/src/cautilinterface.c +++ b/resource/csdk/connectivity/util/src/cautilinterface.c @@ -339,8 +339,8 @@ CAResult_t CAUtilStopLEAdvertising() CAResult_t CAUtilSetBTConfigure(CAUtilConfig_t config) { OIC_LOG_V(DEBUG, TAG, "CAUtilSetConfigure"); - OIC_LOG_V(DEBUG, TAG, "bleFlag [%d]", config.bleFlags); #if (defined(__ANDROID__) && defined(LE_ADAPTER)) + OIC_LOG_V(DEBUG, TAG, "bleFlag [%d]", config.bleFlags); CAManagerSetConfigure(config); return CA_STATUS_OK; #else diff --git a/resource/csdk/include/octypes.h b/resource/csdk/include/octypes.h index 13f6711..77b466b 100755 --- a/resource/csdk/include/octypes.h +++ b/resource/csdk/include/octypes.h @@ -676,11 +676,15 @@ typedef enum typedef enum { + /** default flag is 0.*/ OC_DEFAULT_BT_FLAGS = 0, - // flags for BLE transport - OC_LE_ADV_DISABLE = 0x1, // disable BLE advertisement - OC_LE_ADV_ENABLE = 0x2, // enable BLE advertisement - // flags for EDR transport + /** disable BLE advertisement.*/ + OC_LE_ADV_DISABLE = 0x1, + /** enable BLE advertisement.*/ + OC_LE_ADV_ENABLE = 0x2, + /** disable gatt server.*/ + OC_LE_SERVER_DISABLE = (1 << 4), + /** disable rfcomm server.*/ OC_EDR_SERVER_DISABLE = (1 << 7) } OCTransportBTFlags_t;