updated the code related to descriptor of BLE in android
authorjihwan.seo <jihwan.seo@samsung.com>
Wed, 22 Jul 2015 12:38:15 +0000 (21:38 +0900)
committerErich Keane <erich.keane@intel.com>
Sun, 2 Aug 2015 18:36:47 +0000 (18:36 +0000)
As there are some issue in BLE core as per platform,
I have modified the code of android to support
BLE for Tizen(2.3/2.4) to Android and
Android to Arduino, Android to Android.
- Tizen 2.4 is not support to get
  PROPERTY_NOTIFY through descriptor.
- Arduino have to use Descriptor for PROPERTY_NOTIFY

Change-Id: I4c552b2ee3cb3cf7d5eb17d2e5b2cceda84eb4f2
Signed-off-by: jihwan.seo <jihwan.seo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1813
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Erich Keane <erich.keane@intel.com>
resource/csdk/connectivity/src/bt_le_adapter/android/caleclient.c
resource/csdk/connectivity/src/bt_le_adapter/android/caleserver.c

index f97d59b..7eb3bb9 100644 (file)
@@ -3407,8 +3407,13 @@ Java_org_iotivity_ca_CaLeClientInterface_caLeGattServicesDiscoveredCallback(JNIE
         res = CALEClientSetUUIDToDescriptor(env, gatt, jni_obj_GattCharacteristic);
         if (CA_STATUS_OK != res)
         {
-            OIC_LOG(ERROR, TAG, "CALEClientSetUUIDToDescriptor has failed");
-            goto error_exit;
+            OIC_LOG(INFO, TAG, "Descriptor of the uuid is not found");
+            CAResult_t res = CALEClientWriteCharacteristic(env, gatt);
+            if (CA_STATUS_OK != res)
+            {
+                OIC_LOG(ERROR, TAG, "CALEClientWriteCharacteristic has failed");
+                goto error_exit;
+            }
         }
 
         res = CALEClientUpdateDeviceState(address, STATE_CONNECTED, STATE_CHARACTER_SET,
index 994f9b4..4702408 100644 (file)
@@ -879,7 +879,7 @@ jobject CALEServerCreateGattService(JNIEnv *env)
 
     jfieldID jni_fid_readProperties = (*env)->GetStaticFieldID(env,
                                                                jni_cid_bluetoothGattCharacteristic,
-                                                               "PROPERTY_READ", "I");
+                                                               "PROPERTY_NOTIFY", "I");
     if (!jni_fid_readProperties)
     {
         OIC_LOG(ERROR, TAG, "jni_fid_readProperties is null");
@@ -978,23 +978,21 @@ jobject CALEServerCreateGattService(JNIEnv *env)
                                                              jni_cid_bluetoothGattCharacteristic,
                                                              jni_fid_readPermissions);
 
+    jint jni_int_writePermissions = (*env)->GetStaticIntField(env,
+                                                              jni_cid_bluetoothGattCharacteristic,
+                                                              jni_fid_writePermissions);
+
     jobject jni_readCharacteristic = (*env)->NewObject(env, jni_cid_bluetoothGattCharacteristic,
                                                        jni_mid_bluetoothGattCharacteristic,
                                                        jni_obj_readUuid, jni_int_readProperties,
-                                                       jni_int_readPermissions);
+                                                       jni_int_readPermissions|
+                                                       jni_int_writePermissions);
     if (!jni_readCharacteristic)
     {
         OIC_LOG(ERROR, TAG, "jni_readCharacteristic is null");
         return NULL;
     }
 
-    CAResult_t res = CALEServerAddDescriptor(env, jni_readCharacteristic);
-    if (CA_STATUS_OK != res)
-    {
-        OIC_LOG(ERROR, TAG, "CALEServerAddDescriptor has failed");
-        return NULL;
-    }
-
     jboolean jni_boolean_addReadCharacteristic = (*env)->CallBooleanMethod(
             env, jni_bluetoothGattService, jni_mid_addCharacteristic, jni_readCharacteristic);
     if (!jni_boolean_addReadCharacteristic)
@@ -1014,10 +1012,6 @@ jobject CALEServerCreateGattService(JNIEnv *env)
                                                              jni_cid_bluetoothGattCharacteristic,
                                                              jni_fid_writeProperties);
 
-    jint jni_int_writePermissions = (*env)->GetStaticIntField(env,
-                                                              jni_cid_bluetoothGattCharacteristic,
-                                                              jni_fid_writePermissions);
-
     jobject jni_writeCharacteristic = (*env)->NewObject(env, jni_cid_bluetoothGattCharacteristic,
                                                         jni_mid_bluetoothGattCharacteristic,
                                                         jni_obj_writeUuid, jni_int_writeProperties,