[IOT-1731] To support start/stop LE advertising API for android
authorjihwan.seo <jihwan.seo@samsung.com>
Sat, 7 Jan 2017 06:20:26 +0000 (15:20 +0900)
committerAshok Babu Channa <ashok.channa@samsung.com>
Wed, 11 Jan 2017 07:01:18 +0000 (07:01 +0000)
since some application related gatt server
want to have multi-connect scenario.
we should provide start/stop advertising API.
Change-Id: I3201e563cdd07bb84c38639f9a2b6743122b2385
Signed-off-by: jihwan.seo <jihwan.seo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/16221
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Ashok Babu Channa <ashok.channa@samsung.com>
java/iotivity-android/src/main/java/org/iotivity/ca/CaInterface.java
java/jni/JniCaInterface.c
resource/csdk/connectivity/api/cautilinterface.h
resource/csdk/connectivity/util/inc/camanagerleinterface.h
resource/csdk/connectivity/util/src/camanager/bt_le_manager/android/caleconnectionmanager.c
resource/csdk/connectivity/util/src/cautilinterface.c

index 173c7db..9a05ca7 100644 (file)
@@ -218,6 +218,22 @@ public class CaInterface {
     }
     private static native void stopLeScanImpl();
 
+    /**
+     *  start BLE Advertising.
+     */
+    public synchronized static void startLeAdvertising(){
+        CaInterface.startLeAdvertisingImpl();
+    }
+    private static native void startLeAdvertisingImpl();
+
+    /**
+     *  stop BLE Advertising.
+     */
+    public synchronized static void stopLeAdvertising(){
+        CaInterface.stopLeAdvertisingImpl();
+    }
+    private static native void stopLeAdvertisingImpl();
+
     public synchronized static int setCipherSuite(OicCipher cipher, OcConnectivityType connType){
         return CaInterface.setCipherSuiteImpl(cipher.getValue(), connType.getValue());
     }
index bcce5e8..d7ed9b2 100644 (file)
@@ -411,6 +411,24 @@ Java_org_iotivity_ca_CaInterface_stopLeScanImpl(JNIEnv *env, jclass clazz)
     CAUtilStopLEScan();
 }
 
+JNIEXPORT void JNICALL
+Java_org_iotivity_ca_CaInterface_startLeAdvertisingImpl(JNIEnv *env, jclass clazz)
+{
+    LOGI("startLeAdvertising");
+    (void)env;
+    (void)clazz;
+    CAUtilStartLEAdvertising();
+}
+
+JNIEXPORT void JNICALL
+Java_org_iotivity_ca_CaInterface_stopLeAdvertisingImpl(JNIEnv *env, jclass clazz)
+{
+    LOGI("stopLeAdvertising");
+    (void)env;
+    (void)clazz;
+    CAUtilStopLEAdvertising();
+}
+
 JNIEXPORT jint JNICALL Java_org_iotivity_ca_CaInterface_setCipherSuiteImpl
   (JNIEnv *env, jclass clazz, jint cipherSuite, jint adapter)
 {
index 9f58244..21fd27b 100644 (file)
@@ -196,6 +196,21 @@ CAResult_t CAUtilSetLEScanInterval(jint intervalTime, jint workingCount);
 CAResult_t CAUtilStopLEScan();
 #endif //__JAVA__
 
+#if defined(LE_ADAPTER)
+// BLE util
+/**
+ * start BLE advertising.
+ * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
+ */
+CAResult_t CAUtilStartLEAdvertising();
+
+/**
+ * stop BLE advertising.
+ * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
+ */
+CAResult_t CAUtilStopLEAdvertising();
+#endif // LE_ADAPTER
+
 #ifdef __cplusplus
 } /* extern "C" */
 #endif //__cplusplus
index b5f2dad..95f4916 100644 (file)
@@ -78,9 +78,20 @@ void CAManagerLESetScanInterval(jint intervalTime, jint workingCount);
  * stop BLE scan.
  */
 void CAManagerLEStopScan();
-
 #endif
 
+/**
+ * start BLE advertising.
+ * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
+ */
+CAResult_t CAManagerLEStartAdvertising();
+
+/**
+ * stop BLE advertising.
+ * @return  ::CA_STATUS_OK or ERROR CODES (::CAResult_t error codes in cacommon.h).
+ */
+CAResult_t CAManagerLEStopAdvertising();
+
 #ifdef __cplusplus
 } /* extern "C" */
 #endif
index f57aa45..edefd64 100644 (file)
@@ -292,6 +292,26 @@ void CAManagerLEStopScan()
     CALERestartScanWithInterval(0, 0, BLE_SCAN_DISABLE);
 }
 
+CAResult_t CAManagerLEStartAdvertising()
+{
+    CAResult_t ret = CALEServerStartAdvertise();
+    if (CA_STATUS_OK != ret)
+    {
+        OIC_LOG(ERROR, TAG, "CALEServerStartAdvertise has failed");
+    }
+    return ret;
+}
+
+CAResult_t CAManagerLEStopAdvertising()
+{
+    CAResult_t ret = CALEServerStopAdvertise();
+    if (CA_STATUS_OK != ret)
+    {
+        OIC_LOG(ERROR, TAG, "CALEServerStopAdvertise has failed");
+    }
+    return ret;
+}
+
 JNIEXPORT void JNICALL
 Java_org_iotivity_ca_CaLeClientInterface_caManagerAdapterStateChangedCallback(
         JNIEnv *env, jobject obj, jint state)
index 124b444..b5690f4 100644 (file)
@@ -312,4 +312,28 @@ CAResult_t CAUtilStopLEScan()
     return CA_NOT_SUPPORTED;
 #endif
 }
+#endif // __JAVA__
+
+#if defined(LE_ADAPTER)
+CAResult_t CAUtilStartLEAdvertising()
+{
+    OIC_LOG(DEBUG, TAG, "CAUtilStartLEAdvertising");
+#if defined(__ANDROID__) || defined(__TIZEN__)
+    return CAManagerLEStartAdvertising();
+#else
+    OIC_LOG(DEBUG, TAG, "it is not supported");
+    return CA_NOT_SUPPORTED;
+#endif
+}
+
+CAResult_t CAUtilStopLEAdvertising()
+{
+    OIC_LOG(DEBUG, TAG, "CAUtilStopLEAdvertising");
+#if defined(__ANDROID__) || defined(__TIZEN__)
+    return CAManagerLEStopAdvertising();
+#else
+    OIC_LOG(DEBUG, TAG, "it is not supported");
+    return CA_NOT_SUPPORTED;
+#endif
+}
 #endif