[TBT][tizen_3.0_mobile][Gatt Server and Gatt Client module updated] 25/91125/1
authornazib.ullah <nazib.ullah@samsung.com>
Thu, 6 Oct 2016 02:54:40 +0000 (08:54 +0600)
committernazib.ullah <nazib.ullah@samsung.com>
Thu, 6 Oct 2016 02:55:48 +0000 (08:55 +0600)
Change-Id: I4233ad42f8f4e3757c9af480e3bc83db0fd5b642

release/binary-armv7l/org.tizen.tbtcoreapp-1.0.0-arm.tpk
release/binary-x86/org.tizen.tbtcoreapp-1.0.0-i386.tpk
tbtcoreapp/src/view/tbt-bluetoothle-view.c

index 078da43ec4d68035ba00f142c4c3295f8b8cbede..31fd3b7816ac582a4659ad935398178d96dd596c 100644 (file)
Binary files a/release/binary-armv7l/org.tizen.tbtcoreapp-1.0.0-arm.tpk and b/release/binary-armv7l/org.tizen.tbtcoreapp-1.0.0-arm.tpk differ
index 4860eb0c1aeac7ac9d389b96c61aaf0136453762..cae175ee435ac69d82582de4af90aeb0b432d0e7 100644 (file)
Binary files a/release/binary-x86/org.tizen.tbtcoreapp-1.0.0-i386.tpk and b/release/binary-x86/org.tizen.tbtcoreapp-1.0.0-i386.tpk differ
index d5f7e2bbe8572b98f853b2253c3b526c51196243..1f7afdd21f971d5bbd5c1db39152b2229860611e 100644 (file)
@@ -37,6 +37,9 @@
 
 #define BT_ADAPTER_DEVICE_DISCOVERY_NONE -1
 
+#define BATTERY_SERVICE_UUID "0000180f-0000-1000-8000-00805f9b34fb"
+#define LINK_LOSS_SERVICE_UUID "00001803-0000-1000-8000-00805f9b34fb"
+
 typedef enum
 {
 SERVICE_LISTED,
@@ -400,11 +403,16 @@ static void _bt_device_bond_created_cb(int result_recieved, bt_device_info_s *de
        this = (bluetoothle_view*)user_data;
        RETM_IF(NULL == this, "view is NULL");
 
-       result = bt_gatt_connect(device_info->remote_address, false);
-       RETM_IF(result != BT_ERROR_NONE, "bt_gatt_connect failed --> error: %s", get_bluetooth_error(result));
-       elm_object_text_set(this->bluetoothle_label, "gatt connecting...");
+       if(this->view->tbt_info->apptype == TBT_APP_BLE_GATT_CLIENT)
+       {
+               result = bt_gatt_connect(device_info->remote_address, false);
+               RETM_IF(result != BT_ERROR_NONE, "bt_gatt_connect failed --> error: %s", get_bluetooth_error(result));
+               elm_object_text_set(this->bluetoothle_label, "gatt connecting...");
+       }
        elm_object_disabled_set(this->bluetoothle_btn, EINA_TRUE);
        elm_object_disabled_set(this->disconnect_btn, EINA_FALSE);
+       DBG("IS BONDED %d", device_info->is_bonded);
+       DBG("IS CONNECTED %d", device_info->is_connected);
        this->is_bonded = device_info->is_bonded;
 }
 /**
@@ -1111,12 +1119,21 @@ static bool _bt_gatt_foreach_characterstics_cb(int total, int index, bt_gatt_h g
        int result;
        RETVM_IF(NULL == gatt_handle,false, "gatt_handle is NULL");
 
-       bt_gatt_write_type_e write_type;
-       result = bt_gatt_characteristic_get_write_type(gatt_handle, &write_type);
-       RETVM_IF(result != BT_ERROR_NONE,false, "bt_gatt_characteristic_get_write_type error: %s", get_bluetooth_error(result));
+       char* uuid;
+       result = bt_gatt_get_uuid(gatt_handle, &uuid);
+       RETVM_IF(result != BT_ERROR_NONE, false, "bt_gatt_get_uuid error: %s", get_bluetooth_error(result));
+       DBG("selected service uuid %s", uuid);
 
-       result = bt_gatt_characteristic_set_write_type(gatt_handle, BT_GATT_WRITE_TYPE_WRITE);
-       RETVM_IF(result != BT_ERROR_NONE,false, "bt_gatt_characteristic_set_write_type error: %s", get_bluetooth_error(result));
+       if(!strcmp(uuid, LINK_LOSS_SERVICE_UUID))
+       {
+               DBG("Link Loss Service");
+               bt_gatt_write_type_e write_type;
+               result = bt_gatt_characteristic_get_write_type(gatt_handle, &write_type);
+               RETVM_IF(result != BT_ERROR_NONE,false, "bt_gatt_characteristic_get_write_type error: %s", get_bluetooth_error(result));
+
+               result = bt_gatt_characteristic_set_write_type(gatt_handle, BT_GATT_WRITE_TYPE_WRITE);
+               RETVM_IF(result != BT_ERROR_NONE,false, "bt_gatt_characteristic_set_write_type error: %s", get_bluetooth_error(result));
+       }
 
        bt_gatt_h service;
        result = bt_gatt_characteristic_get_service(gatt_handle, &service);
@@ -1125,7 +1142,6 @@ static bool _bt_gatt_foreach_characterstics_cb(int total, int index, bt_gatt_h g
        this->n_characteristics = total;
        this->all_characteristics[index] = gatt_handle;
 
-       char* uuid;
        result = bt_gatt_get_uuid(gatt_handle, &uuid);
        RETVM_IF(result != BT_ERROR_NONE,false, "bt_gatt_get_uuid error: %s", get_bluetooth_error(result));
        DBG("uuid: %s", uuid);
@@ -1504,12 +1520,12 @@ static void _sevice_selected_cb(void *data, Evas_Object *obj, void *event_info)
        RETM_IF(result != BT_ERROR_NONE, "bt_gatt_get_uuid error: %s", get_bluetooth_error(result));
        DBG("selected service uuid %s", uuid);
 
-       if(!strcmp(uuid, "0000180f-0000-1000-8000-00805f9b34fb"))
+       if(!strcmp(uuid, BATTERY_SERVICE_UUID))
        {
                DBG("Battery Service");
                this->is_battery_svc_selected = true;
        }
-       else if(!strcmp(uuid, "00001803-0000-1000-8000-00805f9b34fb"))
+       else if(!strcmp(uuid, LINK_LOSS_SERVICE_UUID))
        {
                DBG("Link Loss Service");
                this->is_link_loss_svc_selected = true;
@@ -1739,10 +1755,12 @@ void _app_destroy_cb(void* this)
 
        int result;
 
+       bt_device_unset_bond_destroyed_cb();
 
        if(view->view->tbt_info->apptype == TBT_APP_BLE_GATT_CLIENT)
        {
                bt_adapter_le_stop_scan();
+
        }
        else if(view->view->tbt_info->apptype == TBT_APP_BLE_GATT_SERVER)
        {
@@ -1850,7 +1868,7 @@ static void _bt_gatt_server_read_value_requested_cb(const char *remote_address,
 
        char char_value_1[4] = {65, 66, 67,0};
        int resp_status = BT_ERROR_NONE;
-       int result = bt_gatt_server_send_response(request_id, BT_GATT_REQUEST_TYPE_READ, offset, resp_status, char_value_1, 3 - offset);
+       int result = bt_gatt_server_send_response(request_id, BLUETOOTH_GATT_REQUEST_TYPE_READ, offset, resp_status, char_value_1, 3 - offset);
        DBG("bt_gatt_server_send_response %s", get_bluetooth_error(result));
 
        str = format_string("response sent %s", char_value_1);
@@ -1910,7 +1928,7 @@ static void _bt_gatt_server_write_value_requested_cb(const char *remote_address,
        SAFE_DELETE(str);
 
        bt_gatt_server_send_response(request_id,
-                       BT_GATT_REQUEST_TYPE_WRITE, offset,
+                       BLUETOOTH_GATT_REQUEST_TYPE_WRITE, offset,
                resp_status, NULL, 0);
 
        elm_list_go(this->bluetoothle_list);