[IOT-1731] To support start/stop LE advertising API for Tizen 11/16711/3
authorjihwan.seo <jihwan.seo@samsung.com>
Sat, 7 Jan 2017 08:15:22 +0000 (17:15 +0900)
committerAshok Babu Channa <ashok.channa@samsung.com>
Wed, 25 Jan 2017 04:14:54 +0000 (04:14 +0000)
- enable C++ API for stop/start adv
- base patch is https://gerrit.iotivity.org/gerrit/#/c/16221/

Change-Id: I344a243b13cd9c63f6de7918718c07f17df480bc
Signed-off-by: jihwan.seo <jihwan.seo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/16711
Reviewed-by: Jiwon Cha <jw_wonny.cha@samsung.com>
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Dan Mihai <Daniel.Mihai@microsoft.com>
Reviewed-by: Ashok Babu Channa <ashok.channa@samsung.com>
resource/csdk/connectivity/src/bt_le_adapter/tizen/caleserver.c
resource/csdk/connectivity/src/bt_le_adapter/tizen/caleserver.h
resource/csdk/connectivity/util/src/camanager/bt_le_manager/tizen/caleconnectionmanager.c
resource/csdk/connectivity/util/src/cautilinterface.c
resource/include/CAManager.h
resource/src/CAManager.cpp

index af7a58e..d77bddd 100644 (file)
@@ -159,7 +159,7 @@ void CALEGattServerConnectionStateChanged(bool connected, const char *remoteAddr
         CARemoveLEClientInfoFromList(&g_LEClientList, remoteAddress);
         oc_mutex_unlock(g_LEClientListMutex);
 
-        res = CALEStartAdvertise(CA_GATT_SERVICE_UUID);
+        res = CALEStartAdvertise();
         if (CA_STATUS_OK != res)
         {
             OIC_LOG_V(ERROR, TAG, "Failed to start advertising [%d]", res);
@@ -195,9 +195,7 @@ CAResult_t CAStartLEGattServer()
         return CA_STATUS_FAILED;
     }
 
-    char *serviceUUID = CA_GATT_SERVICE_UUID;
-
-    ret  = CAAddNewLEServiceInGattServer(serviceUUID);
+    ret  = CAAddNewLEServiceInGattServer(CA_GATT_SERVICE_UUID);
     if (CA_STATUS_OK != ret)
     {
         OIC_LOG_V(ERROR, TAG, "CAAddNewLEServiceInGattServer failed[%d]", ret);
@@ -243,7 +241,7 @@ CAResult_t CAStartLEGattServer()
         return CA_STATUS_FAILED;
     }
 
-    ret = CALEStartAdvertise(serviceUUID);
+    ret = CALEStartAdvertise();
     if (CA_STATUS_OK != ret)
     {
         OIC_LOG_V(ERROR, TAG, "CALEStartAdvertise failed[%d]", ret);
@@ -271,7 +269,21 @@ void CALENotificationCb(bool notify, bt_gatt_server_h server, bt_gatt_h gatt_han
     OIC_LOG(DEBUG, TAG, "OUT");
 }
 
-CAResult_t CALEStartAdvertise(const char *serviceUUID)
+CAResult_t CALEStartAdvertise()
+{
+    OIC_LOG(DEBUG, TAG, "IN");
+
+    CAResult_t res = CALEStartAdvertiseImpl(CA_GATT_SERVICE_UUID);
+    if (CA_STATUS_OK != res)
+    {
+        OIC_LOG_V(ERROR, TAG, "CALEStartAdvertiseImpl failed[%d]", res);
+    }
+
+    OIC_LOG(DEBUG, TAG, "OUT");
+    return res;
+}
+
+CAResult_t CALEStartAdvertiseImpl(const char *serviceUUID)
 {
     OIC_LOG(DEBUG, TAG, "IN");
 
index d84c4e9..a3fe89f 100644 (file)
@@ -78,7 +78,17 @@ CAResult_t CAInitGattServerMutexVariables();
  * @retval  ::CA_STATUS_INVALID_PARAM  Invalid input arguments.
  * @retval  ::CA_STATUS_FAILED Operation failed.
  */
-CAResult_t CALEStartAdvertise(const char *serviceUUID);
+CAResult_t CALEStartAdvertise();
+
+/**
+ * Used to start advertising with service UUID.
+ *
+ * @return  ::CA_STATUS_OK or Appropriate error code.
+ * @retval  ::CA_STATUS_OK  Successful.
+ * @retval  ::CA_STATUS_INVALID_PARAM  Invalid input arguments.
+ * @retval  ::CA_STATUS_FAILED Operation failed.
+ */
+CAResult_t CALEStartAdvertiseImpl(const char *serviceUUID);
 
 /**
  * Used to stop advertising.
index cc196f2..122f3fc 100644 (file)
@@ -50,28 +50,30 @@ void CASetLENetworkMonitorCallbacks(CAAdapterStateChangedCB adapterStateCB,
     CASetLEConnectionStateChangedCallback(CAManagerConnectionMonitorHandler);
 }
 
-void CAStartServerLEAdvertising()
+CAResult_t CAManagerLEStartAdvertising()
 {
-    OIC_LOG(DEBUG, TAG, "CAStartServerLEAdvertising");
+    OIC_LOG(DEBUG, TAG, "CAManagerLEStartAdvertising");
 
-    CAResult_t res = CALEStartAdvertise(CA_GATT_SERVICE_UUID);
+    CAResult_t res = CALEStartAdvertise();
     if (CA_STATUS_OK != res)
     {
         OIC_LOG_V(ERROR, TAG, "Failed to start le advertising [%d]", res);
-        return;
+        return res;
     }
+    return res;
 }
 
-void CAStopServerLEAdvertising()
+CAResult_t CAManagerLEStopAdvertising()
 {
-    OIC_LOG(DEBUG, TAG, "CAStopServerLEAdvertising");
+    OIC_LOG(DEBUG, TAG, "CAManagerLEStopAdvertising");
 
     CAResult_t res = CALEStopAdvertise();
     if (CA_STATUS_OK != res)
     {
         OIC_LOG_V(ERROR, TAG, "Failed to stop le advertising [%d]", res);
-        return;
+        return res;
     }
+    return res;
 }
 
 CAResult_t CASetLEClientAutoConnectionDeviceInfo(const char * address)
index eb2e25d..f570bcb 100644 (file)
@@ -317,7 +317,7 @@ CAResult_t CAUtilStopLEScan()
 CAResult_t CAUtilStartLEAdvertising()
 {
     OIC_LOG(DEBUG, TAG, "CAUtilStartLEAdvertising");
-#if defined(LE_ADAPTER) && defined(__ANDROID__)
+#if (defined(__ANDROID__) || defined(__TIZEN__)) && defined(LE_ADAPTER)
     return CAManagerLEStartAdvertising();
 #else
     OIC_LOG(DEBUG, TAG, "it is not supported");
@@ -328,7 +328,7 @@ CAResult_t CAUtilStartLEAdvertising()
 CAResult_t CAUtilStopLEAdvertising()
 {
     OIC_LOG(DEBUG, TAG, "CAUtilStopLEAdvertising");
-#if defined(LE_ADAPTER) && defined(__ANDROID__)
+#if (defined(__ANDROID__) || defined(__TIZEN__)) && defined(LE_ADAPTER)
     return CAManagerLEStopAdvertising();
 #else
     OIC_LOG(DEBUG, TAG, "it is not supported");
index d67e96a..e227b16 100644 (file)
@@ -74,6 +74,18 @@ namespace OC
         */
         uint16_t getAssignedPortNumber(OCTransportAdapter adapter, OCTransportFlags flag);
 
+        /**
+         * start BLE advertising.
+        * @return Returns ::OC_STACK_OK if success.
+         */
+        OCStackResult startLEAdvertising();
+
+        /**
+         * stop BLE advertising.
+        * @return Returns ::OC_STACK_OK if success.
+         */
+        OCStackResult stopLEAdvertising();
+
 #if defined(__WITH_DTLS__) || defined(__WITH_TLS__)
         /**
          * Select the cipher suite for TLS/DTLS handshake.
index cbf47e1..47cc11c 100644 (file)
@@ -134,3 +134,17 @@ OCStackResult CAManager::setCipherSuite(const uint16_t cipher, OCTransportAdapte
     return convertCAResultToOCResult(ret);
 }
 #endif // defined(__WITH_DTLS__) || defined(__WITH_TLS__)
+
+OCStackResult CAManager::startLEAdvertising()
+{
+    CAResult_t ret = CAUtilStartLEAdvertising();
+
+    return convertCAResultToOCResult(ret);
+}
+
+OCStackResult CAManager::stopLEAdvertising()
+{
+    CAResult_t ret = CAUtilStopLEAdvertising();
+
+    return convertCAResultToOCResult(ret);
+}