/* Linked list of connected GATT client connection */
static GSList * hal_gattc_client_info_list = NULL;
-
static bt_pending_le_conn_info_s *pending_le_conn_info = NULL;
static guint pending_le_conn_timer_id = 0;
static int bt_conn_id = 0;
}
-static hal_gattc_char_t* _gattc_find_char_from_uuid(hal_gattc_service_t *gattc_svc, bt_uuid_t *char_uuid)
+static hal_gattc_char_t* _gattc_find_char_from_uuid(hal_gattc_service_t *gattc_svc, bt_uuid_t *char_uuid,
+ bt_gatt_characteristic_property_t prop)
{
DBG("+");
if (info == NULL)
continue;
- if (!memcmp(&info->chr_uuid, char_uuid, sizeof(bt_uuid_t))) {
+ if (!memcmp(&info->chr_uuid, char_uuid, sizeof(bt_uuid_t)) &&
+ (info->permission & prop)) {
INFO("Found GATT char uuid");
return info;
}
hal_gattc_server_info_t * conn_info = NULL;
hal_gattc_service_t *gattc_service = NULL;
GSList *l;
+ GSList *m;
hal_gattc_char_t *gattc_char = NULL;
hal_gattc_desc_t *gattc_desc = NULL;
char svc_uuid_str[BT_HAL_UUID_STRING_LEN];
DBG("service uuid [%s]", svc_uuid_str);
/* find characteristics */
- gattc_char = _gattc_find_char_from_uuid(gattc_service, &char_id->uuid);
- if (NULL == gattc_char) {
- DBG("Failed to get the gatt char");
- return BT_STATUS_FAIL;
- }
+ /* a service can have two char with same uuid */
+ for (l = gattc_service->gatt_list_chars; l != NULL; l = g_slist_next(l)) {
+ gattc_char = (hal_gattc_char_t*)l->data;
+ if (gattc_char == NULL)
+ continue;
- DBG("char path [%s]", gattc_char->chr_path);
- _bt_hal_convert_uuid_type_to_string(char_uuid_str, gattc_char->chr_uuid.uu);
- DBG("char uuid [%s]", char_uuid_str);
+ if (!memcmp(&gattc_char->chr_uuid, &char_id->uuid, sizeof(bt_uuid_t))) {
+ INFO("Found GATT char uuid");
+ DBG("char path [%s]", gattc_char->chr_path);
+ _bt_hal_convert_uuid_type_to_string(char_uuid_str, gattc_char->chr_uuid.uu);
+ DBG("char uuid [%s]", char_uuid_str);
+
+ /* get descriptor uuid */
+ for (m = gattc_char->gatt_list_descs; m != NULL; m = g_slist_next(m)) {
+ gattc_desc = (hal_gattc_desc_t *)m->data;
+ if (gattc_desc == NULL)
+ continue;
- /* get descriptor uuid */
- for (l = gattc_char->gatt_list_descs; l != NULL; l = g_slist_next(l)) {
- gattc_desc = (hal_gattc_desc_t *)l->data;
- status = _hal_gattc_get_descriptor_info(gattc_desc);
+ status = _hal_gattc_get_descriptor_info(gattc_desc);
- /* send event */
- if (BT_STATUS_SUCCESS == status) {
- DBG("Sending the success descriptor event");
- _bt_hal_send_client_desc_search_result_event(conn_id, status, srvc_id,
- char_id, &gattc_desc->desc_uuid);
+ /* send event */
+ if (BT_STATUS_SUCCESS == status) {
+ DBG("Sending the success descriptor event");
+ _bt_hal_send_client_desc_search_result_event(conn_id, status, srvc_id,
+ char_id, &gattc_desc->desc_uuid);
+ }
+ }
}
}
/* find characteristic */
- gattc_char = _gattc_find_char_from_uuid(gattc_service, &char_id->uuid);
+ gattc_char = _gattc_find_char_from_uuid(gattc_service, &char_id->uuid,
+ HAL_GATT_CHARACTERISTIC_PROPERTY_READ);
if (NULL == gattc_char) {
DBG("Failed to get the gatt char");
return BT_STATUS_FAIL;
DBG("-");
}
-static bt_status_t __hal_get_write_prop(hal_gatt_write_type_t type, hal_gatt_property_e *prop)
+static bt_status_t __hal_get_write_prop(hal_gatt_write_type_t type, bt_gatt_characteristic_property_t *prop)
{
switch (type) {
case HAL_GATT_WRITE_TYPE_WRITE:
- *prop = HAL_GATT_PROPERTY_WRITE;
+ *prop = HAL_GATT_CHARACTERISTIC_PROPERTY_WRITE;
break;
case HAL_GATT_WRITE_TYPE_WRITE_NO_RESPONSE:
- *prop = HAL_GATT_PROPERTY_WRITE_WITHOUT_RESPONSE;
+ *prop = HAL_GATT_CHARACTERISTIC_PROPERTY_WRITE_NO_RESPONSE;
break;
default:
ERR("Unknow write type : %d", type);
char svc_uuid_str[BT_HAL_UUID_STRING_LEN];
char char_uuid_str[BT_HAL_UUID_STRING_LEN];
char* char_handle = NULL;
- hal_gatt_property_e write_prop = HAL_GATT_PROPERTY_WRITE;
+ bt_gatt_characteristic_property_t write_prop = HAL_GATT_CHARACTERISTIC_PROPERTY_WRITE;
int ret = BT_STATUS_SUCCESS;
DBG("+");
DBG("service uuid [%s]", svc_uuid_str);
/* find characteristic */
- gattc_char = _gattc_find_char_from_uuid(gattc_service, &char_id->uuid);
+ gattc_char = _gattc_find_char_from_uuid(gattc_service, &char_id->uuid, write_prop);
if (NULL == gattc_char) {
DBG("Failed to get the gatt char");
return BT_STATUS_FAIL;
char char_uuid_str[BT_HAL_UUID_STRING_LEN];
char desc_uuid_str[BT_HAL_UUID_STRING_LEN];
char* desc_handle = NULL;
+ GSList *l;
hal_gattc_desc_t *gattc_desc = NULL;
DBG("service uuid [%s]", svc_uuid_str);
/* find characteristic */
- gattc_char = _gattc_find_char_from_uuid(gattc_service, &char_id->uuid);
- if (NULL == gattc_char) {
- DBG("Failed to get the gatt char");
- return BT_STATUS_FAIL;
- }
+ /* service can have two char with same uuid */
+ for (l = gattc_service->gatt_list_chars; l != NULL; l = g_slist_next(l)) {
+ gattc_char = (hal_gattc_char_t*)l->data;
+ if (gattc_char == NULL)
+ continue;
- DBG("char path [%s]", gattc_char->chr_path);
- _bt_hal_convert_uuid_type_to_string(char_uuid_str, gattc_char->chr_uuid.uu);
- DBG("char uuid [%s]", char_uuid_str);
+ if (!memcmp(&gattc_char->chr_uuid, &char_id->uuid, sizeof(bt_uuid_t))) {
+ INFO("Found GATT char uuid");
+ DBG("char path [%s]", gattc_char->chr_path);
+ _bt_hal_convert_uuid_type_to_string(char_uuid_str, gattc_char->chr_uuid.uu);
+ DBG("char uuid [%s]", char_uuid_str);
+
+ /* find descriptor */
+ gattc_desc = _gattc_find_desc_from_uuid(gattc_char, &desc_id->uuid);
+ if (gattc_desc) {
+ DBG("desc path [%s]", gattc_desc->desc_path);
+ _bt_hal_convert_uuid_type_to_string(desc_uuid_str, gattc_desc->desc_uuid.uu);
+ DBG("desc uuid [%s]", desc_uuid_str);
+ break;
+ }
+ }
+ }
- /* find descriptor */
- gattc_desc = _gattc_find_desc_from_uuid(gattc_char, &desc_id->uuid);
if (NULL == gattc_desc) {
DBG("Failed to get the gatt desc");
return BT_STATUS_FAIL;
}
- DBG("desc path [%s]", gattc_desc->desc_path);
- _bt_hal_convert_uuid_type_to_string(desc_uuid_str, gattc_desc->desc_uuid.uu);
- DBG("desc uuid [%s]", desc_uuid_str);
-
g_conn = _bt_hal_get_system_gconn();
if (NULL == g_conn) {
ERR("_bt_gdbus_get_system_gconn returned NULL");
char char_uuid_str[BT_HAL_UUID_STRING_LEN];
char desc_uuid_str[BT_HAL_UUID_STRING_LEN];
char* desc_handle = NULL;
- hal_gatt_property_e write_prop = HAL_GATT_PROPERTY_WRITE;
+ bt_gatt_characteristic_property_t write_prop = HAL_GATT_CHARACTERISTIC_PROPERTY_WRITE;
int ret = BT_STATUS_SUCCESS;
+ GSList *l;
DBG("+");
DBG("service uuid [%s]", svc_uuid_str);
/* find characteristic */
- gattc_char = _gattc_find_char_from_uuid(gattc_service, &char_id->uuid);
- if (NULL == gattc_char) {
- DBG("Failed to get the gatt char");
- return BT_STATUS_FAIL;
- }
+ /* service can have two char with same uuid */
+ for (l = gattc_service->gatt_list_chars; l != NULL; l = g_slist_next(l)) {
+ gattc_char = (hal_gattc_char_t*)l->data;
+ if (gattc_char == NULL)
+ continue;
- DBG("char path [%s]", gattc_char->chr_path);
- _bt_hal_convert_uuid_type_to_string(char_uuid_str, gattc_char->chr_uuid.uu);
- DBG("char uuid [%s]", char_uuid_str);
+ if (!memcmp(&gattc_char->chr_uuid, &char_id->uuid, sizeof(bt_uuid_t))) {
+ INFO("Found GATT char uuid");
+ DBG("char path [%s]", gattc_char->chr_path);
+ _bt_hal_convert_uuid_type_to_string(char_uuid_str, gattc_char->chr_uuid.uu);
+ DBG("char uuid [%s]", char_uuid_str);
+
+ /* find descriptor */
+ gattc_desc = _gattc_find_desc_from_uuid(gattc_char, &descr_id->uuid);
+ if (gattc_desc) {
+ DBG("desc path [%s]", gattc_desc->desc_path);
+ _bt_hal_convert_uuid_type_to_string(desc_uuid_str, gattc_desc->desc_uuid.uu);
+ DBG("desc uuid [%s]", desc_uuid_str);
+ break;
+ }
+ }
+ }
- /* find descriptor */
- gattc_desc = _gattc_find_desc_from_uuid(gattc_char, &descr_id->uuid);
if (NULL == gattc_desc) {
- DBG("Failed to get the gatt char");
+ DBG("Failed to get the gatt desc");
return BT_STATUS_FAIL;
}
- DBG("desc path [%s]", gattc_desc->desc_path);
- _bt_hal_convert_uuid_type_to_string(desc_uuid_str, gattc_desc->desc_uuid.uu);
- DBG("char uuid [%s]", desc_uuid_str);
-
g_conn = _bt_hal_get_system_gconn();
if (NULL == g_conn) {
ERR("_bt_gdbus_get_system_gconn returned NULL");
/* find characteristic */
- gattc_char = _gattc_find_char_from_uuid(gattc_service, &char_id->uuid);
+ gattc_char = _gattc_find_char_from_uuid(gattc_service, &char_id->uuid,
+ HAL_GATT_CHARACTERISTIC_PROPERTY_NOTIFY);
if (NULL == gattc_char) {
DBG("Failed to get the gatt char");
return BT_STATUS_FAIL;
/* find characteristic */
- gattc_char = _gattc_find_char_from_uuid(gattc_service, &char_id->uuid);
+ gattc_char = _gattc_find_char_from_uuid(gattc_service, &char_id->uuid,
+ HAL_GATT_CHARACTERISTIC_PROPERTY_NOTIFY);
if (NULL == gattc_char) {
DBG("Failed to get the gatt char");
return BT_STATUS_FAIL;