#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,
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;
}
/**
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);
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);
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;
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)
{