in this event */
_bt_convert_addr_type_to_string(address,
(unsigned char *)dev_addr.addr);
+
+ if (event->status != OAL_STATUS_SUCCESS)
+ result = BLUETOOTH_ERROR_INTERNAL;
+
__bt_gatt_handle_pending_request_info(result, BT_CONNECT_LE,
address, BT_ADDRESS_STRING_SIZE);
_bt_convert_addr_type_to_string(address,
(unsigned char *)dev_addr.addr);
+ if (event->status != OAL_STATUS_SUCCESS)
+ result = BLUETOOTH_ERROR_INTERNAL;
+
if (NULL == _bt_get_request_info_data(BT_DISCONNECT_LE, address)) {
if (NULL != _bt_get_request_info_data(BT_CONNECT_LE, address)) {
result = BLUETOOTH_ERROR_INTERNAL;
GVariant *param = NULL;
int result = BLUETOOTH_ERROR_NONE;
struct gatt_server_req_info *req_info = NULL;
+ bluetooth_device_address_t dev_addr;
+ char address[BT_ADDRESS_STRING_SIZE] = { 0 };
BT_INFO("GATT Server ACQUIRE Notify Req Connection ID: [%d]", event->attr_trans.conn_id);
BT_INFO("GATT Server ACQUIRE Notify Req Transaction ID:[%d]", event->attr_trans.trans_id);
BT_INFO("GATT Server ACQUIRE Notify Req Attribute Handle: [%d]", event->attr_trans.attr_handle);
+ BT_INFO("GATT Server ACQUIRE notify Req address : [%s]", address);
+
+ memcpy(dev_addr.addr, event->address.addr, 6);
+ _bt_convert_addr_type_to_string(address,
+ (unsigned char *)dev_addr.addr);
+ BT_INFO("GATT Server ACQUIRE notify Req remote address : [%s]", address);
req_info = g_new0(struct gatt_server_req_info, 1);
req_info->request_id = event->attr_trans.trans_id;
req_info->request_type = BLUETOOTH_GATT_REQUEST_TYPE_ACQUIRE_NOTIFY;
gatt_server_requests = g_slist_append(gatt_server_requests, req_info);
- param = g_variant_new("(iiiiii)", result,
+ param = g_variant_new("(iiiiiis)", result,
event->attr_trans.conn_id,
event->attr_trans.trans_id,
event->attr_trans.attr_handle,
- event->mtu, event->attr_trans.offset);
+ event->mtu, event->attr_trans.offset,
+ address);
BT_INFO("GATT Server ACQUIRE Notify Req Attribute : ");
BT_INFO("GATT Client [%s] is connected, conn Id [%d] Instance ID [%d]",
conn_info->addr, conn_info->connection_id, conn_info->instance_id);
} else {
- BT_ERR("GATT Client [%s] is not yet connected..");
+ BT_ERR("GATT Client [%s] is not yet connected..", addr);
return BLUETOOTH_ERROR_NOT_CONNECTED;
}
BT_ERR("ret: %d", ret);
return BLUETOOTH_ERROR_INTERNAL;
}
+
BT_INFO("ATT MTU received from OAL [%d]", stack_mtu);
*mtu = (unsigned int)stack_mtu;
+
+ if (*mtu == 0) {
+ BT_ERR("MTU value is zero, GATT Client [%s] is not yet connected..", addr);
+ return BLUETOOTH_ERROR_NOT_CONNECTED;
+ }
+
return BLUETOOTH_ERROR_NONE;
}
memcpy(&uuid.uuid, &svc_info->uuid, BLUETOOTH_UUID_HEX_MAX_LEN);
_bt_uuid_to_string(&uuid, uuid_string);
- BT_INFO("Service UUID formed [%s] strlen [%d]", uuid_string, strlen(uuid_string));
+ BT_INFO("Service UUID formed [%s] strlen [%zd]", uuid_string, strlen(uuid_string));
/* Fill UUID of service */
g_strlcpy(info->uuids[count], uuid_string,
BLUETOOTH_UUID_STRING_MAX);
- BT_INFO("Service UUID formed TO be sent [%s] strlen [%d]",
+ BT_INFO("Service UUID formed TO be sent [%s] strlen [%zd]",
info->uuids[count], strlen(info->uuids[count]));
/* Fill instance ID of service */
info->inst_id[count] = svc_info->inst_id;
if (event_data->uuid_status.conn_status.status != OAL_STATUS_SUCCESS)
result = BLUETOOTH_ERROR_INTERNAL;
else {
- BT_INFO("desc data len:", event_data->data_len);
+ BT_INFO("desc data len:%d", event_data->data_len);
if (event_data->data_len > 0) {
/* DEBUG */
for (i = 0; i < event_data->data_len; i++)
int client_id)
{
struct gatt_server_info_t *conn_info = NULL;
+ struct gatt_client_info_t *rem_client_conn_info = NULL;
invocation_info_t *req_info = NULL;
int ret = OAL_STATUS_SUCCESS;
char *addr;
}
/* Check if remote GATT Server is connected or not */
conn_info = __bt_find_remote_gatt_server_info(addr);
- if (!conn_info) {
- BT_ERR("GATT Server is not connected..");
- g_free(addr);
- return BLUETOOTH_ERROR_NOT_IN_OPERATION;
- }
+ if (conn_info) {
+ /* Check if app sent 0 client id for Disconnection, in such case, use default gatt client ID */
+ if (client_id == 0) {
+ BT_INFO("GATT CLient Disconnect request sent by an app without any client instance [%d]",
+ client_id);
+ BT_INFO("Assign default GATT client id [%d]", gatt_default_client);
+ client_id = gatt_default_client;
+ }
- /* Check if app sent 0 client id for Disconnection, in such case, use default gatt client ID */
- if (client_id == 0) {
- BT_INFO("GATT CLient Disconnect request sent by an app without any client instance [%d]",
- client_id);
- BT_INFO("Assign default GATT client id [%d]", gatt_default_client);
- client_id = gatt_default_client;
- }
+ BT_INFO("Disconnect remote gatt server using CLient ID [%d] Connection ID [%d]", client_id, conn_info->connection_id);
+ ret = gattc_disconnect(client_id, (bt_address_t*)(address),
+ conn_info->connection_id);
+ } else {
+ /* check if remote client is connected */
+ rem_client_conn_info = __bt_find_remote_gatt_client_info(addr);
- BT_INFO("Disconnect using CLient ID [%d] Connection ID [%d]", client_id, conn_info->connection_id);
- ret = gattc_disconnect(client_id, (bt_address_t*)(address),
- conn_info->connection_id);
+ if (!rem_client_conn_info || client_id != 0) {
+ BT_ERR("GATT device is not connected..");
+ g_free(addr);
+ return BLUETOOTH_ERROR_NOT_IN_OPERATION;
+ }
+
+ BT_INFO("Disconnect remote gatt client ");
+
+ ret = gatts_disconnect(rem_client_conn_info->instance_id,
+ (bt_address_t*)(address), rem_client_conn_info->connection_id);
+ }
if (ret != OAL_STATUS_SUCCESS) {
BT_ERR("ret: %d", ret);