enabled ScanResponse for Advertising in BLE server
authorjihwan.seo <jihwan.seo@samsung.com>
Fri, 1 Apr 2016 00:34:03 +0000 (09:34 +0900)
committerJon A. Cruz <jon@joncruz.org>
Tue, 5 Apr 2016 06:48:16 +0000 (06:48 +0000)
long device name can be used
though using ScanResonse Advertise data.

Change-Id: I42a60591577cd54b7de109a15b096c080bb43667
Signed-off-by: jihwan.seo <jihwan.seo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/7523
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Jon A. Cruz <jon@joncruz.org>
resource/csdk/connectivity/src/bt_le_adapter/android/caleserver.c

index 7242404..7a92538 100644 (file)
@@ -536,6 +536,15 @@ CAResult_t CALEServerStartAdvertise(JNIEnv *env, jobject advertiseCallback)
         return CA_STATUS_FAILED;
     }
 
+    jobject jni_AdvertiseDataBuilderForScanRsp = (*env)->NewObject(env,
+                                                                   jni_cid_AdvertiseDataBuilder,
+                                                                   jni_mid_AdvertiseDataBuilder);
+    if (!jni_AdvertiseDataBuilderForScanRsp)
+    {
+        OIC_LOG(ERROR, TAG, "jni_AdvertiseDataBuilderForScanRsp is null");
+        return CA_STATUS_FAILED;
+    }
+
     jobject jni_obj_serviceUUID = CALEGetUuidFromString(env, OIC_GATT_SERVICE_UUID);
     if (!jni_obj_serviceUUID)
     {
@@ -582,9 +591,10 @@ CAResult_t CALEServerStartAdvertise(JNIEnv *env, jobject advertiseCallback)
         return CA_STATUS_FAILED;
     }
 
-    jobject jni_obj_setIncludeDeviceName  = (*env)->CallObjectMethod(env, jni_AdvertiseDataBuilder,
-                                                                     jni_mid_setIncludeDeviceName,
-                                                                     JNI_TRUE);
+    jobject jni_obj_setIncludeDeviceName  = (*env)->CallObjectMethod(env,
+                                                               jni_AdvertiseDataBuilderForScanRsp,
+                                                               jni_mid_setIncludeDeviceName,
+                                                               JNI_TRUE);
     if (!jni_obj_setIncludeDeviceName)
     {
         OIC_LOG(ERROR, TAG, "jni_obj_setIncludeDeviceName is null");
@@ -671,12 +681,22 @@ CAResult_t CALEServerStartAdvertise(JNIEnv *env, jobject advertiseCallback)
         return CA_STATUS_FAILED;
     }
 
+    jobject jni_obj_build_LeAdvertiseDataForScanRsp = (*env)->CallObjectMethod(env,
+                                                                jni_AdvertiseDataBuilderForScanRsp,
+                                                                jni_mid_build_LeAdvertiseData);
+    if (!jni_obj_build_LeAdvertiseDataForScanRsp)
+    {
+        OIC_LOG(ERROR, TAG, "jni_obj_build_LeAdvertiseDataForScanRsp is null");
+        return CA_STATUS_FAILED;
+    }
+
     jmethodID jni_mid_startAdvertising = CALEGetJNIMethodID(env, "android/bluetooth/le/"
                                                             "BluetoothLeAdvertiser",
                                                             "startAdvertising",
                                                             "(Landroid/bluetooth/le/"
                                                             "AdvertiseSettings;Landroid/bluetooth/"
                                                             "le/AdvertiseData;Landroid/bluetooth/"
+                                                            "le/AdvertiseData;Landroid/bluetooth/"
                                                             "le/AdvertiseCallback;)V");
     if (!jni_mid_startAdvertising)
     {
@@ -686,7 +706,7 @@ CAResult_t CALEServerStartAdvertise(JNIEnv *env, jobject advertiseCallback)
 
     (*env)->CallVoidMethod(env, jni_obj_getBluetoothLeAdvertiser, jni_mid_startAdvertising,
                            jni_obj_build_LeAdvertiseSettings, jni_obj_build_LeAdvertiseData,
-                           advertiseCallback);
+                           jni_obj_build_LeAdvertiseDataForScanRsp, advertiseCallback);
 
     if ((*env)->ExceptionCheck(env))
     {