To support BLE server disable flag in BT configure.
authorjihwan.seo <jihwan.seo@samsung.com>
Wed, 18 Jan 2017 09:09:52 +0000 (18:09 +0900)
committerAshok Babu Channa <ashok.channa@samsung.com>
Mon, 6 Feb 2017 14:07:42 +0000 (14:07 +0000)
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 <jihwan.seo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/16909
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Dan Mihai <Daniel.Mihai@microsoft.com>
Reviewed-by: Larry Sachs <larry.j.sachs@intel.com>
Reviewed-by: Rick Bell <richard.s.bell@intel.com>
Reviewed-by: Ashok Babu Channa <ashok.channa@samsung.com>
resource/csdk/connectivity/api/cacommon.h
resource/csdk/connectivity/src/bt_le_adapter/android/calenwmonitor.c
resource/csdk/connectivity/src/bt_le_adapter/caleadapter.c
resource/csdk/connectivity/util/src/cautilinterface.c
resource/csdk/include/octypes.h

index 8b6ab8b..a952477 100755 (executable)
@@ -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;
index f9a0a63..82bc169 100644 (file)
@@ -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);
     }
index 5e86577..1b31ee1 100644 (file)
@@ -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
index 57e8261..2a56b5c 100644 (file)
@@ -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
index 13f6711..77b466b 100755 (executable)
@@ -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;